문제

I'm working on a prepared statement that continuously returns false.

$db = dblogin();
$stmt = $db->prepare("INSERT INTO `tor_request` `name`,`sdate`,`edate,`reason`,`comment` VALUES (?,?,?,?,?)");

echo var_export($stmt,true);
//$stmt->bind_param('siiss',$_POST['name'],$_POST['sdate'],$_POST['edate'],$_POST['reason'],$_POST['comment']);
//$result = $stmt->execute();

The dblogin works everywhere, and it has been EXTENSIVELY tested. I just can not find the error in this one statement. It keeps returning false over and over and over. I've commented out the bind_param and the $result because I can't get past the prepare. It's not an Object. Any ideas? Been stuck at this one line for HOURS

도움이 되었습니까?

해결책

You are not wrapping your columns inside brackets, plus you're missing a backtick around edate

$db = dblogin();
$stmt = $db->prepare("INSERT INTO `tor_request` (`name`,`sdate`,`edate`,`reason`,`comment`) VALUES (?,?,?,?,?)");

echo var_export($stmt,true);

Add error reporting to the top of your file(s) which will help during production testing.

error_reporting(E_ALL);
ini_set('display_errors', 1);

mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);

Error reporting related links:

다른 팁

"INSERT INTO `tor_request` (`name`,`sdate`,`edate`,`reason`,`comment`) 
VALUES (?,?,?,?,?)"

PS: Named parameters are so much easier to read. The more text you have THE BETTER.

"INSERT INTO `tor_request` (`name`,`sdate`,`edate`,`reason`,`comment`) 
VALUES (:name,:startDate,:endDate,:reason,:comment)"
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top