Jump to content

You have an error in your SQL syntax;


jasraj

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.