Jump to content

Recommended Posts

Hey i keep getting this error in my code and i can't seem to work out why its not work could you please help thank you.

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #6' at line 1

 

<?php 

session_start();

include('../library/connectdb.php');
include('../library/selectdb.php');
include('../library/log_report.php');

$username = $_POST['username'];
$password = $_POST['password'];


// see if there is this user is on the databass
$result = "SELECT * FROM gb_login 
		LEFT JOIN customers ON gb_login.customer_id=customers.customer_id
		WHERE username = '$username' AND userpassword = '$password'";
$result = mysql_query ($result) or die (mysql_error());
$row = mysql_fetch_assoc($result);

//this user is on the databass, set this user as a customer.
if ($row['userstatus']=='active'){
if (mysql_num_rows ($result) == 1){
	switch ($row['userlevel']){
		case"2":
			$_SESSION['user_logged_in'] = true;
			$_SESSION['userid'] = $row['gblogin_id'];
			$_SESSION['customerid'] = $row['customer_id'];
			header('Location: ../website/index.php');
		break;
		//this user is on the databass, set the user as a admin.
		case"1":
			$_SESSION['admin_logged_in'] = true;
			header('Location: ../admin/index.php');
		break;
	}
}
}
else {
$result - "SELECT userstatus FROM gb_login WHERE username='$username' AND password='$password' LIMIT 1;";
$result = mysql_query ($result) or die (mysql_error());
$row = mysql_fetch_assoc($result);
$userstatus = $row['userstatus'];
if ($userstatus == 'disabled'){
	$_SESSION["message"] = "Account Has Been Disabled";
	header('Location: login.php');
}
else {
	$_SESSION["message"] = "login failed, maybe you forgot your password";
	header('Location: login.php');
}
}

?>

Link to comment
https://forums.phpfreaks.com/topic/170291-you-have-an-error-in-your-sql-syntax/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.