Jump to content

Recommended Posts

Here is my index.php. It works like a charm :) Though I have a MAJOR problem. It wont run anymore and i get this sql error

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 '=''' at line 1
...?????? What? Where do I even start? Server version. Im using wamp 2.0. I dont know what to do. can anyone help or suggestions would much appreciated :)

 

runei :'(

 

<?php

session_start();
include "./global.php";


?>
<html>
<head>
<title>Content Management System</title>
</head>

<style type="text/css">
body {
	background-color:#999999;	
	font-family: Tahoma;
}

#holder {
	width: 90%;
	color:#000000;
	font-family: Tahoma;
	border:1px solid #000;
	padding:10px;
}

/*'#userInfo {
	width: 100%;
	color: #000;
	font-family: Tahoma;
	border: 1px solid #CCC;
*/	
}

</style>

<body>
<center>
	<div id="holder">
	<div id="userInfo">
	<?php

	//Checks if session exists and does a query.
	if($_SESSION['uid']){
		$sql = "SELECT id,username FROM `users` WHERE ='".$SESSION['uid']."'";
		$res = mysql_query($sql) or die(mysql_error());

		//Ending session..
		if(mysql_num_rows($res) == 0){
			session_destroy();
			echo "Please <a href=\"./login.php\">Login</a> to your account or <a href=\"./register.php\">Register</a> new account!\n";
		//One session that exists..
		}else{
			$row = mysql_fetch_assoc($res);
			echo"Welcome back <a href=\"./index.php?act=profile&id=".$row['id']."\">".$row['username']."</a>!\n";
		}

	}else{
		echo "Please <a href=\"./login.php\">Login</a> to your account or <a href=\"./register.php\">Register</a> new account!\n";

	}
	?>


	</div>

</center>



</body>

</html>

Link to comment
https://forums.phpfreaks.com/topic/124998-solved-mysql-major-issue/
Share on other sites

$sql = "SELECT id,username FROM `users` WHERE ='".$SESSION['uid']."'";

 

See something missing?  After WHERE you have a variable.  You need to compare $SESSION['uid'] with something...

 

WHERE field_user = '".$SESSION['uid']."'";

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.