|
 |
|
มีปัญหาในการเช็ค หมายเลข truemoney ซ้ำกันใน db เกิดข้อผิดพลาด |
|
 |
|
|
 |
 |
|
Code (PHP)
$sql = "select r_truemoney from tb_refill where r_truemoney='$_POST[codetrue]'";
$result=mysql_query($sql);
$rows =mysql_num_rows($result);
$i=0;
if($rows>$i){
echo "<script>alert(' หมายเลข truemoney มีปัญหากรุณาติดต่อ 086 - 6884285');history.back();</script>";
}else{
$sql="insert into tb_refill values('','$fname1','$id1','$use1','$pass1','$tel1','$codetrue','$money','newrefill','$ip','$date','$zone1')";
$result=mysql_db_query($dbname,$sql);
echo"<script>alert(' การเติมเงินเสร็จสมบูรณ์ท่านสามารถรอสถานะ active ได้ในหน้าถัดไป '); window.location ='chk_status.php';</script>";
}
ปัญหาที่เกิดขึ้นผมยังไม่เข้าใจครับ คือ ถ้า หมายเขบัตร true ซ้ำมีการเตือนเกิดขึ้น
แต่ถ้า หมายเลขไม่ซ้ำกัน ข้อมูลถูกบันทึก แต่ไม่ไม่มีการเตือนข้อความ การเติมเงินเสร็จสมบูรณ์ มันกลับเตือนว่า หมายเลขซ้ำอะครับ
ช่วยดู code ช่วยผมทีครับ ไม่เข้าใจจริงๆ
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2010-12-25 10:08:09 |
By :
chonburi f.c |
View :
1218 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
$sql = "select r_truemoney from tb_refill where r_truemoney='$_POST[codetrue]'";
$result=mysql_query($sql);
$rows =mysql_num_rows($result);
$i=0;
if($rows>$i){
echo "<script>alert(' หมายเลข truemoney มีปัญหากรุณาติดต่อ 086 - 6884285');history.back();</script>";
}else{ //ตรงนี้ให้คุณทำเป็น alert แจ้งเตือนก่อนการบันทึกไว้ครับ
$sql="insert into tb_refill values('','$fname1','$id1','$use1','$pass1','$tel1','$codetrue','$money','newrefill','$ip','$date','$zone1')";
$result=mysql_db_query($dbname,$sql);
echo"<script>alert(' การเติมเงินเสร็จสมบูรณ์ท่านสามารถรอสถานะ active ได้ในหน้าถัดไป '); window.location ='chk_status.php';</script>";//ขอดูหน้านี้หน่อยครับว่าคุณเขียนไว้ยังไง
}
|
 |
 |
 |
 |
Date :
2010-12-25 11:51:21 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตามหลักสากลวรรนโรค(ตั้งใจเขียน)เลยนะครับ
$sql = "select r_truemoney from tb_refill where r_truemoney='$_POST[codetrue]'"; //select ข้อมูลจากฐานข้อมูลตามเงื่อนไข *อันนี้คุณรู้อยู่แล้ว
$result=mysql_query($sql);
$rows =mysql_num_rows($result);//ให้คิวรีแล้วนับเป็นจำนวนแถวมา
$i=0;///สร้างตัวแปร (i) ขึ้นมาหรืออะไรก็ได้ แล้วให้มีค่าเท่ากับ 0 (ไม่มีค่า) เพราะการทำงานในฐานข้อมูลเวลามีข้อมูลมันจะมีค่าเป็น 1 (มีค่า) 0/1
if($rows>$i){///เงื่อนไข ถ้า แถวในฐานข้อมูลมี ค่ามากกว่า $i ที่มีค่าเท่ากับ 0 (ที่ไม่มีค่า)
คำสั่งให้ทำจะเป็นเงื่อนไขอะไรก็ให้เขียนลงไปในขอบเขตนี้ครับ ถ้าเงื่อนไขไปตรงกับข้อมูลในฐานข้อมูลที่ถูกคิวรี่ขึ้นมามันก็จะแจ้งเตือน หรือว่ามีข้อมูลนี้อยู่แล้วโดยมีคำสั่งหลังการคิวรี่
echo "ข้อมูลมีแล้ว";
}
ประมาณนี้ครับ
ปล.ผิดพลาดประการใดก็ขออภัยด้วยเพราะผมอธิบายเป็นแบบภาษาพูดของผมที่ผมเข้าใจครับ
|
 |
 |
 |
 |
Date :
2010-12-25 13:26:45 |
By :
Dragons_first |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|