#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Seattle, WA,USA
    Posts
    84
    Rep Power
    14
    I have a script that checks to see if a users email address is already in the database. But I get this error "Warning: Supplied argument is not a valid MySQL result resource in /home/boham/www/noblesun/checkuserfirst.php on line 6"

    I used this code, and can't figure out what's going on!!
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>$Id_link = mysql_connect('myserver','username','password') &#0124; &#0124; die("cannot connect to db");

    $sql = "SELECT * FROM testaffiliate WHERE emailaddress ='$emailaddress'";
    $result = mysql_db_query("$Id_link","boham","$sql")&#0124; &#0124; die("Cannot excute sql query 1");
    $number_of_rows = mysql_num_rows($result) ;
    if ($number_of_rows > '0'){
    echo "<html>
    <head>
    <title>Error: Email already Exists</title>
    </head>
    <body>
    <h1 align="center"> Cannot have more than one account per e-mail</h1>
    <p> Your e-mail is already in our database. If you think this is incorrect, please email $affadmin
    </p>
    <font size = "1"><br><br>
    &copy; 2000 Noble Sun Storage Networks
    </font>
    </body>
    </html>";
    exit;
    }
    ......//rest emitted
    [/code]

    Please help, it is for a major client and I have a really close deadline.

    Thanks,

    -Jerome


  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Pune, Maharashtra, India
    Posts
    86
    Rep Power
    14
    You can try this things the error u told about comes mostly when table name or query is wroung .
    Try something like this:
    $sql = "SELECT * FROM testaffiliate WHERE emailaddress =$emailaddress"; $result = mysql_query($sql);
    if($row=mysql_fetc_array($result)
    {
    echo ("The email add. already exist in the database");
    }
    else
    {
    blah.....

    }
    If yet it dont work contact me at my mail add from my profile.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Seattle, WA,USA
    Posts
    84
    Rep Power
    14
    I'll try that. Thanks.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    51
    Rep Power
    14
    i think the problem is your mysql query. It should be like this:

    mysql_db_query($dbname, $str_sql, $id_link)

    you kinda got it messy hehe

    sam
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    Seattle, WA,USA
    Posts
    84
    Rep Power
    14
    Thanks nikunj,

    Your code worked (can't beleive I didn't think of it)

IMN logo majestic logo threadwatch logo seochat tools logo