I'm inserting text into a MySQL database. My first test was as follows:
do i need to use addslashes()? i probably don't know what i'm doing, but who cares?
no big deal, right?
Well, I get this when I echo it all back out onto a page:
do i need to use addslashes()? i probably don()'t know what i()'m doing, but who cares? no big deal, right?
I put parenthesis around those backslashes 'cause the board is removing them when they're next to single quotes. Is this an addslashes() thing? This is the code I'm using (notice the addslashes before inserting - should it come as I echo it back out?):
if(isset($_POST['submit'])){
$_POST['body'] = addslashes($_POST['body']);
$db = mysql_connect("localhost", "mybhicom_db", "Ihadn63r!");
mysql_select_db("mybhicom_website");
$q = "INSERT INTO mynews VALUES ('NULL','" . $_POST['title'] . "','" . $_POST['body'] . "',now());";
mysql_query($q,$db); }
Thanks boys and girls. I appreciate your help.
EDIT:
Well, I just tried using addslashes() as I echoed the text back onto a page, but it just turned \ into \. 😕