Here is the code of : select_class.php
<?php
$get_userclass_query="select courseandbatch from studentdetails group by courseandbatch ";
$get_userclass_result=mysql_query($get_userclass_query);
while($get_userclass_row=mysql_fetch_array($get_userclass_result))
{?>
<option value="<?php echo $get_userclass_row['courseandbatch']; ?>"><?php echo $get_userclass_row['courseandbatch']; ?></option>
<?php echo $get_userclass_row['courseandbatch']; ?><?php
}
?>
code:sis.php
Batch:<input type="text" /><select name="search" style="width:100px; height:20px;" >
<?php
include '../select_class.php';
?>
</select>
When I execute this page, I have the following error:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\apnacar\select_class.php on line 5
How can I fix this ?
mysql_*
functions' warning. They're now deprecated.echo mysql_error();
or better more search before asking.mysql_query()
has failed but you have no error processing code in there to check it. Whenmysql_query()
fails it returnsFALSE
and not a result handle, and you get this error.if ($get_userclass_result && mysql_num_rows($get_userclass_result) > 0) { while () { .. } }