lamajlooc Posted October 12, 2006 Share Posted October 12, 2006 I'm trying to write a registration script and I keep getting this error:Warning: mysql_real_escape_string() expects parameter 2 to be resource, boolean given in /mysite/connect.php on line 30Here's the offending code: // Check that the e-mail address conforms if (eregi ("^[[:alnum:]][a-z0-9_.-]*@[a-z0-9.-]+\.[a-z]{2,4}$", stripslashes(trim($_POST['email'])))) { $e = escape_data($_POST['email']); } else { $e = FALSE; echo '<p><font color="red" size="+1">Please enter a valid email address.</p></font>'; } Link to comment https://forums.phpfreaks.com/topic/23730-probably-a-dumb-question/ Share on other sites More sharing options...
Firemankurt Posted October 12, 2006 Share Posted October 12, 2006 1 - I'm guesing you are not actually connected to MySQL database before calling [b]mysql_real_escape_string ()[/b] somewhere (looks like file is : [b]connect.php[/b] on line 30)[i]string[/i] mysql_real_escape_string ( [i]string[/i] unescaped_string[i] [, resource link_identifier][/i] )2 - maybe your script is putting a boolean value in place of the optional [u]resource link_identifier[/u].I'm not sure why you believe the problem is in the code you posted??? Link to comment https://forums.phpfreaks.com/topic/23730-probably-a-dumb-question/#findComment-107794 Share on other sites More sharing options...
lamajlooc Posted October 12, 2006 Author Share Posted October 12, 2006 Originally I thought I wasn't connecting to the DB as well but not only do I not get a connect error but there are about four if statemetns that rely on the DB before the e-mail one I posted (which is line 27-33), for example this apparently executes fine:// Check for a last name if (eregi ("^[[:alpha:].' -]{2,30}$", stripslashes(trim($_POST['last_name'])))) { $ln = escape_data($_POST['last_name']); } else { $ln = FALSE; echo '<p><font color="red" size="+1">Please enter your last name.</font></p>'; }I get that PHP thinks I'm passing it a boolean (that's the error message) but I what I can't figure out where that's happening, and as for the code I posted, that is the if containing line 30 which is, apparently, where the error is occuring (according to PHP).Like I said, this is probably some dumb newbie issue but I'm at my wits' end. Link to comment https://forums.phpfreaks.com/topic/23730-probably-a-dumb-question/#findComment-107970 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.