mySQL Help Needed

Discussion in 'PHP' started by Pixel T., Sep 16, 2009.

  1. #1
    Hey guys,

    I wrote a script for my website which has a mySQL database. The name of the table is "pending". I also have a few rows. "proxyname" "proxyurl" "user" "email" "approved".

    The way I want the script to work is the users add a proxy to the database which I have taken care of. But then I need it to show the users which proxies have been approved and which have been denied. This is in their account when they log in. If the "approved" row is equal to 1, then the proxy is pending. If its equal to 2, then its approved.

    This is where the problem comes in. The script that I wrote is below.

    When I run the script, the "select * from pending..ect" part doesn't work. If the user has a proxy submitted, it shows every single proxy ever submitted.

    How should I write this so that it only shows the proxies that the user submitted? If you can help, please let me know. I can pay a few dollars if needed. I juyst need this fixed.

    Thanks
     
    Pixel T., Sep 16, 2009 IP
  2. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #2
    What error are you getting?
     
    dweebsonduty, Sep 16, 2009 IP
  3. Pixel T.

    Pixel T. Well-Known Member

    Messages:
    1,205
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    170
    #3
    I'm not getting a php error. The problem that I have is that the script is only suppose to select the proxies that the user thats signed in submitted and if approved = 2. Right now its showing all the proxies that were submitted even if it was by other users.

    Thanks
     
    Pixel T., Sep 16, 2009 IP
  4. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #4
    Thats becuase of this line
    $result = mysql_query("SELECT * FROM pending"); 
    PHP:
    That is telling it to search every thing.

    I think you mean

    $result = mysql_query($qryreview);
    PHP:
     
    dweebsonduty, Sep 16, 2009 IP
  5. Pixel T.

    Pixel T. Well-Known Member

    Messages:
    1,205
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    170
    #5
    Thanks bro. It fixed the problem I was having but now it doesn't say if there are no proxies submitted. Theres just a blank spot
     
    Pixel T., Sep 16, 2009 IP
  6. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #6
    Try:
    
    $num_rows = mysql_num_rows($result);
    
    PHP:
    Click the link in my sig and grab my functions for MYSQL, it makes life so much easier.
     
    dweebsonduty, Sep 16, 2009 IP
  7. godwinsam

    godwinsam Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    hi,

    Can you please try this,

    Please put the below code in the place of that you mentioned,

    <b>Active Proxies</b><br /><br />

    <?php
    $result = mysql_query("SELECT * FROM proxy where user = '".$_SESSION['Username']."'");
    while($row = mysql_fetch_array($result))
    {
    if($row['approved']==1)
    {
    echo ("You currently do not have any active proxies.");
    }
    else
    {
    echo "<a href='http://www." . $row['proxyurl'] ."'>". $row['proxyname'] . "</a><br />";
    }
    }
    ?>


    Insert this coding and try,
    if you got the solution please let me know,.

    Thanks & Regards
    www.joomla-web-designer.com,
    Joomla Custom Template Design, Hire PHP & MySql Programmer, Hire LAMP Programmer
     
    godwinsam, Sep 16, 2009 IP
  8. Pixel T.

    Pixel T. Well-Known Member

    Messages:
    1,205
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    170
    #8
    thats the message l am getting. Whats wrong?
     
    Pixel T., Sep 17, 2009 IP
  9. Pixel T.

    Pixel T. Well-Known Member

    Messages:
    1,205
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    170
    #9
    The code works but if there is no proxies submitted, it says the echo x3 or the total amount of proxies.

    How do I fix this?
     
    Pixel T., Sep 17, 2009 IP