1.11M Members

Problem: expects parameter 1 to be resource

 
0
 

I think you are on the right track, but the variable needs to be appended like so:

$checkquery = "SELECT * FROM flowchart WHERE id = ". $id ;

Yes I like to do in this way but the other will also work fine. You can try it.

 
0
 

change this:
$checkquery = "SELECT * FROM flowchart WHERE id = '$id'";
into this:
$checkquery = "SELECT * FROM `flowchart` WHERE `id` = '".$id."'";
so that you separate SQL from PHP code. and don't forget the grave accent on the table and field names

 
0
 

Original poster hasn't posted in this thread since Sep 4th, 2009. Also, Avasulthiris stated here that the project HAD to be finished by Sep 4th, 2009.

I don't think it is going to get marked "Resolved", and I'm pretty sure he isn't coming back to this thread anymore. :)

Just my 2¢.

 
-1
 

If the query doesn't return anything, php will not instantiate the $result variable and php complains about expecting a boolean variable.

if (!$result) {
 // do something.
}
 
0
 

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\dijuv\student_express_entry.php on line 127 on
$sql =$sql = "INSERT INTO tblexpressstudent(zoneid, ";
$sql = $sql . "First_Name, Last_Name, Email, Address, ";
$sql = $sql . "City, State, Zip_Code, Phone_number, Work_Number, Alternate_Number, dob_day, ";
$sql = $sql . "dob_month, dob_year, ";
$sql = $sql . "System_Number, ";
$sql = $sql . "attending_school, level_of_education, credits, credit_outside, credit_transfer, lookingforsubject,";
$sql = $sql . "levelofdegree, enroll_within_three_month, permanent_resident, ";
$sql = $sql . "Graduation_year, internet_access, US_Military, Military_Benfits, ";
$sql = $sql . "WorkedFull, UniversityOffered, SecondaryUniversity, Coments, Acceptance, ";
$sql = $sql . "strStatus, ";
$sql = $sql . "dtCreated, dtModified, StrCreatedUNM, strModifiedUNM, ysnDeleted) ";
$sql = $sql . "VALUES('" . $zoneid . "',";
$sql = $sql . "'" . $first_name . "', '" . $last_name . "', '" . $email . "', ";
$sql = $sql . "'" . $address . "', '" . $city . "', '" . $state . "', " . $zip . ", ";
$sql = $sql . "" . $PhoneNo . ", '" . $WorkNo . "', '" . $AlternateNo . "', ";
$sql = $sql . "" . $dob_day . ", " . $dob_month . ", " . $dob_year . ", ";
$sql = $sql . "" . $SystemNumber . ", ";
$sql = $sql . "'" . $AttendingAnySchool . "', '" . $LevelOfEducation . "', '" .$Credits ."', '" .$CreditOutside . "', '" .$CreditTransfer ."' , ";
$sql = $sql . "'" . $LookingForSubject ."' , '" .$LevelOfDegree ."' , '" . $Enroll . "', ";
$sql = $sql . "'" . $PermanentResident . "', " . $GraduationYear . ", '" . $InternetAccess . "', ";
$sql = $sql . "'" . $USMilitary . "', '" . $MilitaryBenfits . "', '" . $WorkedFull . "', ";
$sql = $sql . "'" . $UniversityOffered . "', '" . $SecondaryUniversity . "', '" . $Coments . "', ";
$sql = $sql . "'" . $Acceptance . "', ";
$sql = $sql . "'" . $strStatus . "', '" . $date . "', '" . $date . "', ";
$sql = $sql . "'" . $Sunam . "', '" . $Sunam . "', '')";

 
0
 

No i'm still here.

I still occasionally get this and I still don't understand why. Often it's a misspelled name or quotations where they are needed. But the rest of the time its just for no reason what so ever. I end up recoding what ever im working on until it works.

I'm assuming its just a php configuration issue, because i've only seen it happen so frequently on my one laptop. It works better on the other computer, so I'm just going to solve the thread. Still unsure though.

Good luck if you get this problem

Question Answered as of 3 Years Ago by dasatti, ShawnCplus, kushmanish and 9 others
 
0
 

Hi all,

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:

require "dbconn.php";
$id=$_POST['id'];
$checkquery = "SELECT * FROM table WHERE id = '$id'";
$checkresults = mysql_query($checkquery);
$row = mysql_fetch_row ($checkresults);

It crashes on the last line :S

Take the code and do this:

require "dbconn.php";
$id=$_POST['id'];
$checkquery = "SELECT * FROM table WHERE id = '$id'";
$checkresults = mysql_query($checkquery) or die(mysql_error());
//this should show an error if it occurs
$row = mysql_fetch_row ($checkresults);

when you get the error, post it back here, though I think, the problem is that either the column name or the table name is wrongly spelt, but the query itself looks fine and let the name of the table be in backticks like `table` incase you're using a reserved word in SQL

 
0
 

Just take table name:

require "dbconn.php";
    $id=$_POST['id'];
    $checkquery = "SELECT * FROM `table` WHERE id = '$id'";
    $checkresults = mysql_query($checkquery);
    $row = mysql_fetch_row ($checkresults);

Attention: ` != ' :)
Hope it'll help.

 
0
 

i used this piece of code to fix the error... this should fix yours...

mysql_select_db('database');

 
0
 

the reason is you cannot connect to your database.. that simple

 
0
 

dasatti TY so much! I've had a headache with that for a while until I found your post. Really helpful :)

 
0
 

I'm having the same issues, and there is nothing wrong with my query. I've check 3wschools.com and a PHP book and they both show that this query format is valid and should work. So why does it give that error, it's frustrating to no end and I've tried all you solutions and none work.

here is the output of scyfox code that I added to my one script:
"Issues trying to fetch results. Check the error-->You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group = 4' at line 1"

But the query isn't even on line one, line one has the <html> tag. So it only helps a little but doesn't give a real working answer to the problem at hand. So why is this happening? We need a real answer with a real solution.

This is the query I'm using:
"SELECT * FROM user WHERE group = " . $grp;

The idea I have is to have the user use a third option when loging in. If he or she is and is an admin then their corresponding group number would be 4 if they're a user then their group number would be 1. So if they want to login they have to selece the wright group. The login script would then selecet all the in formation from the user table where the group number would corrispond with the one selected by the user loging in and check if the user name and password is pressent in the DB under that group.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article