Problem in Retreiveng images from database...!

  • asad_black
  • Graduate
  • Graduate
  • asad_black
  • Posts: 131
  • Loc: pakistan

Post 3+ Months Ago

<?php


// database connection
$conn = mysql_connect("localhost", "sample", "12345")
OR DIE (mysql_error());
@mysql_select_db ("sample", $conn) OR DIE (mysql_error());
$sql = "SELECT * FROM links ";
$result = mysql_query ($sql, $conn);
while($row = mysql_fetch_array($sql))
{
// $row = @mysql_fetch_array ($result);
$image_type = $row["link"];
$image = $row["image"];
Header ("Content-type: $image");
print $image;
}

?>

Every time i got this Error

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\php\mywork\asad_black\final.php on line 12
  • devilwood
  • Silver Member
  • Silver Member
  • User avatar
  • Posts: 436

Post 3+ Months Ago

Looks like you're not putting your query results in your fetch_array call but rather your actual query. You should use what you have commented out.


Code: [ Select ]
$sql = "SELECT * FROM links ";
$result = mysql_query ($sql, $conn);
while ($row = @mysql_fetch_array ($result))
{
$image_type = $row["link"]; // this should be your image type such as image/jpeg
$image = $row["image"];
Header ("Content-type: $image_type");
print $image;
}
  1. $sql = "SELECT * FROM links ";
  2. $result = mysql_query ($sql, $conn);
  3. while ($row = @mysql_fetch_array ($result))
  4. {
  5. $image_type = $row["link"]; // this should be your image type such as image/jpeg
  6. $image = $row["image"];
  7. Header ("Content-type: $image_type");
  8. print $image;
  9. }


Please be sure to put your code in code tags.
  • asad_black
  • Graduate
  • Graduate
  • asad_black
  • Posts: 131
  • Loc: pakistan

Post 3+ Months Ago

my problem has been solved...!


thankx

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 102 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.