I have a query which pulls user info from a database table, and displays it in an HTML table. The user then has the ability to edit this data on the next page by clicking continue, where the first and last name are passed as variables, and are listed as uneditable, whereas all the other fields are able to be edited through a simple form.
Here's my problem, on the final page where the actual database UPDATE occurs, I'm getting a SQL error that looks like this
Error performing query: You have an error in your SQL syntax near 'WHERE first_name='Joe' AND last_name='Schmoe' SET street_address_1='real address' at line 1
It looks like its passing the first and last name fine (through hidden inputs), yet when I start to pass the edited fields as variables, it cuts off for some reason. The actual full value that I entered for "street_address_1" was "real address 333". It looks like it cut off after the "address", and didnt even bother to send the other 8 fields.
My code on the processing page looks like this
$street_address_1_update=$POST['street_address_1_update'];
$street_address_2_update=$POST['street_address_2_update'];
$city_update=$_POST['city_update'];
$sql ="UPDATE mailing_list WHERE first_name='$first_name_update' AND last_name='$last_name_update' SET street_address_1='$street_address_1_update' street_address_2='$street_address_2_update' city='$city_update'"
I only included 3 fields for brevity's sake. The rest pass the same way as these three. Again, the first and last names are simply passed as hidden inputs through the form.
Anybody have any clue what might be causing this? I know the error is a SQL one, but I may not be passing the variables correctly in PHP.
Any help is appreciated.