PHP MYSQL connection succeeded or prompt mysql_query (): Access denied for user '' @ 'localhost' (using password: NO)

mysql_query(): Access denied for user ''@'localhost' (using password: NO)

This prompts that you no database user name, no password, check for input.

If you enter whether you use the connection to the database in this way:

$conn=new mysqli();

Connected in this way is an object-oriented database. That after this connection, $ conn database object is instantiated. Below to use the database, the object to use manner ->, for example:

$db->set_charset("UTF8");
$sql="INSERT INTO ncreentry (xingming,xingbie,school,xuehao,level,zhuanye,beizhu) VALUES ('$xingming','$xingbie','$school','$xuehao','$level','$zhuanye','$beizhu')";
$select = $conn->query($sql);

If you use such
mysqli_set_charset ( "UTF8");
mysqli_query ( "");
the implementation of sql statement will report the above error.

Guess you like

Origin blog.csdn.net/jeesr/article/details/91324427