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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.