Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can !
Moderator: General Moderators
pelowe
Forum Newbie
Posts: 2 Joined: Thu Jan 08, 2009 8:35 pm
Post
by pelowe » Thu Jan 08, 2009 8:38 pm
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
pelowe
Forum Newbie
Posts: 2 Joined: Thu Jan 08, 2009 8:35 pm
Post
by pelowe » Fri Jan 09, 2009 8:09 pm
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.