pappakaka Posted February 6, 2011 Share Posted February 6, 2011 I get this 2 errors everytime i hit "Sign Up" in my registration form i'm creating for my new website: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in on line 64[/b] [b]Deprecated: Function eregi() is deprecated in [php file location] on line 87[/b] I have created a database in, MySQL with phpMyAdmin, named "membership" and a table named "users" with these fields: Field Type Collation Attributes Null Default Extra username varchar(20) latin1_swedish_ci No None first_name varchar(30) latin1_swedish_ci No None last_name varchar(30) latin1_swedish_ci No None password varchar(30) latin1_swedish_ci No None email varchar(50) latin1_swedish_ci No None gender text latin1_swedish_ci No None birth_day date No None This is the 2 parts of the php code where i get the 2 errors: [code=php:0] public function user_exists() { mysql_connect("localhost","root","101Dalmatiner") or die(mysql_error()); mysql_select_db("membership") or die (mysql_error()); $data = mysql_query("SELECT ID FROM users WHERE username = '{$this->username}'"); return mysql_num_rows($data) > 0 ? 1 : 0; <---- the line where the first error appears }[/code] [code=php:0] if(empty($this->email) || !eregi('^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]{2,4}$',$this->email)) $this->errors[] = 'Invalid Email';[/code] There is all the neccesary informationg you'll need if your willing to look through it all and help my i think! I'm kinda new to php and MySQL so don't blame me if the code is messed up or something look really wrong, i'd appreciate any help i can get on this! Quote Link to comment https://forums.phpfreaks.com/topic/226882-please-help-i-cant-figure-out-what-the-errors-mean-and-wants-me-to-do/ Share on other sites More sharing options...
Fergal Andrews Posted February 6, 2011 Share Posted February 6, 2011 hi pappakaka, The first error is because your SQL statement is failing. This looks like it is because there is no column called ID. Try changing it to SELECT username FROM users WHERE username = '{$this->username}' The second error is because eregi is deprecated. This means that it is being phased out of PHP. I think it is no longer in PHP 5.3 but I'm not certain about that. A deprecated function will still work but it is not good to use it. Use preg_match instead: if(empty($this->email) || !preg_match('/^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z]{2,4}$/',$this->email)) $this->errors[] = 'Invalid Email'; cheers, Fergal Quote Link to comment https://forums.phpfreaks.com/topic/226882-please-help-i-cant-figure-out-what-the-errors-mean-and-wants-me-to-do/#findComment-1170651 Share on other sites More sharing options...
pappakaka Posted February 6, 2011 Author Share Posted February 6, 2011 Thank you so much! Solved it instantly! Wish i had your brain! Quote Link to comment https://forums.phpfreaks.com/topic/226882-please-help-i-cant-figure-out-what-the-errors-mean-and-wants-me-to-do/#findComment-1170686 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.