Jump to content

mysql_real_escape_string


gilespatrickson

Recommended Posts

Hello and thanks in advance for the input.  I a fully functioning form.  I am validating the input and successfully inserting the input into the mysql database.  Now I am trying to escape the data by adding the basic line of code:

 

$name = mysql_real_escape_string($_POST['name']);

 

The input is successful but the mysql_database for name field is empty.  If I remove the above line of code and just input the value for $name (without escape) the update works great.  So the question is obvious for the above.  Why?

Link to comment
Share on other sites

You need a connection to the database server before you can use mysql_real_escape_string.

 

You should also have php's error_reporting set to E_ALL and display_errors set to ON so that php would be reporting and displaying all the errors it detects. You would be getting connection errors at the mysql_real_escape_string statement because it attempts to create a connection when a connection does not already exist.

 

 

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.