[MySQL]Connecting to Localhost instead of my IP

Discussion in 'Scripts, 3rd Party Apps, and Programming' started by Blazer9131, Apr 14, 2008.

  1. Blazer9131

    Blazer9131 New Member

    Messages:
    411
    Likes Received:
    0
    Trophy Points:
    0
    Hey guys,

    I have a script, its a simple 3 file registeration script. here are all three parts:

    register.php
    PHP:
    <html>
    <head>
    <title>My maplestory server</title>
    <!--- Version 3.3 ---!>
    <style>
    *{ FONT-SIZE: 8pt; FONT-FAMILY: verdana; } b { FONT-WEIGHT: bold; } .listtitle { BACKGROUND: #425984; COLOR: #EEEEEE; white-space: nowrap; } td.list { BACKGROUND: #EEEEEE; white-space: nowrap; } </style>
    </head>
    <center><br><br><br><br>
    <h1>My maplestory server</h1>
    <table cellspacing=1 cellpadding=5>
    <tr>
    <td class=listtitle colspan=2>Register at my server</td></tr>
    <form action="register_do.php" method="POST">
    <tr><td class=list align=right>Username:</td><td class=list><input type=text name=name maxlength="30"></td></tr>
    <tr><td class=list align=right>Password:</td><td class=list><input type=password name=pass maxlength="30"></td></tr>
    <tr><td class=list align=right>PIN:</td><td class=list>
    <select name="pin1">
    <option value="0">0</option>
    <option SELECTED value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    </select>
    <select name="pin2">
    <option value="0">0</option>
    <option value="1">1</option>
    <option SELECTED value="2">2</option>
    <option value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    </select>
    <select name="pin3">
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option SELECTED value="3">3</option>
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    </select>
    <select name="pin4">
    <option value="0">0</option>
    <option value="1">1</option>
    <option value="2">2</option>
    <option value="3">3</option>
    <option SELECTED value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>
    </select></td></tr>
    <tr><td class=list align=right>Gender:</td><td class=list>
    <select name="gender">
    <option value="0">Male</option>
    <option value="1">Female</option>
    </select>
    </td></tr>
    <tr><td class=listtitle align=right colspan=2><input type=submit name=submit value='Register'></td></tr>
    </form>
    </table>
    <br>
    <!--- thanks Antv912 ---!>
    <?php
    include('config.php');
    $result mysql_query("SELECT * FROM users"$db);// Account section
    $num_rows mysql_num_rows($result);
    $result2 mysql_query("SELECT * FROM characters"$db);// Character section
    $num_rowsc mysql_num_rows($result2);
    echo 
    'Stats:<br><b>'.$num_rows.'</b> Accounts registed.<br><b>'.$num_rowsc.'</b> Characters created.';
    ?>
    </center></body></html>
    register_do.php
    PHP:
    <?php
    // Version 3.3
    if($_POST['submit']){
    print 
    '<title>My maplestory server</title>';
    // ty hacker_kts for security thing
    $name2 ereg_replace('[^a-zA-Z0-9]'''$_POST['name']);
    $pass2 ereg_replace('[^a-zA-Z0-9]'''$_POST['pass']);
    $gender $_POST['gender'];
    $pin1 ereg_replace('[^0-9]'''$_POST['pin1']);;
    $pin2 ereg_replace('[^0-9]'''$_POST['pin2']);
    $pin3 ereg_replace('[^0-9]'''$_POST['pin3']);
    $pin4 ereg_replace('[^0-9]'''$_POST['pin4']);
    include(
    'config.php');
    $sel 'SELECT * FROM users WHERE username="'.$name2.'"';
    if(
    $name == ""){
    echo 
    'No username filled in';
    exit();
    }elseif(
    mysql_num_rows(mysql_query($sel)) >= ){
    echo 
    'This username does already exists!';
    exit();
    }elseif(
    $pass == ""){
    echo 
    'No password filled in';
    exit();
    }else{
    $d 'INSERT INTO users (username, password, pin, gender, gm) VALUES ("'.$name2.'", "'.$pass2.'", "'.$pin1.$pin2.$pin3.$pin4.'", "'.$gender.'", "0")';
    mysql_query($d) OR die (mysql_error());
    echo 
    'Your account has been created, you can now login.<br><br>Your username is: <b>'.$name2.'</b>';
    }
    }else{
    print 
    '<title>My maplestory server</title>';
    echo 
    '???';
    }
    ?>
    config.php
    PHP:
    <?php
    // Version 3.3
    $host['naam'] = 'localhost';                // my host
    $host['gebruikersnaam'] = 'root';       // my database username
    $host['wachtwoord'] = '';   // my database password
    $host['databasenaam'] = 'maplestory';       // my database name
     
    $db mysql_connect($host['naam'], $host['gebruikersnaam'], $host['wachtwoord']) OR die ('Cant connect to the database');
    mysql_select_db($host['databasenaam'], $db);
    ?>

    I set up the config.php file to connect to my IP, but everytime I try to register an account, it says access denied for Blaze9@localhost.

    Anyway this script can connect to my IP? o.o

    Thanks

    ~Blaze
     
  2. MasterMax1313

    MasterMax1313 New Member

    Messages:
    84
    Likes Received:
    0
    Trophy Points:
    0
    if you're trying to connect to your IP, then you need to change $host['naam'] = 'localhost'; to $host['naam'] = '(YOUR IP HERE)';

    so i would think anyway
     
  3. Blazer9131

    Blazer9131 New Member

    Messages:
    411
    Likes Received:
    0
    Trophy Points:
    0
    I already did that, that's the clean script, w.o any info on it. ...


    ~Blaze
     
  4. cowctcat

    cowctcat New Member

    Messages:
    401
    Likes Received:
    0
    Trophy Points:
    0
    change the user to Your user@your ip that should do it
     
  5. Blazer9131

    Blazer9131 New Member

    Messages:
    411
    Likes Received:
    0
    Trophy Points:
    0

    So like if my user was blaze it would be

    Code:
    blaze@blazer9131.no-ip.org
    
    ?


    Thanks.


    ~Blaze
    Edit:
    I keep getting this message :

    Code:
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/blaze9/public_html/eternal/register_do.php on line 16
    
    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/blaze9/public_html/eternal/register_do.php on line 16
    
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/blaze9/public_html/eternal/register_do.php on line 16
    
    Warning: mysql_query() [function.mysql-query]: Access denied for user 'nobody'@'localhost' (using password: NO) in /home/blaze9/public_html/eternal/register_do.php on line 24
    
    Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/blaze9/public_html/eternal/register_do.php on line 24
    Access denied for user 'nobody'@'localhost' (using password: NO)

    Anything?
     
    Last edited: Apr 14, 2008
  6. Starshine

    Starshine Legend Killer

    Messages:
    14,423
    Likes Received:
    0
    Trophy Points:
    0
    I don't know anything about MySQL or whatnot - but are you trying to remote connect to the MySQL on x10 or your own personal mysql?

    If you are trying to remote connect, that may be the issue. x10 no longer allows free users to connect to the mysql remotely.
     
  7. Blazer9131

    Blazer9131 New Member

    Messages:
    411
    Likes Received:
    0
    Trophy Points:
    0
    Well I'm hosting the script on x10, and I'm hosting the SQL on my house PC. Is that allowed? I mean it puts less strain on x10 Server's.

    ~Blaze
     

Share This Page