Help

Any problem with SQL can be discussed here.
Post Reply
Gebbo
Posts: 554
Joined: Tue May 16, 2006 3:22 pm

Help

Post by Gebbo »

help im trying to set up something on my site for registration.
When i **** register i have this error


Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/gebboth/public_html/register.php on line 5
people already have.

this is the code i dont know whats wrong with it its not registering because of the error help!


<?php include("head.php"); ?>

Register to get your Gamers-Fusion account now, and begin the game. Password Sent to E-mail.
<?php
$nump = mysql_num_rows(mysql_query("3"));
print " $nump people already have.";
?>



<form method=post action=register.php?action=register>
<table>
<tr><td>Username:</td><td><input type=text name=user></td></tr>
<tr><td>Email:</td><td><input type=text name=email></td></tr>
<tr><td>Verify Email:</td><td><input type=text name=vemail></td></tr>
<?php
print "<tr><td>Referral ID:</td><td><input type=text name=ref readonly value=$ref> If you don't know what this is, leave it blank.</td></tr>";
?>
<tr><td colspan=2 align=center><input type=submit value=Register></td></tr>
</form>

<?php
if ($action == register) {
if (!$user || !$email || !$vemail ) {
print "You must fill out all fields.";
include("foot.php");
exit;
}
$dupe1 = mysql_num_rows(mysql_query("select * from players where user='$user'"));
if ($dupe1 > 0) {
print "Someone already has that username.";
include("foot.php");
exit;
}
$dupe2 = mysql_num_rows(mysql_query("select * from players where email='$email'"));
if ($dupe2 > 0) {
print "Someone already has that email.";
include("foot.php");
exit;
}
if ($email != $email) {
print "The emails do not match.";
include("foot.php");
exit;
}
$ref = strip_tags($ref);
$user = strip_tags($user);
$pass = strip_tags($pass);
if ($ref) {
mysql_query("update players set refs=refs+1 where id=$ref");
}
$pass = rand(10000 , 90000);
$message = "welcome to $gamename your pass is $pass login now and change it. have fun playing at $gamename. Webmaster";
mysql_query("insert into players (user, email, pass) values('$user','$email','$pass')") or die("Could not register.");
mail("$email", "$gamename", $message,
"From: webmaster@{$_SERVER['SERVER_NAME']}\r\n"
."Reply-To: webmaster@{$_SERVER['SERVER_NAME']}\r\n"
."X-Mailer: PHP/" . phpversion()) or die("could not send mail");

print "You are now registered to play, $user. Please check your e-mail for your pass and login now.";
print "
<a herf=index.php>login</a>";
}
?>

<?php include("foot.php"); ?>


.............................:: Spirit of Fire ::..................................

Image
Magdreamer
Posts: 2
Joined: Sun Dec 03, 2006 11:52 am

Post by Magdreamer »

im a newbie to mysql so i cant help, but why is noone responding...
vinter
Posts: 27
Joined: Fri Dec 22, 2006 5:08 pm

Post by vinter »

$nump = mysql_num_rows(mysql_query("3"));


I dont know what exactly you are trying to do in this line. The PHP function mysql_query exacutes a MySQL query. The query you want to execute has to be written within quotes inside the brackets. Now if this line has to do something tangible, "3" has to be a MySQL query which it is not. Since it's not a query, the function mysql_query returns something meaningless. Something thats not even close to a normal mysql_query result. However, the function mysql_num_rows is accustomed to getting inputs that are the results of certain mysql queries and hence it finds itself in a discomforting dilemma when it sees this weird thing that has come as an output of mysql_query. And hence... The Error.


In short, you should write something of the kind SELECT * FROM noobs WHERE brain = '0' instead of 3!
Post Reply