Page 1 of 1

PHP 4 to 5 migration issue

Posted: Thu Jan 08, 2009 8:38 pm
by pelowe
After migrating from PHP 4.3.10 to 5.2.8 I'm receiving an "undefined index" error from the following code...

Code: Select all

 
<?php
while($row = mysql_fetch_array($result)){?>
  <input id="yard_<?php echo $row['yard_id'];?>" type="checkbox" name="yard_list[]" value="<?php echo $row['yard_id'];?>" checked>
  <label for="yard_<?php echo $row['yard_id'];?>"><?php echo $row['yard'];?></label><br>
<?php
}?>
I know the mysql result is valid since it works fine in PHP4.

The output from var_dump($row) is:

PHP4
array(2) { ["yard"]=> string(22) "Chestnut Ridge Transit" ["yard_id"]=> string(1) "5" }

PHP5
array(2) { [""]=> string(22) "Chestnut Ridge Transit" ["B"]=> string(1) "5" }

Why would I be getting the strange characters for the field values?


Thanks

Re: PHP 4 to 5 migration issue

Posted: Fri Jan 09, 2009 8:09 pm
by pelowe
Tried changing the Collation on the MySQL table to utf8_bin
And all works well. It's only a development MySql server so I wasn't worried about breaking the live applications.

I'm not to familiar with the Collation settings in MySql so I'll need to do some heavy research before make that change across the entire db.

Any help on that topic would be greatly appreciated.