conan318 Posted April 28, 2011 Share Posted April 28, 2011 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> Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/ Share on other sites More sharing options...
kney Posted April 28, 2011 Share Posted April 28, 2011 the second time when you open ur php tags, why do you use <? instead of <?php like in the first tag? Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207455 Share on other sites More sharing options...
conan318 Posted April 28, 2011 Author Share Posted April 28, 2011 <? and <?php both open the php correct me if im wrong. Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207459 Share on other sites More sharing options...
kney Posted April 28, 2011 Share Posted April 28, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207461 Share on other sites More sharing options...
conan318 Posted April 28, 2011 Author Share Posted April 28, 2011 i see in future will keep them the same.. Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207465 Share on other sites More sharing options...
kney Posted April 28, 2011 Share Posted April 28, 2011 also, at what line does it give the error? Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207467 Share on other sites More sharing options...
conan318 Posted April 28, 2011 Author Share Posted April 28, 2011 line 79 where the else statement is. Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207468 Share on other sites More sharing options...
kney Posted April 28, 2011 Share Posted April 28, 2011 you forgot a } before the else Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207470 Share on other sites More sharing options...
conan318 Posted April 28, 2011 Author Share Posted April 28, 2011 so i did it azmazes me how one missing } breaks everything Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207473 Share on other sites More sharing options...
conan318 Posted April 28, 2011 Author Share Posted April 28, 2011 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){ Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207478 Share on other sites More sharing options...
conan318 Posted April 28, 2011 Author Share Posted April 28, 2011 that worked so i answered my own question i am getting better Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207481 Share on other sites More sharing options...
conan318 Posted April 28, 2011 Author Share Posted April 28, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207486 Share on other sites More sharing options...
Muddy_Funster Posted April 28, 2011 Share Posted April 28, 2011 start a new topic for the new problem - giving the full detail again - a lot of people will not check on solved topics (that's kind of why it is used). Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207526 Share on other sites More sharing options...
conan318 Posted April 28, 2011 Author Share Posted April 28, 2011 the problem is now solved i worked it out after my last post and just pressed solved the button Quote Link to comment https://forums.phpfreaks.com/topic/234956-if-statement/#findComment-1207613 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.