Godd night。我有這個代碼爲PHP添加數據到我的數據庫,但我沒有得到成功。我無法將數據添加到我的數據庫
<?php
require("config.inc.php");
if (!empty($_POST)) {
$user = $_POST['User'];
$mail = $_POST['Mail'];
$token = $_POST['Token'];
$pass = $_POST['Pass'];
$result = mysqli_query($con,"SELECT 1 FROM Proteos where
User='$user'");
$row = mysqli_fetch_array($result);
$data = $row[0];
if($data==0){
echo $data;
echo "Hey, un grato saludo mister ".$user."!\n";
$query = "INSERT INTO Proteos (User, Mail) VALUES ($user,$mail) ";
}
mysqli_close($con)
這是我config.inc
<?php
define('DB_SERVER','mysql.smartfreehosting.net');
define('DB_NAME','u178665800_prote');
define('DB_USER','u178665800_carin');
define('DB_PASS','xxxxxx');
$con = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
mysql_select_db(DB_NAME,$con);
?>
放到$用戶中,像 '$用戶', '$郵件' 單引號$郵件 –
你不執行你的查詢$查詢。你只是聲明查詢變量 – Gopalakrishnan
是不是有用的任何建議 –