Today, We want to share with you mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in.In this post we will show you mysqli fetch array expects parameter 1 to be mysqli result, hear for mysqli_fetch_assoc() expects parameter 1 to be mysqli_result boolean given in php we will give you demo and example for implement.In this post, we will learn about PHP Connect to MySQLi with an example.
- Warning mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in…
- solve 1
- Solution 2
- Related posts
mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in ,boolean given in c:\xampp
solve: 1
$result = mysqli_query($this->conn, $this->sql); if (!$result) { printf("Error: %s\n", mysqli_error($this->conn)); //exit();Reference article: PHP MySQLi Database Connection
Solution : 2
That sql query is failing and returning false boolean value.
so you can simply use Put this after mysqli_query() to see what’s going on.
It means that the first parameter that is passed to mysqli_fetch_array is not of type mysqli_result.
$user_sql_query = "SELECT * FROM `members` WHERE `google_id` = " . $google_id . " LIMIT 0, 50 "; $row_messages = mysqli_query($link, $user_sql_query); if (!$row_messages) { printf("Error: %s\n", mysqli_error($link)); exit(); }$row_messages = mysqli_query($user_sql_query,MYSQLI_ASSOC);
ERROR: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given
You can print the error
$user_sql_query = "SELECT * FROM `members` WHERE `google_id` = " . $google_id . " LIMIT 0, 50 "; $row_messages = mysql_query($link, $user_sql_query); if (!$row_messages) { die('Invalid query: ' . mysql_error()); }Warning: mysqli_fetch_all() expects parameter 1 to be mysqli_result, bool given in C:\xammp\htdocs\demo\index.php on line 11
where you are running mysqli_query , add ‘or die( mysqli_error($conn)’
For more information: //www.php.net/manual/en/mysqli.error.php
I hope you get an idea about mysqli_fetch_array() expects parameter 1 to be mysqli_result, object given in.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always
welcome.
If you enjoyed and liked this post, don’t forget to share.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.
11 Years Ago
Hi, I got this error. Please help.
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in
$result_1= mysqli_query($link, "SELECT $criteria FROM table ORDER BY '".$crieria."' ASC);
$array1 = array();
while($row = mysqli_fetch_array($result_1)){
array_push($array1, "$row[0]->$criteria", "$row[5]->$criteria" , "$row[10]->$criteria");
}
Recommended Answers
mysqli_query returns false on failure, indicating something is wrong with your query. See the sticky thread at the top of the PHP forum to find out how you can check for errors (most likely because $criteria is misspelled).
Jump to Post
check your spelling is correct or not for '$crieria' near to ORDER BY
Jump to Post
mysqli_query returns false on failure, indicating something is wrong with your query. See the sticky thread at the top of the PHP forum to find out how you can check for errors (most likely because $criteria is misspelled).
Sorry pritaeas.. I haven't see your post.
Jump to Post
@Karthik: No need to be sorry. We saw the same thing, and were probably typing at the same time.
@Jiaxin: See the sticky thread first. It tells you how to trap and find …
Jump to Post
Replace your query
$result_1= mysqli_query($link, "SELECT $criteria FROM table ORDER BY '".$crieria."' ASC);with
$result_1= mysqli_query($link, "SELECT $criteria FROM table ORDER BY $crieria ASC");
Jump to Post
All 19 Replies
pritaeas 2,080 ¯\_(ツ)_/¯
Moderator Featured Poster mysqli_query returns false on failure, indicating something is wrong with your query. See the sticky thread at the top of the PHP forum to find out how you can check for errors (most likely because $criteria is misspelled). Edited 11 Years Ago by pritaeas because: n/a
11 Years Ago
check your spelling is correct or not for '$crieria' near to ORDER BY
11 Years Ago
mysqli_query returns false on failure, indicating something is wrong with your query. See the sticky thread at the top of the PHP forum to find out how you can check for errors (most likely because $criteria is misspelled). Sorry pritaeas.. I haven't see your post.
11 Years Ago
I typed myself wrongly, but in my code i checked and there is no misspell.
pritaeas 2,080 ¯\_(ツ)_/¯
Moderator Featured Poster @Karthik: No need to be sorry. We saw the same thing, and were probably typing at the same time. @Jiaxin: See the sticky thread first. It tells you how to trap and find errors. Edited 11 Years Ago by pritaeas because:
n/a
11 Years Ago
Replace your query with
Edited 11 Years Ago by karthik_ppts because: n/a
11 Years Ago
I replaced it but still have the same error.
11 Years Ago
just echo out the query as
echo "SELECT $criteria FROM table ORDER BY $crieria ASC";before this line
$result_1= mysqli_query($link, "SELECT $criteria FROM table ORDER BY $crieria ASC");copy the printed query and execute it in the SQL section of your phpmyadmin and see the result. it will tell the error if you have error in your query
ko ko 97 Practically a Master Poster
11 Years AgoSELECT $criteria Why dollar sign before 'criteria' after 'SELECT' ?
pritaeas 2,080 ¯\_(ツ)_/¯ Moderator Featured Poster
11 Years AgoOnly do that if you want to replace it with a variable. If you think it is wrong, replace it with a *
hielo 65 Veteran Poster
11 Years Agotry:
$result_1= mysqli_query($link, "SELECT $criteria FROM table ORDER BY $crieria ASC") or die( mysqli_error($link) );
11 Years Ago
try:
$result_1= mysqli_query($link, "SELECT $criteria FROM table ORDER BY $crieria ASC") or die( mysqli_error($link) );
Always let PHP display errors for you in development. Another way described in PHP Manual is:
/* Create table doesn't return a resultset */ if (mysqli_query($link, "CREATE TEMPORARY TABLE myCity LIKE City") === TRUE) { printf("Table myCity successfully created.\n"); } /* Select queries return a resultset */ if ($result = mysqli_query($link, "SELECT Name FROM City LIMIT 10")) { printf("Select returned %d rows.\n", mysqli_num_rows($result)); /* free result set */ mysqli_free_result($result); }
11 Years Ago
because i pass in the user input at the $criteria
11 Years Ago
i have already echo out this
echo "SELECT $criteria FROM table ORDER BY $crieria ASC";
but then the result shown are only:
SELECT FROM criteria ORDER BY ASC
and not the real data from database. what can i do to make it echo out all the data in ASC?
11 Years Ago
i have already echo out this
echo "SELECT $criteria FROM table ORDER BY $crieria ASC";but then the result shown are only:
SELECT FROM criteria ORDER BY ASCand not the real data from database. what can i do to make it echo out all the data in ASC?
Then problem is not in query. Problem is in your input $criteria. Check your input or post your all codes.
4 Years Ago
<?php include('server.php');
// fetch the record to be updated if (isset($_GET['edit'])){ $Id_alat = $_GET['edit']; $edit_state = true; $rec = mysqli_query($db, "SELECT * FROM alat WHERE Id_alat=$Id_alat"); $record = mysqli_fetch_array($rec); -- > its line 8 (wrong code!!) $timestamp = $record['timestamp']; $klamp = $record['klamp']; $Id_alat = $record['Id_alat']; }?>
Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\php_crud\index.php on line 8
please solve code above it?
4 Years Ago
My Code:
<?php
include("validation.php");
include("conection.php");
if(isset($_POST["button"]))
$sql="INSERT INTO administrator (adminid, adminname, password, address, contactno)
VALUES
('$_POST[adminid]','$_POST[adminname]','$pwde','$_POST[address]','$_POST[contactno]')";
if (!mysql_query($sql,$con))
die('Error: ' . mysql_error());
else
echo "1 record Inserted Successfully...";$result = mysql_query("SELECT * FROM administrator");
while($row1 = mysql_fetch_array($result))
if(isset($_POST["button2"]))
$pwde = md5($_POST[password]);mysql_query("UPDATE administrator SET adminname='$_POST[adminname]', address='$_POST[address]', contactno='$_POST[contactno]'
WHERE adminid = '$_POST[adminid]'");
echo "Record updated successfully";
if($_GET[view] == "administrator")
$result = mysql_query("SELECT * FROM administrator where adminid='$_GET[slid]'");
while($row1 = mysql_fetch_array($result))
$contact = $row1["contactno"];
?>
After execution got below warning:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in
Please Support....
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.