PHP:
<?php
if(isset($_POST['confirm'])){
$db = mysql_connect('localhost','uname','pass');
mysql_select_db("test", $db);
$gawa = "CREATE TABLE users(
userID int NOT NULL AUTO_INCREMENT,
PRIMARY KEY(userID),
Username varchar(15),
Password varchar(15),
E-mail varchar(25),
Age int,
Gender int
)";
mysql_query($gawa,$db);
mysql_query("INSERT INTO users (Username,Password,E-Mail,Age,Gender)
VALUES ('$_POST[uname]','$_POST[pass]','$_POST[email]','$_POST[age]','$_POST[gender]')");
$result = mysql_query("SELECT * FROM users");
while($slect = mysql_fetch_array($result)){
echo $slect['Username'].'<br/>';
echo $slect['Password'].'<br/>';
echo $slect['E-mail'].'<br/>';
echo $slect['Age'].'<br/>';
echo $slect['Gender'].'<br/>';
}
mysql_close($db);
}else{
echo <<<FORM
<form method="POST" action="">
Username:<input type="text" name="uname"/><br/>
Password:<input type="password" name="pass" /><br/>
E-Mail Address:<input type="text" name="email" /><br/>
Age:<input type="text" name="age"/><br/>
Gender: <input type="radio" name="gender" value="Male"/>Male <input type="radio" name="gender"value="Female"/>Female
<input type="hidden" name="confirm"/><br/>
<input type="submit" value="Register"/>
</form>
FORM;
}
?>
When i try out the form it says after submitting:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in Register.php on line 20
This is line 18
Code:
while( $slect = mysql_fetch_array($result) ){