In the php file, when I register, I write a syntax error on line 123, and on line 123 ?>

 <?php if (isset($_POST['login'])) { $login = $_POST['login']; if ($login == '') unset($login); } if (isset($_POST['password'])) { $password=$_POST['password']; if ($password =='') unset($password); } if (empty($login) or empty($password)) { exit ("Вы ввели не всю информацию, вернитесь назад и заполните все поля!"); } $login = stripslashes($login); $login = htmlspecialchars($login); $password = stripslashes($password); $password = htmlspecialchars($password); $login = trim($login); $password = trim($password); if (strlen($login) < 3 or strlen($login) > 15) { exit ("Логин должен состоять не менее чем из 3 символов и не более чем из 15."); } if (strlen($password) < 3 or strlen($password) > 15) { exit ("Пароль должен состоять не менее чем из 3 символов и не более чем из 15."); } if (!empty($_POST['fupload'])) { $fupload=$_POST['fupload']; $fupload = trim($fupload); if ($fupload =='' or empty($fupload)) { unset($fupload); } } if (!isset($fupload) or empty($fupload) or $fupload =='') { $avatar = "avatars/net-avatara.jpg"; } else { $path_to_90_directory = 'avatars/'; if(preg_match('/[.](JPG)|(jpg)|(gif)|(GIF)|(png)| (PNG)$/',$_FILES['fupload']['name'])) { $filename = $_FILES['fupload']['name']; $source = $_FILES['fupload']['tmp_name']; $target = $path_to_90_directory . $filename; move_uploaded_file($source, $target); if(preg_match('/[.](GIF)|(gif)$/', $filename)) { $im = imagecreatefromgif($path_to_90_directory.$filename) ; } if(preg_match('/[.](PNG)|(png)$/', $filename)) { $im = imagecreatefrompng($path_to_90_directory.$filename) ; } if(preg_match('/[.](JPG)|(jpg)|(jpeg)|(JPEG)$/', $filename)) { $im = imagecreatefromjpeg($path_to_90_directory.$filename); } $w = 90; $w_src = imagesx($im); $h_src = imagesy($im); $dest = imagecreatetruecolor($w,$w); if ($w_src>$h_src) imagecopyresampled($dest, $im, 0, 0, round((max($w_src,$h_src)-min($w_src,$h_src))/2), 0, $w, $w, min($w_src,$h_src), min($w_src,$h_src)); if ($w_src<$h_src) imagecopyresampled($dest, $im, 0, 0, 0, 0, $w, $w, min($w_src,$h_src), min($w_src,$h_src)); if ($w_src==$h_src) imagecopyresampled($dest, $im, 0, 0, 0, 0, $w, $w, $w_src, $w_src); $date=time(); imagejpeg($dest, $path_to_90_directory.$date.".jpg"); $avatar = $path_to_90_directory.$date.".jpg"; $delfull = $path_to_90_directory.$filename; unlink ($delfull); } else { exit ("Аватар должен быть в формате <strong>JPG,GIF или PNG</strong>"); } $password = md5($password); $password = strrev($password); $password = $password."b3p6f"; include ("bd.php"); $result = mysql_query("SELECT id FROM users WHERE login='$login'",$db); $myrow = mysql_fetch_array($result); if (!empty($myrow['id'])) { exit ("Извините, введённый вами логин уже зарегистрирован. Введите другой логин."); } $result2 = mysql_query ("INSERT INTO users (login,password,avatar) VALUES('$login','$password','$avatar')"); if ($result2=='TRUE') { echo "Вы успешно зарегистрированы! Теперь вы можете зайти на сайт. <a href='index.php'>Главная страница</a>"; } else { echo "Ошибка! Вы не зарегистрированы."; } ?> 

2 lesson stopped

  • Maybe you have somewhere already fixed the closing tag? - Deonis
  • five
    Give lines 122-124 - Sh4dow
  • one
    O_o how many people wanted to correct the question, and I rolled back all their edits) PS maybe you need to put a semicolon in line 122 after}. Either you have a different number of opening {and closing} - ReinRaus
  • 3
    This is why if ($ result2 == 'TRUE') you have to tear off your hands. Because it will work in the same way as if ($ result2 == 'FALSE') // or if ($ result2 == 'ololo') and give the error text. I suspect you have opened somewhere { and not closed. - Sh4dow
  • one
    If you had formatted the code normally, you would immediately see your mistake. I formatted it approximately as the normal code looks like, and ?> Indented, as it were, hints. PS never use TAB to indent a line. 4 spaces PPS preg_match('/[.](JPG)|(jpg)|(gif)|(GIF)|(png)| (PNG)$/' so preg_match('/[.](jpg)|(gif)|(png)$/i' - ReinRaus

2 answers 2

2 lesson stopped

And they did it right, because these video lessons are a big shit. It is better to read the book D. Koterov

  • thank you very much - Anton

It must be like this!

  else { echo "Ошибка! Вы не зарегистрированы."; }} //тут две } о чем многократно постилось в комментах! ?> 

Instead of if ($result2=='TRUE') Write if ($result2)

And if ($result2=='TRUE') is terrifying to many,