duanliyi5997 2014-02-12 22:04
浏览 44

无法用PHP创建数据库,我的语法是正确的

How is it is can not create a database on phpMyAdmin? I connect to PHP just fine, no error message. But when I am trying to create a database so phpMyAdmin, I keep getting error. In case it matters I have one page with a <form> and has a submit to my second.php file where my database code is (second.php is shown below).

I am pretty much trying to display the database in phpMyAdmin but nothing shows up:

<html>
    <body>
        <?php
            $con = mysqli_connect("localhost", "user", "password");
            if(!$con){
                echo "could not connect";
            } else {
                echo "good connection";
            }

            //creation of database
            $sql= 'CREATE DATABASE project';
            if(mysql_query($sql,$con)){
                echo 'DB created succesfully';
            } else {
                echo 'error creating DB' . mysql_errno();
            }
        ?>
    </body>
</html>
  • 写回答

1条回答 默认 最新

  • ds2128629 2014-02-12 22:10
    关注

    One issue is you connected with mysqli and are using mysql the rest of the time. Pick 1 (not mysql) library and use only that.

    if(mysqli_query($con, $sql)){
    

    and

    echo 'error creating DB' . mysqli_error($con);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取