Jump to content

Recommended Posts

i got an error said 


Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in


    and my code is


$result = mysql_query("SELECT * FROM friendlist WHERE firstname='".$_SESSION['SESS_FIRST_NAME'] ."' and status='pending' ORDER BY firstname ASC");


while($row=mysql_fetch_array($result))

please somebody help me

Link to comment
https://forums.phpfreaks.com/topic/287898-array-prob/
Share on other sites

Your query has most likely encountered an error.

 

Use mysql_error() to find out what the error is.

 

Also you should stop using mysql_* functions these are deperecated and could soon be removed from future versions of PHP. I'd advise you to use either mysqli or PDO from now on.

Link to comment
https://forums.phpfreaks.com/topic/287898-array-prob/#findComment-1476754
Share on other sites

please write code of mysqli and where should i write down and how

here is my code......

$result = mysql_query("SELECT * FROM friendlist WHERE firstname='".$_SESSION['SESS_FIRST_NAME'] ."' and status='pending' ORDER BY firstname ASC");
while($row=mysql_fetch_array($result))
{
$add=$row['addby'];
}
$numberOfRows = MYSQL_NUMROWS($result);
Link to comment
https://forums.phpfreaks.com/topic/287898-array-prob/#findComment-1476758
Share on other sites

In my experience with some versions of the MySQL database engine, status is a reserved word.

 

Please try your query using backticks to delineate table and column names:

AND `status` = 'pending'

 

(The backtick character is on the key just above the TAB key on the keyboard.)

Link to comment
https://forums.phpfreaks.com/topic/287898-array-prob/#findComment-1476761
Share on other sites

Let's try finding the problem by removing some things and testing. Then add them back one at a time:

 

Test, and if it works, do the next:

 

$result = mysql_query("SELECT * FROM friendlist");

Test, and if it works, do the next:

 

$result = mysql_query("SELECT * FROM friendlist ORDER BY firstname ASC");

Test, and if it works, do the next:

 

$result = mysql_query("SELECT * FROM friendlist WHERE status='pending' ORDER BY firstname ASC");

Test.

 

$result = mysql_query("SELECT * FROM friendlist WHERE firstname='".$_SESSION['SESS_FIRST_NAME'] ."' and status='pending' ORDER BY firstname ASC");

If the last test does not work, then we can say there is no record that has the value assigned to $_SESSION['SESS_FIRST_NAME'].

Link to comment
https://forums.phpfreaks.com/topic/287898-array-prob/#findComment-1476765
Share on other sites

the query and php code you have posted CANNOT have produced a query is empty error. the query is empty error does NOT mean that the query didn't match any rows. means that the actual sql query statement supplied as a parameter to the mysql_query() statement was empty.

 

either that's not the actual code or the query with a problem is somewhere else in your code.

Edited by mac_gyver
Link to comment
https://forums.phpfreaks.com/topic/287898-array-prob/#findComment-1476767
Share on other sites

What a horrible attitude you have!!  People are literally giving you step by step debugging advice and you are too much of an idiot to let them help you.  And why don't you learn how to write full words instead of your jibberish misspelled words and abbreviations?

Edited by ginerjm
Link to comment
https://forums.phpfreaks.com/topic/287898-array-prob/#findComment-1476775
Share on other sites

It means that perhaps you are looking at the wrong section of code  Do you have some other queries going on in this script?  Put an echo before this query and after it and be sure that you are getting the error there.  And show us the new code after you have made these changes (with the MySQL_error call too)

Link to comment
https://forums.phpfreaks.com/topic/287898-array-prob/#findComment-1476779
Share on other sites

you have been told that the posted query and posted code cannot produce the errors you are reporting. there's nothing technically wrong with that query. you were also told it's possible that the code inside your loop can be causing one of the errors you are reporting.

 

since you doubt that's the case, there's nothing more that we can tell you because this process of remotely debugging what is going on in your code requires that you have the ability to question and to investigate what your code is doing in order to find where and what the problem is.

Link to comment
https://forums.phpfreaks.com/topic/287898-array-prob/#findComment-1476785
Share on other sites

Let's try this again. Your original post said:

 

i got an error said 

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in

    and my code is

$result = mysql_query("SELECT * FROM friendlist WHERE firstname='".$_SESSION['SESS_FIRST_NAME'] ."' and status='pending' ORDER BY firstname ASC");

while($row=mysql_fetch_array($result))

please somebody help me

You have cutoff the error message. PHP error messages give the name of the file and the line number in that file where the error occurred. Sometimes, the actual problem is a couple of lines BEFORE the line number given.

 

This error message "... boolean given ..." indicates that the parameter passed to the mysql_fetch_array function is the (boolean) value FALSE. It is expected to be a query resource returned by mysql_query. So, the problem is a couple of lines BEFORE there error.

 

Read the error message, find the file and line number in the error message. Post code from that file starting 5 or 10 lines BEFORE the line number in the error message, and continuing through 5 or 10 lines AFTER the error message. SURROUND THE CODE WITH


TAGS. ALSO Post the FULL ERROR MESSAGE (you can X-out the path if you feel it is a security risk).

 

If we need to see more code, we will ask. When we provide a suggestion, and it does not work; post the NEW CODE as you tried it, and tell us what EXACTLY happened. If you get ANY error messages, POST THE FULL TEXT OF THE MESSAGE.

 

We are not sitting there looking at your screen, we have NO IDEA what is happening, so you must provide us with as much pertinent detail as possible.

 

mac_gyver is correct. The code you posted can NOT produce the "query is emtpy" message. So either you posted the wrong code, or you put the mysql_error call in the wrong place, or something. Again, you did not post the NEW CODE so we can't tell what is happening.

Link to comment
https://forums.phpfreaks.com/topic/287898-array-prob/#findComment-1476786
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.