私のコードにいくつかの問題がありますが、同じエラーが発生しています。開いている括弧がないか、行を閉じるのを忘れていないことを確認しました。PHPコードの解析エラー予期しないT_CASE
以下のコードは、これが79から191エラーがライン上に109
if(isset($id) && isset($_SESSION['user_current'])){
switch($option) {
case 1:
$query = mysql_query("SELECT * FROM `ebcs_albums` WHERE `id` = '{$_SESSION[user_current][2]}'");
$result = mysql_fetch_assoc($query);
$img_ext = array('.jpeg','.jpg','.png','.gif');
function getImages($dir) {
global $img_path, $img_ext;
$d = dir($img_path.$dir);
while (false !== ($file = $d->read())) {
$file_basename = substr($file, 0, strripos($file, '.'));
$file_basename = rename($file_basename,strtolower(preg_replace('/[^A-Za-z0-9_-]+/', '-', $file_basename)));
$file_ext = substr($file, strripos($file, '.'));
$file_ext = rename(strtolower($file_ext));
$file = $file_basename.$file_ext;
if(in_array($file_ext,$img_ext)) {
$images[] = array('file' => $file,'size' => getimagesize($file));
}
}
$d->close();
asort($images);
return $images;
}
$array = getImages($result['Albums_Folder']);
foreach ($array as $img) {
mysql_query("INSERT INTO `ebcs_albums_temp` (`id`,`User`,`Image_Name`,`Image_Width`,`Image_Height`)
VALUES ('','$user','{$img[file]}','{$img[size][0]}','{$img[size][1]}')");
}
goto case 3;
break;
case 2:
$query = mysql_query("SELECT * FROM `ebcs_albums_temp` WHERE `User` = '{$_SESSION[user_current][0]}'");
$array = mysql_fetch_array($query);
foreach ($array as $remove) {
mysql_query("DELETE FROM `ebcs_albums_temp` WHERE `id` = '{$remove[id]}'");
}
mysql_query("DELETE FROM `ebcs_albums_users` WHERE `IP` = '{$_SESSION[user_current][0]}'");
$id = $_SESSION['user_current'][2];
unset($_SESSION['user_current']);
$query = mysql_query("SELECT * FROM `ebcs_albums_users` WHERE `Time` > '$inactive'");
$array = mysql_fetch_array($query);
foreach ($array as $remove) {
$last = next($array)===false;
mysql_query("DELETE FROM `ebcs_albums_users` WHERE `id` = '{$remove[id]}'");
if(!$last){
mysql_query("DELETE FROM `ebcs_albums_temp` WHERE `User` = '{$remove[IP]}'");
}
}
$_SESSION['error'] = 'You have be logged out.';
echo '<meta http-equiv="refresh" content="0;URL=album.php?id=$id">';
break;
case 3:
$query = mysql_query("SELECT DISTINCT User FROM `ebcs_albums_temp`");
$array = mysql_fetch_array($query);
if(in_array($_SESSION['user_current'][0],$array)) {
$query = mysql_query("SELECT Time FROM `ebcs_albums_users` WHERE `User` = '{$_SESSION[user_current][0]}'");
$mysql_time = mysql_fetch_assoc($query);
$session_life = time() - $_SESSION['user_current'][1];
$mysql_life = time() - $mysql_time['Time'];
if(($session_life > $inactive) || ($mysql_life > $inactive)){
goto case 2;
break;
}
SmartyPaginate::connect();
SmartyPaginate::setLimit(24);
$query = sprintf("SELECT SQL_CALC_FOUND_ROWS * FROM `ebcs_albums_temp` WHERE `User` = '$user' ORDER BY `id` LIMIT %d,%d", SmartyPaginate::getCurrentIndex(), SmartyPaginate::getLimit());
$results = mysql_query($query);
while($x = mysql_fetch_assoc($results)) {
$images[] = array('file' => $x['Image_Name'],'width' => $x['Image_Width'],'height' => $x['Image_Height']);
}
$query = "SELECT FOUND_ROWS() as total";
$_results = mysql_query($query);
$_row = mysql_fetch_assoc($_results);
SmartyPaginate::setTotal($_row['total']);
SmartyPaginate::assign($smarty);
$albums = mysql_query("SELECT * FROM `ebcs_albums` WHERE `id` = '{$_SESSION[user_current][2]}'");
$albums_arr = array();
while($x = mysql_fetch_assoc($albums)) {
$albums_arr[] = $x;
}
$smarty->assign('id',$id);
$smarty->assign('images',$images);
$smarty->assign('albums_arr',$albums_arr);
include ("_header.php");
$smarty->display('album_images.tpl');
include ("_footer.php");
break;
} else {
goto case 1;
break;
}
default:
break;
}
} else {
$_SESSION['error'] = 'You are not logged in.';
echo '<meta http-equiv="refresh" content="0;URL=album.php?id=$id">';
}
線109 =後藤ケース3行で、私の全体のコードの一部のみです。行110 =ブレーク。
ありがとうございました!
後藤。それは病気です、アーロン。 – JJJ
私はあなたが 'goto'と' case'を一緒に使うことはできないと信じています... – BoltClock
これらのもののための関数を使用します –