【问题标题】:Connecting to MySQL/sqlbuddy PHP连接到 MySQL/sqlbuddy PHP
【发布时间】:2013-11-09 08:36:06
【问题描述】:

我无法让我的代码连接到我的 sql。我正在用 wamp 堆栈在 aptana 中创建。运行时,网页只显示:

无法连接到数据库:mysql_error()。 " ); mysql_select_db ("q4u!") 或 die ("不能选择数据库"); echo " 已连接!

"; $INSERT_sql = "插入客户(cust_Fname, cust_Lname, cust_Phone、cust_alt_phone、cust_Email、cust_notification_preference) 价值观 ('$_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);  
?>

【问题讨论】:

    标签: php html mysql sql connection


    【解决方案1】:

    没有安装PHP或者文件扩展名不是.php

    【讨论】:

      【解决方案2】:

      试试这个$db = mysqli_connect('localhost:3306','root',''); 不要再包含mysql_select_db

      【讨论】:

        猜你喜欢
        • 2019-02-08
        • 1970-01-01
        • 1970-01-01
        • 2012-01-16
        • 2018-12-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多