|
 |
|
รบกวนผู้เก่งกาจช่วยแก้ปัญหาทีครับ ปัญหาของผมคือ ทำไมมันinsert ข้อมูลลงฐานข้อมูลไม่ได้อะครับ ไม่เข้าใจรบกวนช่วยตอบด้วยครับ |
|
 |
|
|
 |
 |
|
ปัญหาของผมคือ ทำไมมันinsert ข้อมูลลงฐานข้อมูลไม่ได้อะครับ ไม่เข้าใจรบกวนช่วยตอบด้วยครับ (ผมพึ่งเริ่มเขียนphp ครับ)
<html>
<head>
<title>เพิ่มเพลง</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<style type="text/css">
<!--
@import url("block.css");
-->
</style>
</head>
<body>
<form name="fm1" method="post">
<table width="100%" border="1" align="center">
<tr>
<td colspan="6"><strong>เพิ่มเพลง</strong></td>
</tr>
<tr>
<td width="56" >ชื่อCD</td>
<td><input name="cd_song" type="text" class="block"></td>
<td>ชื่อศิลปิน</td>
<td><input name="art" type="text" class="block"></td>
<td>ชื่ออัลบั้ม</td>
<td><input name="album" type="text" class="block"></td>
</tr>
<?
for($i=0;$i<10;$i++){
echo" <tr>
<td>ชื่อเพลง</td>
<td colspan='5'><input type='text' name='n_song[]'></td>
</tr>";
if($_POST["cd_song"])
{
if($_POST["n_song"][$i]!="")
{
$cdsong=$_POST["cd_song"];
$album_song=$_POST["album"];
$artist=$_POST["art"];
$name_song=$_POST["n_song"][$i];
echo $name_song."==><br>";
include "connect.php";
$sql = "insert into song_mp(name_album,name_song,name_artist,name_cd) values ('$album_song','$name_song','$artist,'$cdsong')";
echo $sql;
$exec=odbc_exec($con,$sql) or die("NOT EXECUTE");
}
//$exec = odbc_exec($con,$sql) or die("NOT EXECUTE");
/*if($exec){
echo "เพิ่มข้อมูลเรียบร้อยกรุณารอสัก 2 วินาที หรือถ้าไม่ไปกรุณา <a href='index.htm'>คลิ๊กที่นี่</a> เพื่อกลับไปหน้าหลัก";
echo "<META HTTP-EQUIV='Refresh' CONTENT='2;URL=index.htm'>";
}*/
}
}
//$exec=odbc_exec($con,$sql) or die("Not execute");
?>
<!-- <tr>
<td>ชื่อเพลง</td>
<td colspan="5"><input type="text" name="textfield"></td>
</tr>-->
<tr>
<td><div align="right">
<input type="submit" name="Submit" value="Submit">
</div></td>
<td colspan="5"><input type="reset" name="Submit2" value="Reset"></td>
</tr>
</table>
</form>
</body>
</html>
ฐานข้อมูลชื่อ Data_Cd.mdb
ตารางชื่อ song_mp
Filed id_song(primary key,AutoNumber),name_album,name_song,name_artist,name_cd
DsNชื่อ cdpro
ครับ รบกวนช่วยทีครับ แก้ยังไงก็แก้ไม่ตกซักที งงไปหมดแล้วครับ ช่วยด้วยเถิดนะครับ
Tag : - - - -

|
|
 |
 |
 |
 |
Date :
1 ก.ค. 2549 16:46:10 |
By :
ผู้เริ่มเขียนครับ |
View :
2016 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตัวแปรที่ values ผิดต้องตั้งให้ตรงชื่ออินพุตที่รับเข้ามาคุณตั้งผิดทั้งนั้นเลย ตัวแปรนี้คุณเอามาจากไหนทั้งที่อินพุตก็ตั้งว่า
<tr>
<td width="56" >ชื่อCD</td>
<td><input name="cd_song" type="text" class="block"></td>
<td>ชื่อศิลปิน</td>
<td><input name="art" type="text" class="block"></td>
<td>ชื่ออัลบั้ม</td>
<td><input name="album" type="text" class="block"></td>
</tr>
<?
for($i=0;$i<10;$i++){
echo" <tr>
<td>ชื่อเพลง</td>
<td colspan='5'><input type='text' name='n_song[]'></td>
</tr>";
บรรทัดที่ผิด
values ('$album_song','$name_song','$artist,'$cdsong')";
|
 |
 |
 |
 |
Date :
2 ก.ค. 2549 09:08:36 |
By :
nn |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|