Complete code...

<?php require_once('../Connections/damotors.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "",
$theNotDefinedValue = "")
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,
image2, image3, forsale) VALUES ($_POST['model'], $_POST['year'],
$_POST['details'], $_POST['price'], $_FILE['image']['name'][0],
$_FILE['image']['name'][1], $_FILE['image']['name'][2], $_POST['forsale'])";

  mysql_select_db($database_damotors, $damotors);
  $Result1 = mysql_query($insertSQL, $damotors) or die(mysql_error());

  $insertGoTo = "uploadhandler.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
  <table align="center">
    <tr valign="baseline">
      <td nowrap align="right">Model:</td>
      <td><input type="text" name="model" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Year:</td>
      <td><input type="text" name="year" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right" valign="top">Details:</td>
      <td><textarea name="details" cols="50" rows="5"></textarea>      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Price:</td>
      <td><input type="text" name="price" value="" size="32">
      <input type="hidden" name="MAX_FILE_SIZE" value="1900000" /></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Image1:</td>
      <td><input type="file" name="image[]"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Image2:</td>
      <td><input type="file" name="image[]"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Image3:</td>
      <td><input type="file" name="image[]"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Forsale:</td>
      <td><input type="text" name="forsale" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td><input type="submit" value="Insert record"></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</body>
</html>



The reason for the single quotes around the year is something to do with
Dreamweaver's insert wizard.



On 07/04/06, Brad Bonkoski <[EMAIL PROTECTED]> wrote:
>
> why do you have single quotes around year?
> -B
>
> Tom Chubb wrote:
>
> >I'm working on an insert record page with a multiple file upload script
> of
> >which I understand the fundamentals.
> >However, on submission I am getting the following error:
> >
> >Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting
> >T_STRING or T_VARIABLE or T_NUM_STRING in
> >C:\apache2triad\htdocs\damotors\admin\insertnew.php on line 34
> >
> >Where line 34 is...
> >
> >$insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,
> >image2, image3, forsale) VALUES ($_POST['model'], $_POST['year'],
> >$_POST['details'], $_POST['price'], $_FILE['image']['name'][0],
> >$_FILE['image']['name'][1], $_FILE['image']['name'][2],
> $_POST['forsale'])";
> >
> >
> >For info, the HTML for the form is as follows:
> >
> >    <tr valign="baseline">
> >      <td nowrap align="right">Image1:</td>
> >      <td><input type="file" name="image[]"></td>
> >    </tr>
> >    <tr valign="baseline">
> >      <td nowrap align="right">Image2:</td>
> >      <td><input type="file" name="image[]"></td>
> >    </tr>
> >    <tr valign="baseline">
> >      <td nowrap align="right">Image3:</td>
> >      <td><input type="file" name="image[]"></td>
> >    </tr>
> >
> >I've been slaving away for an hour and it's probably something really
> >obvious but I'd really appreciate it if someone could point it out to me
> >please?
> >Previously I was getting an "image1 cannot be null" error which I
> couldn't
> >work out either. That's gone, but I still can't work out what's going on.
> >
> >Many thanks,
> >
> >Tom
> >
> >
> >
> >--
> >Tom Chubb
> >[EMAIL PROTECTED]
> >07915 053312
> >
> >
> >
>
>


--
Tom Chubb
[EMAIL PROTECTED]
07915 053312

Reply via email to