我在获得连接到sql的代码时遇到了困难。我在阿普塔纳创造了一个湿堆。运行时,网页只显示:
无法连接到DB: mysql_error()。);mysql_select_db ("q4u!")或死(“不能选择db");回显”连接“! ";$INSERT_sql =“在客户(cust_Fname、cust_Lname、cust_Phone、cust_alt_phone、cust_Email、cust_notification_preference)中插入值('$_POSTfirstname‘、'$_POSTlastname’、'$_POSTphonenumber‘、'$_POSTaltphone’、'$_POSTemailaddress‘、’$_POSTnotipref‘)、mysql_query($INSERT_sql)、?>
我的代码看起来像
<?php
mysql_connect("localhost:3306", "root", "") or die ("<p>cannot connect to DB: mysql_error().</p>" );
mysql_select_db ("q4u!") or die ("cannot select db");
echo "<p>Connected!</p>";
$INSERT_sql = "insert into customer (cust_Fname, cust_Lname, cust_Phone, cust_alt_phone, cust_Email, cust_notification_preference)
VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[phonenumber]','$_POST[altphone]','$_POST[emailaddress]','$_POST[notipref]')";
mysql_query($INSERT_sql);
?>发布于 2013-10-30 00:52:07
未安装PHP或文件扩展名非.php
发布于 2019-01-19 09:40:25
尝试此$db = mysqli_connect('localhost:3306','root','');不再包含mysql_select_db。
https://stackoverflow.com/questions/19670933
复制相似问题