0

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");
}

8
Contributors
17
Replies
46
Views
6 Years
Discussion Span
Last Post by Xtremefaith
Featured Replies
  • 1

    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). Read More

1

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 by pritaeas: n/a

Votes + Comments
0

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.

0

I typed myself wrongly, but in my code i checked and there is no misspell.

0

@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 by pritaeas: n/a

0

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 by karthik_ppts: n/a

0

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

0

try:

$result_1= mysqli_query($link, "SELECT $criteria FROM table ORDER BY $crieria ASC") or die( mysqli_error($link) );
0

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);
}
0

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?

0

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?

Then problem is not in query. Problem is in your input $criteria. Check your input or post your all codes.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.