我對我創建的MySql查詢感到困惑。當我運行代碼時,查詢無法將數據插入到數據庫中。我試圖弄清楚發生了什麼事。當我嘗試在我的本地主機上運行它時,沒有發現錯誤,查詢插入..我使用PHP 5.6,我的Web服務器也使用PHP 5.6。SQL沒有插入數據庫
<?php
include 'koneksi.php';
$user = $_POST['username'];
$pass = $_POST['password'];
$nama = $_POST['nama'];
$mail = $_POST['email'];
$tlp = $_POST['telp'];
$date = date("j F Y");
$invoice = mt_rand(100000, 999999);
if ($_POST['pack'] === 'Basic') {
$pack_name = 'Basic Pack';
$price = '$5';
$permiti = 'basic';
$limit = '15';
} elseif ($_POST['pack'] === 'Premium') {
$pack_name = 'Premium Pack';
$price = '$10';
$permiti = 'premium';
$limit = '20';
} elseif ($_POST['pack'] === 'Pro') {
$pack_name = 'Pro Pack';
$price = '$15';
$permiti = 'pro';
$limit = '25';
} elseif ($_POST['pack'] === 'Ultimate') {
$pack_name = 'Ultimate Pack';
$price = '$20';
$permiti = 'ultimate';
$limit = '99';
} else {
}
$permit = 'member';
$start = date("md");
$end = date("md", strtotime(date("md", strtotime($start)). " + 30 day"));
$start_date = date("j F Y");
$end_date = date("j F Y", strtotime(date("j F Y", strtotime($start_date)). " + 30 day"));
$encrypts = md5($nama);
$check = mysql_query("SELECT * FROM user WHERE username = '$user'");
if(mysql_num_rows($check) <> 0){
header("location:register.php?message=fail");
} else {
if(!$user || !$pass || !$mail || !$nama || !$tlp){
echo 'Terdapat data yang kosong<br/>';
echo '<a href="register.php">Back</a>';
} else {
$save = mysql_query("INSERT INTO user VALUES('', '$nama', '$user', '$pass', '$date', '$mail', '$tlp', '$permit')");
$gets = mysql_query("INSERT INTO user_pack VALUES('', '$pack_name', '$user', '$start', '$end', '0', '$limit', '$price', '$permiti', '$encrypts', '$invoice', '$start_date', '$end_date', '0')");
if($save || $gets){
session_start();
$_SESSION['username'] = $user;
$_SESSION['status'] = 'login';
header("location:user/invoice.php");
} else {
header("location:register_pack.php?message=fail1");
}
}
}
?>
請幫我:(
所以你是說如果你呼應你的查詢,$保存和$得到每一類又中生成的SQL粘貼到您的本地主機的phpmyadmin SQL選項卡或類似,他們的工作? – TimBrownlaw
這個問題是解決。問題是在我的錯。我沒有檢查查詢,我有導入到數據庫..我不知道爲什麼這是happend,但每當我想導入所有的從我的本地主機到我的在線網絡的數據,它也有同樣的問題..現在它完成了,我已經把所有的查詢表逐一。 –