Jump to content

Mysql Error When Text Field Has '


derekshull

Recommended Posts

I have the following code below and my problem is that in the description field if someone puts a ' (like when they use can't or won't or don't) it has an error....because it makes it act like the query is ending...how do I fix this?

 

global $user;
$needsusername = $user->name;

$needsip = $_POST['ip'];
$firstname = $_POST['firstname'];
$city = $_POST['city'];
$state = $_POST['state'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$typeofneed = $_POST['typeofneed'];
$description = $_POST['description'];
$orgname = $_POST['organizationname'];
if (!mysql_query("INSERT INTO needs (firstname, city, state, phone, email, typeofneed, description, needsip, needsusername, orgname) VALUES ('$firstname', '$city', '$state', '$phone', '$email', '$typeofneed', '$description', '$ip', '$needsusername', '$orgname')")) {
die('Error: ' . mysql_error());
}

Link to comment
https://forums.phpfreaks.com/topic/269661-mysql-error-when-text-field-has/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.