+ Reply to Thread
Results 1 to 7 of 7

Thread: Fix my SQL [800 Credits]

  1. #1
    btfog is offline x10 Sophmore btfog is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    118

    Exclamation Fix my SQL [800 Credits]

    Can figure out what is wrong. Keep getting this error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource... on line 12. I'll test the code in order of the replies, and first correct person gets the credits. Here is the code:
    PHP Code:
    <?
    include("connection.php");
    $username=trim($username);
    $password=trim($lpassword);
    if(
    $username=="" || $password =="")
    {
        
    header("Location: index.php?error=wu");
        exit;
    }
    $sql="SELECT 'password' FROM 'admin' WHERE 'username'='$username'";
    $result=mysql_query($sql);
    while(
    $row=mysql_fetch_array($result))
    {
        
    $dbpass=$row[0];
    }
    if(
    $dbpass==$password)
    {
        
    session_start();
        
    $admin_username=$username;
        
    session_register("admin_username");
    }
    else
    {
        
    $myFile "index.php?error=wu";
        
    $fh fopen($myFile'w');
        exit;
    }
    ?>
    Give me Rep, and I'll give you a cookie...

    http://farm6.static.flickr.com/5176/...7698c919d8.jpg

  2. #2
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Fix my SQL [800 Credits]

    Wrap the 'password', 'admin' and 'username' with ` instead, like so:
    $sql="SELECT `password` FROM `admin` WHERE `username`='$username'";
    or remove the quotes completely:
    $sql="SELECT password FROM admin WHERE username='$username'";
    Last edited by lemon-tree; 05-09-2010 at 04:29 PM.

  3. #3
    btfog is offline x10 Sophmore btfog is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    118

    Re: Fix my SQL [800 Credits]

    Didn't do anything...
    Getting the error on http://www.astrosnation.co.cc/qa/admin/adminhome.php
    Thanks for the response
    Try admin for username and admin for password
    Last edited by btfog; 05-09-2010 at 04:40 PM.
    Give me Rep, and I'll give you a cookie...

    http://farm6.static.flickr.com/5176/...7698c919d8.jpg

  4. #4
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Fix my SQL [800 Credits]

    OK, try inserting mysql_error() like this and it'll tell you what is wrong with your SQL:
    ...
    $sql="SELECT 'password' FROM 'admin' WHERE 'username'='$username'";
    $result=mysql_query($sql);
    echo mysql_error();
    while($row=mysql_fetch_array($result))
    ...
    Last edited by lemon-tree; 05-09-2010 at 04:44 PM.

  5. #5
    btfog is offline x10 Sophmore btfog is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    118

    Re: Fix my SQL [800 Credits]

    it is saying no database selected, however, that should have been achieved by my "connection.php"
    Give me Rep, and I'll give you a cookie...

    http://farm6.static.flickr.com/5176/...7698c919d8.jpg

  6. #6
    lemon-tree's Avatar
    lemon-tree is offline x10 Minion lemon-tree has a spectacular aura about
    Join Date
    Nov 2007
    Posts
    1,420

    Re: Fix my SQL [800 Credits]

    Well clearly it hasn't, are you sure you are selecting a valid database?

  7. #7
    btfog is offline x10 Sophmore btfog is an unknown quantity at this point
    Join Date
    Oct 2007
    Posts
    118

    Re: Fix my SQL [800 Credits]

    I'm obviously retarded... uploaded my connection file without making changes. Thanks... will sent credits when the system works again
    Give me Rep, and I'll give you a cookie...

    http://farm6.static.flickr.com/5176/...7698c919d8.jpg

+ Reply to Thread

Similar Threads

  1. [OFF][30 Credits]Sign up + earn up to 30 + credits!
    By TPI007 in forum The Marketplace
    Replies: 20
    Last Post: 11-29-2008, 09:26 AM
  2. Replies: 2
    Last Post: 10-02-2008, 08:53 AM
  3. Replies: 10
    Last Post: 06-01-2008, 11:44 PM
  4. convert Tmondo credits in to X10 credits
    By tittat in forum The Marketplace
    Replies: 7
    Last Post: 05-15-2008, 12:38 AM
  5. Replies: 0
    Last Post: 04-14-2008, 03:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers