freddy
freddy

Reputation: 157

Trouble to link to a MySQL table

I have this piece of code:

<?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);
             ?>

My problem is that the link to the users_event table is never made, and the:

«Sorry TitreEvent not found»

message always pop-up in my face. What am I doing wrong?

EDIT: THE FULL CODE

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

Upvotes: 0

Views: 55

Answers (1)

General_Twyckenham
General_Twyckenham

Reputation: 2261

You have quotes mixed and matched way too much. Try this

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

Upvotes: 1

Related Questions