8 Replies - 1086 Views - Last Post: 13 October 2013 - 01:03 PM Rate Topic: -----

#1 mutago234  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 248
  • Joined: 08-September 13

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

Posted 12 October 2013 - 09:42 AM

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 here with my
web hosting account

Take a look at the code below
<?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

Is This A Good Question/Topic? 0
  • +

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

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13656
  • View blog
  • Posts: 54,498
  • Joined: 12-June 08

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

Posted 12 October 2013 - 10:28 AM

Does your linux box have the right version of PHP?

Quote

PDO ships with PHP 5.1, and is available as a PECL extension for PHP 5.0; PDO requires the new OO features in the core of PHP 5, and so will not run with earlier versions of PHP.

http://www.php.net/m...n/intro.pdo.php
Was This Post Helpful? 0
  • +
  • -

#3 mutago234  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 248
  • Joined: 08-September 13

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

Posted 12 October 2013 - 12:16 PM

i have check the cpanel and The current PHP version is above 5.1,
Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6442
  • View blog
  • Posts: 26,059
  • Joined: 12-December 12

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

Posted 12 October 2013 - 12:25 PM

error_reporting(0);

This turns off error reporting - you don't want this! You need to see all errors during development:

error_reporting(E_ALL);
ini_set('display_errors', '1');

Was This Post Helpful? 0
  • +
  • -

#5 mutago234  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 248
  • Joined: 08-September 13

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

Posted 12 October 2013 - 01:34 PM

I have remove error_reporting but no further error was shown on all the application as why it does not run. I when i tested using MYSQL_DEprecated, everything works.

Am just crazily insane as i need to submit and have my school assignment reviewed. There is no time on my side.

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
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw  Icon User is offline

  • blow up my boots
  • member icon

Reputation: 6442
  • View blog
  • Posts: 26,059
  • Joined: 12-December 12

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

Posted 12 October 2013 - 01:53 PM

Your recent post indicates that you've mis-spelt success:

header("location: sucess.php");

You should make use of print_r() and var_dump() to display your variable-values, particularly $_SERVER['REMOTE_ADDR'] and the $_POST array. These are essential tools (weapons?) in the php-debugging arsenal ;)
Was This Post Helpful? 0
  • +
  • -

#7 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4139
  • View blog
  • Posts: 13,089
  • Joined: 08-June 10

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

Posted 13 October 2013 - 05:46 AM

both header() calls will fail and produce a "header already sent" notice.
Was This Post Helpful? 0
  • +
  • -

#8 mutago234  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 248
  • Joined: 08-September 13

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

Posted 13 October 2013 - 01:02 PM

resolved by enabling output_buffering via ob_start();

thank you
Was This Post Helpful? 0
  • +
  • -

#9 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 4139
  • View blog
  • Posts: 13,089
  • Joined: 08-June 10

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

Posted 13 October 2013 - 01:03 PM

View Postmutago234, on 13 October 2013 - 10:02 PM, said:

resolved by enabling output_buffering via ob_start();

wouldn’t it be easier to just remove lines #3-#7? they are useless anyways.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1