|
 |
|
สินค้าชื่อ ท่อ PVC 8.5 ขนาด 6" กำหนด VARCHAR(150) ปรากฏว่า MySQL ไม่รับข้อมูล พอเปลี่ยนเป็น 6 นิ้ว รับเลย แก้ชนิดข้อมูลเป็นอะไรดีครับ? |
|
 |
|
|
 |
 |
|
อยากให้มันรับ 6" (สัญลักษณ์ " แทนคำว่านิ้วครับ)
|
 |
 |
 |
 |
Date :
2012-05-02 11:28:14 |
By :
jackinfo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มัน Insert ได้ปกตินะครับ "
INSERTINTO test.xxx (
id ,
name
)
VALUES (
NULL ,'6 "'
);
ขอดู code ตอน Insert หน่อยครับ
|
 |
 |
 |
 |
Date :
2012-05-02 13:54:18 |
By :
birdbird27 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
code insertproduct ตามนี้เลยครับ ขอบคุณครับ
Code (PHP)
?
session_start();
if ($_SESSION['active']!=1)
{
print("Invalid Access");
exit();
}
?>
<html>
<head>
<title>M.E.S.I. ENGINEERING</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="styleerp.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="container">
<div class="content">
<?
if ($_POST[productname]==null)
{
print("กรุณากรอกข้อมูลสินค้าใหม่<br />");
}
else
{
$link = mysql_connect("localhost","tipawatc","");
if (!$link)
{
print("ไม่สามารถเชื่อต่อระบบฐานข้อมูล");
}
else
{
mysql_select_db("tipawatc_mesi",$link);
mysql_query("SET NAMES UTF8");
$sql="select * from tbproduct where productname='$_POST[productname]';";
$res = mysql_query($sql, $link);
$n = mysql_num_rows($res);
if ($n==0)
{
$img_data = "";
if($_FILES['image']['error'] == 0)
{
$file = $_FILES['image']['tmp_name'];
$f = fopen($file, "r");
$img_data = fread($f, filesize($file));
$img_data = addslashes($img_data);
fclose($f);
}
$sql="insert into tbproduct (productname,categorycode,subcategorycode,unitmeasure,unitcost,begining,image,remark)values('$_POST[productname]','$_POST[categorycode]','$_POST[subcategorycode]','$_POST[unitmeasure]','$_POST[unitcost]','$_POST[begining]','$img_data','$_POST[remark]');";
$res = mysql_query($sql, $link);
if ($res==1)
print("เพิ่มสินค้าใหม่สำเร็จ");
else
print("ไม่สามารถเพิ่มสินค้าใหม่ได้");
}
else
{
$row=mysql_fetch_row($res);
print("รายการสินค้า $_POST[productname] มีอยู่ในฐานข้อมูลเรียบร้อยแล้ว");
}
}
}
?>
<form name="form1" method="post" action="insertproduct.php" enctype="multipart/form-data">
<table align="center">
<tr><td>ชื่อสินค้า:</td><td><input type="text" name="productname" ></td></tr>
<tr><td>หมวดหมู่สินค้าหลัก:</td><td><?
$link = mysql_connect("localhost","tipawatc","");
if (!$link)
{
print("ไม่สามารถเชื่อต่อระบบฐานข้อมูล");
}
else
{
mysql_select_db("tipawatc_mesi",$link);
mysql_query("SET NAMES UTF8");
$sql="select catcode, catname from tbcategory order by catname ASC";
$res=mysql_query($sql);
echo("<select name=categorycode>");
while($row=mysql_fetch_row($res))
{
echo("<option value=$row[0]>$row[1]</option>");
}
echo("</select>");
}
?></td></tr>
<tr><td>หมวดหมู่สินค้าย่อย:</td><td><?
$link = mysql_connect("localhost","tipawatc","");
if (!$link)
{
print("ไม่สามารถเชื่อต่อระบบฐานข้อมูล");
}
else
{
mysql_select_db("tipawatc_mesi",$link);
mysql_query("SET NAMES UTF8");
$sql="select subcatcode, subcatname from tbsubcategory order by subcatname ASC";
$res=mysql_query($sql);
echo("<select name=subcategorycode>");
while($row=mysql_fetch_row($res))
{
echo("<option value=$row[0]>$row[1]</option>");
}
echo("</select>");
}
?></td></tr>
<tr><td>หน่วยนับ:</td><td><?
$link = mysql_connect("localhost","tipawatc","");
if (!$link)
{
print("ไม่สามารถเชื่อต่อระบบฐานข้อมูล");
}
else
{
mysql_select_db("tipawatc_mesi",$link);
mysql_query("SET NAMES UTF8");
$sql="select uomcode, uomname from tbunitmeasure order by uomname ASC";
$res=mysql_query($sql);
echo("<select name='unitmeasure'>");
while($row=mysql_fetch_row($res))
{
echo("<option value='$row[1]'>$row[1]</option>");
}
echo("</select>");
}
?></td></tr>
<tr><td>ต้นทุนต่อหน่วย:</td><td><input name="unitcost" type="text" size="10"></td></tr>
<tr><td>ยอดยกมา:</td><td><input name="begining" type="text" size="10"></td></tr>
<tr valign="top"><td>หมายเหตุ:</td><td><textarea name="remark" cols="37" rows="2"></textarea></td></tr>
<tr><td>ภาพสินค้า(ไม่เกิน 65KB 250X250px):</td><td><input type="file" name="image" size="30"></td></tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td align="center"><input type="submit" name="Submit" value="เพิ่มสินค้าใหม่" /></td>
</tr>
</table>
</form>
</div><!-- end .content -->
</div><!-- end .container -->
</body>
</html>
|
ประวัติการแก้ไข 2012-05-03 00:00:44
 |
 |
 |
 |
Date :
2012-05-02 23:58:08 |
By :
jackinfo |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
mysql_real_escape_string()
|
 |
 |
 |
 |
Date :
2012-05-03 00:09:31 |
By :
pjgunner.com |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|