douyiyang6317 2013-08-14 19:56
浏览 104
已采纳

SQL语法错误[关闭]

I have the following code.

<?php
include ('include/DB_Functions.php');

if(isset($_POST['submit']))
{   $id =$_REQUEST['roomid'];
    $title = $_POST['title'];
    $uid = $_POST['clientId'];
    $location = $_POST['location'];
    $quantity = $_POST['number'];
    $price = $_POST['price'];
    $size = $_POST['size'];
    $description = $_POST['description'];
    $categoryID = 1;
    $sellerAddress = $_POST['selleradd'];
    $sellerPhone = $_POST['sellerphn'];

    mysql_query("UPDATE room_tb SET location ='$location', quantity ='$quantity',price ='$price',area ='$size' description = '$description' postTitle = '$title' WHERE roomID = '$id'")
                or die(mysql_error()); 

    echo "Saved!";  

header('Location:table.php'); 
}

I get an 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 'description = '' postTitle = '' WHERE roomID = '983'' at line 1 What have i done wrong. The DB_Functions.php contains all database connectivity.

  • 写回答

6条回答 默认 最新

  • duandou8457 2013-08-14 19:58
    关注

    Well of course, look at your sql query... it's missing commas.

    UPDATE room_tb SET location ='$location', quantity ='$quantity',price ='$price',area ='$size' description = '$description' postTitle = '$title' WHERE roomID = '$id'"
    

    Should be:

    UPDATE room_tb SET location ='$location', quantity ='$quantity', price ='$price', 
    area ='$size', description = '$description', postTitle = '$title' WHERE roomID = '$id'"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部