안녕하세요, 제 코드를 제 SQL에 연결하는 데 문제가 있습니다. 나는 wamp 스택으로 aptana에서 생성 중이다. 웹 페이지를 실행할 때MySQL/sqlbuddy에 연결하기 PHP
은 DB에 연결할 수 없습니다 : mysql_error(). "); mysql_select_db ("q4u! ") 또는 die ("can not select db "); echo" Connected!
"; $ 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);
처럼 보인다
?>