|
 |
|
INSERT ข้อมูลลง DB ไม่ได้ ไม่ทราบเกิดจากอะไรครับ ช่วยดูให้ที มีนไปหมดละ |
|
 |
|
|
 |
 |
|
แสดงข้อความ ติดต่อไม่ได้
config.php
<?
$hostname = "127.0.0.1";
$username="root";
$password="password";
$dbname = "appointment";
$dblogin = "appointment";
$connection=mysql_connect($hostname,$username,$password) or die("ติดต่อฐานข้อมูลไม่ได้");
$db=mysql_select_db($dbname,$connection) or die("ไม่สามารถเลือกฐานข้อมูลได้");
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET collation_connection = ’utf8_thai_ci’ ");
?>
processregister.php
<?php
ob_start();
include('config.php');
$username=$_POST['username'];
$password=$_POST['password'];
$email=$_POST['email'];
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$day=$_POST['day'];
$month=$_POST['month'];
$year=$_POST['year'];
$gender=$_POST['radio'];
$address=$_POST['address'];
$province=$_POST['province'];
$zipcode=$_POST['zipcode'];
$position=$_POST['position'];
$hobby=$_POST['hobby'];
$date=$_POST['date'];
$birthday=$year."-".$month."-".$day;
$sql="SELECT custUsername FROM customer WHERE custUsername='$username' ";
$numrow=mysql_db_query($dbname,$sql);
$total=mysql_num_rows($numrow);
if($total==0)
{
$sql1="INSERT INTO customer ( custDate,custUsername,custPassword,custEmail,custFirstname,custLastname,custBirthday,custGender,custAddress,custProvince,custZipcode,custPosition,custHobby) values ( '$date','$username','$password','$email','$firstname','$lastname','$birthday','$gender','$address','$province','$zipcode','$position','$hobby') ";
$numrow1=mysql_db_query($dbname,$sql1)or die("ติดต่อไม่ได้");
header('Location: index.php');
mysql_close();
}
else if($total>=1)
{
echo"<script type='text/javascript' language='javascript'>
alert('Username นี้มีคนใช้งานแล้วค่ะ');
history.back();
</script>";
mysql_close();
}
else{}
?>
Tag : PHP, MySQL, HTML/CSS

|
|
 |
 |
 |
 |
Date :
2014-03-11 20:26:37 |
By :
งงงงง |
View :
714 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
บรรทัดที่ 31 เปลี่ยนเป็น
Code (PHP)
$numrow1=mysql_query($sql1) or die(mysql_error());
ขอดู error หน่อยครับ
|
 |
 |
 |
 |
Date :
2014-03-11 22:29:11 |
By :
ผู้มาเยือน |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|