mysql syntax question
Posted: Tue Feb 14, 2006 10:12 am
I have the following mysql statement:
Which appeared to be working correctly, as it wouldn't create an error. But when veiwing the database it didn't actually change anything. Eventhough I was displaying all values directly before the UPDATE... so the variables were correct.
But when I change the WHERE to read:
With single quotes around the $original_name it works correctly.
I assume that I should have the single quotes around all variables?
Thanks
EDIT: The reason I ask is because I copied the first $sql statement from a different page changed some values and the original statement didn't use single quotes around the last variable. So, I'm wondering why one works without the quotes and one doesn't.
Code: Select all
$sql = "UPDATE inv_type SET inv_type_name='$type_name', inv_type_function='$type_function'
WHERE inv_type_name=$original_name";But when I change the WHERE to read:
Code: Select all
$sql = "UPDATE inv_type SET inv_type_name='$type_name', inv_type_function='$type_function'
WHERE inv_type_name='$original_name' ";I assume that I should have the single quotes around all variables?
Thanks
EDIT: The reason I ask is because I copied the first $sql statement from a different page changed some values and the original statement didn't use single quotes around the last variable. So, I'm wondering why one works without the quotes and one doesn't.