Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Update on a text field.

Status
Not open for further replies.

Knackers

Technical User
Apr 26, 2001
59
AU
New to PHP and MySQL....

I have a form to update data in a specific row. Data types for each of the columns are mostly VarChars but I also have a text field.

When I run an update query such as:

$sql = "UPDATE EMPLOYMENT SET ref='$ref',date='$date',title='$title',desc='$desc' WHERE id='$job_id'";

It fails at the 'desc' field which is the only test field.
If I run the query without the Desc field in it - no problems...

The MySQL error is:
You have an error in your SQL syntax near 'desc='new description' WHERE id='3'' at line 1

This has me completely stumped....

 
DESC is a reserved word in SQL. It sets the order to 'descending'.
Using reserved words as column or table names is not a good idea.
MySQL provides a workaround using the backticks to quote the offending word:
`desc`

As said above, using reserved words is never a good idea.
 
Yup.....desc for descending.

My only defence is that it is 4 in the morning down under....might go to bed now I have that sorted out.

Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top