doushao1948 2013-02-24 01:19
浏览 8
已采纳

PHP echo不会出现在一台计算机上?

I have a php script that queries a MySQL database and populates a drop-down menu using the data received. Everything was working fine and suddenly, the echo "Custom" option doesn't show up for me. I asked someone else to check the same page, and it showed up for him. I tried changing browsers, and nothing. Does anyone know why this would happen?

echo '<div class="c_element" style="height: auto;"> 
    <select class="c_sel">';
        $c= mysql_query("SELECT * FROM C WHERE c_lo_id =".$sel_lo_id) or die(mysql_error());

        while($row = mysql_fetch_array($c))
        {
            echo '<option value='.$row['c_id'].'>'.$row['c_name'].'</option>';              
        }

        echo '<option value="0">Custom </option>
    </select>';
  • 写回答

1条回答 默认 最新

  • donglinxi1467 2013-02-24 01:23
    关注

    This can happen if your values contain characters that break your html, like ', > or <. When outputting to html, you should always make sure that these are encoded correctly.

    Apart from that this would also happen if there are spaces in your values as you don't quote the attribute value.

    With both corrections:;

     echo '<option value="'.htmlspecialchars($row['c_id']).'">'.htmlspecialchars($row['c_name']).'</option>';
                         ^ added as well                    ^
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 msix packaging tool打包问题
  • ¥15 finalshell节点的搭建代码和那个端口代码教程
  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据