简体   繁体   English

这个错误是什么意思?

[英]What does this error mean?

You have an error in your SQL syntax; 您的SQL语法有误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #2' at line 1 检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的“资源ID#2”附近使用

[Edit: following code picked out of a comment further down... indentation could be wrong] [编辑:从注释中进一步选择以下代码...缩进可能是错误的]

//This is the directory where images will be saved 
$target_path = "images/";     
$target = $target_path . basename ($_FILES['photo']['name']); 
$did = $_POST['did']; 
$name = $_POST['dname']; 
$disc = $_POST['ddisc']; 
$price = $_POST['dprice']; 
$pic=($_FILES['photo']['name']); 
$con = mysql_connect("","restoraunt","123456"); 
// àéôä ùí äùøú ùìê, localhost àå îùäå? 
if (!$con) { die('Could not connect: ' . mysql_error()); } 
mysql_select_db("restoraunt", $con); 
mysql_query("INSERT INTO menu VALUES ('$did', '$name', '$disc', '$price','a','c','$pic')") ;

The fact that you're saying "near 'Resource id #2'" means that your SQL is actually the text Resource id #2 which is not a valid SQL. 您所说的“'资源ID#2'附近”的事实意味着您的SQL实际上是文本资源ID#2 ,它不是有效的SQL。

I figure that you are doing this: mysql_query($someVariable) The variable that you are passing is actually an object, not a string. 我认为您正在执行此操作: mysql_query($someVariable)您传递的变量实际上是一个对象,而不是字符串。

There is an error in you're sql query right before Resource id #2 , mysql server can't iterpret it . Resource id #2之前的sql查询中出现错误,mysql服务器无法对其进行解释。 Post the full query and we'll be able to tell you more about the error . 发布完整的查询,我们将能够告诉您有关该错误的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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