Jump to content

Invalid MySQL result resource


neridaj

Recommended Posts

Hello,

 

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:

 

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>';
}

 

Is it because I'm not using mysql_query? I tried that and I just got connection errors so I reverted back to:

$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

Link to comment
Share on other sites

  • 2 weeks later...

me too i'm getting same error...here is my code

<?php  
  

mysql_select_db($database_JaceyConn, $JaceyConn); 
    $sql = "SELECT  product_name, product_price, product_status from
            FROM  product   
            WHERE product_id = $productId;";

    $result = mysql_query($sql, $JaceyConn); 
     
    while ($row_result = mysql_fetch_array($result)) { 
        
        echo $row_result['product_name']; 
    } 
     
     ?>

 

where is the error?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.