Jump to content

Strange PHP-MySQL Problem


vvenomouss

Recommended Posts

I am facing a strange problem while adding rows to MySQL, I googled alot but could not find a solution either. Here is an example:

 

$text = "hello \' \" hello';
echo $text; // prints hello \' \" hello as expected


$database->query("INSERT into table (madID, ad_text) VALUES (NULL, '$text')"); 

 

The entry is successfully added to the database but not with the slashes, it is added like:

hello ' " hello

 

I cant figure out why is Mysql removing those slashes, I have magic quotes turned off...

Link to comment
https://forums.phpfreaks.com/topic/190954-strange-php-mysql-problem/
Share on other sites

No, I am not calling any stripslashes function, moreover if the actual string did not have the "\", mysql would not add it and return an error which means the string sent to Mysql is actually stripped...

 

I tried my example as:

 

$text = $_POST['something']; // without using addslashes ($_POST['something'] contained " & ')

 

and Mysql did not add the entry returned error

You sure you're not calling any functions such as stripslashes before inserting your data into your query?

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.