hI, i need help.... I'm using dreamweaver insert code into the mysql database, and works great. and the user need to upload images file path name into the database and save image file into one of folder name "images'.
However, after i created insert code, i just can't figure out what to change for upload images to insert images file path name into the mysql database and store images into folder name "images".
I need some can help me to change that to make works. thanks for your time.
here is code from dreamweaver..
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
$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 movie (title, `state`, location, `date`, trailer, photo) VALUES (%s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['state'], "text"),
GetSQLValueString($_POST['location'], "text"),
GetSQLValueString($_POST['date'], "text"),
GetSQLValueString($_POST['trailer'], "text"),
GetSQLValueString($_POST['images'], "text"));
mysql_select_db($database_moviedata, $moviedata);
$Result1 = mysql_query($insertSQL, $moviedata) or die(mysql_error());
}
$colname_movie_database = "-1";
if (isset($_GET['id'])) {
$colname_movie_database = $_GET['id'];
}
mysql_select_db($database_moviedata, $moviedata);
$query_movie_database = sprintf("SELECT * FROM movie WHERE id = %s", GetSQLValueString($colname_movie_database, "int"));
$movie_database = mysql_query($query_movie_database, $moviedata) or die(mysql_error());
$row_movie_database = mysql_fetch_assoc($movie_database);
$totalRows_movie_database = mysql_num_rows($movie_database);
?>
and the forms code
<form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1">
<table width="500" border="1" align="center">
<tr>
<td width="90">Title</td>
<td width="229"><label for="title"></label>
<input type="text" name="title" id="title" /></td>
<td colspan="2"> </td>
</tr>
<tr>
<td>State:</td>
<td><label for="state"></label>
<input type="text" name="state" id="state" /></td>
<td colspan="2"> </td>
</tr>
<tr>
<td>location:</td>
<td><label for="location"></label>
<input type="text" name="location" id="location" /></td>
<td colspan="2"> </td>
</tr>
<tr>
<td>Date:</td>
<td><label for="date"></label>
<input type="text" name="date" id="date" /></td>
<td colspan="2"> </td>
</tr>
<tr>
<td>Trailer:</td>
<td><label for="trailer"></label>
<input type="text" name="trailer" id="trailer" /></td>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td>Images:</td>
<td><label for="images"></label>
<input type="file" name="images" id="images" /></td>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td width="65"><input type="submit" name="submit" id="submit" value="Submit" /></td>
<td width="88"><input type="submit" name="cancel" id="cancel" value="Cancel" /></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1" />
</form>