...

View Full Version : Posting Apostrophes



stevenmw
10-20-2009, 11:32 AM
I've written a simple script that submits text from a textarea into a database using the $_POST function.

For some reason the text area cannot submit apostrophes.

Can anyone tell me how to make my form submit apostrophes?

mlseim
10-20-2009, 01:26 PM
Show us your script ...

It relates to "stripslashes"

stevenmw
10-21-2009, 02:01 AM
my code:

require('config.php');

$message = $_POST['message'];
$cat = $_POST['cat'];
$date = date("dMy");
$time = date("h:ia");

$query = "INSERT INTO talk (id, message, date, time) VALUES ('', '$message', '$date', '$time')";

mysql_query($query) or die(mysql_error());

mlseim
10-21-2009, 02:15 AM
Steven, Try this ...



require('config.php');

$message = mysql_real_escape_string($_POST['message']);
$cat = $_POST['cat'];
$date = date("dMy");
$time = date("h:ia");

$query = "INSERT INTO talk (id, message, date, time) VALUES ('', '$message', '$date', '$time')";

mysql_query($query) or die(mysql_error());




Then, the apostrophe contains a slash ...
So when you read it back out, you'll need to remove slashes ...

$message = stripslashes($message);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum