HELP - Issue with Functions and mysql connect

Discussion in 'PHP' started by nickharper, Sep 8, 2010.

  1. #1
    Hi Guys,

    I am having issues with this bit of code:

    I keep getting this error on the line of code I have made bold.

        function get_proxy()
        {
            require_once('../Connections/Proxys.php');
            mysql_connect($hostname_Proxys, $username_Proxys, $password_Proxys) or die(mysql_error());
            mysql_select_db($database_Proxys) or die(mysql_error());
    
            $sql = "SELECT address
                    FROM proxy
                    ORDER BY rand()
                    LIMIT 1";
            $q = mysql_query($sql);
            $r = mysql_fetch_array($q);
            if (empty($r) || empty($r["address"]))
            {
                echo 'You have run out of proxys. <a href="addproxys.php">Click Here</a> to add some more.';
                die;
            }
            return $r["address"];
        }   
    
        function delete_proxy($address)
        {
                require_once('../Connections/Proxys.php');
            mysql_connect($hostname_Proxys, $username_Proxys, $password_Proxys) or die(mysql_error());
            mysql_select_db($database_Proxys) or die(mysql_error());
            $sql = "DELETE FROM proxy WHERE address = '" . mysql_escape_string($address) . "'";
            mysql_query($sql);
        }
    PHP:
    Can anybody help?
     
    nickharper, Sep 8, 2010 IP
  2. Eager2Seo

    Eager2Seo Member

    Messages:
    72
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #2
    Find the require_once include../Connections/Proxys.php, and be sure the variable $hostname_Proxys is initialized to a proper string (localhost?) and is spelled correctly with proper case!
     
    Eager2Seo, Sep 8, 2010 IP
  3. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #3
    The variable $hostname_Proxys is not set, set it within the file ../Connections/Proxys.php to resolve the issue.
     
    danx10, Sep 8, 2010 IP
  4. Wolf Security

    Wolf Security Peon

    Messages:
    78
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    hostname_Proxys ( variable ) isn't preset ( you need to create it ) or is a local variable ( you need to make it global ).
     
    Wolf Security, Sep 8, 2010 IP