-1
我試圖插入數據到MySQL,但它不工作。這裏沒有在這段代碼中顯示任何錯誤。我試圖插入數據到MySQL,沒有錯誤,但數據沒有插入?
<?php
$connection = mysqli_connect("localhost", "root", "");
if(!$connection) {
echo 'Server Not Found';
}
else {
echo 'Server Found';
}
// Establishing Connection with Server
$db = mysqli_select_db($connection,"colleges"); // Selecting Database from Server
if (!$db) {
echo 'Databaje Not Found';
}
else {
echo 'Databaje found';
}
if(isset($_POST['submit'])) { // Fetching variables of the form which travels in URL
$name = $_POST['name'];
$email = $_POST['email'];
$contact = $_POST['contact'];
$address = $_POST['address'];
if($name !=''||$email !='') {
//Insert Query of SQL
$query = mysqli_query("insert into students(student_name, student_email, student_contact,student_adress) values ('$name', '$email', '$contact', '$address')", $connection);
echo "<br/><br/><span>Data Inserted successfully...!!</span>";
}
else {
echo "<p>Insertion Failed <br/> Some Fields are Blank....!!</p>";
}
}
mysqli_close($connection); // Closing Connection with Server
?>
你得到哪個迴應信息作爲迴應? – Ma3x
猜''學生地址'應該''student_address' – Carl
$連接第一次在mysqli_query() – nogad