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

Ensure that 'session_stat()' was in'success.php'.

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

yes it is

Edit: Thanks working now :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.