Results 1 to 6 of 6

Thread: PHP Help.

  1. #1
    Regular Member powerfulsquid's Avatar
    Join Date
    Apr 2000
    Location
    NJ
    Posts
    114

    PHP Help.

    hey guys, i just read a tutorial from devshed.com and used their code as a sample. it works and all, but i get an unwanted error and am unsure on how to get rid of it.

    this is the error:
    Warning: Supplied argument is not a valid MySQL result resource in c:\newsite\phptest\newuser.php on line 11

    Thanks for logging in!

    To see what the page looks like with your personal settings, please return.
    that obviously means it works, but i get that error. and i also know it works because i go back, login and etc. and it recognizes the new username.

    heres the code for the newuser.php

    Code:
    <? SetCookie("visitor",$login,time()+864000);  ?>
    <HTML>
    <HEAD><TITLE>Thanks!</TITLE></HEAD>
    <BODY>
    <?
    mysql_connect("localhost", "joe", "joe") or DIE("Unable to
    connect to database");
    @mysql_select_db("login5") or die("Unable to select database");
    
    $result = mysql_query("Select * from users where login='$login'");
    if(!mysql_numrows($result)) {
    #Make a new login - entire page follows
    $result = mysql_query("insert into users values (
    			'$login',
    			'$password',
    			NOW(),
    			'$news1',
    			'$news2',
    			'$news3')");
    ?>
    
    <br>
    Thanks for logging in!<br><br>
    To see what the page looks like with your personal
    settings, please <a href="index.php">return</a>.
    <? }
    
    else {
    
    echo "Whoa!  Someone has already picked that username!<br><br>";
    echo "Please hit the back button and pick a unique login.";
    
    } ?>
    </body>
    </html>

    does anyone know how to get rid of this error?

    also, this is using apache and mysql from my own computer, which i installed and am using for this script.

  2. #2
    New Member
    Join Date
    Jan 2002
    Posts
    46
    nm

  3. #3
    Regular Member Sadrok's Avatar
    Join Date
    Jul 2001
    Location
    South of Africa
    Posts
    265
    can you maybe point out line 11 in your source. at least I can try to help you
    You will experience a strong urge to do good; but it will pass.

  4. #4
    Regular Member powerfulsquid's Avatar
    Join Date
    Apr 2000
    Location
    NJ
    Posts
    114
    woops, sorry. this is line 11

    if(!mysql_numrows($result)) {

  5. #5
    Regular Member Sadrok's Avatar
    Join Date
    Jul 2001
    Location
    South of Africa
    Posts
    265
    agh. can't find any documents on PHP.
    mebe it's mysql_num_rows and not mysql_numrows
    damn, wished I could've been more help
    You will experience a strong urge to do good; but it will pass.

  6. #6
    New Member
    Join Date
    Jan 2002
    Posts
    46
    That's it Sadrok.

    It is mysql_num_rows.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •