Jump to content

Archived

This topic is now archived and is closed to further replies.

lamajlooc

Probably a dumb question...

Recommended Posts

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

Share this post


Link to post
Share on other sites
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???

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.