Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > PHP > PHP Forum > ช่วยดูโค้ดให้หน่อยครับ มันฟ้องว่า Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource i



 

ช่วยดูโค้ดให้หน่อยครับ มันฟ้องว่า Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource i

 



Topic : 091594

Guest




11



Tag : PHP







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-02-28 13:17:56 By : narin View : 849 Reply : 9
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Quote:
$tableSQL = "select * from member where username='$id'";
$tableQUERY = mysql_db_query($dbname, $tableSQL);
$tableRS = mysql_fetch_array($tableQUERY);


แก้เป็น

Code (PHP)
$tableSQL = "select * from member where username='$id'";
$tableQUERY = mysql_query($tableSQL) or die(mysql_error());
$tableRS = mysql_fetch_array($tableQUERY);


แล้วเอา Error มาดูครับ






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-28 14:09:13 By : mr.win
 


 

No. 2

Guest


ตอบความคิดเห็นที่ : 1 เขียนโดย : mr.win เมื่อวันที่ 2013-02-28 14:09:13
รายละเอียดของการตอบ ::
มันฟ้องว่า ระบบผิดพลาด ไม่สามารถบันทึกข้อมูลนี้ได้ในขณะนี้ นะครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-28 16:21:43 By : narin
 

 

No. 3



โพสกระทู้ ( 4,169 )
บทความ ( 7 )

Hall of Fame 2012

สถานะออฟไลน์


สมัครสมาชิกกันก่อนดีกว่าครับ เดี๋ยวมาช่วยกันครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-28 16:23:07 By : Ex-[S]i[L]e[N]t
 


 

No. 4



โพสกระทู้ ( 55 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ตอบความคิดเห็นที่ : 3 เขียนโดย : Ex-[S]i[L]e[N]t เมื่อวันที่ 2013-02-28 16:23:07
รายละเอียดของการตอบ ::
ผมสมัครแล้วครับ แต่ลืมรหัสผ่าน เพิ่งเข้าได้ครับ

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-28 17:16:08 By : FREEDOOM
 


 

No. 5



โพสกระทู้ ( 4,169 )
บทความ ( 7 )

Hall of Fame 2012

สถานะออฟไลน์


ขอดูโค๊ดล่าสุดหน่อยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-28 17:19:36 By : Ex-[S]i[L]e[N]t
 


 

No. 6



โพสกระทู้ ( 55 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ตอบความคิดเห็นที่ : 5 เขียนโดย : Ex-[S]i[L]e[N]t เมื่อวันที่ 2013-02-28 17:19:36
รายละเอียดของการตอบ ::
ตามนี้เลยครับพี่ มือใหม่หัดเขียนครับ


Code (PHP)
<SCRIPT language=JavaScript src="_javascript.js"></SCRIPT>
<?
include('connDB.php');
if($act=="add") {
$dmy = $dmy_yy-543 ."-$dmy_mm-$dmy_dd";
$age = $age_yy-543 ."-$age_mm-$age_dd";
$time = $time_yy-543 ."-$time_mm-$time_dd";
$time_t = $time_t_yy-543 ."-$time_t_mm-$time_t_dd";
$Add="insert into member set 
             username='$username',
             password='$password',
             user='$user',
             user_e='$user_e',
             branch='$branch',
             quality='$quality',
             among_stu='$among_stu',
             religion='$religion',
             dmy='$dmy',
             age='$age',
             talent='$talent',
             address='$address',
             c_address='$c_address',
             location='$location',
             time='$time',
             time_t='$time_t',
             controller='$controller',
             emerging='$emerging',
             teacher_s='$teacher_s',
             group='$group'";
     if (mysql_db_query($dbname, $Add)) {
         echo "<script>alert('ระบบบันทึกข้อมูลนี้   เรียบร้อยแล้ว.....');</script>";
     } else {
         echo "<script>alert('ระบบผิดพลาด  ไม่สามารถบันทึกข้อมูลนี้ได้ในขณะนี้.....');</script>";
     }
}
?>
<script language="JavaScript">
<!-- Begin
function checkFields() {
missinginfo = "";
if (document.addform.username.value == "" || document.addform.username.value == "0") {
missinginfo += "\n - * รหัสนักศึกษา";
}
if (document.addform.password.value == "") {
missinginfo += "\n - * password";
}
if (document.addform.user.value == "") {
missinginfo += "\n - * ชื่อ นามสกุล";
}
if (document.addform.user_e.value == "") {
missinginfo += "\n - * ชื่อภาษาอังกฤษ";
}
if (document.addform.branch.value == "") {
missinginfo += "\n - * สาขา";
}
if (document.addform.quality.value == "") {
missinginfo += "\n - * ระดับ";
}
if (document.addform.among_stu.value == "") {
missinginfo += "\n - * หมู่เรียน";
}
if (document.addform.religion.value == "") {
missinginfo += "\n - * ศาสนา";
}
if (document.addform.dmy_dd.value == "" || document.addform.dmy_dd.value == "0") {
missinginfo += "\n - * วันที่ วัน เดือน ปี เกิด";
}
if (document.addform.dmy_yy.value == "" || document.addform.dmy_yy.value == "0") {
missinginfo += "\n - * พ.ศ. วัน เดือน ปี เกิด";
}
if (document.addform.age_dd.value == "" || document.addform.age_dd.value == "0") {
missinginfo += "\n - * วันที่ อายุ";
}
if (document.addform.age_yy.value == "" || document.addform.age_yy.value == "0") {
missinginfo += "\n - * พ.ศ. อายุ";
}
if (document.addform.talent.value == "") {
missinginfo += "\n - * ความสามารถพิเศษ";
}
if (document.addform.address.value == "") {
missinginfo += "\n - * ที่อยู่เดิม";
}
if (document.addform.c_address.value == "") {
missinginfo += "\n - * ที่อยู่ปัจจุบัน";
}
if (document.addform.location.value == "") {
missinginfo += "\n - * สถานที่ฝึกงาน";
}
if (document.addform.time_dd.value == "" || document.addform.time_dd.value == "0") {
missinginfo += "\n - * วันที่ ชาวงเวลาฝึกงาน";
}
if (document.addform.time_yy.value == "" || document.addform.time_yy.value == "0") {
missinginfo += "\n - * พ.ศ. ชาวงเวลาฝึกงาน";
}
if (document.addform.time_t_dd.value == "" || document.addform.time_t_dd.value == "0") {
missinginfo += "\n - * วันที่ ถึงวันที่";
}
if (document.addform.time_t_yy.value == "" || document.addform.time_t_yy.value == "0") {
missinginfo += "\n - * พ.ศ. ถึงวันที่";
}
if (document.addform.controller.value == "") {
missinginfo += "\n - * ผู้ควบคุมการฝึกงาน";
}
if (document.addform.emerging.value == "") {
missinginfo += "\n - * กรณีฉุกเฉิน";
}
if (document.addform.teacher_s.value == "") {
missinginfo += "\n - * อาจารย์นิเทศ";
}
if (document.addform.group.value == "") {
missinginfo += "\n - * กลุ่ม";
}
if (missinginfo != "") {
missinginfo ="_____________________________\n" +
"คุณยังไม่ได้กรอกข้อมูลในช่อง' " +
missinginfo + "\n_____________________________" +
"\nกรุณากลับไปกรอกอีกครั้ง ";
alert(missinginfo);
return false;
}
else return true;
}
// End -->
</script>

<?
//=============================================================
//Creator : Ch. Weeratep
//Organize : Satangnet Studio (Nakhonsawan)
//Email Address : [email protected]
//Website : www.satangsoft.com
//Created : 28/02/2013       (12:28:27)
//=============================================================
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf8\">";

$tableSQL = "select * from member where username='$id'";
$tableQUERY = mysql_query($tableSQL) or die(mysql_error());
$tableRS = mysql_fetch_array($tableQUERY);

       $username = $tableRS["username"];
       $password = $tableRS["password"];
       $user = $tableRS["user"];
       $user_e = $tableRS["user_e"];
       $branch = $tableRS["branch"];
       $quality = $tableRS["quality"];
       $among_stu = $tableRS["among_stu"];
       $religion = $tableRS["religion"];
       $dmy = $tableRS["dmy"];
       $age = $tableRS["age"];
       $talent = $tableRS["talent"];
       $address = $tableRS["address"];
       $c_address = $tableRS["c_address"];
       $location = $tableRS["location"];
       $time = $tableRS["time"];
       $time_t = $tableRS["time_t"];
       $controller = $tableRS["controller"];
       $emerging = $tableRS["emerging"];
       $teacher_s = $tableRS["teacher_s"];
       $group = $tableRS["group"];
?>
<table width="57%" border="0" align="center" cellpadding="10" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#CCCCCC">
  <form name="addform" method="post" action="<? $PHP_SELF; ?>" onSubmit="return checkFields();">
    <tr>
      <td bgcolor="#EEEEEE">
        <table width="100%" border="0" cellspacing="0" cellpadding="2">
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">รหัสนักศึกษา</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="username" maxlength="50" onkeypress="check_number();" value="<? echo "$username"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">password</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="password" maxlength="50" value="<? echo "$password"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">ชื่อ นามสกุล</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="user" maxlength="50" value="<? echo "$user"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">ชื่อภาษาอังกฤษ</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="user_e" maxlength="50" value="<? echo "$user_e"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">สาขา</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="branch" maxlength="50" value="<? echo "$branch"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">ระดับ</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="quality" maxlength="50" value="<? echo "$quality"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">หมู่เรียน</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="among_stu" maxlength="50" value="<? echo "$among_stu"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">ศาสนา</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="religion" maxlength="50" value="<? echo "$religion"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">วัน เดือน ปี เกิด</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
<?
 // แสดงวันที่
 $dd=subStr($dmy,8,2);
 $mm=subStr($dmy,5,2);
 $yy=subStr($dmy,0,4);
 $yy=$yy+543;
 if($dd==0) {
     $dd = "";
     $mm="";
     $yy="";
 }
?>
              <input type="text"size="3" name="dmy_dd" maxlength="2" onkeypress="check_number();" value="<? echo "$dd"; ?>">
<select name="dmy_mm" id="mm">
             <? if($mm!="") { echo "<option value=\"$mm\">". $thaimonth[$mm-1] ."</option>"; } ?>
             <option value="01">มกราคม</option>
             <option value="02">กุมภาพันธ์</option>
             <option value="03">มีนาคม</option>
             <option value="04">เมษายน</option>
             <option value="05">พฤษภาคม</option>
             <option value="06">มิถุนายน</option>
             <option value="07">กรกฎาคม</option>
             <option value="08">สิงหาคม</option>
             <option value="09">กันยายน</option>
             <option value="10">ตุลาคม</option>
             <option value="11">พฤศจิกายน</option>
             <option value="12">ธันวาคม</option>
</select>
              <input type="text" size="5" name="dmy_yy" maxlength="4" onkeypress="check_number();" value="<? echo "$yy"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">อายุ</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
<?
 // แสดงวันที่
 $dd=subStr($age,8,2);
 $mm=subStr($age,5,2);
 $yy=subStr($age,0,4);
 $yy=$yy+543;
 if($dd==0) {
     $dd = "";
     $mm="";
     $yy="";
 }
?>
              <input type="text"size="3" name="age_dd" maxlength="2" onkeypress="check_number();" value="<? echo "$dd"; ?>">
<select name="age_mm" id="mm">
             <? if($mm!="") { echo "<option value=\"$mm\">". $thaimonth[$mm-1] ."</option>"; } ?>
             <option value="01">มกราคม</option>
             <option value="02">กุมภาพันธ์</option>
             <option value="03">มีนาคม</option>
             <option value="04">เมษายน</option>
             <option value="05">พฤษภาคม</option>
             <option value="06">มิถุนายน</option>
             <option value="07">กรกฎาคม</option>
             <option value="08">สิงหาคม</option>
             <option value="09">กันยายน</option>
             <option value="10">ตุลาคม</option>
             <option value="11">พฤศจิกายน</option>
             <option value="12">ธันวาคม</option>
</select>
              <input type="text" size="5" name="age_yy" maxlength="4" onkeypress="check_number();" value="<? echo "$yy"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">ความสามารถพิเศษ</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="talent" maxlength="255" value="<? echo "$talent"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">ที่อยู่เดิม</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="address" maxlength="255" value="<? echo "$address"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">ที่อยู่ปัจจุบัน</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="c_address" maxlength="255" value="<? echo "$c_address"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">สถานที่ฝึกงาน</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="location" maxlength="255" value="<? echo "$location"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">ชาวงเวลาฝึกงาน</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
<?
 // แสดงวันที่
 $dd=subStr($time,8,2);
 $mm=subStr($time,5,2);
 $yy=subStr($time,0,4);
 $yy=$yy+543;
 if($dd==0) {
     $dd = "";
     $mm="";
     $yy="";
 }
?>
              <input type="text"size="3" name="time_dd" maxlength="2" onkeypress="check_number();" value="<? echo "$dd"; ?>">
<select name="time_mm" id="mm">
             <? if($mm!="") { echo "<option value=\"$mm\">". $thaimonth[$mm-1] ."</option>"; } ?>
             <option value="01">มกราคม</option>
             <option value="02">กุมภาพันธ์</option>
             <option value="03">มีนาคม</option>
             <option value="04">เมษายน</option>
             <option value="05">พฤษภาคม</option>
             <option value="06">มิถุนายน</option>
             <option value="07">กรกฎาคม</option>
             <option value="08">สิงหาคม</option>
             <option value="09">กันยายน</option>
             <option value="10">ตุลาคม</option>
             <option value="11">พฤศจิกายน</option>
             <option value="12">ธันวาคม</option>
</select>
              <input type="text" size="5" name="time_yy" maxlength="4" onkeypress="check_number();" value="<? echo "$yy"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">ถึงวันที่</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
<?
 // แสดงวันที่
 $dd=subStr($time_t,8,2);
 $mm=subStr($time_t,5,2);
 $yy=subStr($time_t,0,4);
 $yy=$yy+543;
 if($dd==0) {
     $dd = "";
     $mm="";
     $yy="";
 }
?>
              <input type="text"size="3" name="time_t_dd" maxlength="2" onkeypress="check_number();" value="<? echo "$dd"; ?>">
<select name="time_t_mm" id="mm">
             <? if($mm!="") { echo "<option value=\"$mm\">". $thaimonth[$mm-1] ."</option>"; } ?>
             <option value="01">มกราคม</option>
             <option value="02">กุมภาพันธ์</option>
             <option value="03">มีนาคม</option>
             <option value="04">เมษายน</option>
             <option value="05">พฤษภาคม</option>
             <option value="06">มิถุนายน</option>
             <option value="07">กรกฎาคม</option>
             <option value="08">สิงหาคม</option>
             <option value="09">กันยายน</option>
             <option value="10">ตุลาคม</option>
             <option value="11">พฤศจิกายน</option>
             <option value="12">ธันวาคม</option>
</select>
              <input type="text" size="5" name="time_t_yy" maxlength="4" onkeypress="check_number();" value="<? echo "$yy"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">ผู้ควบคุมการฝึกงาน</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="controller" maxlength="50" value="<? echo "$controller"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">กรณีฉุกเฉิน</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="emerging" maxlength="50" value="<? echo "$emerging"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">อาจารย์นิเทศ</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="teacher_s" maxlength="50" value="<? echo "$teacher_s"; ?>">
            </td>
          </tr>
          <tr> 
            <td width="42%"> 
              <div align="right"><font face="MS Sans Serif"><font face="MS Sans Serif"><font size="1">กลุ่ม</font></font></font></div>
            </td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="text" name="group" maxlength="50" value="<? echo "$group"; ?>">
            </td>
          </tr>
              <input type="hidden" name="act" value="add">
          <tr>
            <td width="42%">&nbsp;</td>
            <td width="2%">&nbsp;</td>
            <td width="56%">
              <input type="submit" name="Submit" value="Submit">
              <input type="reset" name="Submit2" value="Reset">
            </td>
          </tr>
        </table>
      </td>
    </tr>
</form>
</table>


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-28 17:23:20 By : FREEDOOM
 


 

No. 7



โพสกระทู้ ( 4,169 )
บทความ ( 7 )

Hall of Fame 2012

สถานะออฟไลน์


ต้องปรับปรุง แนวทางการเขียนค่อนข้างเยอะครับ
1. ควรรับค่าตัวแปร จาก form แนะนำให้ใช้ method POST หรือ GET เผื่อ function glabal ไม่ได้ทำการเปิดใช้
2. การรับค่าแต่ละครั้งจาก form สังเกตุจาก method ว่าเราใช้ method อะไร POST หรือ GET
3. ในการ insert ข้อมูลแต่ละครั้ง syntax จะไม่ใช่อย่างที่คุณเขียน ที่ถูกต้องคือ
syntax insert into
Code (PHP)
$insert=mysql_query("INSERT INTO tb_eaxmple (ชื่อฟิวล์ของคุณ) VALUE (variable หรือค่าตัวแปร)") or die(mysql_error);

4. ในการอัพเดทแต่ละครั้ง syntax จะเป็น
syntax update
Code (PHP)
$update=mysql_query("UPDATE tb_example set ชื่อฟิวล์=ตัวแปร WHERE ชื่อฟิวล์โฟกัส=ตัวแปร") or die (mysql_error);

5.username='$id' $id มาจากไหนครับหาไม่เจอ และ เพื่อในความง่ายต่อการใช้งาน variable ควรตั้งให้ตรงกับการกระทำเช่น username=$Username; เป็นต้น
ลองแก้เบื้องต้นอย่างที่บอกก่อนครับ


ประวัติการแก้ไข
2013-02-28 17:47:44
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-02-28 17:38:22 By : Ex-[S]i[L]e[N]t
 


 

No. 8



โพสกระทู้ ( 1,819 )
บทความ ( 20 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Facebook

ลองแก้ส่วนนี้แบบนี้ดูครับ

if (mysql_db_query($dbname, $Add)) {
    echo "<script>alert('ระบบบันทึกข้อมูลนี้ เรียบร้อยแล้ว.....');</script>";
} else {
    // echo "<script>alert('ระบบผิดพลาด ไม่สามารถบันทึกข้อมูลนี้ได้ในขณะนี้.....');</script>";
    echo "<script>alert('ระบบผิดพลาด ไม่สามารถบันทึกข้อมูลนี้ได้ในขณะนี้.....\\n" . addslashes(mysql_error()) . "');</script>"; // เปลี่ยนเป็นแบบนี้ดู แล้วช่วยบอกครับว่า error อะไร
}



ส่วน syntax INSERT ของคุณก็ถูกต้องแล้วนะครับ เพราะมันไม่ได้มีแบบเดียวครับ

แบบที่สอนกันทั่วไปคือ INSERT INTO table (name) VALUES (value)
เหมาะสำหรับ INSERT ทีเดียวหลายๆ แถว

กับแบบที่ไม่ค่อยคุ้นเคยกันคือ INSERT INTO table SET name = value
แบบนี้เขียนแล้วอ่านง่ายกว่า ผิดพลาดน้อยกว่า เหมาะสำหรับการ INSERT ทีละแถว

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-02 11:42:20 By : cookiephp
 


 

No. 9



โพสกระทู้ ( 55 )
บทความ ( 0 )



สถานะออฟไลน์
Facebook

ตอบความคิดเห็นที่ : 8 เขียนโดย : cookiephp เมื่อวันที่ 2013-03-02 11:42:20
รายละเอียดของการตอบ ::
ได้แล้วนะครับ เขียนแบบง่ายๆเอา ไม่ต้องเช็คอะไรมาก ได้แบบนี้ครับ ขอบคุณพี่ๆทุกคนนะครับที่ให้คำแนะนำ

Code (PHP)
<?php include "connDB.php"; ?>
<?php 
if($_POST[Submit]){
$sql = "INSERT INTO member(username,
password,user,user_e,quality,among_stu,religion,dmy,age,talent,address, c_address,location,date_time,date_time_t,controller,emerging,teacher_s,id_group)
VALUES('$_POST[username]','$_POST[password]','$_POST[user]', '$_POST[user_e]','$_POST[quality]','$_POST[among_stu]','$_POST[religion]', '$_POST[dmy]','$_POST[age]','$_POST[talent]','$_POST[address]' ,'$_POST[c_address]','$_POST[location]','$_POST[date_time]','$_POST[date_time_t]', '$_POST[controller]','$_POST[emerging]','$_POST[teacher_s]','$_POST[id_group]')";
	$query = mysql_query($sql) or die(mysql_error());
	?>
	<script language="javascript">
			alert("ท่านได้สมัครสมาชิกเรียบร้อยแล้ว");
			window.location = "?main=login";
		</script>
	<?php }?><fieldset>
	<form action="" method="post" name="form1" id="form1">
      <h3 align="center">สมัครสมาชิก</h3>
	  <p align="center">หน้าจอในการสมาชิก</p>
	  <table width="98%">
        <tr>
          <td width='30%'  align='right'>Username : </td>
          <td width='70%'><input name="username" type="text" id="username" size="50" />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Password : </td>
          <td width='70%'><input name="password" type="password" id="password" size="50" />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>User : </td>
          <td width='70%'><input name='user' id='user' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>User_e : </td>
          <td width='70%'><input name='user_e' id='user_e' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Branch : </td>
          <td width='70%'><input name='branch' id='branch' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Quality : </td>
          <td width='70%'><input name='quality' id='quality' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Among_stu : </td>
          <td width='70%'><input name='among_stu' id='among_stu' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Religion : </td>
          <td width='70%'><input name='religion' id='religion' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Dmy : </td>
          <td width='70%'><input  name='dmy' id='dmy'/>
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Age : </td>
          <td width='70%'><input name='age' id='age' type='text' size='50'/>
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Talent : </td>
          <td width='70%'><input name='talent' id='talent' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Address : </td>
          <td width='70%'><input name='address2' id='address2' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>C_address : </td>
          <td width='70%'><input name='c_address' id='c_address' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Location : </td>
          <td width='70%'><input name='location' id='location' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Time : </td>
          <td width='70%'><input  name='time' id='time' class='datepicker' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Time_t : </td>
          <td width='70%'><input  name='time_t' id='time_t'/>
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Controller : </td>
          <td width='70%'><input name='controller' id='controller' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Emerging : </td>
          <td width='70%'><input name='emerging' id='emerging' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Teacher_s : </td>
          <td width='70%'><input name='teacher_s' id='teacher_s' type='text' size='50' />
            * </td>
        </tr>
        <tr>
          <td width='30%'  align='right'>Group : </td>
          <td><select name="id_group" id="id_group">
              <?php
		  	$q_l = "SELECT * FROM `group`";
			$qr_l=mysql_query($q_l);
			while($rs_l=mysql_fetch_array($qr_l)){
		  ?>
              <option value="<?=$rs_l[id_group];?>">
              <?=$rs_l[name_group];?>
              </option>
              <?php }?>
            </select>
            * </td>
        </tr>
        <tr height='50'>
          <td></td>
          <td align='left' valign='middle'><input type='submit' name='Submit' value='บันทึก'/>
              <input type='reset' name='Submit2' value='ล้างข้อมูล' />
              <input type='button' name='Submit22' value='   ยกเลิก   ' onclick="document.location.href='?main=FromRegistre'" /></td>
        </tr>
      </table>
    </form>
	</fieldset>



แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-03-02 20:50:39 By : FREEDOOM
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ช่วยดูโค้ดให้หน่อยครับ มันฟ้องว่า Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource i
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่