<?php include 'connect.php';?>
<?php include 'functions.php';?>
<?php include 'header.php';?>
<?php
if(isset($_GET['user']) && !empty($_GET['user'])){
$user=$_GET['user'];
}else{
$user=$_SESSION['user_id'];
}
$my_id = $_SESSION['user_id'];
$username=getuser($user,'username');
?>
<h3> <?php echo $username; ?> </h3>
<?php
if($user != $my_id){
$check_frnd_query=mysql_query("select id from frnds where (user_one='$my_id' and user_two='$user') or (user_one='$user' and user_two='$my_id')");
if(mysql_num_rows($check_frnd_query) == 1){
echo "<a href=''>already frnd</a> | <a href='actions.php?action=unfrnd&user'> Unfrnd $username</a>";
}else {
$from_query = mysql_query("SELECT 'id' FROM 'frnd_req' WHERE 'from'='$user' AND 'to'='$my_id'");
$to_query = mysql_query("SELECT 'id' FROM 'frnd_req' WHERE 'from'='$my_id' AND 'to'='$user'");
if (mysql_num_rows($from_query) == 1)
{
echo "<a href=''>ignore </a> | <a href='actions.php?action?action=accept&user=$user'> accept </a>";
} else if (mysql_num_rows($to_query) == 1)
{
echo "<a href='actions.php?action=cancel1&user=$user'>cancel</a>";
}else{
echo "<a href='actions.php?action=send&user=$user'> send req</a>";
}
}}
?>
//// i have error in two lines is if (mysql_num_rows($from_query) == 1) & else if (mysql_num_rows($to_query) == 1) plz help me
Ambrish_1 0 Newbie Poster
Recommended Answers
Jump to PostAs a standard practice you should be testing your queries before you try doing anything with them. Ideally this would be with an if statement so but at the very least you should add a die statement to your query. Add this and see what gets outputted:
Jump to PostNo quotes on table or column name. Try this:
$from_query = mysql_query("SELECT id FROM frnd_req WHERE from='$user' AND to='$my_id'"); $to_query = mysql_query("SELECT id FROM frnd_req WHERE from='$my_id' AND to='$user'");
Jump to PostSorry I didn't even clue into this when I first looked. The words to and from are reserved words in MySQL and serve functions. When using reserved words as an identifier you need to quote them using the ` character (Left of the top "1" key, not the single quote). …
All 12 Replies
ryantroop 177 Practically a Master Poster
Ambrish_1 0 Newbie Poster
Ambrish_1 0 Newbie Poster
ryantroop 177 Practically a Master Poster
Ambrish_1 0 Newbie Poster
GliderPilot 33 Posting Whiz
Ambrish_1 0 Newbie Poster
urtrivedi 276 Nearly a Posting Virtuoso
Ambrish_1 0 Newbie Poster
GliderPilot 33 Posting Whiz
Ambrish_1 0 Newbie Poster
GliderPilot 33 Posting Whiz
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.