my_sql_fetch problem
Posted: Sun Nov 18, 2012 10:19 pm
I did user profile registration system but when i want to go to profile.php or profile.php?uid=3 i get
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in public_html/core/inc/user.inc.php on line 33
That user does not exist.
Now i dont know, is it a problem with a profile.php code, user,inc.php code or maybe hosting?
Profile.php code
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in public_html/core/inc/user.inc.php on line 33
That user does not exist.
Now i dont know, is it a problem with a profile.php code, user,inc.php code or maybe hosting?
Profile.php code
<?php include('core/init.inc.php'); $user_info = fetch_user_info($_get['uid']); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>Global Betting</title> </head> <body> <div> <?php if ($user_info === false){ echo 'That user does not exist.'; }else{ ?> <h1><?php echo $user_info['website'] ?> <?php echo $user_info['titles']; ?></h1> <p>Username: <?php echo $user_info['username']; ?></p> <p>Grad: <?php echo $user_info['grad']; ?></p> <p>Drzava: <?php echo $user_info['drzava']; ?></p> <p>Fan of: <?php echo $user_info['fan']; ?></p> <p>Website: <?php echo $user_info['website']; ?></p> <p>Titles: <?php echo $user_info['titles']; ?></p> <p></p> <?php } ?> </div> </body> </html>User.inc.php code
<?php function fetch_users (){ $result = mysql_query('SELECT `userID` AS `id`, `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 `username` AS `username`, `grad` AS `grad`, `drzava` AS `drzava', `fan` AS `fan`, `Website` AS `Website`, `Titles` AS `Titles` FROM users WHERE `userID` = '$uid'"; $result = mysql_query($sql); return mysql_fetch_assoc($result); } function set_profile_info($grad, $drzava, $fan, $website, $titles){ $grad = mysql_real_escape_string(htmlentities($grad)); $drzava = mysql_real_escape_string(htmlentities($drzava)); $fan = mysql_real_escape_string(htmlentities($fan)); $website = mysql_real_escape_string(htmlentities($website)); $titles = mysql_real_escape_string(htmlentities($titles)); $uid = $_SESSION['uid']; $sql = "UPDATE users SET grad='$grad' drzava='$drzava' fan='$fan' website='$website' titles='$titles' WHERE UserID = '$uid'"; mysql_query($sql); } ?>