我这样更改了代码。但是仍然没有将数据添加到WAMP表中。这也不显示任何消息
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
//$user_name = "root";
//$password = "";
//$database = "cs_project";
//$server = "localhost";
$linkz=mysqli_connect("localhost","root","","cs_project") or die("Can't connect to the server");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_select_db($linkz,"cs_project") or die("Can't connect to database");
if(isset($_REQUEST['submit'])) {
$v_number=$_POST["v_number"];
$date=$_POST["date"];
$from=$_POST["from"];
$to=$_POST["to"];
$destination=$_POST["destination"];
$collectpoint=$_POST["collectpoint"];
$payment_method=$_POST["payment_method"];
$sql="INSERT INTO order_table(v_number,date,from,to,destination,collectpoint,payment_method) VALUES('$v_number','$date','$from','$to','$destination','$collectpoint','$payment_method')";
$result = mysqli_query($linkz,$sql); if (!$result) { die('Invalid query: ' . mysqli_error()); }
echo "Data added";
}
mysqli_close($linkz);
?>
答案 0 :(得分:0)
在PHP 5.5中已弃用了具有mysql扩展名的功能,并已在PHP 7中将其删除。下一次将功能与mysqli扩展名或PDO一起使用。除了那和$ sql语句,一切看起来都没问题。