I've been hitting the same problem over and over in my development. Sometimes when i do a MySQL query I keep getting the error
Warning: mysql_fetch_row() expects parameter 1 to be resource.
I don't understand why. What does this error mean, am I doing something wrong? I've googled it but I just get pages with the same error...
I'm using php 5.3, it's definitely not my mysql statement. I'm lost >.<
I even simplify my query code and still the same problem. The general code look something like this:
Still cant find anything. What do you mean by stickied?
The code is literally as simple as what I have above in my original thread. I'm just trying to understand the error.
It's been popping up everywhere. Even with the most simple code. It's unhappy with the mysql_fetch_row command.
Sometimes it works if i copy the code into a new file. I thought I might be using reserved words in mysql, but i'm definitely not. The database also has nothing weird in. It's just being weird.
And I have to finish this system by tomorrow night >.<
*is stressing*
What does that error mean? How is $checkresults not a resource?
I changed my code entirely throughout the night and now that specific problem is gone.
I do still occasionally get the same error, I just dont have an example of it right now. When i printf the error it comes out blank. It's been boggling me for a while.
I will post an example as soon as I run into it again
$checkquery = "SELECT * FROM flowchart WHERE id = '$id'";
$checkresults = mysql_query($checkquery);
if($checkresults)
{
$row = mysql_fetch_row($checkresults);
}
The reason is when it encounters some invalid $id, the mysql_query() function does not return valid result set. You can use mysql_error() to find out the reason why returned resultset is not valid
One of the reasons that invalid result set is returned could be you are comparing a string value with an integer type field in database.
Make sure that if the id field in flowchart table is int then use this statement $checkquery = "SELECT * FROM flowchart WHERE id = $id"; instead of $checkquery = "SELECT * FROM flowchart WHERE id = '$id'";
Another module of the project im working on is mysqli instead of mysql. Could it be that that is causing the problems? That module uses its own dbconn file though so i dunno why its having this issue
Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.
This thread is more than three months old
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.