[SOLVED] Images
Moderator: General Moderators
Images
Can anyone tell me whether you can test scripts locally that involve dynamic display of images? I am trying to display a page where i am supossed to retrieve an image from my db and I cant get the image to be displayed...
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
yes you can. Maybe you should post your code. Use
Code: Select all
andCode: Select all
correctly nowHere is my code:
feyd | flipped
Code: Select all
<html>
<head>
<title>e-Music Image Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
// This page displays the details for a particular print.
if (is_numeric ($HTTP_POST_GET['pid'])) { // Make sure there's a print ID.
@ $db= mysql_pconnect('localhost','root','password');
if (!$db)
{
echo 'Error:Could not connect to the database. Please try again later';
exit;
}
mysql_select_db('emusic');
$query = "SELECT * FROM songs, images WHERE songs.song_id = images.song_id AND images.image_id = {$HTTP_POST_GET['pid']}";
$result = mysql_query ($query);
$row = mysql_fetch_array ($result, MYSQL_ASSOC);
// Display a header.
echo "<div align="center">
<b>{$row['image_name']}</b>
</div>";
// Get the image information and display the image.
if ($image = @getimagesize ("C:\Program Files\Apache Group\Apache\htdocs/{$row['image_name']}"))
{
echo "<div align="center"><img src="C:\Program Files\Apache Group\Apache\htdocs/{$row['image_name']}" $image[3] alt="{$row['image_name']}" />";
}
else
{
echo "<div align="center">No image available.";
}
echo '<br />' . stripslashes($row['description']) . '</div>';
}
?>
</body>
</html>Code: Select all
toCode: Select all
. [/color]it is coming from here:
Code: Select all
<?php
<html>
<head>
<title>e-Music Search Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div align="center"><strong><font color="#FF0000" size="7">e - Music</font></strong></div>
<?php
//create short variable names
$searchtype=$HTTP_POST_VARS['searchtype'];
$searchterm=$HTTP_POST_VARS['searchterm'];
$searchterm=trim($searchterm);
if (!$searchtype || !$searchterm)
{
echo 'You have not entered search details. Please go back and try again.';
exit;
}
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
@ $db= mysql_pconnect('localhost','root','password');
if (!$db)
{
echo 'Error:Could not connect to the database. Please try again later';
exit;
}
mysql_select_db('emusic');
$query = "select * from songs,images where ".$searchtype." like '%".$searchterm."%'";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo '<table border="0" width="90%" cellspacing="3" cellpadding="3" align="center">
<tr>
<td align="left" width="20%"><b>Title</b></td>
<td align="left" width="20%"><b>Group Name</b></td>
<td align="centre" width="20%"><b>Type of Music</b></td>
<td align="center" width="20%"><b>Review</b></td>
<td align="right" width="20%"><b>Image</b></td>
</tr>';
echo '<p>Number of songs found: '.$num_results.'</p>';
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC)) {
// Display each record.
echo " <tr>
<td align="left"><a href="results.php?aid={$row['song_id']}">{$row['title']}</a></td>
<td align="left">" . stripslashes($row['group_name']) . "</td>
<td align="left">" . stripslashes($row['type']) . "</td>
<td align="center">{$row['review']}</td>
<td align="right"><a href="view_image.php?pid={$row['image_id']}">{$row['image_name']}</td>
</tr>\n";
} // End of while loop.
echo '</table>'
?>
</body>
</html>
?>what i've done is that i have created my db and then stored in the field image_name the name of a picture which I have stored in htdocs. I am searching for the song I find the song which has a link, that is supposed to open a new page called <i>http://localhost/view_image.php?pid=1</i> and display the picture. The page is opening but I dont get anything at all!!!