I'm working on what conceptually is a very simple website design, but I'm running into syntax errors and language barriers
So, what I'm trying to do is create a SIMPLE webpage that has images in a table (heck, to start with, I just want images to DISPLAY) and the lady who maintains the website will only have to update the mysql database with the new items. A bit like a catalog, but not one that you can order from.
My sql is:
Code: Select all
CREATE TABLE inventory
( ItemID int not null auto_increment primary key,
CatID int,
ImgSrc char(255),
thumbnail char(255),
Description char(100),
Size char(100)
);
insert into inventory values
( NULL,1,"/images/1001.jpg","images/1001_sm.jpg","Pine","17w x 17d x 22h"),
( NULL,1,"/images/1003.jpg","images/1003_sm.jpg","Pine","17w x 16d x 30h");Now, since I'm such a newbie, I'm not trying to build Rome or anything, I just want to start by displaying that ImgSrc as a jpg. When I tried just using the imagecreatefromjpeg function, I got "can't open file" errors. SO, I went to the function that is shown below (and copied from the php manual) hoping that it had to do w/ the image creation and such, but now it doesn't crash, but does nothing.
I'm failing at getting a function to be recognized in another file...so I've ended up declaring the function in the main php file.
It looks like this:
Code: Select all
<html>
<head>
<title>Erneys Results</title>
</head>
<body>
<h1>Test Connection Script</h1>
<?
function LoadJpeg ($imgname)
{
$im = @imagecreatefromjpeg ($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreate (150, 30); /* Create a blank image */
$bgc = imagecolorallocate ($im, 255, 255, 255);
$tc = imagecolorallocate ($im, 0, 0, 0);
imagefilledrectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring ($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}?>
<?
@ $db = mysql_pconnect("localhost", "erneys", "xSugD8VB");
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("erneys_com");
$query = "select * from inventory";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p>Number of Items found: ".$num_results."</p>";
//require ("imagefunctions.php");
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "</strong><br>Image source: ";
echo stripslashes($rowї"ImgSrc"]);
LoadJpeg (($rowї"ImgSrc"]));
echo "<br>Description: ";
echo stripslashes($rowї"Description"]);
echo "<br>Size: ";
echo stripslashes($rowї"Size"]);
echo "</p>";
}
?>
</body>
</html>Is it the image dimensions? The creation? Am I trying to use the wrong function?
Any suggestions are much appreciated.
Thanks,
Mel