Jump to content

Please help! I can't figure out what the errors mean and wants me to do??


pappakaka

Recommended Posts

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!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.