mySQL question 
Author Message
 mySQL question

ok here is what i am currently doing

$result = mysql_query ("SELECT * FROM users");

while (list ($stuff) = mysql_fetch_row ($result)) {

print $stuff['login'];

Quote:
}

and when i run through the while loop all it prints out is the first letter
of all the "login"s. What am i doing wrong?

thanks for any help



Sat, 21 May 2005 11:09:47 GMT  
 mySQL question
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In a fit of e{*filter*}ment on Tue, 03 Dec 2002 03:09:47 GMT,

Quote:
> ok here is what i am currently doing

> $result = mysql_query ("SELECT * FROM users");

> while (list ($stuff) = mysql_fetch_row ($result)) {

> print $stuff['login'];

> }

> and when i run through the while loop all it prints out is the first
> letter of all the "login"s. What am i doing wrong?

> thanks for any help

$conn = mysql_connect("host", "user", "passwd");

$sql = "
  SELECT *
  FROM   users";
$result = mysql_query($sql, $conn);

if (mysql_num_rows($result) > 0) {
  while ($db_data = mysql_fetch_object($result)) {
    echo $db_data->login . "<br />\n";
  }

Quote:
}


This might fix it =)

Regards,

  Ian

-----BEGIN PGP SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPewitmfqtj251CDhEQJijACeImkDWfscEBqH5B/DsRKLYZkQtkcAoKq/
yb7JcJiMTXafI6MD8xtgyC6y
=B9jO
-----END PGP SIGNATURE-----

--
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.



Sat, 21 May 2005 11:17:52 GMT  
 mySQL question
In a fit of e{*filter*}ment on Tue, 03 Dec 2002 03:17:52 GMT, "Ian.H [dS]"

[snip]

Quote:
> $conn = mysql_connect("host", "user", "passwd");

> $sql = "
>   SELECT *
>   FROM   users";

    ^^^^^^^^^^^^^^

Should read:

    FROM   some_database.users";

Regards,

  Ian

--
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.



Sat, 21 May 2005 11:20:10 GMT  
 mySQL question

Quote:

> while (list ($stuff) = mysql_fetch_row ($result)) {

I think what you want is
while ($stuff = mysql_fetch_array($result)) {

john



Sat, 21 May 2005 11:28:09 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. mySQL question

2. MySQL question: KEY keyname (fieldname, fieldname,...)

3. PHP/mysql question

4. MySQL questions

5. another mySQL question

6. OT: Mysql questions

7. MySQL locally vs. MySQL on server

8. question about awk and mysql

9. MySQL/PostgreSQL Question

10. Newbie Question: Object Rexx with MySQL

11. mysql+php account question

12. newbie question: MySQL installation

 

 
Powered by phpBB® Forum Software