 |
ผมผิดตรงไหน ช่วยทีครับ ใช้ MySQL สร้าง Database ชื่อ test มี table ชือ manufacturer ต้องการเพิ่มข้อมูลลงผู้ประกอบการใน |
|
 |
|
|
 |
 |
|
ใช้ MySQL สร้าง Database ชื่อ test มี table ชือ manufacturer ต้องการเพิ่มข้อมูลลงผู้ประกอบการใน Table ผมตั้งชื่อ name ในช่อง input type='text' name= 'get_xxxx' ทุกช่องครับ
xxxx คือชื่อ field ของตาราง ครับ
สคริปต์ มีดังนี้
1. ไฟล์ connect.php
<?
$host="localhost";
$user = "root";
$pw = "";
$dbname = "test";
$c =mysql_connect($host,$user,$pw) ;
if (!$c) {
echo "<h3> ERROR : ติดต่อฐานข้อมูลไม่ได้ </h3> " ;
exit() ;
}
?>
2. ไฟล์ add_manufac.php เพิ่มผู้ประกอบการที่รับค่าจาก form.html
<?
include "connect.php";
$sql = "INSERT INTO manufacturer values ('$get_manuid','$get_titlename','$get_fname', '$get_lname','$get_address1','$get_amphurname','$get_provincename','$get_zipcode', '$get_manuphone','$get_manufax','$get_dateregis','$get_email','$get_username', '$get_password')";
mysql_query($dbname,$sql) or die ("Add ข้อมูลล Table ไม่ได้ ");
?>
ผลลัพธ์
Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in c:\appserv\www\folkliquor\add_manufac.php on line 37
Add ข้อมูลลง Table ไม่ได้
---------------------------------------------------------------------------------------------------------------------
ผมตัดบางส่วนของสคริปต์มา on line 37 คือบรรทัด ที่ฟ้อง Add ข้อมูลไม่ได้
ขอขอบคุณล่วงหน้า สำหรับทุกคำตอบครับ
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
3 ธ.ค. 2549 11:48:27 |
By :
หัดเขียน |
View :
2035 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ex..
..........................................
sql = "INSERT INTO manufacturer (field_menuid,field_titlename,field_firstname) values ('$get_manuid','$get_titlename','$get_fname');
...........................................
>> set field for insert data (field_menuid,field_titlename,field_firstname)
and by value ('$get_manuid','$get_titlename','$get_fname')
|
 |
 |
 |
 |
Date :
3 ธ.ค. 2549 14:56:22 |
By :
abc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ คุณ abc ครับ แต่ผมใส่ชื่อ field ตามที่บอกแล้ว และลองคีย์ข้อมูลผ่าน form.html ใหม่อีกครั้ง
มันก็ยังฟ้องเหมือนเดิมครับ
|
 |
 |
 |
 |
Date :
3 ธ.ค. 2549 15:10:57 |
By :
เจ้าของคำถามครับ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมว่าลองเช็คตัวแปร ใน mysql_query(): ดูอีกทีนะครับว่า ตัวแปรตรงกันกับที่รับค่าใน form หรือเปล่า ปัญหานี้ผมเจอบ่อยครับ
|
 |
 |
 |
 |
Date :
24 ก.พ. 2550 11:08:40 |
By :
คนจร |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|