duangang3832 2014-04-11 18:31
浏览 48
已采纳

堆栈溢出调用堆栈#timememoryfunctionlocation 10.0000143728

Hi this is my second time posting on this site. I looked @ the other article pertaining to this message and am unable to figure this out.

So i'm trying to dynamically populate the content of a drop down box with data store in the DB.

I'm getting the following error message displayed in the drop down for each record in the DB (3times)

Any help would be appreciated. Thanks

<!DOCTYPE html>
<?php
$con=mysqli_connect("localhost","root","","project1");
// Check connection
        if (mysqli_connect_errno())
          {
          echo "Failed to connect to MySQL: " . mysqli_connect_error();
          }

// this block would be at the top of your file above the html
$query = "select * from countries";
$country_results = mysqli_query($con,$query);
$number_of_returns = mysqli_num_rows($country_results);
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="site.css">
</head>
<body>
<h1>Insert Site into DB</h1>
    <h2 class="button"><a href=/index.html>Home</a></h2>
    <h2 class="button"><a href=/insert.html>add site</a></h2>
    <h2 class="button"><a href=/delete.html>delete site</a></h2>
    <h2 class="button"><a href=/search.html>search site</a></h2>
        <form class="insert" action="insert.php" method="post">
                <p>Site Info</p>
                Site code:<input type="text" name="site_code"><br>
                Site name: <input type="text" name="site_name"><br>
                Address: <input type="text" name="site_address"><br>
                City:<br>
                Postal code: <input type="text" name="site_postalcode"><br>
                Province: <select name="province"></select><br>
                Country: <select name=”country”>
                <?php while (($row = mysqli_fetch_row($country_results)) != null){ ?>
                <option value=”<?php echo $row[‘country’];?></option>
            <?php } ?>
                </select><br>


            <p>Site Contact Info</p>
            Site contact name: <input type="text" name="site_contact_name"><br>
            Phone number 1: <input type="number" name="site_contact_number1"><br>
            Phone number 2: <input type="number" name="site_contact_number2"><br>
            Email address: <input type="email" name="site_contact_email"><br> 
            <input type="submit">
</form>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • dongxing8650 2014-04-11 19:11
    关注

    If you want to access the result as an associative array e.g. $row['country'] you have to use mysqli_fetch_assoc. By using mysqli_fetch_row you can access you results as $row[0]. Also, the are some odd quotes in your code which have to be replaced as well as some other errors in your html e.g. missing value attribute closing quotes in options.This will work:

    <select name="country">
    
    <?php while($row = mysqli_fetch_assoc($country_results)){ ?>
    
    <option value="<?php echo $row['title'];?>"><?php echo $row['title'];?></option>
    
    <?php } ?>
    
    </select>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题