Problemen met MySQL met leden systeem
Jamiel - 01/06/2008 14:21 (laatste wijziging 01/06/2008 16:44)
Nieuw lid
Ik krijg als ik op submit klik krijg ik deze foutmelding: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/arens/domains/arens.gethost.nl/public_html/register.php on line 136
dit is mijn script:
<?
if($_SESSION['login'] == "true"){
print " You have allready an account.";//because your logged in stupid
}
include('connect.inc.php');
if(!isset($_REQUEST['submit'])){
?>
<form method=post acion=""<? $_SERVER['PHP_SELF'] ?>"">
<table>
<tr>
<td>
<font face=verdana size=1>Username:
</td>
<td>
<input type="text" name="name" maxlength="15">
</td>
</tr>
<tr>
<td>
<font face=verdana size=1>Password:
</td>
<td>
<input type="password" name="pass1">
</td>
</tr>
<tr>
<td>
<font face=verdana size=1>Confirm:
</td>
<td>
<input type="password" name="pass2">
</td>
</tr>
<tr>
<td>
<input type="submit" value=submit name="submit">
</td>
<td>
<input type="reset">
</td>
</tr>
</table>
</form>
<?php
}else{
//request everything
$dead = "false";//We make 'dead' if some fields are not filled in don't check for pass and name in db.
$message = "<font face=verdana size=1>Pleas fill in all fields correctly:<br>";
$username = $_POST['name'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
$ip = $_SERVER['REMOTE_ADDR'];
$status = "1";//1 member, 2,co-admin 3, admin
//begin search for errors
if(strlen($username) <= 1 or strlen($username) >=15){
$dead = "true";
$message .= "Username (2-14)<br>";
}
if(strlen($pass1) < 6 or strlen($pass1) > 20 or $pass1 !== $pass2) {
$dead = "true";
$message .= "Password (6-20) or passwords does not match";
}
if($dead = "false"){
$username = strtolower(trim(strip_tags($username)));
$pass1 = trim($pass1);
$pass1 = md5($pass1);
$query = mysql_query("SELECT * FROM members WHERE username ='$username'");
$aantalrijen = mysql_num_rows($query);
if($aantalrijen == 1){
print "<font face=verdana size=1>Sorry, your username exists allready.";
}
else{
$query1 = "INSERT INTO members(username, password, ip, status) VALUES ('$username','$pass1', '$ip','$status')";
if(mysql_query($query1)){
print "<font face=verdana size=1>Well donne your now a member of the RTD group.<br><a href=login.php>Login</a>";
}
}
}
elseif($dead == "true"){
print $message;
}
}
?>
<?
if ( $_SESSION [ 'login' ] == "true" ) {
print " You have allready an account." ; //because your logged in stupid }
include ( 'connect.inc.php' ) ;
if ( ! isset ( $_REQUEST [ 'submit' ] ) ) { ?>
<form method=post acion=""<? $_SERVER [ 'PHP_SELF' ] ?> "">
<table>
<tr>
<td>
<font face=verdana size=1>Username:
</td>
<td>
<input type="text" name="name" maxlength="15">
</td>
</tr>
<tr>
<td>
<font face=verdana size=1>Password:
</td>
<td>
<input type="password" name="pass1">
</td>
</tr>
<tr>
<td>
<font face=verdana size=1>Confirm:
</td>
<td>
<input type="password" name="pass2">
</td>
</tr>
<tr>
<td>
<input type="submit" value=submit name="submit">
</td>
<td>
<input type="reset">
</td>
</tr>
</table>
</form>
<?php
} else {
//request everything
$dead = "false" ; //We make 'dead' if some fields are not filled in don't check for pass and name in db.
$message = "<font face=verdana size=1>Pleas fill in all fields correctly:<br>" ;
$username = $_POST [ 'name' ] ;
$pass1 = $_POST [ 'pass1' ] ;
$pass2 = $_POST [ 'pass2' ] ;
$ip = $_SERVER [ 'REMOTE_ADDR' ] ;
$status = "1" ; //1 member, 2,co-admin 3, admin
//begin search for errors
$dead = "true" ;
$message .= "Username (2-14)<br>" ;
}
if ( strlen ( $pass1 ) < 6 or
strlen ( $pass1 ) > 20 or
$pass1 !== $pass2 ) { $dead = "true" ;
$message .= "Password (6-20) or passwords does not match" ;
}
if ( $dead = "false" ) {
$query = mysql_query ( "SELECT * FROM members WHERE username ='$username '" ) ; if ( $aantalrijen == 1 ) {
print "<font face=verdana size=1>Sorry, your username exists allready." ; }
else {
$query1 = "INSERT INTO members(username, password, ip, status) VALUES ('$username ','$pass1 ', '$ip ','$status ')" ;
print "<font face=verdana size=1>Well donne your now a member of the RTD group.<br><a href=login.php>Login</a>" ; }
}
}
elseif ( $dead == "true" ) {
}
}
?>
wat moet ik doen?
Psycho schreef:
Als eerste moet je leren de UBB tags te gebruiken...
8 antwoorden
Gesponsorde links
Jamiel - 01/06/2008 14:24 (laatste wijziging 01/06/2008 14:25)
Nieuw lid
<?
if($_SESSION['login'] == "true"){
print " You have allready an account.";//because your logged in stupid
}
include('connect.inc.php');
if(!isset($_REQUEST['submit'])){
?>
<form method=post acion=""<? $_SERVER['PHP_SELF'] ?>"">
<table>
<tr>
<td>
<font face=verdana size=1>Username:
</td>
<td>
<input type="text" name="name" maxlength="15">
</td>
</tr>
<tr>
<td>
<font face=verdana size=1>Password:
</td>
<td>
<input type="password" name="pass1">
</td>
</tr>
<tr>
<td>
<font face=verdana size=1>Confirm:
</td>
<td>
<input type="password" name="pass2">
</td>
</tr>
<tr>
<td>
<input type="submit" value=submit name="submit">
</td>
<td>
<input type="reset">
</td>
</tr>
</table>
</form>
<?php
}else{
//request everything
$dead = "false";//We make 'dead' if some fields are not filled in don't check for pass and name in db.
$message = "<font face=verdana size=1>Pleas fill in all fields correctly:<br>";
$username = $_POST['name'];
$pass1 = $_POST['pass1'];
$pass2 = $_POST['pass2'];
$ip = $_SERVER['REMOTE_ADDR'];
$status = "1";//1 member, 2,co-admin 3, admin
//begin search for errors
if(strlen($username) <= 1 or strlen($username) >=15){
$dead = "true";
$message .= "Username (2-14)<br>";
}
if(strlen($pass1) < 6 or strlen($pass1) > 20 or $pass1 !== $pass2) {
$dead = "true";
$message .= "Password (6-20) or passwords does not match";
}
if($dead = "false"){
$username = strtolower(trim(strip_tags($username)));
$pass1 = trim($pass1);
$pass1 = md5($pass1);
$query = mysql_query("SELECT * FROM members WHERE username ='$username'");
$aantalrijen = mysql_num_rows($query);
if($aantalrijen == 1){
print "<font face=verdana size=1>Sorry, your username exists allready.";
}
else{
$query1 = "INSERT INTO members(username, password, ip, status) VALUES ('$username','$pass1', '$ip','$status')";
if(mysql_query($query1)){
print "<font face=verdana size=1>Well donne your now a member of the RTD group.<br><a href=login.php>Login</a>";
}
}
}
elseif($dead == "true"){
print $message;
}
}
?>
<?
if ( $_SESSION [ 'login' ] == "true" ) {
print " You have allready an account." ; //because your logged in stupid }
include ( 'connect.inc.php' ) ;
if ( ! isset ( $_REQUEST [ 'submit' ] ) ) { ?>
<form method=post acion=""<? $_SERVER [ 'PHP_SELF' ] ?> "">
<table>
<tr>
<td>
<font face=verdana size=1>Username:
</td>
<td>
<input type="text" name="name" maxlength="15">
</td>
</tr>
<tr>
<td>
<font face=verdana size=1>Password:
</td>
<td>
<input type="password" name="pass1">
</td>
</tr>
<tr>
<td>
<font face=verdana size=1>Confirm:
</td>
<td>
<input type="password" name="pass2">
</td>
</tr>
<tr>
<td>
<input type="submit" value=submit name="submit">
</td>
<td>
<input type="reset">
</td>
</tr>
</table>
</form>
<?php
} else {
//request everything
$dead = "false" ; //We make 'dead' if some fields are not filled in don't check for pass and name in db.
$message = "<font face=verdana size=1>Pleas fill in all fields correctly:<br>" ;
$username = $_POST [ 'name' ] ;
$pass1 = $_POST [ 'pass1' ] ;
$pass2 = $_POST [ 'pass2' ] ;
$ip = $_SERVER [ 'REMOTE_ADDR' ] ;
$status = "1" ; //1 member, 2,co-admin 3, admin
//begin search for errors
$dead = "true" ;
$message .= "Username (2-14)<br>" ;
}
if ( strlen ( $pass1 ) < 6 or
strlen ( $pass1 ) > 20 or
$pass1 !== $pass2 ) { $dead = "true" ;
$message .= "Password (6-20) or passwords does not match" ;
}
if ( $dead = "false" ) {
$query = mysql_query ( "SELECT * FROM members WHERE username ='$username '" ) ; if ( $aantalrijen == 1 ) {
print "<font face=verdana size=1>Sorry, your username exists allready." ; }
else {
$query1 = "INSERT INTO members(username, password, ip, status) VALUES ('$username ','$pass1 ', '$ip ','$status ')" ;
print "<font face=verdana size=1>Well donne your now a member of the RTD group.<br><a href=login.php>Login</a>" ; }
}
}
elseif ( $dead == "true" ) {
}
}
?>
Jamiel - 01/06/2008 14:31
Nieuw lid
hoe verander ik dat?
Jamiel - 01/06/2008 14:38
Nieuw lid
hij doet het nog steeds niet
Jamiel - 01/06/2008 14:50
Nieuw lid
waar dan precies?
Jamiel - 01/06/2008 14:52
Nieuw lid
waar achter me query
Jamiel - 01/06/2008 15:22
Nieuw lid
nu krijg ik een tstring error
Ibrahim - 02/06/2008 11:06
PHP expert
@Sandernerd, de error is een T_STRING error, dat betekent dat hij ergens een quote ofzo niet heeft afgesloten.
@Jamiel: het zou handig zijn als je je code op plaatscode zet en per verandering het even update zodat de rest het proces mee kunnen volgen.
Gerard - 09/06/2008 01:45
Ouwe rakker
Probeer het anders eens met dit script . Of neem er anders een voorbeeldje aan ;)
Gesponsorde links
Dit onderwerp is gesloten .