Jump to content

Recommended Posts

hey i've echoed this onto the page and pasted it into mysql... i have an error in my mysql syntax...

 

I'm assuming I cannot use all of these "and where's" that i have in my code.

 

What would be an alternative way do do this?

 

 $conn = db_connect();

  // insert customer address
  $query = "UPDATE `orders` SET `c_phone` = '$c_phone', `c_email` = '$c_email', `card_type` = '$card_type', `card_number` = '$card_number', `card_month` = '$card_month', `card_year` = '$card_year', `card_name` = '$card_name', `three_number` = $amex_code, `total_amount` = $c_total, `total_cost` = $t_price, `total_shipping` = $c_ship WHERE `orders` .`ship_name` = '$name' AND WHERE `orders` .`amount` = '$t_price' AND WHERE `orders` .`ship_address` = '$address'";
  
  echo $query;

Link to comment
https://forums.phpfreaks.com/topic/54227-trouble-updating-info/
Share on other sites

Try:

$conn = db_connect();

  // insert customer address
  $query = "UPDATE `orders` SET `c_phone` = '$c_phone', `c_email` = '$c_email', `card_type` = '$card_type', `card_number` = '$card_number', `card_month` = '$card_month', `card_year` = '$card_year', `card_name` = '$card_name', `three_number` = $amex_code, `total_amount` = $c_total, `total_cost` = $t_price, `total_shipping` = $c_ship WHERE `ship_name` = '$name' AND `amount` = '$t_price' AND `ship_address` = '$address'";
  
  echo $query;

Link to comment
https://forums.phpfreaks.com/topic/54227-trouble-updating-info/#findComment-268110
Share on other sites

SQL query:

UPDATE `orders` SET `c_phone` = '555.555.5555',
`c_email` = 'test@testing.com',
`card_type` = 'VISA',
`card_number` = '5555666677778888',
`card_month` = '01',
`card_year` = '00',
`card_name` = 'mr. test',
`three_number` =123,
`total_amount` = ,
`total_cost` = 58.42,
`total_shipping` = 12.99 WHERE `ship_name` = 'mr. test' AND `amount` = '58.42' AND `ship_address` = '121 test lane'

MySQL said: Documentation
#1064 - 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 ' `total_cost` = 58.42, `total_shipping` = 12.99 WHERE `ship_name` = 'mr. test' A' at line 1

 

 

here is what echoed onto the page:

 

SQL query:

UPDATE `orders` SET `c_phone` = '555.555.5555',
`c_email` = 'test@testing.com',
`card_type` = 'VISA',
`card_number` = '5555666677778888',
`card_month` = '01',
`card_year` = '00',
`card_name` = 'mr. test',
`three_number` =123,
`total_amount` = ,
`total_cost` = 58.42,
`total_shipping` = 12.99 WHERE `ship_name` = 'mr. test' AND `amount` = '58.42' AND `ship_address` = '121 test lane'

MySQL said: Documentation
#1064 - 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 ' `total_cost` = 58.42, `total_shipping` = 12.99 WHERE `ship_name` = 'mr. test' A' at line 1

 

i pasted this into the sql and got the above error

Link to comment
https://forums.phpfreaks.com/topic/54227-trouble-updating-info/#findComment-268113
Share on other sites

sorry... this is what echoed onto the page.. :

 

UPDATE `orders` SET `c_phone` = '555.555.5555', `c_email` = 'test@testing.com', `card_type` = 'VISA', `card_number` = '5555666677778888', `card_month` = '01', `card_year` = '00', `card_name` = 'mr. test', `three_number` = 123, `total_amount` = , `total_cost` = 58.42, `total_shipping` = 12.99 WHERE `ship_name` = 'mr. test' AND `amount` = '58.42' AND `ship_address` = '121 test lane'

Link to comment
https://forums.phpfreaks.com/topic/54227-trouble-updating-info/#findComment-268114
Share on other sites

$conn = db_connect();

  // insert customer address
  $query = "UPDATE `orders` SET `c_phone` = '$c_phone', `c_email` = '$c_email', `card_type` = '$card_type', `card_number` = '$card_number', `card_month` = '$card_month', `card_year` = '$card_year', `card_name` = '$card_name', `three_number` = '$amex_code', `total_amount` = '$c_total', `total_cost` = '$t_price', `total_shipping` = '$c_ship' WHERE `ship_name` = '$name' AND `amount` = '$t_price' AND `ship_address` = '$address'";
  
  echo $query;

 

Just INSERT into the sql db and get the query it shows you after that...

Link to comment
https://forums.phpfreaks.com/topic/54227-trouble-updating-info/#findComment-268117
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.