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
11 Years Ago@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
$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");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.