Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\profile\include\user.inc.php on line 32
Code (PHP)
<?php
//user from table
function fetch_users(){
$result = mysql_query('SELECT `user_id` AS `id`, `user_username` AS `username` FROM `users`');
$users = array();
while (($row = mysql_fetch_assoc($result)) !== false){
$users[] = $row;
}
return $users;
}
//profile information
function fetch_user_info($uid){
$uid = (int)$uid;
$sql = "SELECT
`user_username` AS `username`,
`user_password AS `password`,
`user_name` AS `name`,
`user_email` AS `email`,
`user_about` AS `about`,
`user_status` AS `status`
FROM `users`
WHERE `user_id = {$uid}";
$result = mysql_query($sql);
return mysql_fetch_assoc($result);
}
?>
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 '`, `user_name` AS `name`, `user_email` AS `email`, `user_about' at line 3
<?php
function fetch_users(){
$result = mysql_query('SELECT `user_id` AS `id`, `user_username` AS `username` FROM `users`');
$users = array();
while (($row = mysql_fetch_assoc($result)) !== false){
$users[] = $row;
}
return $users;
}
function fetch_user_info($uid){
$uid = (int)$uid;
$sql = "SELECT *
`user_username` AS `username`,
`user_pwd` AS `password`,
`user_name` AS `name`,
`user_email` AS `email`,
`user_about` AS `about`,
`user_status` AS `status`
FROM `users`
WHERE `user_id = {$uid}";
$result = mysql_query($sql) or die(mysql_error());
return mysql_fetch_assoc($result);
}
?>