i have a php script does some computations then connects to a mysql database to write some data. when i run the script from a terminal, the script runs fine. when i run the script from a webpage (starts when i click a button in the page), the script dies once it hits the mysql_connect statement in the php code.
not sure what code or data to provide you folks to help with the debug...just dies with no error message. if anyone has suggestions on what additional data to post, please let me know.
could it be some kind of permissions issue? for some reason at the terminal my account can access the mysqli libs containing the mysqli_connect functon, but the apache web user doesn't have those permissions? i'm stuck...have never seen this before.
test.php:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
connectToDB();
print "hi manny";
function connectToDB() {
$hostname = "XXXXX";
$port = "XXX";
$schema = "XXXX";
$username = "XXXXX";
$password = "XXXXX";
print "got inside\n";
$dbh = mysqli_connect($hostname, $username, $password, $schema, $port);
print "got connect\n";
// Check connection
if (!$dbh) {
echo "connection failed\n";
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully\n";
return $dbh;
}
?>
when run from command line:
[manoli@app01 site1]$ php -f test.php
got inside
got connect
Connected successfully
hi mannywhen run from webpage via ajax:
got inside
Fatal error: Call to undefined function mysqli_connect() in >/var/www/apps/site1/test.php on line 16
ini_set('display_errors', 1); error_reporting(E_ALL);and show us what pops up.mysql_connectis the issue?phpinfo();and see if mysqli is there.