Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 mysql_fetch_assoc error
Index -> Programming, PHP -> PHP Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
unknowngiver




PostPosted: Sat Jun 17, 2006 7:32 pm   Post subject: mysql_fetch_assoc error

hey
i am getting this error
code:


Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in D:\htdocs\Zubair\details.php on line 13
????
:S
i dont know how to fix it Sad
here is the code:
php:

<?php
$user = $_GET['user'];
$detailpass = $_GET['detailpass'];
$action = $_GET['action'];
$dbusername="zubair";
$dbpassword="";
$database= "z_game";
if ($detailpass == "aa") {
        mysql_connect(localhost, $dbusername, $dbpassword);
        @mysql_select_db($database) or die("Unable to select database");
        $sql = mysql_query("Select * From user where username = ".$user." LIMIT 1")  ;
       
        $get_row = mysql_fetch_assoc($sql);
       
                if ($action = "list"){
        echo $get_row['health'];
        echo "?";
        echo $get_row['money'];
        echo "?";
        echo $get_row['country'];
        echo "?";
        echo $get_row['level'];
        echo "?";
        } }
else {
echo "error\n";
}
?>
Sponsor
Sponsor
Sponsor
sponsor
rdrake




PostPosted: Sat Jun 17, 2006 8:05 pm   Post subject: (No subject)

You must put quotes around "localhost" in your script. Unless stored in a variable, you need those quotes.

Also, as I recall it's the following, without the spaces.
[syntax = "php"]
<?php
echo "This is PHP";
?>
[/syntax]
So you'd get:
php:

<?php
    echo "This is PHP";
?>
JackTruong




PostPosted: Sun Jun 18, 2006 4:29 pm   Post subject: (No subject)

code:
$sql = mysql_query("Select * From user where username = ".$user." LIMIT 1")  ;


Maybe change that to:
code:
$sql = mysql_query("Select * From user where username = \"".$user."\" LIMIT 1")  ;


Unless username is of type int...
Display posts from previous:   
   Index -> Programming, PHP -> PHP Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: