I have a function that calls a SQL query, the function is type fetch_user
Now i get an Undefined Index error when I call my query, The error message is
Undefined index: uid in profile.php on line 3
But the thing is that i cant find the error,
This is my user.inc.php that have the function
x
function fetch_user_info($uid){
$uid = (int)$uid;
$sql = "SELECT
`user_name` AS `username`,
`user_email` AS `email`
FROM `users`
WHERE `user_id` = {$uid} ";
$result = mysql_query($sql);
return mysql_fetch_assoc($result);
}
?>
And this is my profile.php that gets the function
$user_info = fetch_user_info($_GET['uid']);
print_r($user_info);
Any ideas what could be the problem ?
Advertisement
Answer
It means the GET variable uid
is unset, so you’re doing something wrong when calling the page.
Have you tried going to profile.php?uid=000 (where 000 is a uid
)