search

Home  >  Q&A  >  body text

PHP cannot connect to database

<?php
$conn=mysqli_connect("127.0.0.1","root","root","PJ")or die("Failed to connect to the database! Username or Wrong password!");
mysql_select_db("PJ","$conn");
mysql_query($conn,"CREATE TEMPORMARY TABLE 'MESSAGE'");
?>


Error Warning: mysqli_connect(): (HY000/2002):

雨木木雨木木2166 days ago1104

reply all(1)I'll reply

  • 天蓬老师

    天蓬老师2018-12-20 20:59:52

    Are you using mysql or mysqli? These are two different things. Mysqli is an enhanced version of mysqli

    What you use to connect is: mysqli_connect(). To select the database later, use The one is: mysql_select_db(), you should also use: mysqli_select_db()

    reply
    0
  • Cancelreply