gpt4 book ai didi

javascript - php Javascript 变量引用错误

转载 作者:行者123 更新时间:2023-11-29 13:01:39 25 4
gpt4 key购买 nike

我在附加代码行中的引号时遇到问题。

它是图片查看器的一部分。图片数据url“PicNotes”是从mysql读取的。我试图通过添加图片信息弹出窗口来增强结果,但无法获得正确的引号。

我在 3 个版本(尝试)中添加了一些 rem 语句以使其正常工作。

    $data = mysql_query("SELECT * FROM $tbl_name WHERE type='$type' LIMIT $start, $limit_col_1");}
// Your while loop here
while($row = mysql_fetch_array($data))
{//REM If there is no info don't show the info link
if ($row[PicNotes]) {
// $icon=<a href="JavaScript:Popup('notes/$row['PicNotes']');"> <img src='images/info.png'></a>; //REM This line was the original call for the pop-up script
// $icon = "<a href=notes/tempest_series.php><img src=images/info.png></a>"; //REM This line works but does not have any of the Jarvascript or URL variable from the DB
// $icon = "<a href=notes/$row[PicNotes]><img src=images/info.png></a>"; //REM This line doesn't crash but the URL is corrupted
$icon = "<a href="JavaScript:Popup(notes/$row[PicNotes]);"><img src=images/info.png></a>"; //REM This line crashes with an "Unexpected T_STRING error
}else{
$icon='';}
// Display LHS Thumbnail and Viewer Pic Data

echo "<a href='images/".$row['vfile']."' rel='enlargeimage::mouseover' rev='loadarea' title='&lt;b&gt;".$row['Title']."&lt;/b&gt;&lt;br /&gt;".$row['Medium']." &nbsp; &nbsp; &nbsp; ".$row['iw']." x ".$row['ih']." cm. $icon'><img border='1' src='images/".$row['tnfile']."
' alt='' width='".$row['tnx']."' height='".$row['tny']."' class='tn' /></a><br />";

}

请有人让我走上正轨。

最佳答案

1)转义内部引号:

$icon = "<a href=\"JavaScript:Popup(notes/$row[PicNotes])\"><img src=images/info.png></a>";

2)使用单引号:

$icon = "<a href='JavaScript:Popup(notes/$row[PicNotes])'><img src=images/info.png></a>";

关于javascript - php Javascript 变量引用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23252839/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com