mysql error

Status
Not open for further replies.

Benden

maging ang maganda mamatay
Jun 4, 2010
2,280
1,480
Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\zelo\register.php on line 26

here is line 26: $username_exist = mysql_num_rows($checkuser);

Here is the full code,

PHP:
<?php
/* 
============================================================================
-----ZeloCMS - Built for roleplay hotels.
============================================================================
-----Copyright (C) 2011 Undefiend. All rights reserved.
-----All layouts, scripts and images
============================================================================
-----ZeloCMS is provided "as is"
-----As this is a free release their is no warrenty.
-----ZeloCMS is a free release, Any provit goes to the creator
============================================================================*/

require_once'./include/config.php'; 
?>
<head>
<title> HabbSpin </title>
	<link type="text/css" rel="stylesheet" href="./style/login.css" />
</head>
<?php
$name = $_POST['name'];
$password = md5($_POST['password']);

$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'"); 

$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0){
    echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";
    unset($username);
    include 'register.html';
    exit();
}
$query = "INSERT INTO users (name, password)
VALUES('$name', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();

echo "You have successfully Registered";
?>

<div class="bot">
<?php
include'./include/login_footer.php';
?>
</div>
 

Kryptos

prjRev.com
Jul 21, 2010
2,205
1,252
No, you don't have to edit the database.
Look, I'll do it easier for you. Just put this:
PHP:
<?php 
/** 
============================================================================ 
-----ZeloCMS*-*Built*for*roleplay*hotels. 
============================================================================ 
-----Copyright*(C)*2011*Undefiend.*All*rights*reserved. 
-----All*layouts,*scripts*and*images 
============================================================================ 
-----ZeloCMS*is*provided*"as*is" 
-----As*this*is*a*free*release*their*is*no*warrenty. 
-----ZeloCMS*is*a*free*release,*Any*provit*goes*to*the*creator 
============================================================================*/ 

require_once'./include/config.php';* 
?> 
<head> 
<title>*HabbSpin*</title> 
****<link*type="text/css"*rel="stylesheet"*href="./style/login.css"*/> 
</head> 
<?php 
$name*=*$_POST['name']; 
$password*=*md5($_POST['password']); 

$checkuser*=*mysql_query("SELECT*username*FROM*users*WHERE*name='$name'");* 

$username_exist*=*mysql_num_rows($checkuser); 

if($username_exist*>*0){ 
****echo*"I'm*sorry*but*the*username*you*specified*has*already*been*taken.**Please*pick*another*one."; 
****unset($username); 
****include*'register.html'; 
****exit(); 
} 
$query*=*"INSERT*INTO*users*(name,*password) 
VALUES('$name',*'$password')"; 
mysql_query($query)*or*die(mysql_error()); 
mysql_close(); 

echo*"You*have*successfully*Registered"; 
?> 

<div*class="bot"> 
<?php 
include'./include/login_footer.php'; 
?> 
</div>
You made a mess, this code is supposing that your username column in the database is named 'name'.
If you don't understand me I suggest you keep learning and not rush yourself.
Also, remember to delete the *'s, don't know how they appeared.
 
Status
Not open for further replies.

Users who are viewing this thread

Top