|
 |
|
มันไม่บันทึกข้อมูลลงตารางให้ค่ะ ... ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ... INSERT INTO contact |
|
 |
|
|
 |
 |
|
Code (PHP)
<?
$host="localhost";
$username="";
$password="";
$db=testdb";
$connect= mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");
$sql="select * from testtb";
$db_query=mysql_db_query($db,$sql);
$num_rows=mysql_num_rows($db_query);
$mystatus = "";
mysql_query("INSERT INTO contact (id, name,email,phone,header,message,dateregist,status) values('', '$_POST[name]', '$_POST[email]', '$_POST[phone] ', '$_POST[header]', '$_POST[message]', '$mystatus')") or die (mysql_error(););
mysql_close($connect);
?>
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
2009-10-11 09:21:30 |
By :
gigza |
View :
988 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีเออเร่อไหม
|
 |
 |
 |
 |
Date :
2009-10-11 09:36:46 |
By :
NanoThoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตรงนี้เกี่ยวกันไหมอ่ะ
mysql_select_db($db) แก้ไขเป็น mysql_select_db($db,$connect)
|
 |
 |
 |
 |
Date :
2009-10-11 09:39:52 |
By :
somparn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
สวัสดีเพ่สมภาณ ไม่ค่อยออนเอ็มเลยนะ
|
 |
 |
 |
 |
Date :
2009-10-11 09:41:11 |
By :
NanoThoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
น้องเอ๋ลองสั่งให้แสดงคำสั่งเอสคิวแอลออกมาดูก่อนก็ได้ว่ามีค่าส่งเข้าไปหรือเปล่า
echo $sql;
|
 |
 |
 |
 |
Date :
2009-10-11 09:48:08 |
By :
NanoThoro |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
<?
$host="localhost";
$username=""; //ตรงนี้น่าจะเป็น rootหรือป่าวอ่ะ
$password="";
$db=testdb";
$connect= mysql_connect( $host,$username,$password) or die ("ติดต่อกับฐานข้อมูล Mysql ไม่ได้ ");
mysql_select_db($db) or die("เลือกฐานข้อมูลไม่ได้");
$sql="select * from testtb";
$db_query=mysql_db_query($db,$sql);
$num_rows=mysql_num_rows($db_query);
$mystatus = "";
mysql_query("INSERT INTO contact (id, name,email,phone,header,message,dateregist,status) values('', '$_POST[name]', '$_POST[email]', '$_POST[phone] ', '$_POST[header]', '$_POST[message]', '$mystatus')") or die (mysql_error(););
mysql_close($connect);
?>
echo $sql; แล้วเป้นไง อ่ะ แล้วก้ ชื่อ table อะไรถูกหรือปล่าวอ่ะ
|
 |
 |
 |
 |
Date :
2009-10-11 09:58:08 |
By :
heilender |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|