MySQL INSERT help please!
Posted: Sun Apr 25, 2010 8:43 am
Hello
Im sure there is a simple answer to this that im not seeing but anyways....
I am using the php code:
INSERT INTO blog (title,date_day,date_month,date_year,time,auth_id,description,cat_id) VALUES ("'.$title.'","'.$_POST['date_day'].'","'.$_POST['date_month'].'","'.$_POST['date_year'].'","'.$_POST['time'].'",'.
$_POST['author'].',"'.$description.'","'.$category.'")';
To insert a blog entry into my database, which works fine. The problem comes because I am using CKeditor/CKfinder as the $description value.
If someone uses the WYSIWYG editor to upload a photo (for example) this generates typical HTML code for an image, something like <img src="images/logo.jpg" alt="logo" width="409" height="64"/> Which is added to the $description string.
When i try and insert this record, it brings up an error because of the "" marks in the image code is affecting the SQL string.
Kind of annoying because I know why its not working but cant work out how to fix it!
Any help you guys can offer would be greatly appreciated, thanks in advance
Im sure there is a simple answer to this that im not seeing but anyways....
I am using the php code:
INSERT INTO blog (title,date_day,date_month,date_year,time,auth_id,description,cat_id) VALUES ("'.$title.'","'.$_POST['date_day'].'","'.$_POST['date_month'].'","'.$_POST['date_year'].'","'.$_POST['time'].'",'.
$_POST['author'].',"'.$description.'","'.$category.'")';
To insert a blog entry into my database, which works fine. The problem comes because I am using CKeditor/CKfinder as the $description value.
If someone uses the WYSIWYG editor to upload a photo (for example) this generates typical HTML code for an image, something like <img src="images/logo.jpg" alt="logo" width="409" height="64"/> Which is added to the $description string.
When i try and insert this record, it brings up an error because of the "" marks in the image code is affecting the SQL string.
Kind of annoying because I know why its not working but cant work out how to fix it!
Any help you guys can offer would be greatly appreciated, thanks in advance