Well the subject says most of it. I have a javascript function that uses an Ajax call, using POST, and returns an array created by a php sql query. Well... it's supposed to at least. I can get the ajax to return a very simple php echo. When I add the rest of the code necessary to build my db connect, even without trying to pass the array, I start to get an Exception Object, 503 error.
JAVASCRIPT
function updateYears(pageLoaded) {
var yearSelect = document.getElementById("vehicle_year");
var makeSelect = document.getElementById("vehicle_make");
var modelSelect = document.getElementById("vehicle_model");
$('#vehicle_year').html('');
var $data = [];
$.ajax({ url: '/new.php',
data: {action: 'test'},
type: 'post',
success:function(result)//we got the response
{
alert(result);
},
error:function(exception){alert('Exception:'+exception);}
});
return false;
}
PHP
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
$db = new $sql_db();
$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport);
// We do not need this any longer, unset for safety purposes
unset($dbpasswd);
if(isset($_POST['action']) && !empty($_POST['action'])) {
$action = $_POST['action'];
switch($action) {
case 'get_vehicle_makes' :
get_vehicle_makes();
break;
case 'get_vehicle_models' :
get_vehicle_models();
break;
case 'test' :
get_vehicle_years();
break;
}
}
//Populate a unique list of vehicle years - this only runs on page load
//The vehicle years list will always be the same regardless of make or model - block_var = "vehicle_years"
function get_vehicle_years()
{
echo ("good job");
exit;
}
Now, there's a lot going on in the PHP file, but I am really just trying to echo ("test");
for right now. If I remove the code in the PHP file that is between, define('IN_PHPBB', true);
and unset($dbpasswd);
, it works, so I know there is something wrong with the db connection code. The include statements are fine, because I don't get an error saying the file doesn't exist. The connection credential variables are also fine, because I get those from the config.php file that's included. I'm at a loss, and could really use some help.
</div>