Jump to content

if statement


conan318

Recommended Posts

need a little of help if i click on a users profile and they are on the freinds list i need to echo profile with the send message link if not echo the profile with the contact request link.

 

this my code so far but i get an Parse error: syntax error, unexpected T_ELSE

 

<?php
session_start();
$myusername=$_SESSION['myusername'];
$getuname=$_POST['to_user'];
$amessage =" is Checking you out ";
$message=$_POST['message'];


require "database.php";


$queryuser=mysql_query("SELECT * FROM freinds WHERE username='$myusername' ");
//$result=mysql_query($sql);
$checkuser=mysql_num_rows($queryuser);
if($checkuser != 0){



if (!isset($_GET['username'])) {
       $data = mysql_query("SELECT * FROM users LEFT JOIN status  ON status.username=users.username WHERE status.username = '".$_SESSION['myusername']."' ORDER BY id DESC LIMIT 1;") or die(mysql_error());
}  else  {
       $getuname = mysql_real_escape_string($_GET['username']);
       $data = mysql_query("SELECT * FROM users LEFT JOIN status  ON status.username=users.username WHERE status.username = '".$getuname."' ORDER BY id DESC LIMIT 1;") or die(mysql_error());
}

while($info = mysql_fetch_array( $data )) {



?>

<!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=utf-8" />
<title>Untitled Document</title>
<link href="css/main.css" rel="stylesheet" type="text/css">
</head>

<body>
<div class="header">
<img name="Untitled1" src="Untitled-1.gif" width="1000" height="40" border="0" id="Untitled1" usemap="#m_Untitled1" alt="" /><map name="m_Untitled1" id="m_Untitled1">
<area shape="rect" coords="874,0,931,40" href="eurochat.php" alt="" title="Euro Chat"/>
<area shape="rect" coords="828,0,865,40" href="englandchat.php" alt="" title="UK Chat"/>
<area shape="rect" coords="754,0,822,40" href="usachat.php" alt="" title="USA Chat"/>
<area shape="rect" coords="201,21,242,40" href="search.php" alt="" title="Profile Search" />
<area shape="rect" coords="697,0,747,40" href="http://datenight.netne.net/ausnz.php" alt="" title="AU n NZ Chat" />
<area shape="rect" coords="167,20,201,40" href="http://datenight.netne.net/inbox.php" alt="" title="Inbox" />
<area shape="rect" coords="119,21,164,40" href="http://datenight.netne.net/login_success.php" alt="" title="Home"/></map>


</div>

<div class="profile">
<?

//Outputs the image and other data
Echo '<a href="freinds.php?username=' . "$getuname" . '">Contact request</a>';
Echo '<a href="new_message.php?username=' . "$getuname" . '">send meesage</a>';

Echo "<img src='http://datenight.netne.net/images/".$info['img'] ."' width='150' height='150''> <br>"; 

  Echo "<b>Name:</b> ".$info['username'] . "<br> <hr>"; 
Echo "<b>Sex:</b> ".$info['sex'] . " <br><hr>"; 
Echo "<b>Intrested in</b>" . "<br><hr>"; 
Echo "".$info['rel'] . " ";
Echo "".$info['frwb'] . " ";
Echo "".$info['ons'] . " "; 
Echo "".$info['fr'] . "<br><hr>";
Echo "<b>About me:</b> ".$info['aboutme'] . "<br><hr> ";
Echo "<b>Looking for:</b> ".$info['looking'] . " <br><hr>"; 
Echo "<a href='login_success.php'>'Back'</a>";






else {

Echo '<a href="freinds.php?username=' . "$getuname" . '">Contact request</a>';
Echo '<a href="new_message.php?username=' . "$getuname" . '">send meesage</a>';

Echo "<img src='http://datenight.netne.net/images/".$info['img'] ."' width='150' height='150''> <br>"; 

  Echo "<b>Name:</b> ".$info['username'] . "<br> <hr>"; 
Echo "<b>Sex:</b> ".$info['sex'] . " <br><hr>"; 
Echo "<b>Intrested in</b>" . "<br><hr>"; 
Echo "".$info['rel'] . " ";
Echo "".$info['frwb'] . " ";
Echo "".$info['ons'] . " "; 
Echo "".$info['fr'] . "<br><hr>";
Echo "<b>About me:</b> ".$info['aboutme'] . "<br><hr> ";
Echo "<b>Looking for:</b> ".$info['looking'] . " <br><hr>"; 
Echo "<a href='login_success.php'>'Back'</a>";


}
}
mysql_query("INSERT INTO alog (from_user, to_user, message ) VALUES ('$myusername', '$getuname','$amessage')") OR die("A log error <br>".mysql_error()); 



?>
</div>
</body>
</html>

Link to comment
Share on other sites

It's usually a good idea to use <?php ?> to maintain portability.  If what you write gets moved to a system that has short_open_tag turned off (like your current system it seems) your code won't break.

Link to comment
Share on other sites

now the code worked but it didit do what i expecting to do.. 

i am new to php so bare with me

// i need this query to check the friends table to see if user is friends with the profile they clicked on//

$queryuser=mysql_query("SELECT * FROM freinds WHERE username='$myusername' ");
//$result=mysql_query($sql);
$checkuser=mysql_num_rows($queryuser);
if($checkuser != 0){

 

the friends table has id, username and  friend  so i need to check myusername against the friend.

so should this be code?

$queryuser=mysql_query("SELECT * FROM freinds WHERE freind='$myusername' ");
//$result=mysql_query($sql);
$checkuser=mysql_num_rows($queryuser);
if($checkuser != 0){

Link to comment
Share on other sites

that worked so i answered my own question i am getting better

 

not as good as i thought...

 

just did some more testing and seems once's the friend request is made  i can contact any user and the other user cant send messages comes up with contact request.. my algorithm is wrong any idea's?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.