gpt4 book ai didi

php - 这段代码怎么会有错误呢?

转载 作者:行者123 更新时间:2023-11-29 12:54:02 24 4
gpt4 key购买 nike

我不断收到此错误,我非常肯定我的语法是正确的!

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '='00001010'' at line 1

PHP 代码:

<?php
$decode = str_split($_POST['ascii'], 8);
mysql_connect("localhost","Username","Password");
mysql_select_db("information");
foreach($decode as $char){
$query = mysql_query("SELECT * FROM ascii_binary WHERE binary='$char'") or die(mysql_error());
while ($row = mysql_fetch_array($query)) {
$char = $row['character'];
echo $char;
}
}
?>

最佳答案

你必须在 BINARY 周围使用反引号,因为 BINARY 是 mysql 的保留关键字。

像这样:

 SELECT * FROM ascii_binary WHERE `binary` ='$char'

关于php - 这段代码怎么会有错误呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24344776/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com