Warning: mysql_real_escape_string() expects parameter 2 to be resource

I recently moved a website to a new server and now a specific form keeps throwing this error
Warning: mysql_real_escape_string() expects parameter 2 to be resource, null given in /home/blackhil/public_html/ordercatelog.php on line 185

184 $bname = $_POST['to_name'];
185 $bname = mysql_real_escape_string($bname, $link);

The form works (sends emails and writes to database)
katleesAsked:
Who is Participating?
 
Rik-LeggerConnect With a Mentor Commented:
Try removing the ,$link (resource identifier):

mysql_real_escape_string($bname);

Open in new window


If that doesn't work,
use the same resource identifier as you use in mysql_query($query, $your_resource_identifier);
0
 
Ray PaseurCommented:
Print out the contents of $link with var_dump() and post it here, thanks.
0
 
katleesAuthor Commented:
resource(1) of type (mysql link)
0
 
Ray PaseurCommented:
Removing the $link will produce a "default" condition.  If you understand what that default condition is, and it is the condition you want to choose, you might be OK.  If you do not understand that please read the man page for the function.  You may want to consider which DB connection you want to have in play.
http://us.php.net/manual/en/function.mysql-real-escape-string.php
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.