dongpo5239 2011-11-24 16:26
浏览 41
已采纳

插入数据库php变量

I have got this code:

$title = mysql_real_escape_string($_POST['title']);
$description = mysql_real_escape_string($_POST['description']);
$method = mysql_real_escape_string($_POST['method']);

$method1 = '<ul><li>' . implode('</li><li>', explode("
", $description)) . '</li></ul>';


mysql_query("INSERT INTO recipe (title, description, method) VALUES('".$title."', '".$description."', '".$method1."')");

But it isnt adding anything to my database. Should this code be working?

UPDATE***

I have added the following code but it is not outputing anything

if($success)
{
echo "<h1>Success</h1>";
}
else
{
echo "<h1>Error</h1>";
}
  • 写回答

3条回答 默认 最新

  • dougan6402 2011-11-24 16:27
    关注

    try to wrap your fields with ''

    "INSERT INTO recipe (`title`, `description`, `method`) VALUES('".$title."', '".$description."', '".$method1."')");
    

    look on reserved words

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata