If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Not able to retrieve images from database

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-02-09, 02:02
ankitneedshelp ankitneedshelp is offline
Registered User
 
Join Date: Nov 2009
Posts: 1
Red face Not able to retrieve images from database

I have created a mysql database from which i need to call images in the front end.
database description:-

databsae:-my sql
dbname:-dw_bookstore table:-images, field:- type{varchar} size{30}
field name:image and stored path is(C:\wamp\www\images\Bluehills.jpg after that i'll try ..\images\Bluehills.jpg ) but its not working.


PHP code:

<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("dw_bookstore", $con);

$result = mysql_query("SELECT * FROM images");


mysql_close($con);
?>
<html>
<body>
<img src="<?php echo $row['image']; ?> " alt="<?php echo $row['image']; ?>" />
</body>
</html>


and error is:
some time look blank image or with
<br /> <b>Notice</b>: Undefined variable: row in <b>C:\wamp\www\view.php</b> on line <b>17</b><br />


plz help me....................... i am too confused.
Reply With Quote
  #2 (permalink)  
Old 11-02-09, 02:22
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
where did you set the value of the variable $row?

i'd expect to see something similar to:-
PHP Code:
$result = mysql_query("SELECT * FROM images");
if (Mysql_ErrorNo() != 0)
{ //insert any error handling here
} else //we found an image
  $row=mysql_fetch_array($result);
}

mysql_close($con);
?> 
<html>
<body>
<img src="<?php echo $row['image']; ?> " alt="<?php echo $row['image']; ?>" />
</body>
</html>
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Tags
call image, call image from database, database with image

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On