开发者

php mysql , update query is not working

I'm trying to update some info into database but for some reasons it doesn't update. Also I'm not getting error in the server logs.

mysql_query("UPDATE `view_item` SET
              `item_number` = $item_number,
              `title` = $title,
              `price` = $price,
              `shipping` = $shipping, 
              `location` = $location,
              `start_time` = $start_time,
              `end_time` = $end_time,
              `seller_userName` = $seller_userName,
              `seller_UserNum` = $seller_UserNum,
              `number_of_bids` = $number_of_bids,
              `picture_link` = $picture_link 
       开发者_开发百科     WHERE `item_number` = $item_number");


you need to add quotes around your php variables

SET `item_numer` = '$item_number'

and so on. If that doesn't fix the problem. try running the query directly in MySQL and see what DB errors it throws.


This question is too vague...

Run this after that query to see what's happening:

echo mysql_error();

Also, it's a great, useful habit to get your query in a variable and then run it, so you can see what it ultimately has before executing it:

$query = "UPDATE whatever";
// Here you can see what you'll be running
// echo $query;
mysql_query($query);

If you did this, you'd realize you're missing string quotes in your query.


Seriously, use mysqli and parameterized queries.


The query is kinda off - you are trying to update item_number with $item_number, but also trying to limit the query to WHEREitem_number= $item_number. This wouldn't work if the new item number is different than the old one. Do you have access to the old item number? Or do you even need to update it?


I'm using

mysql_query("UPDATE view_item SET item_number = '$item_number', title = '$title', price = '$price', shipping = '$shipping', location = '$location', start_time = '$start_time', end_time = '$end_time', seller_userName = '$seller_userName', seller_UserNum = '$seller_UserNum', number_of_bids = '$number_of_bids', picture_link = '$picture_link' WHERE `item_number` = '$item_number'");

something like this and mine is working

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜