PHP MySQL fetch_array error (boolian given)
i'm currently working on a user profile page. The code should get the
username from the URL with the $_GET function. But when I want to echo
this data it gives a weird error,
( ! ) Warning: mysql_fetch_array() expects parameter 1 to be resource,
boolean given in C:\wamp\www\pvp\user.php on line 22
Call Stack
# Time Memory Function Location
1 0.0010 675120 {main}( ) ..\user.php:0
2 0.0111 697392 mysql_fetch_array ( ) ..\user.php:22
This is the code:
require 'includes/connection.php';
require 'includes/common.php';
if(empty($_SESSION['user']))
{
echo '<a href="login.php">login here</a> to view this profile!';
}else {
echo 'you are logged in!';
if(isset($_GET['user'])){$user=$_GET['user'];echo $user;
$query = "SELECT * FROM `users` WHERE username = $_GET[user]";
$result = mysql_query($query);
$post = mysql_fetch_array($result);
}
else {echo 'No user selected';}
}
What am I doing wrong?? Please help me out thanks
No comments:
Post a Comment