...

View Full Version : How to use ' sign in mysql queries.



withoutnick
05-04-2011, 07:52 PM
Hello,

I'm sure it's very easy to solve, but I don't have a lot of time, so I even don't search for the solution by myself.

So, mysql query breaks when the sign ' comes to the sentence. How is it possible to make these signs available with mysql query?

My mysql_query variable is described like that:

$mysql_query = "INSERT INTO `table` (`id` ,`title` ) VALUES (NULL , '$sentence')";

Thank you for your help!

Old Pedant
05-04-2011, 08:11 PM
mysql_real_escape_string( ).

To wit:


$sentence = mysql_real_escape_string($sentence);
$mysql_query = "INSERT INTO `table` (`id` ,`title` ) VALUES (NULL , '$sentence')";

oesxyl
05-04-2011, 08:12 PM
Hello,

I'm sure it's very easy to solve, but I don't have a lot of time, so I even don't search for the solution by myself.

So, mysql query breaks when the sign ' comes to the sentence. How is it possible to make these signs available with mysql query?

My mysql_query variable is described like that:

$mysql_query = "INSERT INTO `table` (`id` ,`title` ) VALUES (NULL , '$sentence')";

Thank you for your help!

http://www.php.net/manual/en/function.mysql-real-escape-string.php

best regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum