User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,713 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,435 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1067 | Replies: 1
Reply
Join Date: Sep 2005
Posts: 51
Reputation: tristan17 is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 1
tristan17 tristan17 is offline Offline
Junior Poster in Training

image retrieval problem

  #1  
Jan 3rd, 2006
Hi PHPers,

Firstly, a Very Happy New Year To ALL!!

Hope everybody enjoyed this festive season :cheesy:

Back to work, sigh...

I am encountering this problem, below is a code which i have written, but the page only displayed the result of my code which is line 27. But when want to retrieved the image from my database on line 33, nothing happens..may i knoe what is wrong with my code??

thanks and appreciates for any advice,
tristan

<?
// database connection
$host = "localhost";
$user = " ";
$pass = " ";
$db = "imagedb";
$usertable= "userrgbvalues3020";
$imagetable="imagergbvalues3020";

$conn = mysql_connect($host, $user, $pass)
OR DIE (mysql_error());
@mysql_select_db ($db, $conn) OR DIE (mysql_error());

//sql statement to select similar images

$sql_retrievename="SELECT distinct $imagetable.image_name FROM $imagetable,$usertable WHERE $imagetable.position = $usertable.position AND $imagetable.red =

$usertable.red AND $imagetable.green = $usertable.green AND $imagetable.blue = $usertable.blue AND $imagetable.red !=0 AND $usertable.red !=0 AND

$imagetable.green !=0 AND $usertable.green !=0 AND $imagetable.blue !=0 AND $usertable.blue !=0" ;

$sql_queryname=mysql_query($sql_retrievename) or die(mysql_error());
$numrows_name=mysql_num_rows($sql_queryname);

for($i=0;$i<$numrows_name;$i++){
$row_name = @mysql_fetch_array($sql_queryname);
$retrieved_name = $row_name["image_name"];
print $retrieved_name ; // line 27
echo "\n";
}

//sql statements to retrieve image

$sql_retrieveimage="SELECT * FROM image WHERE image_name= '$retrieved_name' "; // line33
$sql_queryimage=mysql_query($sql_retrieveimage) or die(mysql_error());
$numrows_image=mysql_num_rows($sql_queryimage);

for($j=0;$j<numrows_image;$j++){
$row_image = @mysql_fetch_array($sql_queryimage);
$retrieved_image = $row_image["image"];
print $retrieved_image;
echo "\n";
}

?>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2005
Location: Costa Rica
Posts: 46
Reputation: RamiroS is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
RamiroS's Avatar
RamiroS RamiroS is offline Offline
Light Poster

Re: image retrieval problem

  #2  
Jan 7th, 2006
replace this:
[php]
$sql_queryname=mysql_query($sql_retrievename) or die(mysql_error());
$numrows_name=mysql_num_rows($sql_queryname);

for($i=0;$i<$numrows_name;$i++){
$row_name = @mysql_fetch_array($sql_queryname);
$retrieved_name = $row_name["image_name"];
print $retrieved_name ; // line 27
echo "\n";
}
[/php]

for this... it is simple

[php]
$sql_queryname=mysql_query($sql_retrievename) or die(mysql_error());

while ($data=mysql_fetch_object($sql_queryname)) {

print $data->image_name;
echo "\n";
}
[/php]
LOTRO Tips - Lord of the Rings Online Tips & Tricks
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:14 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC