Insert html tag into db?

I’m trying to insert html tag into a db field but I keep getting this error?

Error: (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 ‘from) VALUES (’<p>‘)’ at line 1

My code is as follows;

$rep = htmlentities('<p>');
		
$insert = "INSERT INTO ".$prefix."_str_replaces (from) VALUES ('$rep')";
mysql_query($insert) or die("Error: (" . mysql_errno() . ") " . mysql_error());

Where do I go wrong?

Thanks in advance…

from is a reserved word. If you’re using it for a field name… #1 i’d recommend not (because of the aforementioned problem), but if you absolutely must use from, put backticks (`) around the field name in the query.

the error message is telling you ~exactly~ where you went wrong – the column named “from”

FROM is a reserved word, and if you want to use a reserved word as a column name (hint: you shouldn’t) then you have to escape it properly

:slight_smile:

edit: curses, sniped again! :smiley:

Oh yes…,. Stupid me… Thanks for pointing this out :slight_smile: