连接到MySQL / sqlbuddy PHP

嗨,我很难让我的代码连接到我的SQL。 我正在用一个压缩栈创建aptana。 运行网页时只显示

无法连接到DB:mysql_error()。 “); mysql_select_db(”q4u!“)或死(”无法选择数据库“);回声”连接!

“; $ 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);  

?>


链接地址: http://www.djcxy.com/p/93677.html

上一篇: Connecting to MySQL/sqlbuddy PHP

下一篇: How to insert data in a table with a foreign key?