0

Hi i have problem in my login code.
Firts someone fill in login informations
this is checking code

// mysql connection
$username=$_POST['username']; 
$password=md5($_POST['password']);


$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

$sql="SELECT * FROM users WHERE username = '$username' and password = '$password'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count==1){
session_register("username");    
session_register("password");
$_SESSION['username']=$username; 
header("location:success.php");

and this is part of "success.php" with error

//mysql connection
$username=$_SESSION['username'];
$resulta = mysql_query("SELECT access FROM users WHERE username=$username");                                                              
$acces = mysql_result($resulta, 0);   
$res=mysql_query("SELECT name FROM access WHERE id=$acces");
$access=mysql_result($res ,0);

and i have error : Warning: mysql_result() expects parameter 1 to be resource, boolean given in /home/users/richard/webgamesnet.g6.cz/web/success.php on line 10
Warning: mysql_result() expects parameter 1 to be resource, boolean given in /home/users/richard/webgamesnet.g6.cz/web/success.php on line 13

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by solidrichard
0

I think the last reply meant session_start();

Also, try putting single quotes around the $username variable in your MySQL select statement.

Example:

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

Hi i have problem in my login code.
Firts someone fill in login informations
this is checking code

// mysql connection
$username=$_POST['username']; 
$password=md5($_POST['password']);


$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

$sql="SELECT * FROM users WHERE username = '$username' and password = '$password'";
$result=mysql_query($sql);

$count=mysql_num_rows($result);

if($count==1){
session_register("username");    
session_register("password");
$_SESSION['username']=$username; 
header("location:success.php");

and this is part of "success.php" with error

//mysql connection
$username=$_SESSION['username'];
$resulta = mysql_query("SELECT access FROM users WHERE username=$username");                                                              
$acces = mysql_result($resulta, 0);   
$res=mysql_query("SELECT name FROM access WHERE id=$acces");
$access=mysql_result($res ,0);

and i have error : Warning: mysql_result() expects parameter 1 to be resource, boolean given in /home/users/richard/webgamesnet.g6.cz/web/success.php on line 10
Warning: mysql_result() expects parameter 1 to be resource, boolean given in /home/users/richard/webgamesnet.g6.cz/web/success.php on line 13

0

yes it is

Edit: Thanks working now :)

Edited by solidrichard: edit

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.