Weird Error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jcunningham
Forum Newbie
Posts: 1
Joined: Tue Jul 08, 2003 11:07 am

Weird Error

Post by jcunningham »

Parse error: parse error in /home/httpd/vhosts/mydomain.com/httpdocs/thumbs.php on line 49

Code: Select all

<?php

                //*********************************
                // What the hell is going on?
                //*********************************
 
                $columns = 3;
                $a = '0';
                while (list ($key, $val) = #each ($itemname)) {
                    //$columns is how many columns are in your table once $a reaches the value of
                    //$columns it will terminate the row in the table and create another one.        
                    if ($a % $columns == 0)  // LINE 49
                        {
                            echo "</TR>";                
                            echo "<TR>";
                        }
                    echo "<TD ALIGN=CENTER VALIGN=CENTER>";
 
      ?>
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

you have a hanging line (whats that doing... hehe):

Code: Select all

while (list ($key, $val) = #each ($itemname)) {
also you have give the variable $a, a string value so your if statement will never be equal to 0...
SBukoski
Forum Contributor
Posts: 128
Joined: Wed May 21, 2003 10:39 pm
Location: Worcester, MA

Post by SBukoski »

Doesn't PHP do type conversions when possible? So, for example:

Code: Select all

$a = '0';

if ($a == 0) {
  // do stuff here
}

if ($a == '0') {
  // do stuff here
}
Both of these if statements would run. However, if you used the approach of using === for your comparisons, then it would only recgonzie the string '0' as being equal as it does a true comparison and doesn't do any type conversions.

Of course, I could be wrong on this. :)
User avatar
m@ndio
Forum Regular
Posts: 163
Joined: Fri Jun 06, 2003 12:09 pm
Location: UK

Post by m@ndio »

Sbukoski you are correct I screwed that one up :lol: but still it's awfull practice to do the above.
Post Reply