我正在尝试验证名称以确保未使用该名称,但由于某种原因,验证错误不断自我重复,在这里我希望它显示用户何时使用之前的“名称已在使用中”但我'我得到这个“名称已经在用户名已经在用户名已经在用户名已经在用户名已经在用户名已经在用户名已经在用户名已经在使用”。我怎么能阻止它?
$types = array();
$result = mysql_query("SELECT * FROM `im_album` WHERE username = '".$user_data['username']."' ");
while(($row = mysql_fetch_assoc($result))) {
$types[] = $row['name'];
}
if (isset($_POST['img_album'])) {
$al_name = $_POST['name'];
$al_description = $_POST['description'];
$mode = $_POST['mode'];
if(empty($al_name)){
$errors[] = 'album name required';
}
if (strlen($al_name) > 55 || strlen($al_name) > 255) {
$errors[] = 'name fields are to long ';
}
foreach($types as $album){
if ($al_name == $album)
$errors[] = "name already in use";
}};
echo output_errors($errors);