我无法让我的代码连接到我的 sql。我正在用 wamp 堆栈在 aptana 中创建。运行时,网页只显示:
无法连接到数据库:mysql_error()。" ); mysql_select_db ("q4u!") or die ("cannot select db"); echo " 已连接!
"; $INSERT_sql = "插入客户 (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); ?>
我的代码看起来像
<?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);
?>