Jump to content

PHP mysql_real_escape_string and xampp


Zoranos

Recommended Posts

Hi, i had today problem with my script. Everything worked well on my localhost(xampp server) and when i uploaded on dedi machine functions with MySQL database stoped working. Problem was with mysql_real_escape_string and i forgot that i must first open connection and then mysql_real_escape_string...

 

But strange thing is that on xampp server i dont need to open connection for mysql_real_escape_string, and everything worked well... is there any solutio to php scripts on xampp worke same as php script on linux apache server?

Link to comment
Share on other sites

The solution is to always open the connection first, then use mysql_real_escape_string()

 

Note:

 

A MySQL connection is required before using mysql_real_escape_string() otherwise an error of level E_WARNING is generated, and FALSE is returned. If link_identifier isn't defined, the last MySQL connection is used.

Link to comment
Share on other sites

The solution is to always open the connection first, then use mysql_real_escape_string()

 

Note:

 

A MySQL connection is required before using mysql_real_escape_string() otherwise an error of level E_WARNING is generated, and FALSE is returned. If link_identifier isn't defined, the last MySQL connection is used.

 

yes i know that, but i want to have same problem on xampp but there you can use mysql_real_escape_string without connection...

 

i want to know does enyone have solution for xampp...

Link to comment
Share on other sites

You should have php's error_reporting set to E_ALL (or even better a -1) and display_errors set to ON in your master php.ini on your xampp development system so that all the php detected errors will be reported and displayed.

 

As long as you are not using any server specific language extensions or system calls, there will be no difference when you run your php script between servers that have the same php.ini configuration and installed extensions.

 

It's highly unlikely your code is working the way you think it is on your xampp system without a mysql connection. You either do have a connection or your code isn't actually using the output from the mysql_real_escape_string statements. Posting your code (less any database credentials) would be the quickest way of both determining what it is doing or not doing both on your development system and the live server.

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.