tags:

views:

41

answers:

5

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");

+2  A: 

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.

GSto
+1  A: 

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.

Seb
I got the following error :<pre>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 '9736364'' at line 1</pre>9736364 is value of $item_number.
Michael
The lasted version of the query that i have is<pre> mysql_query("UPDATE `view_item` SET `title` = '$title', `price` = '$price', `shipping` = '$shipping', `location` = '$location', `start_time` = '$start_time', `end_time` = '$end_time', `seller_userName` = '$seller_userName', `seller_UserNum` = '$seller_UserNum', `picture_link` = '$picture_link WHERE `item_number` = '$item_number'");</pre>
Michael
+1  A: 

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?

BenHayden
indeed I just seen that I also update item_number with item_number so I removed this from the syntax but the rest of syntax is fine . Basically I'm trying to update the details(title, price, etc) related to the item_number.
Michael
A: 

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

ahmet2106
+1  A: 

Seriously, use mysqli and parameterized queries.

Donnie