Take the tour ×

$dbconnect = new DB_Class('ctresults', 'root', '');

    $query="SELECT name FROM `studentrecord` WHERE rollno=$roll And sem=$sem";

if (!$RS) {


    $row = mysql_fetch_array($RS);
    $name = mysql_result($RS, 0);



I am getting mysql errors,because the result set is returning null value what should i do? I want that when result set returns null value the page must be redirected to 'pagetwo.html' please help!

share|improve this question
Why are you using both mysql_fetch_array and mysql_result? Pick one. –  aynber Aug 27 at 19:07
mysql_fetch_array increments the pointer in the resultset, so there's nothing for mysql_result to return, assuming there's just one record returned. –  andrewsi Aug 27 at 19:09
my database contains more then one row when result set is not empty, and I want first row at a time. –  Karan Bhatia Aug 27 at 19:09
If you want just the first row, use mysql_fetch_array. If you want to iterate over the rows, use while($row = mysql_fetch_array($RS)){} –  aynber Aug 27 at 19:12
add comment


Your Answer



Browse other questions tagged or ask your own question.