weixin_33720078 2017-11-28 02:35 采纳率: 0%
浏览 42

PHP异常对象错误

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>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 数据量少可以用MK趋势分析吗
    • ¥15 使用VH6501干扰RTR位,CANoe上显示的错误帧不足32个就进入bus off快慢恢复,为什么?
    • ¥15 大智慧怎么编写一个选股程序
    • ¥100 python 调用 cgps 命令获取 实时位置信息
    • ¥15 两台交换机分别是trunk接口和access接口为何无法通信,通信过程是如何?
    • ¥15 C语言使用vscode编码错误
    • ¥15 用KSV5转成本时,如何不生成那笔中间凭证
    • ¥20 ensp怎么配置让PC1和PC2通讯上
    • ¥50 有没有适合匹配类似图中的运动规律的图像处理算法
    • ¥15 dnat基础问题,本机发出,别人返回的包,不能命中