images in db
Moderator: General Moderators
images in db
Guys,
I have an mysql db where I have stored the pathname for an image e.g. ring2.jpg.
I then use the code below to show the image, but nothing pulls up. Any idea what I am doing wrong?
echo "<img src='http://www.umuc.edu/~em680a10/";
echo $row["image"];
The url is : http://nova.umuc.edu/cgi-bin/cgiwrap/em ... oducts.php
I have an mysql db where I have stored the pathname for an image e.g. ring2.jpg.
I then use the code below to show the image, but nothing pulls up. Any idea what I am doing wrong?
echo "<img src='http://www.umuc.edu/~em680a10/";
echo $row["image"];
The url is : http://nova.umuc.edu/cgi-bin/cgiwrap/em ... oducts.php
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
try:
echo "<img src='http://www.umuc.edu/~em680a10/";
echo $row["image"];
echo ">";
because i see in your images they have the <br> tag locked on
echo "<img src='http://www.umuc.edu/~em680a10/";
echo $row["image"];
echo ">";
because i see in your images they have the <br> tag locked on
actually, try...
Code: Select all
echo "<img src="http://www.umuc.edu/~em680a10/" . $rowї"image"] . "" border="0">";Thank you for your response. What do I do? close the <br> with a </br>. (byt he way tried that with the >br> in from of the image tag and it didn't work) Remove all <br> or something else?hob_goblin wrote:try:
echo "<img src='http://www.umuc.edu/~em680a10/";
echo $row["image"];
echo ">";
because i see in your images they have the <br> tag locked on
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
phice wrote:actually, try...
Code: Select all
echo "<img src="http://www.umuc.edu/~em680a10/" . $rowї"image"] . "" border="0">";
try his
Tried it, but it didn't work. Should my path be something else? In the table I only list ring2.jpg. and the pictures are located in my www directory on the unix server and copies are also in the cgi-bin directory. I have tried different variations of the img source tag below to include the www, cgi-bin, etc, but still no luck.hob_goblin wrote:it does practically the same thing, but i figured since he's not using the images as links so people wouldn't have to worry about it
Here is my entire code:
#!/usr/local/bin/php
<html>
<head>
<title>Show available products</title>
</head>
<body><body bgcolor=beige>
<center><A HREF="http://nova.umuc.edu/~em680a10/diamondhome.html">Back to Php Home Page</A>.<br><br>
<h1> Jewelry to love </h1>
</center>
<?
@ $db = mysql_pconnect("localhost", "em680a10", "3s8d5m2f");
if (!$db)
{
echo "Error: Could not connect to database. Please try again later. ";
exit;
}
mysql_select_db("em680a10");
$query = "select * from products";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<P> <strong> Number of products available: </strong> ".$num_results."</p>";
for($i=0; $i<$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<P><strong>Product Name : </strong>";
echo htmlspecialchars( stripslashes($row["name"]));
echo "<br><strong> Product Description: </strong> ";
echo htmlspecialchars (stripslashes($row["description"]));
echo "<br><strong> Price: </strong></br> ";
echo htmlspecialchars (stripslashes($row["price"]));
echo "<img src='http://www.umuc.edu/~em680a10/";
echo $row["image"];
echo ">";
echo "<br><strong> Product ID: </strong>";
echo htmlspecialchars (stripslashes($row["productid"]));
echo "</p>";
}
?>
<A HREF="http://nova.umuc.edu/~em680a10/phphome.html">Back to Php Home Page</A>.<br><br>
</body>
</html>
I know this is an incredibly stupid question but where does the second ' go? At the very end of the third row befre the last "?phice wrote:If ya look at your code, you would have noticed that you forget the second ' in the 3rd line of your code.
echo "<img src='http://www.umuc.edu/~em680a10/";
echo $row["image"];
echo ">";
Hey you - it worked. I could kiss you!!!hob_goblin wrote:phice wrote:actually, try...
Code: Select all
echo "<img src="http://www.umuc.edu/~em680a10/" . $rowї"image"] . "" border="0">";
try his
I have spent days trying to figure this out. Thank you, thank you!!
I have some fine tuning to do with the display, but the funtionality is there.
http://nova.umuc.edu/cgi-bin/cgiwrap/em ... oducts.php
Last edited by Denisem on Tue May 07, 2002 6:06 pm, edited 1 time in total.
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
