简体   繁体   中英

Server error 500 in PHP

So today I have another small little issue with my PHP, that is causing me to get a server error. You see, I have this javascript function:

 $.post('script.php', { limit: str }, function(result) { 
  console.log(result); 
 });

which of course makes a call to my php file:

 require_once("../data/db-settings.php");
 require_once("../data/file.php");
 global $pdo;
 $list = array();
 $limit = $_POST["limit"];
 chop($limit, ";");
 $stmt = $pdo->prepare("SELECT cust_id, cust_addr FROM project  WHERE " . $limit . " = cust_id");
 $stmt->execute();
 while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
        $list[] = $row;
    }       
 echo $list;

The point of the php is to grab some information from a database that a user can dynamically change and use. The issue, I'm assuming, is with how I'm using PDO, because the code I'm using is in working order in another section. I also know that my function call is sending data and working properly, because when I check for just what I send, it sends properly.

Thanks for any help guys.

Check your query FROMproject can not be together.

Your query should look like this:

$pdo->prepare("SELECT cust_id, cust_addr FROM project  WHERE " . $limit . " = cust_id");

PDO doesn't throw Internal server error. Must be require_once.

checkout db-settings.php and file.php files. Require_once throws 500 error if it can't find files.

If the paths are correct, then check out included files.

proper way: check your log files.

It is an unobvious error! So you step by step following the : http://pcsupport.about.com/od/findbyerrormessage/a/500servererror.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM