Would somebody mind explaining my error please?

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
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Would somebody mind explaining my error please?

Post by impulse() »

This script serves no purpose other than to educate me in array manipulation.
It basically grabs the results of a MySQL querys from 3 different columns in a table and output them to an array, which works fine. The part that's playing up is echoing out the results of a flipped array once it had been flipped further down. PHP is reporting that there's an unexpected ";" on line 31, which is the 2nd while loop. Can anybody see why?

Code: Select all

mysql_connect("x", "x", "x");
mysql_select_db("people");

$q = mysql_query("SELECT * from counter");
$i = 0;



while ($row = mysql_fetch_array($q)) {
  $counter[$i] = $row['counter'];
  $ip[$i] = $row['ip'];
  $date[$i] = $row['date'];


  echo "$counter[$i] <br>";
  echo "$ip[$i] <br>";
  echo "$date[$i] <br>";
  }


      $flipCounter = array_flip($counter);
      $flipIp = array_flip($ip);
      $flipDate = array_flip($date);
      $k = count($counter);
      echo "<br><br><b><br>";



while ($j = 0; $j < $k; $j++) {    //Line 31 //
  echo "$flipCounter[$j]";
  echo "$flipIp[$j]";
  echo "$flipDate[$j]";
  }
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

you set it up like a for loop... it's not a for loop, it's a while loop :wink:
Post Reply