Helpful Information
 
 
Category: PHP Development
Problem in inserting values into database thru variables.

I'm trying to insert a value into a table thru a varible which ia a string type.
If the string is a simple text without any quotes (' or ") embeded, it's inserting but if there is any quotes embeded in the string it does not inserts, the reason being I'm writing the following code :
$query = "INSERT INTO (table) VALUES('$country','$description')";
$result = MYSQL_QUERY($query);

Now the variable '$description' contains a string which can have quotes embeded like (I'm a hard working guy). Now since there is a (') in the string it causes problem and does not execute the insert statement.
How can I overcome this problem.

Pl. help.

Dhiraj

Look in the manual under addslashes()

Try:

$description=addslashes($description);

before the query.










privacy (GDPR)