Re: Trouble running a select query against a database, when I know the connection is working, and the data is there
| From: | Jacob Kruger | Date: | Thu, 15 Apr 2010 00:48:48 +0000 |
| Subject: | Re: Trouble running a select query against a database, when I know the connection is working, and the data is there | ||
| References: | 1 2 3 4 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-30034@lists.php.net to get a copy of this message | ||
Thanks.
Will be honest, and while have played around with PHP etc., have never really done much with it in terms of going into production as such anyway, so, yes, will need to learn/figure out how to do things the best way, etc.
Stay well
Jacob Kruger
Blind Biker
Skype: BlindZA
'...fate had broken his body, but not his spirit...'
----- Original Message ----- From: "Jean Delefrati" <jeandelefrati@gmail.com>
To: "Jacob Kruger" <jacobk@mailzone.co.za>
Sent: Wednesday, April 14, 2010 10:29 PM
Subject: Re: [PHP-WIN] Trouble running a select query against a database, when I know the connection is working, and the data is there
You should try add some "or"(s) in your script - so, if an error
ocurred, you can kill your script.
Like this:
$qry = mysql_query($sql) or die("An error ocurred: " . mysql_error());
Of course you shouldn't put the mysql_error() in the final code, for
security issues, just replace by one better message to your users.
[ ]'s!
Jean Rafael
2010/4/13 Jacob Kruger <jacobk@mailzone.co.za>:
Thanks. Figured it out, and also know shouldn't just copy and paste too much code as such...<smile> Stay well Jacob Kruger Blind Biker Skype: BlindZA '...fate had broken his body, but not his spirit...' ----- Original Message ----- From: "Toby Hart Dyke" <toby@hartdyke.com> To: "Jacob Kruger" <jacobk@mailzone.co.za> Cc: <php-windows@lists.php.net> Sent: Tuesday, April 13, 2010 12:00 PM Subject: Re: [PHP-WIN] Trouble running a select query against a database, when I know the connection is working, and the data is there__________ Information from ESET NOD32 Antivirus, version of virus signature database 5029 (20100414) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com __________ Information from ESET NOD32 Antivirus, version of virus signature database 5029 (20100414) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.comOn 4/13/2010 9:36 AM, Jacob Kruger wrote:__________ Information from ESET NOD32 Antivirus, version of virus signature database 5026 (20100413) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php$qry = mysql_query($sql); $arr = mysql_fetch_array($qry); if ($arr.count > 0) { echo "<ul>"; while($row = mysql_fetch_array($arr))You retrieve a row, check if it has any elements, then attempt to retrieve the next row, using the array you just created as the argument. You should be using $qry as the argument, but you're skipping over the first row. Toby __________ Information from ESET NOD32 Antivirus, version of virus signature database 5026 (20100413) __________ The message was checked by ESET NOD32 Antivirus. http://www.eset.com