Jump to content

extract() expects parameter 1 to be array no information displayed.


Namtip

Recommended Posts

Problem:

"Warning: extract() expects parameter 1 to be array, null given in C:\x\xampp\htdocs\pages\user_personal.php on line 32" - error also found on lines 33 and 38.

and none of the information is displayed.

 

Goal: I'm trying to retrieve profile information and multiple user inserted pictures and display the pictures through a while loop from one query.

 

 

 

<?php$query = 'SELECT        u.name_id, i.bio, i.exhib, p.product_code        FROM        user u LEFT JOIN profile i ON u.name_id = i.name_id	LEFT JOIN ecomm_products p ON u.name_id = p.product_code        WHERE        u.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '" and p.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '"';    $result = mysql_query($query, $db) or die(mysql_error());extract($bio);  //line 32extract($exhib); //line 33$odd = true;while ($row = mysql_fetch_array($result)) {    echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">';    $odd = !$odd;     extract($rows); line 38    echo '<td><a href="' . $dir . '/' . $row['product_code'] . '.jpg">';    echo '<img src="' . $thumbdir . '/' . $row['product_code'] . '.jpg">';    echo '</a></td>';    echo '</tr>';	}	echo "</table>";	echo "<p>";?>  <ul>   <li>Biography: <?php echo $bio; ?></li>   <li>Exhibitions: <?php echo $exhib; ?></li>  </ul>

 

This works.

 

<?php$query = 'SELECT        u.name_id, i.bio, i.exhib, p.product_code        FROM        user u LEFT JOIN profile i ON u.name_id = i.name_id	LEFT JOIN ecomm_products p ON u.name_id = p.product_code        WHERE        u.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '" and p.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '"';    $result = mysql_query($query, $db) or die(mysql_error());$row = mysql_fetch_array($result);extract($row);mysql_free_result($result);mysql_close($db);	?>  <ul>   <li>Biography: <?php echo $bio; ?></li>   <li>Exhibitions: <?php echo $exhib; ?></li>  </ul>

 

 

but i want try to loop out the pictures it says different errors.

This gives out this error "Warning: mysql_fetch_array(): 5 is not a valid MySQL result resource in C:\x\xampp\htdocs\pages\user_personal.php on line 54"

 

<?php$query = 'SELECT        u.name_id, i.bio, i.exhib, p.product_code        FROM        user u LEFT JOIN profile i ON u.name_id = i.name_id	LEFT JOIN ecomm_products p ON u.name_id = p.product_code        WHERE        u.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '" and p.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '"';    $result = mysql_query($query, $db) or die(mysql_error());$row = mysql_fetch_array($result);extract($row);mysql_free_result($result);mysql_close($db);	?>  <ul>   <li>Biography: <?php echo $bio; ?></li>   <li>Exhibitions: <?php echo $exhib; ?></li>  </ul>  <p><a href="update_profile.php">Update Profile</a> |<a href="upload_image.php">Upload Work</a> |<a href="update_account.php">Update Account</a> |<a href="delete_account.php">Delete Account</a> |<a href="logout.php">Sign out</a>   </p></body></html><?php$odd = true;while ($row = mysql_fetch_array($result)) {                 // line 54    echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">';    $odd = !$odd;     extract($rows);    echo '<td><a href="' . $dir . '/' . $row['product_code'] . '.jpg">';    echo '<img src="' . $thumbdir . '/' . $row['product_code'] . '.jpg">';    echo '</a></td>';    echo '</tr>';	}	echo "</table>";	echo "<p>";?>

 

Is it not possible to pull two different results from the array? Do I need to give variables to the mysql WHERE function in the SELECT table?

 

Am I making sense?  :shy:

<?php
$query = 'SELECT
        u.name_id, i.bio, i.exhib, p.product_code
        FROM
        user u LEFT JOIN profile i ON u.name_id = i.name_id
	LEFT JOIN ecomm_products p ON u.name_id = p.product_code
        WHERE
        u.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '" and p.name = "' . mysql_real_escape_string($_SESSION['name'], $db) . '"';
    $result = mysql_query($query, $db) or die(mysql_error());

$row = mysql_fetch_array($result);
extract($row);

?>
<html>
<head></head>
<body>
  <ul>
   <li>Biography: <?php echo $bio; ?></li>
   <li>Exhibitions: <?php echo $exhib; ?></li>
  </ul>
  <p><a href="update_profile.php">Update Profile</a> |
<a href="upload_image.php">Upload Work</a> |
<a href="update_account.php">Update Account</a> |
<a href="delete_account.php">Delete Account</a> |
<a href="logout.php">Sign out</a>
   </p>

<?php
$odd = true;
while ($row = mysql_fetch_array($result)) {
    echo ($odd == true) ? '<tr class="odd_row">' : '<tr class="even_row">';
    $odd = !$odd; 
    extract($rows);
    echo '<td><a href="' . $dir . '/' . $row['product_code'] . '.jpg">';
    echo '<img src="' . $thumbdir . '/' . $row['product_code'] . '.jpg">';
    echo '</a></td>';
    echo '</tr>';
	}
	echo "</table>";
	echo "<p>";

?>
</body>
</html>

No error messages display but no photos loop either. Sorry to be a bother. :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.