バグ修正 | |
■2005/06/27 | MySQLとPHPを利用する住所検索(myphp/zipdb.php)の不具合 |
●エラー詳細 | 北海道地方の070-0000(旭川市)のように0から始まる郵便番号の検索が正しく行われません。 |
●修正 |
myphpzipフォルダ内zipdb.phpのfunction create()で以下の部分を見つけて、$array[0]をシングルクオーテーションで括ります($array[0]→'$array[0]')。 ---修正前--- // 郵便番号データ格納 [email protected]($sourcefile,"r") or die("$sourcefileを開けません"); while(!feof($file)){ $data=fgets($file,1024); $array=explode("<>",$data); $sql="insert into zip(zip,address) values($array[0],'$array[1]')";←☆この行を修正 if(!$res=mysql_query($sql)){ echo mysql_error(); echo " データ格納に失敗しました"; exit(); } } ---修正後--- // 郵便番号データ格納 [email protected]($sourcefile,"r") or die("$sourcefileを開けません"); while(!feof($file)){ $data=fgets($file,1024); $array=explode("<>",$data); $sql="insert into zip(zip,address) values('$array[0]','$array[1]')"; if(!$res=mysql_query($sql)){ echo mysql_error(); echo " データ格納に失敗しました"; exit(); } } 上の修正を行った後に、住所データ格納テーブルを改めて作成しなおしてください。 以上で修正は終わりです。 |