Jump to content


Photo

Probably a dumb question...


  • Please log in to reply
2 replies to this topic

#1 lamajlooc

lamajlooc
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 12 October 2006 - 05:33 AM

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 30

Here'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>';
        }

#2 Firemankurt

Firemankurt
  • Members
  • PipPipPip
  • Advanced Member
  • 56 posts
  • LocationWashington State

Posted 12 October 2006 - 07:22 AM

1 - I'm guesing you are not actually connected to MySQL database before calling mysql_real_escape_string () somewhere (looks like file is :  connect.php on line 30)

string mysql_real_escape_string ( string unescaped_string [, resource link_identifier] )

2 - maybe your script is putting a boolean  value in place of the optional resource link_identifier.

I'm not sure why you believe the problem is in the code you posted???

#3 lamajlooc

lamajlooc
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 12 October 2006 - 05:21 PM

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.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users