mysql - PHP script cannot access database in sql -


i trying connect mysql database through php script. gives me error mysql_error(): access denied user '@localhost' database 'userinfo'

userinfo database.

my script this

<?php $servername = "localhost"; $username = "root"; $password = "'mm'"; $database = "userinfo"; $conn = mysqli_connect($servername, $username, $password);  if (!$conn) {     die("connection failed: " . mysqli_connect_error()); }  echo "connected successfully<br>";  mysql_select_db($database) or die(mysql_error());  echo "connected db:" . $database . "<br>"; ?> 

you connecting using

mysqli_ 

function , selecting data with

mysql_ 

avoid using both @ same time. since they're incompatible. use mysqli_ alternative instead

mysqli_select_db($conn, $database); 

and

mysqli_error($conn) 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -