-
i finally managed to get it to echo the request, BUT, there are hundreds of the same request!
this is my code so far:
PHP Code:
$get = mysql_query("SELECT * FROM `friend_requests` WHERE `username` = '$session->username' ");
if (mysql_num_rows($get)==0){
echo ("<font color='black' face='Arial'><u><b>Friend Requests</b></u></font><br><br>You have no new friend requests");
}else{
echo ("<font color='black' face='Arial'><u><b>Friend Requests</b></u></font><br><br>
<font color='#003399' face='Arial'><b>$reqs[by]</b></font><b></b> wants to be friends with you!<br>
[<a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a>]
[<a href='newfriends.php?friends=delete&user=$reqs[by]'>Ignore</a>]
[<a href='userinfo.php?user=$reqs[by]' target='blank'>View Profile</a>]"); //displays requests and shows accept delete links
}
}
break;
Any ideas why this is happening? have i created some kind of loop or something?
-
i got the request echo loop thing sorted, now it wont echo ' you have no new requests'!
this is severely hurting my brain lol
this the code i got now:
PHP Code:
if (mysql_num_rows($get)==0){
echo ("<font color='black' face='Arial'><u><b>Friend Requests</b></u></font><br><br>You have no new friend requests");
}else{
echo ("<font color='black' face='Arial'><u><b>Friend Requests</b></u></font><br><br>
<font color='#003399' face='Arial'><b>$reqs[by]</b></font><b></b> wants to be friends with you!<br>
[<a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a>]
[<a href='newfriends.php?friends=delete&user=$reqs[by]'>Ignore</a>]
[<a href='userinfo.php?user=$reqs[by]' target='blank'>View Profile</a>]"); //displays requests and shows accept delete links
}
break;
}
can anyone help me plz?
-
i been working on this all day now, just cant seem to get it to work! it is now echoing the request no problem, its just the echoing of 'you have no new requests' bit!
has anyone got any ideas, or can you help? thanx
-
I don't understand what is wrong here. the IF works, but the ELSE does not? That doesn't make any sense.
The way to debug this is to take the code apart piece by piece-- start with the switch-- remove that and find out what's really going on.
Alternatively (probably easier) you can track the variables. Run the script and echo all of the variables when you can to see what they are. For example, start with $_GET['friends'] and see what happens in all cases. Then try another variable.
-
i tried echoing the variables, but no value was returned and the script worked as normal.
i also tried removing the switch, which resulted in a blank error screen.
i dont know if this will help, but i got the script from:RMB-Scripting
-
This is why working with existing (broken) scripts is hard. Sometimes it's easier to just start over.
The only way to figure it out from here is to test different versions-- find where the code is broken. Something doesn't make sense with the data, so that should be the best way to find out what's wrong-- some variable, somewhere, is not what you expect and things aren't working. I can't see anything wrong with the code-- it must be in the logic/organization of information.
-
i finally sussed it, i took on what you said about writing my own script so i started writing my own using the original as a template, rearranged the friend request section and it worked.
this is how the working version looks:
PHP Code:
$get = mysql_query( "SELECT * FROM `friend_requests` WHERE `username` = '$session->username' "); //gets requests
while ($reqs = mysql_fetch_array($get))
{
echo ( "<font color='#003399' face='Arial'><b>$reqs[by]</b></font><b></b> wants to be friends with you!<br>
[<a href='newfriends.php?friends=accept&user=$reqs[by]'>Accept</a>]
[<a href='newfriends.php?friends=delete&user=$reqs[by]'>Ignore</a>]
[<a href='userinfo.php?user=$reqs[by]' target='blank'>View Profile</a>]<br><br>" );
}
if (mysql_num_rows($get)==0){
echo ("You have no new friend requests");
}
break;
thanx for all your help daniel :D and sorry for being a pest lol :p