I have a litle Problem with an if else ????

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
maceved23
Forum Newbie
Posts: 17
Joined: Sun Jul 13, 2003 11:56 pm

I have a litle Problem with an if else ????

Post by maceved23 »

Hi please help me with a litle problem.

I have a query to my DB, with this code I get a user data and generate a query.

THE CODE IS :
db_connect();
viewheader();

$email5=$email_busca;


$sql = "SELECT * FROM $dbtable";
$resultat = mysql_db_query($dbname, $sql);

if(empty($debut)) $debut = 0;
$nb_total=mysql_num_rows($resultat);

$sql = "SELECT * FROM $dbtable ORDER BY username ASC limit $debut, $max";
$resultat = mysql_db_query($dbname, $sql);
$nbenr = mysql_num_rows($resultat);



while ($profil = mysql_fetch_array($resultat))
{
$myid = ($profil["id"]);
$username = ($profil["username"]);
$nombre = ($profil["nombre"]);
$apellido1 = ($profil["apellido1"]);
$apellido2 = ($profil["apellido2"]);
$inst_pre = ($profil["inst_pre"]);
$date = ($profil["date_reg"]);
$email1 = ($profil["email1"]);
$url = ($profil["url"]);
$clicks = ($profil["clicks"]);
$pais = ($profil["pais"]);
$photo = ($profil["photo"]);
$annee = date("Y", $date);
$mois = date("m", $date);
$jour = date("d", $date);
$heures = date("H", $date);
$minutes = date("i", $date);
$date = $jour."/".$mois."/".$annee." a las ".$heures."h".$minutes;


if (($email1)== ($email5))
{
echo"<h2>Este el usuario del que solicito informacion</h2><br>";

$photo' target='_blank'><img src='$imgs_folder/$photo' width='44' height='44' border='1'></a></td>";
echo"<b>$nombre $apellido1 $apellido2</b><br>";
echo"usuario desde el<br>$date</font></td><br>";
echo"<a href='mailto:$email1'>$email1</a><br>";
echo"$inst_pre</a><br>";

echo"<a href='fiche_membre1.php?id=$myid' target='_blank') onMouseOver=\"status='Consultar'; return true;\" onMouseOut=\"status='';\">Consultar</a><br>";
echo"<b>$clicks</b> hits";
//echo"<td alingn='center'><center><br><font><b>Mail</b> </font></center></td>";

echo"<a href='envio_mail.php?id=$myid' target='_blank' onMouseOver=\"status='Ingresar'; return true;\" onMouseOut=\"status='';\"><center><img src='checkbox.gif' width='18' height='18' border='0'><b></b></center></a><br>";
}

///// **************** HERE'S THE PROBLEM ////////////

else
echo"This email does not exist !!!";
}

THE PROBLEM IS IF THE EMAIL EXIST, THE FIRST PART OF THE CODE EXECUTES.
THE INFO OF MY USER IS SHOW.
AND THE MESSAGE This email does not exist !!! IS POSTED AS MANY TIMES AS USERS I HAVE.

IF THE EMAIL DOES NOT EXISTS THE MESSAGE This email does not exist !!! IS POSTED AS MANY TIMES AS USERS I HAVE.


COULD YOU HELP ME???
I ALREADY TRY WITH EXIT;


HELP ?????
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Re: I have a litle Problem with an if else ????

Post by McGruff »

I think this might be a syntax problem (missing { after the else):

Code: Select all

<?php	
while ($profil = mysql_fetch_array($resultat))
{

    // ..etc

} else {

    echo 'This email does not exist !!!';
}

?>
PS: if you post a chunk of code, it's easier to read if you wrap it up in the PHP BB code tags.

Oh, and use double quotes for attributes in html tags.
Post Reply