Hi
Here is the code I that is generated within Dreamweaver…I guess I should be coding manually and not using dreamweaver because it seems to make things unreadable!!
What I want is when I in insert a record via Mysql into a database (product detail) I also at exactly the same time want to upload the product image as selected in the browse file value to the server via php… can this be done in the same page or do I have to call a new php page to process the code to upload?
I have the code and can do this seperately, in fact I can do both items seperately but not together!!
I have not put the PHP file upload code in this bit, the question is where should it go?
Many Thanks
Ian
[code]<?php require_once('Connections/TheGoatCompany.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 = sprintf("INSERT INTO categorydet (seq, productimage, category, ProductName, Description, ProductPrice, uomovride) VALUES (%s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['seq'], "int"),
GetSQLValueString($_POST['productimage'], "text"),
GetSQLValueString($_POST['category'], "text"),
GetSQLValueString($_POST['ProductName'], "text"),
GetSQLValueString($_POST['Description'], "text"),
GetSQLValueString($_POST['ProductPrice'], "text"),
GetSQLValueString($_POST['uomovride'], "text"));
mysql_select_db($database_TheGoatCompany, $TheGoatCompany);
$Result1 = mysql_query($insertSQL, $TheGoatCompany) or die(mysql_error());
}
mysql_select_db($database_TheGoatCompany, $TheGoatCompany);
$query_product = "SELECT * FROM categorydet";
$product = mysql_query($query_product, $TheGoatCompany) or die(mysql_error());
$row_product = mysql_fetch_assoc($product);
$totalRows_product = mysql_num_rows($product);
mysql_select_db($database_TheGoatCompany, $TheGoatCompany);
$query_Catergories = "SELECT * FROM categories";
$Catergories = mysql_query($query_Catergories, $TheGoatCompany) or die(mysql_error());
$row_Catergories = mysql_fetch_assoc($Catergories);
$totalRows_Catergories = mysql_num_rows($Catergories);
?>
Untitled Document
Seq: |
|
Product image: |
|
Category: |
|
Product Name: |
|
Description: |
Cats
<?php
do {
?>
<?php echo $row_Catergories['catname']?>
<?php
} while ($row_Catergories = mysql_fetch_assoc($Catergories));
$rows = mysql_num_rows($Catergories);
if($rows > 0) {
mysql_data_seek($Catergories, 0);
$row_Catergories = mysql_fetch_assoc($Catergories);
}
?>
|
Product Price: |
|
UOM overide: |
|
|
|
<?php
mysql_free_result($product);
mysql_free_result($Catergories);
?>[/code]
MOD EDIT: Added code tags