Forum Moderators: coopster

Message Too Old, No Replies

PHP and mySQL question

Resource id #3 displaying?

         

stillsix

7:01 pm on Dec 14, 2004 (gmt 0)

10+ Year Member



New to PHP and just trying to do a simple select and output the result. But I get the following output message "Resource id #3". HUH? No error just that. Not in my DB since the table contains only names,emails, that sort of data. And earlier I tested the connections and no errors.

Here's my code:
$link = mysql_connect("localhost",$username,$password);
$q = "Select * From onlinegames.user";
$result = mysql_query($q, $link);
printf("Results:%s",$result,"-");

also tried below with same result
$q = "Select * From games";
$result = mysql_db_query("onlinegames",$q, $link);

kpaul

7:08 pm on Dec 14, 2004 (gmt 0)

10+ Year Member



while ($data = mysql_fetch_array($result)) {

// do something with the data

}

you're missing the above step to get the data out of the $result. google: 'php mysql_fetch_row' and 'php mysql_fetch_array'

-kpaul

stillsix

7:34 pm on Dec 14, 2004 (gmt 0)

10+ Year Member



Wow. Coming from ASP had no idea you had to do something with the result before displaying. Thanks.

coopster

9:33 pm on Dec 14, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, stillsix.

Different languages and databases each have different syntax and methods for accomplishing similar tasks. You'll get over the humps fairly quickly I'm sure, especially now that you've joined us here at WebmasterWorld ;)

kpaul

9:47 pm on Dec 14, 2004 (gmt 0)

10+ Year Member



yes, sorry about that. welcome to WebmasterWorld ;)

-kpaul