在数据库中有一张表present,字段有p_id,p_name,p_link.
p_link就是p_name的链接在a.php页面代码是:
<?
  include("db_conn.php");  session_start();
  $present=$_SESSION['present'];  $SQLStr="select * from presents where p_name='$present'";
  $res=mysql_query($SQLStr);
  $row=mysql_fetch_array($res);
  $link=$row['p_link'];
  
   echo "<script>";
   echo "alert(\".$link.\");";
   echo "</script>";
?>现在那个提示框显示的就只是两个“.”
请问这是什么原因啊????

解决方案 »

  1.   

    echo " <script>";
      echo 'alert("'.$link.'");';
      echo " </script>"; 
      

  2.   

    $link 是php变量 <?=$link ?> 这样就好了。
      

  3.   

    $_SESSION['present'] 没有值或表中没有对应值
      

  4.   

    看$link中有没有上引号,有双引号改成这样echo "alert('".$link."');"; 试试
      

  5.   

    显示空值,是因为你的查询里没有值。$_SESSION['present'] 没有值或表中没有对应值
      

  6.   

    那个$_SESSION['present']有值啊
    我后面的代码是
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <link href="smallwindow.css" rel="stylesheet" type="text/css" />
    </head><body>
    <div id="prize">
      <div>
        <div id="prizeblank"></div>
       <div id="prizemessage">
      <div id="prizetitle">恭喜您!</div><br>
      <div id="prizecontent">您已获得由xx公司送出<a style="color:#CC3333" target="_top" href=<?=$link?>><?=$present?></a>一份,请继续加油哦,还有更精致的礼物在等着你呢。</div>
       </div>
      </div>
    </div>
    </body>
    </html>那个<?=$present?>能显示啊