Problem inserting html code in database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
winsonlee
Forum Commoner
Posts: 76
Joined: Thu Dec 11, 2003 8:49 pm

Problem inserting html code in database

Post by winsonlee »

When i tried saving html codes into the mysql database, it comes out the following error.

Code: Select all

Failed to execute query: 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 '<IMG src="http://techcommunity.us/uploads/smil3dbd4dbc14f3f.gi


"<IMG src=\"http://techcommunity.us/uploads/smil3dbd4dbc14f3f.gif\"> a"

The above is the string that i tried to insert into the database using the bellow code.

Code: Select all

$title = $_POST&#1111;'title'];
$message = $_POST&#1111;'yourFieldNameHere'];

echo $message;

$result = database("INSERT INTO xoops_weblog ( blog_id , user_id , cat_id , created , title , contents , private , comments , reads , description , dohtml ) VALUES ('', '1', '2', UNIX_TIMESTAMP(NOW()), '$title', $message, 'N', '0', '0', '', '0')");
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

put single quotes around $message
Post Reply