[英]Attempting to INSERT multiple rows into MySQL table
Currently I'm trying to insert multiple rows into a MySQL database with the following code, however I keep receiving error 500 (Internal Server Error)...I'm I doing something in correctly here? 目前,我正在尝试使用以下代码在MySQL数据库中插入多行,但是我一直收到错误500(内部服务器错误)...我在这里正确地做什么吗? I'm relatively new to PHP.
我对PHP比较陌生。 Thanks
谢谢
for ($i = 0; $i < $numberOfOptions; $i++) {
var $insertOptions; <<<<<<<< Error here. Should not have 'var' pre-fix
if ($numbersOrLetters == 0) {
$optionNumber = $i + 1;
$insertOptions = "INSERT INTO Survey_results (Survey_authKey, Option_name, Option_value)
VALUES ('$userAuthKey','$optionNumber','0')";
}
else {
$currentValue = $letter[$i];
$insertOptions = "INSERT INTO Survey_results (Survey_authKey, Option_name, Option_value)
VALUES ('$userAuthKey','$currentValue','0')";
}
mysql_query($insertOptions);
}
Add this on top of your script to enable error reporting. 将其添加到脚本顶部以启用错误报告。
ini_set('display_errors','On');
error_reporting(E_ALL);
Then you will know what the problem might be. 然后,您将知道可能是什么问题。
as requested: 按照要求:
`var $insertOptions; `var $ insertOptions;
out of place OOP or to much javascript on the brain? 不合适的OOP还是大脑上的大量JavaScript?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.