June 16, 2009 at 12:59 am
View an example at.. http://sheprealty.com/
half the property photos aren't loading for some reason, when you reload they will load and same again and again.
------------
//------------------------------------------------------------------------ -
// Created:2004-08-13 @ 10:08
// Revised:2004-08-13 @ 11:06
// Revision:1
//------------------------------------------------------------------------ -
// Returns the medium image for the specified ID, or returns the default
// image (which could contain anything).
//------------------------------------------------------------------------ -
// Configuration options:
$DefaultImage = "default.jpg";// Shown when the listing has no image
// Target DB information (where the images arestored)
//$DBHost = "WGCWeb2";
$DBHost = "127.0.0.1";
$DBName = "xxxx";
$DBUser = "xxxx";
$DBPass = "xxxx";
// Lets get started!
global $PubID;
//$PubID = "757487";
// Make sure we have an ID
if ( $PubID == "" )
{
echo("You need to specify a PubID (MLS #) to use this script!");
exit();
}
// Connect to the target DB
$DBHandle = mssql_connect($DBHost, $DBUser, $DBPass);
if ( $DBHandle == FALSE )
{
echo("Error!");
$ErrorMsg = mssql_get_last_message();
echo("Couldn't connect to image DB: $ErrorMsg");
exit();
}
// Try to pull up the picture for the specified ID
$GetImage = mssql_query("SELECT id_no,image1 FROM DBName.TABLENAME WHERE id_no = '$PubID'",$DBHandle);
if ( $GetImage == FALSE )
{
echo("Error with DB");
exit();
}
// Send out the header so the browser knows we're gunna spit image data at it
header("Content-type: image/jpeg");
if ( mssql_num_rows($GetImage) > 0 )
{
// Found the image
$ImageRow = mssql_fetch_array($GetImage);
if ( trim($ImageRow["image1"]) == "" )
{
// Image is blank or not there
$FH = fopen($DefaultImage,"r");
while( $L = fgets($FH) )
echo($L);
//echo("Record has no image!");
}
else
{
// Image is there, return it
echo($ImageRow["image1"]);
}
}
else
{
// The ID wasn't found
$FH = fopen("default.jpg","r");
while( $L = fgets($FH) )
echo($L);
}
// Time log - for my own accounting
// 2004-08-13 - 1 hr
?>
June 16, 2009 at 6:55 am
There is a new PHP driver for SQL Server from Microsoft it may not solve all your problem but it may be better that OLE DB driver.
Kind regards,
Gift Peddie
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply