I have created a real estate site for a client. I created a form where they can upload data to a mySQL database (stuff like MLS#, address, city, etc). They also want several images per property, so in the DB I set up five fields (BLOB) and figured out how to input that data in the same form. I know because i've read a billion places that putting and using images into a database is a bad bad idea. I get that. I know the best route is to 'put your images into a folder and use php to reference the path'. Great. I would if I could but the user is going to be putting the images into their site using a form. The only way I knew how to do that was put it in the mySQL as a blob. The user isn't savy enough to go onto the host and place the images into a folder.
So what I need, what it seems everyone says to do at this point, is to use a 'simple script' that takes the blob data/images from the DB and have that script place it in a folder on the site and replaces the data in the mysql with a path name. But while everyone tells me this no one tells me how, nor can i find anything about it on the web.
Please help.
Below is the whole page (I use DreamWeaver for this stuff because I'm new to php/mysql). I'm open to any suggestions.
<?php require_once('Connections/dottieann.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_rsMultiListings = 9;
$pageNum_rsMultiListings = 0;
if (isset($_GET['pageNum_rsMultiListings'])) {
$pageNum_rsMultiListings = $_GET['pageNum_rsMultiListings'];
}
$startRow_rsMultiListings = $pageNum_rsMultiListings * $maxRows_rsMultiListings;
mysql_select_db($database_dottieann, $dottieann);
$query_rsMultiListings = "SELECT listingsID, title, `lastModified`, address, city, `state`, zip, price, mlsID, img1 FROM listings ORDER BY `lastModified` ASC";
$query_limit_rsMultiListings = sprintf("%s LIMIT %d, %d", $query_rsMultiListings, $startRow_rsMultiListings, $maxRows_rsMultiListings);
$rsMultiListings = mysql_query($query_limit_rsMultiListings, $dottieann) or die(mysql_error());
$row_rsMultiListings = mysql_fetch_assoc($rsMultiListings);
if (isset($_GET['totalRows_rsMultiListings'])) {
$totalRows_rsMultiListings = $_GET['totalRows_rsMultiListings'];
} else {
$all_rsMultiListings = mysql_query($query_rsMultiListings);
$totalRows_rsMultiListings = mysql_num_rows($all_rsMultiListings);
}
$totalPages_rsMultiListings = ceil($totalRows_rsMultiListings/$maxRows_rsMultiListings)-1;
?>
<!DOCTYPE>
<html>
<head>
<?php
include "_include/phpCode.php";
?>
<?php
include "_include/styles.php";
?>
<title>Dottie Dooley and V. Ann Rozier Realtors</title>
</head>
<body>
<div id="wrapper">
<?php
include "_include/header.php";
?>
<div id="contentContainer">
<div class="contentContainerHeader"> Our Listings</div>
<div class="listingsContainer">
<?php do { ?>
<div class="singleListingsContainer">
<div class="imgBox"><?php echo $row_rsMultiListings['img1']; ?></div>
<div class="thumbMLS">MLS: <?php echo $row_rsMultiListings['mlsID']; ?></div>
<div class="address">
<?php echo $row_rsMultiListings['address']; ?> <br />
<?php echo $row_rsMultiListings['city']; ?>, <?php echo $row_rsMultiListings['state']; ?> <?php echo $row_rsMultiListings['zip']; ?> </div>
<div class="price">$<?php echo $row_rsMultiListings['price']; ?></div>
<div class="button"><a href="linkToBig">details</a></div>
</div>
<?php } while ($row_rsMultiListings = mysql_fetch_assoc($rsMultiListings)); ?><!-- end singleListingsContainer-->
<div class="nextPrevBtn"> Our Listings</div>
<!-- next and previous line-->
</div><!-- end listingsContainer-->
</div> <!--end contentContainer-->
<?php
include "_include/footer.php";
?>
</div> <!--end wrapper-->
</body>
</html>
<?php
mysql_free_result($rsMultiListings);
?>

