Jump to content

Query not updating.


Namtip

Recommended Posts

I've echoed all the variables and all the values match up.

 

problem: There is no parse of sql error, but the query does not update the database.

$query3 = 'UPDATE ecomm_orders_details
    SET
        feedback = "' . mysql_real_escape_string($feed) . '",
    WHERE
        order_id = "' . $order_id . '"';
mysql_query($query3, $db) or (mysql_error($db));
        header('Refresh: 5; URL=main.php');

 

Can you guys see why this isn't working?

Link to comment
Share on other sites

 

since adding or die to the query I get this error messages with the adaptions to the code.

$query3 = 'UPDATE ecomm_orders_details
    SET
        feedback = "' . mysql_real_escape_string($feed) . '",
    WHERE
        order_id = ' . $order_id;
mysql_query($query3, $db) or die(mysql_error($db));

 

I recieve this error: Duplicate entry '1' for key 'PRIMARY'

 

$query3 = 'UPDATE ecomm_orders_details
    SET
        feedback = "' . mysql_real_escape_string($feed) . '",
    WHERE
        order_id = ' . $order;
mysql_query($query3, $db) or die(mysql_error($db));

 

and I get: 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 'WHERE order_id = 1' at line 4

Link to comment
Share on other sites

$query3 = 'UPDATE ecomm_orders_details
    SET
        feedback = "' . mysql_real_escape_string($feed) . '",
    WHERE
        order_id = "' . $order . '"';
mysql_query($query3, $db) or die(mysql_error($db));

 

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 'WHERE order_id = "1"' at line 4

 

I don't understand why it has a problems with where order_id = 1. because thats where I want the query to change the already existing column.

Link to comment
Share on other sites

I don't know what you have for a query at this point, but I can tell you that the original query is invalid.

 

UPDATE ecomm_orders_details SET feedback = "1", WHERE order_id = "1" 

 

The comma is invalid.  The query should be:

 

UPDATE ecomm_orders_details SET feedback = '1' WHERE order_id = 1 

 

I'm actually not even sure if this is correct because it depends on the datatype of the feedback column.  If things are "strings" you put quotes around the values.  If they are numbers, then you don't.  Regardless, you can't have a comma hanging out there, commas only go  in the list of columns or values part of a query.  For update queries it would only be in the SET part of the query if you're updating multiple columns.

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.