[英]PHP stops at, and shows, a single line of code
Recently I copied a PHP script to use it for another database. 最近,我复制了一个PHP脚本以用于另一个数据库。 After I correctly edited all the words and links, I got an weird error.
正确编辑所有单词和链接后,出现一个奇怪的错误。
SELECT naam, aantal, prijs
FROM boeken, bestelling
WHERE boeken.Boekcode = bestelling.Boekcode
AND bestelling.Boekcode IN ('101','102')
AND bestelnummer = 3;
It's not a regular error that say something like 像这样的错误不是正常错误
Error on line 42
Basically what the code does, is that when you order books and filled in a form (Name, last name, email etc) it puts that in a database. 基本上,代码的作用是,当您订购书籍并填写表格(姓名,姓氏,电子邮件等)时,会将其放入数据库中。 And afterwards puts it in a "thankyou.html" page.
然后将其放在“ thankyou.html”页面中。
Here's part of the code that causes this 这是导致此问题的部分代码
mysqli_query($con, $query) or die($query . "<br>");
$bestelnummer = MYSQLI_INSERT_ID($con);
$object = array_filter($object);
$objectnaam = join("','",array_keys($object));
$object = http_build_query($object);
$object = str_replace('=', ',', $object);
$object = str_replace('&', "),($bestelnummer,", $object);
$query = "INSERT INTO bestelling (bestelnummer, Boekcode, aantal) VALUES ($bestelnummer,$object)";
$result = mysqli_query($con, $query) or die($query."<br>");
$aantal = "SELECT naam, aantal, prijs FROM boeken, bestelling WHERE boeken.Boekcode = bestelling.Boekcode AND bestelling.Boekcode IN ('".$objectnaam."') AND bestelnummer = $bestelnummer";
$result = mysqli_query($con, $aantal) or die($aantal . "<br>");
$res = mysqli_fetch_all($result);
$prijs = 0;
The $object is an array of the books you choose. $ object是您选择的书籍的数组。
I've Google'd for this problem, and yes, I have Apache and everything enabled. 我已经用Google解决了这个问题,是的,我启用了Apache和所有功能。
Sorry if I'm unclear, it's been a while, I can answer any questions you might have. 很抱歉,如果我不清楚,已经有一段时间了,我可以回答您可能遇到的任何问题。
Well you echo out the query if it fails. 那么,如果查询失败,您可以回显该查询。
$aantal = "SELECT naam, aantal, prijs FROM boeken, bestelling WHERE boeken.Boekcode = bestelling.Boekcode AND bestelling.Boekcode IN ('".$objectnaam."') AND bestelnummer = $bestelnummer";
$result = mysqli_query($con, $aantal) or die($aantal . "<br>");
You might want to check the error message that is returned from the database using mysqli_error(). 您可能想使用mysqli_error()检查从数据库返回的错误消息。
$result = mysqli_query($con, $aantal) or die(mysqli_error() . "<br>");
first need to refine 首先需要完善
$query = "INSERT INTO bestelling (bestelnummer, Boekcode, aantal) VALUES ($bestelnummer,$object)";
you are selecting values insertion for 3 columns and passing only two values 您正在为3列选择值插入并且仅传递两个值
For second query try to use backticks for tablename and column 对于第二个查询,请尝试对表名和列使用反引号
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.