Jump to content

ima getting errors in queries


Recommended Posts

$query = mysqli_query($con,"SELECT * from posts2 order by rand() LIMIT 0,4");
$post_title ="shazz";
while ($row=mysqli_fetch_array($query))

the following are the errors im facing:
Warning: mysqli_connect(): (HY000/1044): Access denied for user ''@'localhost' to database 'shazz' inC:\xampp\htdocs\shazz\include\main_content.php on line 3

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given inC:\xampp\htdocs\shazz\include\main_content.php on line 4

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given inC:\xampp\htdocs\shazz\include\main_content.php on line 6
Edited by Zane
Link to comment
Share on other sites

The error and the code that you posted don't match. The connection string for mysqli looks like this:



So the error Access denied for user ''@'localhost' to database 'shazz' meens that the "myuser" parameter is empty, not the "mypassw" as you show in your code. 

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.