Hmmm....the error I am getting now is
You have an error in your SQL syntax near ''Idf', 'office_id', 'comments', 'submit') VALUES ('897966', '1', 'fdsfds', 'Add ' at line 1
The php script is:
<?
$username="xxx";
$password="xxx";
$database="xxx";
while(list($key, $val) = each($_POST))
{
$$key = $val; //make $_POST vars into named vars like globals ie $_POST['Idf']
into $Idf equal to $_POST['Idf']
if ($val) //if a value exits in the post variable, add it to the list to replace
{
$fields .= "'$key', "; //building field list
$values .= "'$val', "; //building values list
}
}
$query = "REPLACE INTO featuredlistings (" .substr($fields,0,strlen($fields)-2). ")
VALUES (" .substr($values,0,strlen($values)-2). ")"; //making them all into one big
happy SQL Query
mysql_pconnect("xxx",$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$result=mysql_query($query) or die (mysql_error());
exec("mkdir /var/www/html/propimages/featured/$Idf");
exec("cp $picture /var/www/html/propimages/featured/$Idf/$picture_name");
exec("cp $picture2 /var/www/html/propimages/featured/$Idf/$picture2_name");
exec("cp $picture2 /var/www/html/propimages/featured/$Idf/$picture3_name");
exec("cp $picture2 /var/www/html/propimages/featured/$Idf/$picture4_name");
?>
The form code is:
<form enctype="multipart/form-data" action="addfeaturedscript.php" method="POST">
<?php
include("adminheader.php");
?>
<div align="center">
<center>
<table border="0" cellspacing="0" cellpadding="0" width="701">
<tr>
<td colspan="2"> <hr color="#F2891D"> </td>
</tr>
<tr>
<td colspan="2"><p align="center">To add/edit a featured listing to
your website, simply use the form below. </p>
<p align="center"><strong>You must enter the correct MLS number in
order for your additional images to appear.</strong></p></td>
</tr>
<tr>
<td width="167"> <div align="right">MLS Id:</div></td>
<td width="534"> <div align="left">
<input type="Text" name="Idf" size="15">
<input type="hidden" name="office_id" value="1">
</div></td>
</tr>
<tr>
<td width="167"><div align="right"></div></td>
<td width="534"><div align="left"></div></td>
</tr>
<tr>
<td width="167"><div align="right">Picture 1</div></td>
<td width="534"> <div align="left">
<input type="File" name="picture" size="25">
</div></td>
</tr>
<tr>
<td width="167"><div align="right">Picture 2</div></td>
<td width="534"> <div align="left">
<input type="File" name="picture2" size="25">
</div></td>
</tr>
<tr>
<td width="167"><div align="right">Picture 3</div></td>
<td width="534"> <div align="left">
<input type="File" name="picture3" size="25">
</div></td>
</tr>
<tr>
<td width="167"><div align="right">Picture 4</div></td>
<td width="534"> <div align="left">
<input type="File" name="picture4" size="25">
</div></td>
</tr>
<tr>
<td width="167"><div align="right">Picture 5</div></td>
<td width="534"> <div align="left">
<input type="File" name="picture5" size="25">
</div></td>
</tr>
<tr>
<td width="167"><div align="right">Picture 6</div></td>
<td width="534"> <div align="left">
<input type="File" name="picture6" size="25">
</div></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td> </td>
</tr>
<tr>
<td><div align="right">Additional Comments</div></td>
<td><textarea name="comments" cols="50" rows="10" id="comments"></textarea></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"> <p align="center">
<input type="submit" name="submit" value="Add Featured Listing">
</td>
</tr>
</table>
</center>
</div>
</form>
</p>
<?php
include("adminfooter.php");
?>
What could I be doing wrong?