JavaScript OnMouseOver 解析错误:语法错误,意外的 T_STRING

发布于 2024-11-09 14:42:51 字数 5100 浏览 0 评论 0原文

当我在 中编写此代码时,

<a href="'.get_permalink($niphell[post_id]).' " onmouseover="mns('#msnbtn-'.($j+1).'','#msn-'.($j+1).'','.mnsli','.mnsbtbg');">

我收到此错误

Parse error: syntax error, unexpected T_STRING in /home/azerinfo/public_html/wp-content/themes/anntheme/scroller.php on line 125

jQuery 代码:

<script type="text/javascript">
function mns(e,d,c,s){
   jQuery(s).removeClass('aktif');
   jQuery(e).addClass('aktif');
   jQuery(c).css({display: 'none'});
   jQuery(d).css({display: 'block'});
}
mns('#msnbtn-1','#msn-1','.mnsli','.mnsbtbg');
</script>

更新:

<div class="mns">
<div class="crv">

  <style>

.imns{
    background-color: #E8E5E5;
    display: block;
    float: left;
    height: 376px;
    margin-top: 5px;
    padding:10px 0px 10px 10px;
    position: relative;
    width: 600px;
}
.imns .imns_content{
    background-color: #E8E5E5;
    display: block;
    float: left;
    height: 376px;
    position: relative;
    width:400px;
}
.imns .imns_content li{
    background-color: #E8E5E5;
    display: none;
    float: left;
    height: 376px;
    position: relative;
    width:400px;
}
.imns .imns_content li a.hbr{
    background-color: #E8E5E5;
    display: block;
    float: left;
    height: 376px;
    position: relative;
    width:400px;
}
.imns .imns_link{
    background-color: #E8E5E5;
    display: block;
    float: left;
    height: 376px;
    position: relative;
    width: 200px;
}
.imns .imns_link li{
    background-color: #E8E5E5;
    display: block;
    float: left;
    height: 50px;
    position: relative;
    width: 200px;
   padding-bottom:4px;
}
.imns .imns_link li a div.mnsbtbg{
   background:url(http://azerinform.com/wp-content/themes/anntheme/images/mns_numa.jpg) left top;
    display: block;
    height: 50px;
    position: relative;
    width: 196px;
   color:#004072;
   z-index:999999;
   cursor:pointer;
   overflow:hidden;
}
.imns .imns_link li a div.aktif{
   background:url(http://azerinform.com/wp-content/themes/anntheme/images/manset_a.gif) no-repeat left top;
    display: block;
    height: 50px;
    position: absolute;
    width:215px;
   color:#FFFFFF;
   margin-right:6px;
   z-index:999999;
   right:0;
   cursor:pointer;
}
.imns .imns_link li a div.aktif div.mnsbaslik{
   line-height:16px;
   margin-left:15px;
}
.imns .imns_link li a div.mnsbaslik{
   margin:-3px 0 0 3px;
   width:157px;
   line-height:18px;
}
.imns .imns_link li a div.mnsnumara{
   color:#d2d0d1;
}
.tummansetler {
    background: url(http://azerinform.com/wp-content/themes/anntheme/images/tum_mans.png) repeat scroll 0 0 transparent;
    display: block;
    float: left;
    height: 27px;
    width: 400px;
   margin-top:350px;
   position:absolute;
   z-index:999;
}
.mnsustkategori {
    color: #FFFFFF;
    float: left;
    font-weight: bold;
    height: 20px;
    padding-left: 5px;
    padding-top: 12px;
    width: 120px;
}
</style>





<?php
$resim  = mysql_query("SELECT * FROM ".$table_prefix."postmeta LEFT OUTER JOIN ".$table_prefix."posts ON ".$table_prefix."postmeta.post_id = ".$table_prefix."posts.id Where ".$table_prefix."postmeta.meta_key='manset' ORDER By ".$table_prefix."postmeta.post_id DESC Limit 7");
        for ($j=0; $niphell=mysql_fetch_array($resim); $j++){
        $ust .= '<li><a href="'.get_permalink($niphell[post_id]).'" onmouseover="mns('#msnbtn-'.($j+1).'','#msn-'.($j+1).'','.mnsli','.mnsbtbg');">




<div id="msnbtn-'.($j+1).'" onclick="window.location.href='.get_permalink($niphell[post_id]).'" class="mnsbtbg">
            <table height="50" border="0"><tr>
               <td valign="middle"><div class="mnsbaslik font2">'.$niphell[post_title].'</div></td>
               <td valign="middle"><div class="mnsnumara font3">'.($j+1).'</div></td>
            </tr></table>
            </div> </a></li>
            ';


$alt .='<li id="msn-'.($j+1).'" class="mnsli">
            <img  src="'.$niphell[meta_value].'" width="420" height="370"  alt="" />

        </li>
            ';
        }
echo '<!-- Wordpress Manset Eklentisi NipHeLL Tarafindan Kodlanmistir [email protected] -->';
?>


<div class="imns">
<div class="imns_content">

<ul>
            <?php echo $alt;?> 

</ul>
</div>


<div class="imns_link"> 


<ul>

            <?php echo $ust;?> 


</ul>
</div>





</div>

<script type="text/javascript">
function mns(e,d,c,s){
   jQuery(s).removeClass('aktif');
   jQuery(e).addClass('aktif');
   jQuery(c).css({display: 'none'});
   jQuery(d).css({display: 'block'});
}
mns('#msnbtn-1','#msn-1','.mnsli','.mnsbtbg');
</script>


</div>

</div>

When I write this code in <a and >

<a href="'.get_permalink($niphell[post_id]).' " onmouseover="mns('#msnbtn-'.($j+1).'','#msn-'.($j+1).'','.mnsli','.mnsbtbg');">

I got this error

Parse error: syntax error, unexpected T_STRING in /home/azerinfo/public_html/wp-content/themes/anntheme/scroller.php on line 125

jQuery code:

<script type="text/javascript">
function mns(e,d,c,s){
   jQuery(s).removeClass('aktif');
   jQuery(e).addClass('aktif');
   jQuery(c).css({display: 'none'});
   jQuery(d).css({display: 'block'});
}
mns('#msnbtn-1','#msn-1','.mnsli','.mnsbtbg');
</script>

Update:

<div class="mns">
<div class="crv">

  <style>

.imns{
    background-color: #E8E5E5;
    display: block;
    float: left;
    height: 376px;
    margin-top: 5px;
    padding:10px 0px 10px 10px;
    position: relative;
    width: 600px;
}
.imns .imns_content{
    background-color: #E8E5E5;
    display: block;
    float: left;
    height: 376px;
    position: relative;
    width:400px;
}
.imns .imns_content li{
    background-color: #E8E5E5;
    display: none;
    float: left;
    height: 376px;
    position: relative;
    width:400px;
}
.imns .imns_content li a.hbr{
    background-color: #E8E5E5;
    display: block;
    float: left;
    height: 376px;
    position: relative;
    width:400px;
}
.imns .imns_link{
    background-color: #E8E5E5;
    display: block;
    float: left;
    height: 376px;
    position: relative;
    width: 200px;
}
.imns .imns_link li{
    background-color: #E8E5E5;
    display: block;
    float: left;
    height: 50px;
    position: relative;
    width: 200px;
   padding-bottom:4px;
}
.imns .imns_link li a div.mnsbtbg{
   background:url(http://azerinform.com/wp-content/themes/anntheme/images/mns_numa.jpg) left top;
    display: block;
    height: 50px;
    position: relative;
    width: 196px;
   color:#004072;
   z-index:999999;
   cursor:pointer;
   overflow:hidden;
}
.imns .imns_link li a div.aktif{
   background:url(http://azerinform.com/wp-content/themes/anntheme/images/manset_a.gif) no-repeat left top;
    display: block;
    height: 50px;
    position: absolute;
    width:215px;
   color:#FFFFFF;
   margin-right:6px;
   z-index:999999;
   right:0;
   cursor:pointer;
}
.imns .imns_link li a div.aktif div.mnsbaslik{
   line-height:16px;
   margin-left:15px;
}
.imns .imns_link li a div.mnsbaslik{
   margin:-3px 0 0 3px;
   width:157px;
   line-height:18px;
}
.imns .imns_link li a div.mnsnumara{
   color:#d2d0d1;
}
.tummansetler {
    background: url(http://azerinform.com/wp-content/themes/anntheme/images/tum_mans.png) repeat scroll 0 0 transparent;
    display: block;
    float: left;
    height: 27px;
    width: 400px;
   margin-top:350px;
   position:absolute;
   z-index:999;
}
.mnsustkategori {
    color: #FFFFFF;
    float: left;
    font-weight: bold;
    height: 20px;
    padding-left: 5px;
    padding-top: 12px;
    width: 120px;
}
</style>





<?php
$resim  = mysql_query("SELECT * FROM ".$table_prefix."postmeta LEFT OUTER JOIN ".$table_prefix."posts ON ".$table_prefix."postmeta.post_id = ".$table_prefix."posts.id Where ".$table_prefix."postmeta.meta_key='manset' ORDER By ".$table_prefix."postmeta.post_id DESC Limit 7");
        for ($j=0; $niphell=mysql_fetch_array($resim); $j++){
        $ust .= '<li><a href="'.get_permalink($niphell[post_id]).'" onmouseover="mns('#msnbtn-'.($j+1).'','#msn-'.($j+1).'','.mnsli','.mnsbtbg');">




<div id="msnbtn-'.($j+1).'" onclick="window.location.href='.get_permalink($niphell[post_id]).'" class="mnsbtbg">
            <table height="50" border="0"><tr>
               <td valign="middle"><div class="mnsbaslik font2">'.$niphell[post_title].'</div></td>
               <td valign="middle"><div class="mnsnumara font3">'.($j+1).'</div></td>
            </tr></table>
            </div> </a></li>
            ';


$alt .='<li id="msn-'.($j+1).'" class="mnsli">
            <img  src="'.$niphell[meta_value].'" width="420" height="370"  alt="" />

        </li>
            ';
        }
echo '<!-- Wordpress Manset Eklentisi NipHeLL Tarafindan Kodlanmistir [email protected] -->';
?>


<div class="imns">
<div class="imns_content">

<ul>
            <?php echo $alt;?> 

</ul>
</div>


<div class="imns_link"> 


<ul>

            <?php echo $ust;?> 


</ul>
</div>





</div>

<script type="text/javascript">
function mns(e,d,c,s){
   jQuery(s).removeClass('aktif');
   jQuery(e).addClass('aktif');
   jQuery(c).css({display: 'none'});
   jQuery(d).css({display: 'block'});
}
mns('#msnbtn-1','#msn-1','.mnsli','.mnsbtbg');
</script>


</div>

</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

痴情 2024-11-16 14:42:51

您的问题是 JS 使用单引号以及 PHP 单引号。 PHP 无法判断某些单引号不是为它设计的。

举个例子,这里:

    $ust .= '<li><a href="'.get_permalink($niphell[post_id]).'" onmouseover="mns('#msnbtn-'.($j+1).'','#msn-'.($j+1).'','.mnsli','.mnsbtbg');">
            P             P                                  P                   J                       

您打算由 JS 解释第四个单引号,但 PHP 正在捕获它。

您可能应该更改为在 PHP 中使用双引号,并在 HTML 中转义所需的双引号,如下所示:

    $ust .= "<li><a href=\"".get_permalink($niphell[post_id])."\" onmouseover=\"mns('#msnbtn-'.($j+1).'','#msn-'.($j+1).'','.mnsli','.mnsbtbg');\">

等等。

Your issue is the use of single quotes for JS along with single quotes for PHP. PHP can't tell that some of the single quotes aren't intended for it.

As an example, here:

    $ust .= '<li><a href="'.get_permalink($niphell[post_id]).'" onmouseover="mns('#msnbtn-'.($j+1).'','#msn-'.($j+1).'','.mnsli','.mnsbtbg');">
            P             P                                  P                   J                       

You've intended the fourth single quote to be interpreted by JS but PHP is catching it.

You should probably change to using double quotes in PHP and escaping the double quotes you want in your HTML like this:

    $ust .= "<li><a href=\"".get_permalink($niphell[post_id])."\" onmouseover=\"mns('#msnbtn-'.($j+1).'','#msn-'.($j+1).'','.mnsli','.mnsbtbg');\">

etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文