Re: php+mysql simple query help me pls! ty.
| From: | Mehmet Kamil ERISEN | Date: | Thu, 03 Jan 2002 20:22:10 +0000 |
| Subject: | Re: php+mysql simple query help me pls! ty. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-79357@lists.php.net to get a copy of this message | ||
I hope I am not wrong, but the problem is with the
mysql_result() functions.
Instead, I would use:
whilie ($myrow=mysql_fetch_array($result)) {
//put whatever you like here.
}
and instead of
mysql_result($result,0,"asl")
$myrow["asl"]
I hope this helps.
from the manual
http://www.php.net/manual/en/function.mysql-result.php
mysql_result() returns the contents of one cell from a
MySQL result set. The field argument can be the field's
offset, or the field's name, or the field's table dot field
name (tablename.fieldname). If the column name has been
aliased ('select foo as bar from...'), use the alias
instead of the column name.
When working on large result sets, you should consider
using one of the functions that fetch an entire row
(specified below). As these functions return the contents
of multiple cells in one function call, they're MUCH
quicker than mysql_result(). Also, note that specifying a
numeric offset for the field argument is much quicker than
specifying a fieldname or tablename.fieldname argument.
Calls to mysql_result() should not be mixed with calls to
other functions that deal with the result set.
Recommended high-performance alternatives:
mysql_fetch_row(), mysql_fetch_array(), and
mysql_fetch_object().
--- louie miranda <louie@chikka.com> wrote:
> 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 General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail:
> php-general-unsubscribe@lists.php.net
> For additional commands, e-mail:
> php-general-help@lists.php.net
> To contact the list administrators, e-mail:
> php-list-admin@lists.php.net
>
=====
Mehmet Erisen
http://www.erisen.com
__________________________________________________
Do You Yahoo!?
Send your FREE holiday greetings online!
http://greetings.yahoo.com