Forum Moderators: coopster
Is this something I should worry about? I can't seem to find a way to avoid the warning other than turning error reporting off.
$SQL = "select * from reminders order by reminderSend";
$reminderResults = mysql_query($SQL);
$reminderCount = mysql_num_rows($reminderResults);
...
for ($i = 0; $i < $reminderCount; $i++) {
mysql_result($reminderResults,$i,"reminderID")
};
...
So basically I'm trying to list all of my reminders after first getting a count to see if there are any at all. Am I doing this wrong?
In this case your just retieving all rows from resultset 'reminders'.
Best pracice to use mysql_fetch* functions with a while loop. [uk.php.net...]
<?php
$SQL = "select * from reminders order by reminderSend";
$reminderResults = mysql_query($SQL);
while ($reminder = mysql_fetch_object($reminderResults)) {
echo $reminder ->reminderID;
}?>
So if I understand correctly, if I want to loop through a set of data (reminders for example) and also display a name associated with the reminder (in a client table for example) should I use mysql_result for that if I'm only pulling one value from the table?
Back to the original question for a second. First off, you should not be allowing the errors to appear in a browser on a production server so if that is the case you should be immediately start logging those errors. If you do have a lot of scripts that have a lot of warnings coming from them, then maybe you'd want to lessen your error reporting level in your php.ini file so that your error logs aren't going to fill up so quickly and will only contain more crucial information. I tend to always log everything and be as strict as possible with my error reporting, so I log everything, but I also make sure that I don't have any warnings in my code at all. Most of the time warnings will not cause any problems to your actual application itself, but sometimes it could create issues.
If you'd like to post your new code, then I'm sure we can get those warnings fixed up for you :)
I was just curious to see how critical it was to clean up all of the warnings and if there was something I was doing wrong because it never hurts to learn a new way to do things.
I haven't had a chance to work on that part of my code yet, so I don't have any code to post yet, but when I get back to it I'll be sure to add it here.