PDA

View Full Version : PHP Help.



powerfulsquid
02-20-02, 09:33 PM
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



<? 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.

4oh4
02-21-02, 01:04 PM
nm

Sadrok
02-21-02, 02:37 PM
can you maybe point out line 11 in your source. at least I can try to help you

powerfulsquid
02-21-02, 03:05 PM
woops, sorry. this is line 11


if(!mysql_numrows($result)) {

Sadrok
02-21-02, 03:16 PM
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

4oh4
02-21-02, 08:07 PM
That's it Sadrok. :)

It is mysql_num_rows.