试图使用表单将数据插入到我的数据库中,但我不断收到此错误 [英] trying to insert data into my database using a form and I keep getting this error

查看:93
本文介绍了试图使用表单将数据插入到我的数据库中,但我不断收到此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:您的SQL语法有错误;检查与您的MySQL服务器版本相对应的手册以获取正确的语法,以在第1行的资源ID#3"附近使用

这是我可以帮助他人解决此错误的代码,我已经重做了很多,但不确定是什么问题.


Error: 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 ''Resource id #3'' at line 1

Here is the code that I have can someone help me with this error, I have redone this a ton and not sure what the problem is.


<?php
require_once("database.php");

$sql = "INSERT INTO Recipe(Category, Recipe Name, Ingredients, Preparations, Cooking Time, Servings, Optional Notes) VALUES ('$category','$recipename','$ingredients','$preparations','$cookingtime','$servings','$optionalnotes')";
$sql = mysql_query("SELECT * FROM Recipe",$conn) or die("Problem reading table: " .mysql_error());

    if (!mysql_query($sql,$conn))
  {
        die('Error: ' . mysql_error());
  }
        echo "1 record added";
        mysql_close($con)


?>

推荐答案

sql = 插入到配方中(类别,配方名称,配料,制备,烹饪时间,份量,可选说明)值('
sql = "INSERT INTO Recipe(Category, Recipe Name, Ingredients, Preparations, Cooking Time, Servings, Optional Notes) VALUES ('


类别','


食谱名称','


这篇关于试图使用表单将数据插入到我的数据库中,但我不断收到此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆