Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: blank screen when no requests!

  1. #11
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Angry

    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?

  2. #12
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Unhappy

    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?

  3. #13
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Default

    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

  4. #14
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #15
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Default

    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

  6. #16
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  7. The Following User Says Thank You to djr33 For This Useful Post:

    liamallan (04-16-2010)

  8. #17
    Join Date
    Feb 2010
    Location
    Falkirk, Scotland
    Posts
    142
    Thanks
    21
    Thanked 4 Times in 4 Posts

    Default

    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 and sorry for being a pest lol

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •