mySQL数据库和PHP中的URL字符串

mySQL数据库和PHP中的URL字符串,php,mysql,special-characters,Php,Mysql,Special Characters,我在数据库中存储的URL显示不正确时遇到问题。这是我的密码: $sqlCommand = "SELECT rotator.title, rotator.imageURL, rotator.targetURL, rotator.caption FROM rotator WHERE ( ( rotator.visible = '1' ) OR ( rotator.visible = '2' AND ( NOW() BETWEEN ro

我在数据库中存储的URL显示不正确时遇到问题。这是我的密码:

    $sqlCommand = 
       "SELECT  rotator.title, rotator.imageURL, rotator.targetURL, rotator.caption  FROM rotator   
        WHERE ( ( rotator.visible = '1' )
        OR ( rotator.visible = '2' AND ( NOW() BETWEEN rotator.schedstart AND rotator.schedstop ) ) )
        ORDER BY rotator.displayorder ASC";
    $query = mysqli_query($myConnection,$sqlCommand) or die (mysqli_error($myConnection));

    $rotatorsDisplay = '';
    while ($row = mysqli_fetch_array($query)){
        $rotatorstitle = $row["title"];
        $rotatorsimg = $row["imgURL"];
        $rotatorsURL = $row["targetURL"];
        $rotatorscaption = $row["caption"];

        $rotatorsDisplay .= '<li>
                <a href="'. $rotatorsURL .'"><img src="'. $rotatorsimg .'"></a>
                <div id="title">'. $rotatorstitle .'</div>
                <div class="caption">'. $rotatorscaption .'</div>
            </li>';
    }
    mysqli_free_result($query);
$sqlCommand=
从rotator中选择rotator.title、rotator.imageURL、rotator.targetURL、rotator.caption
其中((rotator.visible='1')
或(rotator.visible='2'和(现在是rotator.schedstart和rotator.schedstop之间的()))
按旋转器顺序。显示顺序ASC”;
$query=mysqli_query($myConnection,$sqlCommand)或die(mysqli_error($myConnection));
$rotatorsDisplay='';
while($row=mysqli\u fetch\u数组($query)){
$rotatorTitle=$row[“title”];
$rotatorsimg=$row[“imgURL”];
$rotatorsURL=$row[“targetURL”];
$rotatorCaption=$row[“caption”];
$rotatorsDisplay.='
  • “.$rotatorstitle” “.$rotatorscaption”
  • '; } mysqli_free_结果($query);
    给我带来麻烦的是$rotatorsimg变量。在数据库中,我手动输入了rotator.imageURL的值,如下所示:“images/rotator/name.jpg”,但当我从数据库中查询它们时,将它们添加到$rotatorsDisplay变量中,然后用以下代码输出它们:

        <?php echo $rotatorsDisplay; ?> 
    
    
    
    在生成的页面中,我只得到以下内容:

        <a href="doctor.php"><img src=""></a>
    
    
    
    我很确定这不起作用的原因是URL中的斜杠。我也很确定我需要以某种方式编码/转换HTML,从输入数据库的代码中去除特殊字符,然后在输出时将其解码/转换回HTML,但由于我使用phpMyAdmin手动将此信息输入数据库,我还没有想出如何做


    感谢您的帮助

    看起来您使用了错误的索引键

    $rotatorsimg = $row["imgURL"];
    
    应该是

    $rotatorsimg = $row["imageURL"];
    

    因为这就是您从数据库查询的内容。

    非常感谢。我知道这一定是很明显的事情。