PDA

View Full Version : Php Error On This - Help Please.



:Woof
04-08-2005, 12:03 PM
Errors ;
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/extreme/public_html/login/register.php on line 27

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home2/extreme/public_html/login/register.php on line 30
Table 'extreme_join.users' doesn't exist

Any ideas?

Im creating a simpel login / register system and when you enter all info to register you click enter and that error comes.

Thanks,
Whitecorn.

splintercell!
04-08-2005, 12:07 PM
post the contents of register please :) Also are you using the phpfreaks tutorial??

:Woof
04-08-2005, 12:13 PM
No im not :p


<?php
// set your infomation.
$dbhost='localhost';
$dbusername='extreme_join';
$dbuserpass='5d9v8e';
$dbname='extreme_join';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die("Cannot select database");

//Are they just getting here or submitting their info?
if (isset($_POST["username"])) {
$username = $_POST["username"];
$password = $_POST["password"];
$cpassword = $_POST["cpassword"];
$email = $_POST["email"];
//Was a field left blank?
if($username==NULL|$password==NULL|$cpassword==NUL L|$email==NULL) {
echo "A field was left blank.";
}else{
//Do the passwords match?
if($password!=$cpassword) {
echo "Passwords do not match";
}else{
//Has the username or email been used?
$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");
$username_exist = mysql_num_rows($checkuser);

$checkemail = mysql_query("SELECT email FROM users WHERE email='$email'");
$email_exist = mysql_num_rows($checkemail);

if ($email_exist>0|$username_exist>0) {
echo "The username or email is already in use";
}else{
//Everything seems good, lets insert.
$query = "INSERT INTO users (username, password, email) VALUES('$username','$password','$email')";
mysql_query($query) or die(mysql_error());
echo "The user $username has been successfully registered.";
}
}
}
}
?>
<h1>Register</h1>
<form action="register.php" method="POST">
<table style="border:1px solid #000000;">
<tr>
<td align="right">
Username: <input type="text" size="15" maxlength="25" name="username">
</td>
</tr>
<tr>
<td align="right">
Password: <input type="password" size="15" maxlength="25" name="password">
</td>
</tr>
<tr>
<td align="right">
Confirm Password: <input type="password" size="15" maxlength="25" name="cpassword">
</td>
</tr>
<tr>
<td align="right">
Email: <input type="text" size="15" maxlength="25" name="email">
</td>
</tr>
<tr>
<td align="center">
<input type="submit" value="Register">
</td>
</tr>
<tr>
<td align="center">
<a href="login.php">Login Here</a>
</td>
</tr>
</table>
</form>
</center>

There You Go :p

:Woof
04-08-2005, 12:39 PM
:o Enigma bumping :o means i have to ROFL!
Bump ^_^

мϊкэ
04-08-2005, 12:42 PM
this looks exactly like the thing im using at the moment so ill look through mine and check

try running this file


<?php
// set your infomation.
$dbhost='localhost';
$dbusername='extreme_join';
$dbuserpass='5d9v8e';
$dbname='extreme_join';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
//select the database
mysql_select_db($dbname) or die('Cannot select database');

//create the table, customize it if you want
$query = 'CREATE TABLE users(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
username VARCHAR(30) NOT NULL,
password VARCHAR(20) NOT NULL,
email VARCHAR(40) NOT NULL)';
$result = mysql_query($query);
echo "Table Created!";
?>

splintercell!
04-08-2005, 12:42 PM
that seems fine :S The coding seems ok.. sure you are connected to the database... although thats a different error "/ Im stuck sorry.

мϊкэ
04-08-2005, 12:44 PM
try running this file! call it install.php


<?php
// set your infomation.
$dbhost='localhost';
$dbusername='extreme_join';
$dbuserpass='5d9v8e';
$dbname='extreme_join';
// connect to the mysql database server.
mysql_connect ($dbhost, $dbusername, $dbuserpass);
//select the database
mysql_select_db($dbname) or die('Cannot select database');

//create the table, customize it if you want
$query = 'CREATE TABLE users(
id INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
username VARCHAR(30) NOT NULL,
password VARCHAR(20) NOT NULL,
email VARCHAR(40) NOT NULL)';
$result = mysql_query($query);
echo "Table Created!";
?>

:Woof
04-08-2005, 03:50 PM
OMG! it works ROFL thanks alot, And maybe it is maybe we have great minds ;p.

Anyway thanks
Whitecorn.

Want to hide these adverts? Register an account for free!