Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2003
    Posts
    8

    Unanswered: need help with PHP/MySQL query syntax

    Here's the line of code I'm having trouble with:

    $update_data_query = "UPDATE prices SET (part_no=".$part_no_update.",part_description=".$p art_description_update.",price_1_9=".$price_1_9_up date.",price_10_24=".$price_10_24_update.",price_2 5_49=".$price_25_49_update.",price_50_99=".$price_ 50_99_update.",price_100=".$price_100_update." WHERE part_no=".$part_no.")";

    The query works on the command line (with different syntax) and the variables contain values. I don't get a syntax error, the query simply won't run.

    I would appreciate any advice or help that anyone has- thanks!

  2. #2
    Join Date
    Oct 2002
    Location
    Plymouth UK
    Posts
    116
    you are missing the quotes required for the SQL statement. You need to modify your code like this:

    Code:
    $update_data_query = "UPDATE prices SET (part_no='".$part_no_update."',part_description='".$part_description_update.'"
    ,price_1_9='".$price_1_9_update."'
    ,price_10_24='".$price_10_24_update."',price_25_49='".$price_25_49_update."'
    ,price_50_99='".$price_50_99_update."',price_100='".$price_100_update."'
     WHERE part_no='".$part_no."')";
    Last edited by gannet; 06-26-03 at 06:44.

  3. #3
    Join Date
    Jun 2003
    Posts
    8

    gannet,

    Thanks for replying!

    Not trying to anticipate you but I did what you're suggesting, as per my reference book, and that didn't work either.

    I'll redo my code as per your suggestion and look again for any logical problems.

  4. #4
    Join Date
    Oct 2002
    Location
    Plymouth UK
    Posts
    116
    You could try displaying $update_data_query on your page to help look for errors. I often find this helpful especially with complex queries. That way you can also see the value of the variables.

  5. #5
    Join Date
    Jun 2003
    Posts
    2
    If you're not getting a syntax error then be happy.

    Directly after this line:

    mysql_query($update_data_query);

    simply add this line to your code

    print mysql_error($link);

    where $link is the variable you used to establish the connection to your database.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •