0

我有这段代码:

<?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>
4

1 回答 1

1

您的引号混合和匹配的方式太多了。尝试这个

$dn = mysql_query("select TitreEvent, DescriptionEvent from users_event where  MomentEvent=$MomentEvent ");
于 2013-07-29T18:03:42.940 回答