|
 |
|
Insert บนเครื่องตัวเองทำได้ แต่พอ Insert บนเซิฟเวอร์ไม่ได้ครับ |
|
 |
|
|
 |
 |
|
Code
<?php
session_start();
mysql_connect("localhost","db_service","1234");
mysql_select_db("db_service");
$RoomNumber = $_POST['ddlRoomNumber'];
$RegisCode = $_POST['txtRegisCode'];
$Id_Room = $_Get['Id_Room'];
$Id_Inventory = $_Get['Id_Inventory'];
$Id_Room = $_POST['Id_Room'];
$Id_Inventory = $_POST['Id_Inventory'];
$strSQL = " select room.RoomNumber,inventory.RegisCode,room.Id_Room,inventory.Id_Inventory
from room,inventory
where RoomNumber = '".mysql_real_escape_string( $RoomNumber)."' and RegisCode = '".mysql_real_escape_string( $RegisCode)."'";
$objQuery = mysql_query($strSQL);
$objResult = mysql_fetch_array($objQuery);
if(trim($_POST["txtdatepick2"]) == "")
{
echo "กรุณาระบุวันที่ติดตั้ง";
exit();
}
if(trim($_POST["txtInstallers"]) == "")
{
echo "กรุณาระบุผู้ติดตั้ง";
exit();
}
else
{
$_SESSION["Id_Room"] = $objResult["Id_Room"];
$_SESSION["Id_Inventory"] = $objResult["Id_Inventory"];
}
$strSQL1 = "INSERT INTO list (Id_Room,Id_Inventory,RegisCode,InstallationDate,Installers,Note,Status_List) VALUES ('".$objResult["Id_Room"]."','".$objResult["Id_Inventory"]."','".$_POST["txtRegisCode"]."','".$_POST["txtdatepick2"]."','".$_POST["txtInstallers"]."','".$_POST["txtNote"]."','".$_POST["ddlStatus"]."')";
$objQuery1 = mysql_query($strSQL1);
echo "บันทึกสำเร็จ<br>";
echo $objResult["Id_Room"],$objResult["Id_Inventory"],$_POST["txtRegisCode"],$_POST["txtdatepick2"],$_POST["txtInstallers"],$_POST["txtNote"],$_POST["ddlStatus"];
mysql_close();
session_write_close();
?>
<meta http-equiv=refresh content=10;URL='addList.php'>
แก้ไขตรงไหนหรอครับ รบกวนด้วยครับ
Tag : PHP, MySQL

|
ประวัติการแก้ไข 2014-07-16 16:15:16
|
 |
 |
 |
 |
Date :
2014-07-16 16:14:25 |
By :
indysyndrome |
View :
696 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
mysql_connect("localhost","db_service","1234");
น่าจะต้องแก้ตรงนี้นะครับ ^^
ไม่น่าจะใช่ localhost นะครับ หรือถ้าใช่ แล้ว id pass ถูกต้องหรือไม่
|
 |
 |
 |
 |
Date :
2014-07-16 16:17:06 |
By :
progamer2000 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
$objConnect = mysql_connect("localhost","db_service","1234");
if($objConnect)
{
echo "Database Connected.";
}
else
{
echo "Database Connect Failed.";
}
mysql_close($objConnect);
?>
แสดงผลออกมาว่ายังไงครับ
|
ประวัติการแก้ไข 2014-07-16 16:28:37
 |
 |
 |
 |
Date :
2014-07-16 16:28:12 |
By :
progamer2000 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่มี error อะไรขึ้นเลยหรือครับ
ลอง echo $strSQL1
ออกมาดูค่าว่า มีข้อมูลถูกต้องไหม ดูครับ
หรือลองปิด session tag เอาออกไปก่อนครับ
|
 |
 |
 |
 |
Date :
2014-07-16 16:35:56 |
By :
progamer2000 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
echo $strSQL1 แล้วเอาคำสั่งที่ได้ไปแปะ ใน phpMyadmin ตรง tab เมนู SQL ดูครับ ว่าได้ผลยังไง 
แต่ผมเดานะครับว่า น่าจะติดเรื่อง case sensitive ของทาง server ไม่ได้เปิด mod นี้ครับ จึงทำให้ มองตัวพิมพ์เล็กพิมพ์ใหญ่เป็นคนละอันกัน
เช่น RegisCode กับ regiscode หรือ regisCode ลองตรวจสอบชื่อฟิลด์ ชื่อตารางดูก่อนครับ ว่าตรงกันกับคำสั่งใน $strSQL1 หรือไม่? 
|
 |
 |
 |
 |
Date :
2014-07-16 17:08:38 |
By :
Manussawin |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|