Re: [PHP-DB] newbie: MySQL Problem or severe ignorance..
Hello: I would actually disagree with [EMAIL PROTECTED] The mysql_query() function does not require both database and query as arguments, only query. The mysql_db_query() function does, thus the function name. Using mysql_query() with database as a parameter would actually be incorrect. (See the PHP manual for details on these two functions?) I can't tell from the code snippet, but it may not be working because there's no database connection defined. Cheers, db [EMAIL PROTECTED] wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Hi Chris Hogben, > > > I've just been looking at this snippet, and wondering why it's not working.. > > Either i'm doing something wrong, or i'm just totally ignorant.. (More > > likely the latter). But if anyone can help me out, please let me know.. > > > > --- > > > > $query = "SELECT * from counter"; > > $result = mysql_query($query); > > incorrect - must be mysql_query($database,$query); > > or better you use mysql_db_query(...), in this case a > id will generated if no id for the query-executing is generated. > > > $numone = mysql_numrows($result); > > $i = 0; > > while ($i <= $numone) { > > $seekrow = mysql_data_seek($result, $i); > > $fetchrow = mysql_fetch_row($result); > > $time = $fetchrow["time"]; > > echo "$i = $time"; > > $i++; > > } > > > > --- > > > > > > > > -- > > 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] > > - -- > E-Mail: [EMAIL PROTECTED] > Date: 01-Jan-2002 > Time: 13:48:00 > > This message was sent by XFMail > - -- > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.0.6 (GNU/Linux) > Comment: Weitere Infos: siehe http://www.gnupg.org > > iD8DBQE8MbCfEK4asBW3N7wRArMPAKC2GPb8uwDgEUn2dOZG2B2PkXESSACgkDIQ > oFxpZgl8eue2n39eG71O0uw= > =DK3J > -END PGP SIGNATURE- > > -- > 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] -- -- Dan Barton Terrestrial Program Biologist Data Manager Point Reyes Bird Observatory http://www.prbo.org [EMAIL PROTECTED] [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]
RE: [PHP-DB] newbie: MySQL Problem or severe ignorance..
Go with: $query = "SELECT * from counter"; $result = mysql_query($query) or die("Error:".mysql_error()); $i = 0; while( $row=mysql_fetch_array(result) { echo "$i = ".$row['time'].""; $i++; } this assumes that you've opened your server connection and selected database prior to executing the snippet -Original Message- From: Chris Hogben [mailto:[EMAIL PROTECTED]] Sent: Monday, December 31, 2001 3:56 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] newbie: MySQL Problem or severe ignorance.. I've just been looking at this snippet, and wondering why it's not working.. Either i'm doing something wrong, or i'm just totally ignorant.. (More likely the latter). But if anyone can help me out, please let me know.. --- $query = "SELECT * from counter"; $result = mysql_query($query); $numone = mysql_numrows($result); $i = 0; while ($i <= $numone) { $seekrow = mysql_data_seek($result, $i); $fetchrow = mysql_fetch_row($result); $time = $fetchrow["time"]; echo "$i = $time"; $i++; } --- -- 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]
RE: [PHP-DB] newbie: MySQL Problem or severe ignorance..
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Chris Hogben, > I've just been looking at this snippet, and wondering why it's not working.. > Either i'm doing something wrong, or i'm just totally ignorant.. (More > likely the latter). But if anyone can help me out, please let me know.. > > --- > > $query = "SELECT * from counter"; > $result = mysql_query($query); incorrect - must be mysql_query($database,$query); or better you use mysql_db_query(...), in this case a id will generated if no id for the query-executing is generated. > $numone = mysql_numrows($result); > $i = 0; > while ($i <= $numone) { > $seekrow = mysql_data_seek($result, $i); > $fetchrow = mysql_fetch_row($result); > $time = $fetchrow["time"]; > echo "$i = $time"; > $i++; > } > > --- > > > > -- > 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] - -- E-Mail: [EMAIL PROTECTED] Date: 01-Jan-2002 Time: 13:48:00 This message was sent by XFMail - -- -BEGIN PGP SIGNATURE- Version: GnuPG v1.0.6 (GNU/Linux) Comment: Weitere Infos: siehe http://www.gnupg.org iD8DBQE8MbCfEK4asBW3N7wRArMPAKC2GPb8uwDgEUn2dOZG2B2PkXESSACgkDIQ oFxpZgl8eue2n39eG71O0uw= =DK3J -END PGP SIGNATURE- -- 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-DB] newbie: MySQL Problem or severe ignorance..
I've just been looking at this snippet, and wondering why it's not working.. Either i'm doing something wrong, or i'm just totally ignorant.. (More likely the latter). But if anyone can help me out, please let me know.. --- $query = "SELECT * from counter"; $result = mysql_query($query); $numone = mysql_numrows($result); $i = 0; while ($i <= $numone) { $seekrow = mysql_data_seek($result, $i); $fetchrow = mysql_fetch_row($result); $time = $fetchrow["time"]; echo "$i = $time"; $i++; } --- -- 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]