Ok I wrote a custom PHP function to pull a value from a mysql DB, originally this function was in a class and I was trying to call it form the class, it kept giving me trouble so I moved it locally to the file to troubleshoot it as I wasn't getting any error other than 500, I'm not seeing any errors in /var/log/httpd/error_log and if I comment out the $host variable where I call the getSetting function the script just says failed to login which is expected as I don't supply any info the to ssh login method.
<?php
//testing for php
//created by dylan kraklan do not use without permission
//setenforce 0 on host machine is required
//header('Content-type: text/plain');
error_reporting('E_ALL | E_STRICT');
ini_set('display_errors', 'On');
include('Net/SSH2.php');
include('general.php');
include('config.php');
$database =Database::getInstance();
$db = $database->getConnection();
$gen = new Gen ();
function getSetting($setting) {
$set_sql = "SELECT value FROM settings WHERE setting='$setting'";
$set_query =$db->query($set_sql);
$value_a = $set_query->fetch_assoc();
$value =$value_a['value'];
return $value;
}
$host = getSetting('remote_host');
//$user = $gen->getSetting('remote_user');
//$pass = $gen->getSetting('remote_pass');
//echo $host.$user.$pass;
$ssh = new Net_SSH2($host);
if(!$ssh->login($user, $pass)) {
exit('Login Failed');
}
print_r($ssh->exec('pwd'));
print_r($ssh->exec('ls -la'));
?>
I have enabled all the error logging optiosn I saw in php.ini and I even specified to log errors to php_error.log , I assumed this file would be in the same dir as php.ini (/etc) didn't see it generate. Then I tried switching it to /var/log/httpd/php_error.log and I still don't see it generate.
EDIT: Ok so I found some code that will show me the error, PHP's white screen of death
Now the error is
E_NOTICE Error in file �test.php� at line 21: Undefined variable: db Fatal error: Call to a member function query() on a non-object in /var/www/html/sync/lib/test.php on line 21 E_ERROR Error in file �test.php� at line 21: Call to a member function query() on a non-object
Line 21 is
$set_query =$db->query($set_sql);
I'm not sure whats wrong with my mysql statement but it seems to be causing issues.