0

I am using the below code to populate drop down list in php html,

<?php                       
$mid="mario";
$sql = "SELECT * FROM tbl_prdy WHERE col_master_id = '$mid'";

$result = mysqli_query($conn,$sql);
echo "<select name='list'>";
while ($row = mysql_fetch_array($result)) {
    echo "<option value='" . $row['col_of_fa'] . "'>" . $row['col_of_fa'] . "
    </option>";
}
echo "</select>";
?>

But, I am getting internal server error. I have debugged the code and found that the issue is with the following 2 lines in the above code. There is not much information in server logs. Can you tell me what might be the issue with the following 2 lines of code?

while ($row = mysql_fetch_array($result)) {
echo "<option value='" . $row['col_of_fa'] . "'>" . $row['col_of_fa'] . 
"/option>";
}
1
  • The beauty of this API is that it affords the use of parametrised queries Commented Jul 21, 2017 at 6:19

3 Answers 3

2

mixing mysqli with mysql

change

$row = mysql_fetch_array($result)

to

$row = mysqli_fetch_array($result)
Sign up to request clarification or add additional context in comments.

Comments

0

You would use this

while($row=mysqli_fetch_assoc($result )){
}

or

while($row=mysqli_fetch_array($result )){
}

Comments

0

//Try this :

while ($row = mysqli_fetch_array($result)) { ?>
    <option value="<?php echo $row['col_of_fa'] ?>" ><?php echo $row['col_of_fa'] ?>
    </option>
<?php }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.