|
|
|
ช่วยดูให้ทีนะครับ เป็นหน้าเพิ่มข้อมูลอะครับ ใส่รูปด้วยอะครับ มัน ERROR อะครับ |
|
|
|
|
|
|
|
ช่วยดูให้ทีนะครับ เป็นหน้าเพิ่มข้อมูลอะครับ ใส่รูปด้วยอะครับ
Code
<?php require_once('Connections/work.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")) {
if (isset($_FILES["d_pic"]["name"]))
{
$uploaddir="../upload/";
$d_pic = $uploaddir.basename($_FILES['d_pic']['name']);
if (move_uploaded_file($_FILES['d_pic']['tmp_name'], $d_pic))
{
$d_pic =$_FILES["d_pic"]["name"]; // Pathfile\
}else{
$d_pic = $d_picoldx;
}
}
$insertSQL = sprintf("INSERT INTO dog (d_id, d_pun, d_name, d_sex, d_bith, d_wight, d_price, d_status, d_pic) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, '$d_pic_file')",
GetSQLValueString($_POST['d_id'], "int"),
GetSQLValueString($_POST['d_pun'], "text"),
GetSQLValueString($_POST['d_name'], "text"),
GetSQLValueString($_POST['d_sex'], "text"),
GetSQLValueString($_POST['d_bith'], "text"),
GetSQLValueString($_POST['d_wight'], "text"),
GetSQLValueString($_POST['d_price'], "text"),
GetSQLValueString($_POST['d_status'], "text"),
//GetSQLValueString($_POST['d_pic'], "text"));
mysql_select_db($database_work, $work);
$Result1 = mysql_query($insertSQL, $dog) or die(mysql_error());
$insertGoTo = "file:///C|/AppServ/www/Work/showdog.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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>"enctype="multipart/form-data">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">D_pun:</td>
<td><input type="text" name="d_pun" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_name:</td>
<td><input type="text" name="d_name" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_sex:</td>
<td><input type="text" name="d_sex" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_bith:</td>
<td><input type="text" name="d_bith" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_wight:</td>
<td><input type="text" name="d_wight" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_price:</td>
<td><input type="text" name="d_price" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_status:</td>
<td><input type="text" name="d_status" value="" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">D_pic:</td>
<td><input type="file" name="d_pic" value="" ></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
<input type="hidden" name="d_id" value="">
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
Tag : PHP
|
|
|
|
|
|
Date :
2012-09-04 20:22:49 |
By :
kupramza |
View :
913 |
Reply :
3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ลองดูบรรทัด 58 หรือบรรทัด 57 ว่าตัว ; หายไป หรือ เกิน รึป่าวครับ
|
|
|
|
|
Date :
2012-09-04 20:46:02 |
By :
compiak |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mysql_select_db($database_work, $work);
$Result1 = mysql_query($insertSQL, $dog) or die(mysql_error());
อันนี้บรรทัดที่ 58 กับ 59 ครับผมตรงไหนหรอครับ
|
|
|
|
|
Date :
2012-09-05 12:23:25 |
By :
kupramza |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
น่าจะเป็นส่วนนี้ครับที่ผิด
Code (PHP)
$insertSQL = sprintf("INSERT INTO dog (d_id, d_pun, d_name, d_sex, d_bith, d_wight, d_price, d_status, d_pic) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, '$d_pic_file')",
GetSQLValueString($_POST['d_id'], "int"),
GetSQLValueString($_POST['d_pun'], "text"),
GetSQLValueString($_POST['d_name'], "text"),
GetSQLValueString($_POST['d_sex'], "text"),
GetSQLValueString($_POST['d_bith'], "text"),
GetSQLValueString($_POST['d_wight'], "text"),
GetSQLValueString($_POST['d_price'], "text"),
GetSQLValueString($_POST['d_status'], "text"),
//GetSQLValueString($_POST['d_pic'], "text"));
|
|
|
|
|
Date :
2012-09-05 13:10:13 |
By :
arm8957 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|