Quick soln. is to put a "@" symbol in front of the error generating line.
E.g.@$i++;
actual soln. would be to do some initialization like
$i = 0; outside your while loop and $last_name="";
> I'm just curious if there's a way to restructure my code so as to avoid
> getting "Undefined Variable" errors. I keep getting them and I know they're
> nothing to worry about for the most part, I'd like to get rid of them
> without turning off error reporting if possible. In the following code, I
> get an undefined variable error for $i and for $last_name, is there anything
> I can do to actually define them? $last_name is a variable produced by my
> MySQL query, $i is just a counter:
>
> while ($row = mysql_fetch_array($result)) {
> extract($row);
> $i++;
> if($i=="1") {
> print "<tr>\n";
> }
>
> if($last_name) {
> <print stuff here>
> } else {
> <print other stuff>
> }
> ...
> if ($i=="5") {
> print "</tr>\n";
> $i=0;
> }
> }
>
> Thanks!
>
> Jason Soza
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
-Pushkar S. Pradhan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php