orige Posted November 3, 2012 Share Posted November 3, 2012 I got that error ... from this coding ... <?php $rnum = $_REQUEST["txtrn"]; $con = mysql_connect('localhost','root',''); mysql_select_db ('q4',$con); if (!$con) {echo 'connection error!';} else {$result = mysql_query("Select * from student where rollno = '$rnum'"); $row = mysql_fetch_array ($result); if ($row) {echo "rollno : ".$row[0]; echo "Name : ".$row[1];} else {echo "rollno doesnt exist!";} } ?> can u find where the error is ?? and fix it plz ?? Link to comment https://forums.phpfreaks.com/topic/270237-mysql_fetch_array-expects-parameter-1-to-be-resource/ Share on other sites More sharing options...
trq Posted November 3, 2012 Share Posted November 3, 2012 Your query is failing for some reason and you are not checking that $result is a resource before using it. What does mysql_error have to say? Link to comment https://forums.phpfreaks.com/topic/270237-mysql_fetch_array-expects-parameter-1-to-be-resource/#findComment-1389876 Share on other sites More sharing options...
orige Posted November 3, 2012 Author Share Posted November 3, 2012 sorry ... im newbie to php ... so how should i check it ?? Link to comment https://forums.phpfreaks.com/topic/270237-mysql_fetch_array-expects-parameter-1-to-be-resource/#findComment-1389879 Share on other sites More sharing options...
jazzman1 Posted November 3, 2012 Share Posted November 3, 2012 sorry ... im newbie to php ... so how should i check it ?? For example, $result = mysql_query("Select * from student where rollno = '$rnum'") or die(myslq_error()); Link to comment https://forums.phpfreaks.com/topic/270237-mysql_fetch_array-expects-parameter-1-to-be-resource/#findComment-1389931 Share on other sites More sharing options...
orige Posted November 3, 2012 Author Share Posted November 3, 2012 thank you !! Link to comment https://forums.phpfreaks.com/topic/270237-mysql_fetch_array-expects-parameter-1-to-be-resource/#findComment-1389948 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.