Is there a way to add a image to existing data in a batabase without corrupting.
The database is stuctured for images
The database is stuctured for images
+----+--------+--------+ | ID | Value | Value2 | +----+--------+--------+ | 1 | First | Nr. 1 | | 2 | Second | Nr. 2 | | 3 | Third | Nr. 3 | +----+--------+--------+
UPDATE `table` SET `Value` = 'Row 2', `Value2` = 'Second' WHERE `ID` = 2 LIMIT 1
+----+--------+--------+ | ID | Value | Value2 | +----+--------+--------+ | 1 | First | Nr. 1 | | 2 | Row 2 | Second | | 3 | Third | Nr. 3 | +----+--------+--------+
<?php require_once('file:///C|/Unnamed%20Site%202/Connections/database.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; } } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE tooltable SET FileName=%s, FileMime=%s, FileSize=%s, FileData=%s, ToolNumber=%s WHERE FileID=%s", GetSQLValueString($_POST['file'], "name"), GetSQLValueString($_POST['file'], "type"), GetSQLValueString($_POST['file'], "size"), GetSQLValueString($_POST['file'], "tmp_name"), GetSQLValueString($_POST['textfield'], "text"), GetSQLValueString($_POST['textfield2'], "int")); mysql_select_db($database_database, $database); $Result1 = mysql_query($updateSQL, $database) or die(mysql_error()); } ?><!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 action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="form1" id="form1"> <label> <input type="file" name="file", type="file", size="file", data="file" /> </label> <p> <label> <input type="text" name="textfield" /> </label> Tool Number </p> <p> <label> <input type="text" name="textfield2" /> </label> ID Number </p> <p> <label> <input type="submit" name="Submit" value="Submit" /> </label> </p> <input type="hidden" name="MM_update" value="form1"> </form> </body> </html>
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' FileMime=, FileSize=, FileData=, ToolNumber='CH-47914-3' WHERE FileID=43' at line 1PHP Notice: Undefined index: file in C:\Inetpub\wwwroot\newtools\1.php on line 39 PHP Notice: Undefined index: file in C:\Inetpub\wwwroot\newtools\1.php on line 40 PHP Notice: Undefined index: file in C:\Inetpub\wwwroot\newtools\1.php on line 41 PHP Notice: Undefined index: file in C:\Inetpub\wwwroot\newtools\1.php on line 42
GetSQLValueString($_FILES['file'], ("name")), GetSQLValueString($_FILES['file'], ("type")), GetSQLValueString($_FILES['file'], ("size")), GetSQLValueString($_FILES['file'], ("tmp_name")), GetSQLValueString($_POST['textfield'], ("text")), GetSQLValueString($_POST['textfield2'], ("int")));
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' FileMime=, FileSize=, FileData=, ToolNumber='CH-47914-3' WHERE FileID=43' at line 1PHP Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in C:\Inetpub\wwwroot\newtools\1.php on line 8 PHP Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in C:\Inetpub\wwwroot\newtools\1.php on line 8 PHP Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in C:\Inetpub\wwwroot\newtools\1.php on line 8 PHP Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in C:\Inetpub\wwwroot\newtools\1.php on line 8
GetSQLValueString($_FILES['file']['name'], "text"), GetSQLValueString($_FILES['file']'type'], "text"), GetSQLValueString($_FILES['file']['size'], "int"), GetSQLValueString($_FILES['file']['tmp_name'], "text"), GetSQLValueString($_POST['textfield'], ("text")), GetSQLValueString($_POST['textfield2'], ("int")))
Comment