Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14

Thread: script error

  1. #1
    New Coder cheat's Avatar
    Join Date
    Nov 2006
    Location
    England, Britain
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    script error

    i have been given teh scripts for a mmorpg game. i have the scripts uploaded and the database set up however i keep getting a error on the register.

    e.g. i try registering using signup.php, it goes to complete.php and says:


    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/game/public_html/complete.php on line 66
    Unsucessful sign-up please try again


    this is where the error is supposed to be located:
    lse {
    $sql = "INSERT INTO users VALUES ('', '$username', password('$_POST[password]'), '$_POST[full_name]', '$email', '0', '0', '500', 'none', '100', '0', '0', '0', '0', 'alive', '0', '0', '0', '$time', '0', '$country', '0','0', '0', 'no', '', '1', '$drug_prices', '0', 'none', 'middle.jpg', 'none', '$_POST[username]', '0', '0', '0', '0', '0', '1')";
    $_SESSION["name"] = $_POST["username"];
    if (mysql_query($sql, $conn)) {
    echo "Succesful signup!<br><a href='index.php'>Sign in</a>";
    } else {
    echo "Unsucessful sign-up please try again";
    }

    this is line 66:
    if (mysql_query($sql, $conn)) {

    .......................
    can someone help me with this plz

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    You have many columns. This makes it likely that you could have missed a field?

    Try to do some debugging. This should give some indication where the error might be.
    PHP Code:
    else {
    $sql "INSERT INTO users VALUES ('', '$username', password('$_POST[password]'), '$_POST[full_name]', '$email', '0', '0', '500', 'none', '100', '0', '0', '0', '0', 'alive', '0', '0', '0', '$time', '0', '$country', '0','0', '0', 'no', '', '1', '$drug_prices', '0', 'none', 'middle.jpg', 'none', '$_POST[username]', '0', '0', '0', '0', '0', '1')";

    echo 
    $sql;
    mysql_query($sql$conn) or die(mysql_error());
    }

    $_SESSION["name"] = $_POST["username"];
    /*
    if (mysql_query($sql, $conn)) {
    echo "Succesful signup!<br><a href='index.php'>Sign in</a>";
    } else {
    echo "Unsucessful sign-up please try again";
    }
    */ 

  • #3
    New Coder cheat's Avatar
    Join Date
    Nov 2006
    Location
    England, Britain
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts
    the script i got came with a database backup

  • #4
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    What have you tried? If you're not sure what you are doing, start changing line 66 to this and tell us what you see:
    PHP Code:
    if (mysql_query($sql$conn) or die(mysql_error())) { 

  • #5
    New Coder cheat's Avatar
    Join Date
    Nov 2006
    Location
    England, Britain
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts
    im still quite new to php and with sql i only just started learning

  • #6
    New Coder cheat's Avatar
    Join Date
    Nov 2006
    Location
    England, Britain
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i put that code in and this came up

    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/game/public_html/complete.php on line 66

  • #7
    New Coder cheat's Avatar
    Join Date
    Nov 2006
    Location
    England, Britain
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i dont know if this makes it any easier but this is the full script for complete.php

    <?php
    session_start();
    include("conn.php");
    $country = $_POST[location];
    if ($country == "England") {
    $drug_prices = "8-13-21-9-106-36-32-103-159";
    } elseif ($country == "France") {
    $drug_prices = "12-54-28-2-129-29-19-97-147";
    } elseif ($country == "Italy") {
    $drug_prices = "10-26-54-19-97-23-25-89-153";
    } elseif ($country == "Germany") {
    $drug_prices = "11-47-13-121-39-12-93-149-131";
    } elseif ($country == "China") {
    $drug_prices = "7-38-17-22-152-27-14-95-144";
    } elseif ($country == "Russia") {
    $drug_prices = "4-41-33-7-122-65-21-94-120";
    } elseif ($country == "Mexico") {
    $drug_prices = "11-40-28-14-136-21-81-100-160";
    } elseif ($country == "Japan") {
    $drug_prices = "9-45-22-63-101-30-100-87-152";
    } elseif ($country == "Australia") {
    $drug_prices = "21-33-27-6-100-35-22-88-133";
    }
    ?>
    <html>
    <head>
    <title>Sign Up</title>
    <style type="text/css">
    <!--
    body,td,th {
    color: #FFFFFF;
    }
    body {
    background-color: #000000;
    }
    a:link {
    color: #00FFFF;
    text-decoration: underline;
    }
    a:visited {
    text-decoration: underline;
    color: #00FFFF;
    }
    a:hover {
    text-decoration: none;
    color: #FFFFFF;
    }
    a:active {
    text-decoration: underline;
    }
    -->
    </style>
    </head>
    <body>
    <?php
    $time = time();
    $email = $_POST["email"];
    $user = str_replace(" ", "_", $_POST[username]);
    $username = strtolower($user);
    $user_exist = mysql_query("SELECT * FROM users WHERE username='$username'") or die(mysql_error());
    if (mysql_num_rows($user_exist) == "1") {
    echo "Username already in use";
    } else {
    $sql = "INSERT INTO users VALUES ('', '$username', password('$_POST[password]'), '$_POST[full_name]', '$email', '0', '0', '500', 'none', '100', '0', '0', '0', '0', 'alive', '0', '0', '0', '$time', '0', '$country', '0','0', '0', 'no', '', '1', '$drug_prices', '0', 'none', 'middle.jpg', 'none', '$_POST[username]', '0', '0', '0', '0', '0', '1')";
    $_SESSION["name"] = $_POST["username"];
    if (mysql_query($sql, $conn) or die(mysql_error())) {
    echo "Succesful signup!<br><a href='index.php'>Sign in</a>";
    } else {
    echo "Unsucessful sign-up please try again";
    }
    }
    ?>
    </body>
    </html>




    p.s sorry to anyone who finds posting the full script annoying;

  • #8
    Regular Coder ralph l mayo's Avatar
    Join Date
    Nov 2005
    Posts
    951
    Thanks
    1
    Thanked 31 Times in 29 Posts
    Sounds like the problem is conn.php failing to make a legitimate connection to the mysql database. Check that your details match there.. username/password/host/etc

    plz 2b reading some sticky threads ok thx

  • #9
    New Coder cheat's Avatar
    Join Date
    Nov 2006
    Location
    England, Britain
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok lol thanks, ive been trying for 4 days to get this working lol

  • #10
    New Coder cheat's Avatar
    Join Date
    Nov 2006
    Location
    England, Britain
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <?
    $host = 'localhost';
    $user = 'username';
    $pass = 'password';
    $data = 'database';
    mysql_connect($host, $user, $pass);
    mysql_select_db($data);
    ?>

    details removed

  • #11
    New Coder cheat's Avatar
    Join Date
    Nov 2006
    Location
    England, Britain
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok i have just changed the conn to

    <?php

    $conn = mysql_connect("localhost", "user", "pass");

    mysql_select_db("database", $conn);

    ?>

    and it came up with this error

    Column count doesn't match value count at row 1

  • #12
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    So what does your table 'users' look like?

  • #13
    New Coder cheat's Avatar
    Join Date
    Nov 2006
    Location
    England, Britain
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts
    its phpmyadmin 4.1

  • #14
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    What koyama meant was, what is the structure of the table, what fields does it have?

    Also, whoever gave you the script isn't such a great programmer. You should always error check your code! ALWAYS!
    PHP Code:
    <?php
    $conn 
    mysql_connect("localhost""user""pass");
    if(!
    $conn){
       die(
    "Unable to make connection to database.<br/>MySQL Says:".mysql_error());
    }
    mysql_select_db("database"$conn);
    ?>
    You could have saved a lot of time to begin with, if only the conn.php file contained 3 more lines.

    Obviously you would realistically handle errors in a different fashion in real-world applications but that will help you debug at least!
    Omnis mico antequam dominus Spookster!


  •  

    Posting Permissions

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