无法链接到MySQL表

时间:2013-07-29 18:01:35

标签: php mysql hyperlink

我有这段代码:

<?php
include('base.php');
?>

<?php
if(isset($_GET['MomentEvent']))
{
     $MomentEvent = intval($_GET['MomentEvent']);
     $dn = mysql_query('select TitreEvent, DescriptionEvent from users_event where  MomentEvent="'.$MomentEvent.'"');
     if(mysql_num_rows($dn)>0)
     {
             $dnn = mysql_fetch_array($dn);
             ?>

我的问题是永远不会发生到users_event表的链接,而且是:

  

«抱歉没有找到TitreEvent»

消息总是弹出我的脸。我做错了什么?

编辑:完整代码

<?php
include('base.php');
?>

<?php
if(isset($_GET['MomentEvent']))
 {
     $MomentEvent = intval($_GET['MomentEvent']);
     $dn = mysql_query('select TitreEvent, DescriptionEvent from users_event where MomentEvent="'.$MomentEvent.'"');
     if(mysql_num_rows($dn)>0)
     {
             $dnn = mysql_fetch_array($dn);

 ?>
 This is the profile of "<?php echo htmlentities($dnn['TitreEvent']); ?>" :
 <table style="width:500px;">
     <tr>
     <td><?php
 if($dnn['avatar']!='')
{
     echo '<img src="'.htmlentities($dnn['avatar'], ENT_QUOTES, 'UTF-8').'" alt="Avatar"      style="max-width:100px;max-height:100px;" />';
}
 else
{
     echo 'This user dont have an avatar.';
 }
?></td>
     <td class="left"><h1><?php echo htmlentities($dnn['TitreEvent'], ENT_QUOTES, 'UTF-8'); ?   ></h1>
      Email: <?php echo htmlentities($dnn['DescriptionEvent'], ENT_QUOTES, 'UTF-8'); ?><br />
      </tr>
 </table>
 <?php
     }
     else
     {
             echo 'Sorry TitreEvent not found';
     }
 }
 else
 {
     echo 'The user ID is not defined.';
 }
 ?>
                      </body>
 </html>

1 个答案:

答案 0 :(得分:1)

你的报价混合和匹配的方式太多了。试试这个

$dn = mysql_query("select TitreEvent, DescriptionEvent from users_event where  MomentEvent=$MomentEvent ");