How do i enter the following text into the database ?
date of meeting = '4/4/2003'
i have tried
$text="date of meeting = '4/4/2003'";
$result=MYSQL_QUERY( "update $table SET text='$text') where user='$user' ");
but it doesn`t add it - any ideas ?
thanks
inserting special chars in mysql
Moderator: General Moderators
are you trying to make it a new table or just add it into the database?
if youre just adding it into the database, it should look like this:
if youre just adding it into the database, it should look like this:
Code: Select all
<?
$sql = "INSERT INTO `table name` (column name, column name) values ("value","value","value")";
?>Code: Select all
<?php
$sql = "INSERT INTO `$table` (`text`) VALUES ('" . $addslashes($text) . "' WHERE `user` = '$user')";
mysql_query($sql) or die(mysql_error()."<p>$sql");
?>stripslashes
just remeber to do a striplashes() on the value when you pull it out of the db or you will not get the correct output and you will end up with a case of the nasty backslashes.
each backslash will be escaped as well as the orginal character that it was escaping.
bob's place
bob''s place
bob\\''s place
you get the idea and doing a stripslashes will only remove the escaping \ so you would end up with
bob''s place if you stripslashed just the last line.
avoid the headache now and remeber the stripslashes() function
learned from a really bad experience.
phpScott
each backslash will be escaped as well as the orginal character that it was escaping.
bob's place
bob''s place
bob\\''s place
you get the idea and doing a stripslashes will only remove the escaping \ so you would end up with
bob''s place if you stripslashed just the last line.
avoid the headache now and remeber the stripslashes() function
learned from a really bad experience.
phpScott
