Connecting to MySQL/sqlbuddy PHP
Hi I'm havving trouble getting my code to connect to my sql. I am creating in aptana with a wamp stack. When running the web page only displays
cannot connect to DB: mysql_error(). " ); mysql_select_db ("q4u!") or die ("cannot select db"); echo " Connected!
"; $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); ?>
my code looks like
<?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/93678.html