Hello,
I am trying to use the mysql_real_escape_string() function, but I can't seem to use it without losing the content of the variable. When I use

$act="It's now or never"
$act=mysql_real_escape_string($act);{

then attempt to insert the value of $act--it comes out null.

I have established the database connection, so that does not appear to be the problem.

Any idea what I'm doing wrong.

hmmm what is the { at the end of the $act=mysql_real_escape_string($act);

hmmm what is the { at the end of the $act=mysql_real_escape_string($act);

Indeed and did you use mysql_connect() before the mysql_real_escape_string() function? You need a mysql connection open before you are able to use mysql_real_escape_string().

cwarn23--Yes, I've established the database connection with mysql_connect()--I call it just before the mysql_real_escape_string() function.

ApocDen--I checked to see if the form field feeding the variable was empty before assigning the value--the "{" is from the the If-Else statement.

Thanks for any help you can provide--I've tried to use this function many times, but always have the same experience. It appears to be a very useful function and easier that using REPLACE.

Member Avatar for Zagga

Hi visualmonk,

It may have been a typo, but don't you need a semicolon at the end of line1?

$act="It's now or never"[B];[/B]

Zagga

Thanks to everyone for the help in this.

Your if else might not be executing that portion of the code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.