I'm getting this error:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in output_fns.php on line 416
Here are the two functions involved:
Code: Select all
function get_user_info($username)
{
// connect to db
$conn = db_connect();
// query user info
$result = $conn->query("select first_name, last_name, email from user where username='$username'");
if (!$result)
return false;
else
return $result;
}
function display_folders()
{
$userinforesult = get_user_info($username);
if(!$userinforesult)
echo 'nothing';
else
while ($row = mysql_fetch_array($result, MYSQL_NUM)) { // line 416
printf("Last Name: %s Last Name: %s Email: %s", $row[0], $row[1], $row[2]);
}
echo '<a href="logout.php">Logout</a>';
$userfolder = $_SESSION['valid_user'] . '/';
echo '<table align="center" border="1" cellpadding="5"><tr><th></th></tr><tr>';
$dir = 'members/' . $userfolder;
$files = scandir($dir);
foreach($files as $value) {
if(!in_array($value, array('.', '..'))) {
// check for folders
if(is_dir($dir.DIRECTORY_SEPARATOR.$value)) {
printf('<td><a href="preview.php?pa=%s">'.
'<img src="'. $dir . $value .'.jpg" width=75" height="75" />'.
'<br />%s<a/></td>',
$value, $value);
}
}
}
echo '</tr></table>';
}
$result = $conn->query(), which at least connects and returns something. Is there an alternative to mysql_fetch_array() that I should be using instead?
Thanks for any help,
Jason