Test the mysql_query() return value:
$result = mysql_query("SELECT * FROM members") or
die("Error:".mysql_error());

there may be an error in your query.

-----Original Message-----
From: louie miranda [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 03, 2002 1:59 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: [PHP-DB] php+mysql simple query help me pls! ty.


Hi, can someone help me here! :(
I can't query the data on my sql from php.
db is fine, i couldnt see the prob in php!
pls help, ty.



# MSQL #######################################################
mysql> desc members;
+----------+-------------+------+-----+---------+----------------+
| Field    | Type        | Null | Key | Default | Extra          |
+----------+-------------+------+-----+---------+----------------+
| id       | tinyint(5)  |      | PRI | NULL    | auto_increment |
| ircname  | varchar(30) | YES  |     | NULL    |                |
| email    | varchar(30) | YES  |     | NULL    |                |
| realname | varchar(40) | YES  |     | NULL    |                |
| asl      | varchar(30) | YES  |     | NULL    |                |
| info     | varchar(70) | YES  |     | NULL    |                |
+----------+-------------+------+-----+---------+----------------+



# PHP ########################################################
<html>
<body>

<?php

$db = mysql_connect("my_db_host", "my_db_user", "my_db_pass")
        or die("Could not connect");

mysql_select_db("mydb",$db);

$result = mysql_query("SELECT * FROM members",$db);

printf("ircname: %s<br>n", mysql_result($result,0,"ircname"));
printf("email: %s<br>n", mysql_result($result,0,"email"));
printf("realname: %s<br>n", mysql_result($result,0,"realname"));
printf("asl: %s<br>n", mysql_result($result,0,"asl"));
printf("info: %s<br>n", mysql_result($result,0,"info"));

?>

</body>
</html>


# ERROR ############################################################


  Warning: Supplied argument is not a valid MySQL result resource in
/mnt/host-users/cavite/irc/members/t2.php on line 13
ircname:
n
Warning: Supplied argument is not a valid MySQL result resource in
/mnt/host-users/cavite/irc/members/t2.php on line 14
email:
n
Warning: Supplied argument is not a valid MySQL result resource in
/mnt/host-users/cavite/irc/members/t2.php on line 15
realname:
n
Warning: Supplied argument is not a valid MySQL result resource in
/mnt/host-users/cavite/irc/members/t2.php on line 16
asl:
n
Warning: Supplied argument is not a valid MySQL result resource in
/mnt/host-users/cavite/irc/members/t2.php on line 17
info:
n


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to