Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: php PDO codes runs on windows but does not run on linux

  1. #1
    Join Date
    Aug 2013
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default php PDO codes runs on windows but does not run on linux

    During development,
    I develop my php codes using PDO on windows via Xammp server.

    now when i deployed it on the server, some of them run , some did not run at all.
    what could be the problem.

    1: Is there something that i need to enable.
    2: Is php PDO not supported on this server
    3: Why did all my applications runs execellent on windows via Xammp server but does not run on linux with webhosting account

    Take a look at the code below
    Code:
    <?php
    	error_reporting(0); 
    ?>
    
    <?php	
    
    
       require("pdodatabase.php");
    
    
    $usern=strip_tags($_POST['usern']);
    $pass=strip_tags($_POST['pass']);
    $ip_adres = strip_tags($_SERVER['REMOTE_ADDR']); 
    
    $statement = $db->prepare('INSERT INTO report (offender,offence,reporter_ip) 
                              values
                    ( :offender,:offence,:reporter_ip)');
    
    
    
     if($statement->execute(array( 
    			':offender' => $usern,
                    ':offence' => $pass,
    			':reporter_ip' => $ip_adres
                     
                             
    ))){
    
    header("location: sucess.php");
    
    
    }else{
    header("location: fail.php");
    
    }
    
    
    ?>
    This code above runs on my Xammp server perfectly and displays a success.php page but here it runs but cannot display the success page.

    Almost all my application refuses to run.

    Thank You

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,953
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    get rid of:

    PHP Code:
    <?php
        error_reporting
    (0); 
    ?>
    and:

    PHP Code:
    else{
    header("location: fail.php");


    and you might be able to see the error.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    1. You can check if PDO is supported on your server (and what version/library/drivers are available) by looking at the output of phpinfo.

    2. Yes, Windows and Linux are very different. PHP does an okay job at abstracting this, but there are things that simply can't be ignored. It takes a lot of study to figure out what all those things are.

    A quicker, and more sure, solution is to make your development environment match your production environment more closely. If you're deploying to a Linux server (most people are), then write your code on a Linux server. Download Ubuntu and Xampp and dual-boot. It's not complicated (you don't even have to install Ubuntu if you don't want to - it can run from a flash drive).

    3. You should never find yourself in a situation where you need to use strip_tags. You should turn magic quotes off instead (talk to your host about how to do this). Better yet, upgrade to php 5.4 and never worry about it again. If magic quotes are "on" and your host won't let you turn them off, find a different host. If you have no choice, then you should check if magic quotes is on or not and handle tag-stripping at the beginning of your script, when the data first comes in, not on a one-by-one basis when you use each value.

    --------------------------------
    If you want more help with your specific issue, then you need to explain your problems more clearly. Tell us what you expect, what happens instead, and what error messages you receive (hint: turning off error reporting is good for live sites, but very bad for figuring out problems). Be as detailed as possible.

  4. #4
    Join Date
    Aug 2013
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    All my application does not show any error on the linux. is just that some code will run while others does not. Even those that run just run partiallly. The code above inserts records into the server on the linux server without displaying eg. success.php page. On my windows 7 via xammp server. the above code runs 100% correct even if its displayed 1000's time. I think my hosting server does not fully support PDO or the Linux itself. Am just in a mess for my school assignment.

    I think i regret learning PDO in the first place. If i cannot find any windows shared hosting company that uses Xammp server with unlimited space and bandwidth. I will just go back to mysql deprecated functions and try to secure
    my application against SQL INJECTION using mysql_real_escape_string();
    Thanks for help rendered so far

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,953
    Thanks
    43
    Thanked 3,195 Times in 3,157 Posts
    Blog Entries
    12

    Default

    Your application will not show any error until you remove:

    PHP Code:
    <?php 
        error_reporting
    (0);  
    ?>
    Once you remove that, if there are any errors you should be able to see them.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by mutago View Post
    All my application does not show any error on the linux.
    As John says, that's because you are expressly ignoring the error output. Use error_reporting( -1 ); ini_set( 'display_errors',1 ); instead.
    If your error is occurring in MySQL, you may also need to use the appropriate PDO methods to check (in fact, you should be doing so anyway).

    Quote Originally Posted by mutago View Post
    The code above inserts records into the server on the linux server without displaying eg. success.php page.
    If it inserts the records successfully, then the problem is probably in the part that follows:
    PHP Code:
    header("location: sucess.php"); 
    If you look up the manual page for header(), you'll see that you are not using the correct form for the header $string. The fact that it works on your local server is probably an accident.

    Quote Originally Posted by mutago View Post
    I think my hosting server does not fully support PDO or the Linux itself.
    Even as bad as many hosts are, I doubt that is the case.

    Quote Originally Posted by mutago View Post
    I think i regret learning PDO in the first place. If i cannot find any windows shared hosting company that uses Xammp server with unlimited space and bandwidth. I will just go back to mysql deprecated functions and try to secure my application against SQL INJECTION using mysql_real_escape_string();
    If you find a hosting company that runs xampp on Windows (I've never heard of such a thing), you need to avoid them. The xampp package is fine for local development on your own computer, but it is not at all suitable for production (live sites).
    Last edited by traq; 10-12-2013 at 10:45 PM.

  7. #7
    Join Date
    Aug 2013
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    i think problem lies here also
    header("location: sucess.php");

    can you give an example od a working header

    thank you

  8. #8
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Quote Originally Posted by mutago View Post
    can you give an example od a working header
    Did you look at the php manual page?

  9. #9
    Join Date
    Aug 2013
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    the header() is the problem. it does not return success.php page.
    what am seeing in the manual is the same as this above

    echo 'submitted';
    it will print submitted when echoed but cannot redirect to sucess.php
    header("location: sucess.php");

  10. #10
    Join Date
    Aug 2013
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This is all about linux issue

Similar Threads

  1. Replies: 1
    Last Post: 12-09-2008, 01:35 PM
  2. PHP Windows or Linux
    By Hanky58 in forum PHP
    Replies: 6
    Last Post: 07-21-2008, 01:37 PM
  3. Mac - Linux - Windows
    By tacmig99 in forum Computer hardware and software
    Replies: 19
    Last Post: 08-24-2006, 01:13 PM
  4. Windows or Linux hosting?
    By Suzy in forum The lounge
    Replies: 1
    Last Post: 05-10-2005, 06:37 AM
  5. windows vs linux
    By sofy60 in forum JavaScript
    Replies: 2
    Last Post: 03-25-2005, 10:53 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •