Wonderful little PHP problem.

Soldato
Joined
26 Jun 2009
Posts
3,023
Location
Sheffield
Hi there, I'm using this little bit of code:

Code:
$id = $_REQUEST['id'];
$id = mysql_real_escape_string($id);
echo $id;

The $id just contains a number, in fact any number that I care to put into it, but for some reason when the 2nd isn't commented out, it empties the variable?

I've paired the script right down so that is literally all that is left PHP wise.

If I remove the 2nd line, it displays whatever is in the $id. If I change mysql_real_escape_string to strip_slashes, then it works. :s

Just wondering if anyone can help? I've got to be missing something, I've never had a problem like this before. :(
 
Last edited:
Are you actually using mysql_connect anywhere, or are you simply just calling mysql_real_escape_string? You haven't said what the script is so my next sentence is based on an assumption!

You're only meant to use mysql_real_escape_string when interacting with a database. It'll throw an error if you aren't (or not if you don't display errors or are supressing the errors), which is why you're not getting anything.
 
Cheers guys but the duy in the first post had it! I have a require_once() that has all the connection data and the link was broken. :P
 
Back
Top Bottom