Mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in
I'm have some trouble checking if a Facebook User_id already exists in my database (if it doesn't it should then accept the user as a new one and else just load the canvas application). I ran it on my hosting server and there was no problem, but on my localhost it gives me the following error: Show
Here's my code:
I've read it has something to do with my query being wrong, but it has worked on my hosting provider so that can't be it! I am creating a basic website for one of my assignments, which must view a database I created in MyPHPAdmin , add and delete a record. In my View.php on line 55 which is: while($row = mysqli_fetch_array( $result )). The following error appears: Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in C:\xampp\htdocs\View.php on line 55 Why is this happening and what can I do to resolve this error ? What I have tried: Tried using sites similar to this one such as StackOverflow and have not found a solution that answers my question as well as one that I understand as I am a beginner in PHP. where you are running
mysqli_query , add 'or die( mysqli_error($db)' $sql = "SELECT * FROM users"; $result = mysqli_query($db, $sql) or die( mysqli_error($db)); $db being the variable holding the connection to db You have to check the return value of the previous PHP: mysqli::query -
Manual[^] call for success. If that fails it returns a boolean See the above link on how to check for errors and report them. Printing the error message is useful to know what went wrong (usually an SQL syntax error).
if($result){ while($row = mysqli_fetch_array( $result )) i want to print my invoice report but this error sowing . How can I solve ? Fatal error: Uncaught TypeError: mysqli_fetch_array(): Argument #1 ($result) must be of type mysqli_result, bool given in mysqli_fetch_array() expects parameter 1 to be mysqli_result, bool given in C:\xampp\htdocs\pertandingan mewarna\item.php on line 8 This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
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)){ Recommended Answers
Jump to Post
Jump to Post
Jump to Post
Jump to Post
Jump to Post All 19 Replies
pritaeas 2,114 ¯\_(ツ)_/¯
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,114 ¯\_(ツ)_/¯
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
before this line
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,114 ¯\_(ツ)_/¯ 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:
11 Years Ago
Always let PHP display errors for you in development. Another way described in PHP Manual is:
11 Years Ago because i pass in the user input at the $criteria
11 Years Ago i have already echo out this but then the result shown are only: and not the real data from database. what can i do to make it echo out all the data in ASC?
11 Years Ago
Then problem is not in query. Problem is in your input $criteria. Check your input or post your all codes.
4 Years Ago
?> 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:
$sql="INSERT INTO administrator (adminid, adminname, password, address, contactno) if (!mysql_query($sql,$con)) die('Error: ' . mysql_error()); else
$result = mysql_query("SELECT * FROM administrator");
if(isset($_POST["button2"]))
mysql_query("UPDATE administrator SET adminname='$_POST[adminname]', address='$_POST[address]', contactno='$_POST[contactno]' if($_GET[view] == "administrator") $result = mysql_query("SELECT * FROM administrator where adminid='$_GET[slid]'");
$contact = $row1["contactno"]; ?> After execution got below warning: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in Please Support.... Reply to this topic 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. How do you fix warning mysqli_fetch_array () expects parameter 1 to be mysqli_result boolean given?Solution 1
You have to check the return value of the previous PHP: mysqli::query - Manual[^] call for success. If that fails it returns a boolean false instead of a mysqli_result object. See the above link on how to check for errors and report them.
What is the function of mysqli_fetch_array?Definition and Usage
The fetch_array() / mysqli_fetch_array() function fetches a result row as an associative array, a numeric array, or both. Note: Fieldnames returned from this function are case-sensitive.
What is the difference between Mysqli_fetch_assoc and mysqli_fetch_array?The major difference between mysqli_fetch_assoc and mysqli_fetch_array is the output format of result data. mysqli_fetch_assoc returns data in an associative array and mysqli_fetch_array returns data in a numeric array and/or in an associative array.
What is mysqli_result?The mysqli_result class ¶
Represents the result set obtained from a query against the database.
|