Помощник
|
Подредактировать скрипт |
dimjan4
|
Сообщение
#1
|
||
|
|
||
|
|||
Apay |
17.8.2009, 20:26;
Ответить: Apay
Сообщение
#2
|
|
нарушен баланс скобок, ищите
|
|
|
dimjan4
|
Сообщение
#3
|
|
Нашёл! Только теперь следующая ошибка:
Notice: Undefined index: img in z:\home\test1.ru\www\add_process.php on line 45 Fatal error: Call to undefined function: makesmallimage() in z:\home\test1.ru\www\add_process.php on line 50 на 45 линии [PHP]$make1 = $_FILES['img']['tmp_name'];[/PHP] на 50 $foto = makeSmallImage ($make1, $make2, $make3, $make4); но 50 строка из за 45... Что тут не так? |
|
|
Apay |
18.8.2009, 8:32;
Ответить: Apay
Сообщение
#4
|
|
перенесите ф-ю в самое начало, сразу после <?php
и еще один совет - делать отступы в коде, например все что в if(..){ с отступом, гораздо легче разбираться с косяками |
|
|
dimjan4
|
Сообщение
#5
|
|
Сделал так:
[PHP]<?php #################################### function makeSmallImage( $source, $destination, $dest_x, $dest_y,$dest_type = IMAGETYPE_JPEG) { $attr = @getimagesize( $source ); if( file_exists( $dest ) ) return true; if( $attr === false ) return false; switch( $attr[2] ){ case IMAGETYPE_JPEG: $imgs = @imagecreatefromjpeg( $source ); break; case IMAGETYPE_GIF: $imgs = @imagecreatefromgif( $source ); break; case IMAGETYPE_PNG: $imgs = @imagecreatefrompng( $source ); break; default: return false; } if( !$imgs ) return false; $result = false; $imgd = @imagecreatetruecolor( $w, $h ); if( $imgd ){ $w = $attr[0]; $h = $attr[1]; if( $w > $dest_x ){ $h = (int) round( $h / $w * $dest_x ); $w = $dest_x; } if( $h > $dest_y ){ $w = (int) round( $w / $h * $dest_y ); $h = $dest_y; } $result = imagecopyresized( $imgd, $imgs, 0, 0, 0, 0, $w, $h, $attr[0], $attr[1] ); if( $result ) switch( $dest_type ){ case IMAGETYPE_JPEG: $result = @imagejpeg( $imgd, $destination ); break; case IMAGETYPE_GIF: $result = @imagegif( $imgd, $destination ); break; case IMAGETYPE_PNG: $result = @imagepng( $imgd, $destination ); break; default: $result = false; } imagedestroy( $imgd ); } imagedestroy( $imgs ); return $result; } ############################ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title></title> <style> body { font-family:Arial, Helvetica, sans-serif; color:#646464; font-size:12px; background-image:url(../st/img/bg.gif); } </style> </head> <body> <?php if (empty($_POST['name']) or empty($_POST['lname']) or empty($_POST['old']) or empty($_POST['dd']) or empty($_POST['mm']) or empty($_POST['gggg']) or empty($_POST['email']) or empty($_POST['town']) or empty($_POST['sity']) or empty($_POST['obrazovanie']) or empty($_POST['img'])) { print "Не все поля заполненны!"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; } else { ################################ if (strlen($_POST['name']) > 25 or strlen($_POST['name']) < 3) { print "Имя должно содержать от 3 до 25 символов"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } if (strlen($_POST['lname']) > 25 or strlen($_POST['lname']) < 3) { print "Фамилия должна содержать от 3 до 25 символов"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } if (!eregi("^([A-Za-z0-9А])", $_POST['sity']) and $_POST['sity'] == "" or !eregi("^([A-Za-z0-9А])", $_POST['town']) and $_POST['town'] == "" or !eregi("^([A-Za-z0-9А])", $_POST['obrazovanie']) and $_POST['obrazovanie'] == "" or !eregi("^([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)$", $_POST['email']) and $_POST['email'] == "") { print "Некорректно заполнена форма!"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } ################################ $make1 = $_FILES['img']['tmp_name']; $make2 = time().rand(100,9999); $make3 = 110; $make4 = 150; $foto = makeSmallImage ($make1, $make2, $make3, $make4); if ($foto == false) { print "Ошибка при обработки фото!"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } else { //Начинаем регистрацию $root = $_SERVER['DOCUMENT_ROOT']."/foto/"; if (copy($foto,"$root".$foto)) { print "Ошибка при загрузки фото!"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } else { print "Далее"; //end registration } } } ?> </body> </html>[/PHP]Опять был нарушен баланс скобок...так что я переделал, теперь следующие ошибки: [PHP]Notice: Undefined index: img in z:\home\test1.ru\www\add_process.php on line 89 [Денвер: показать возможную причину ошибки] Notice: Undefined variable: dest in z:\home\test1.ru\www\add_process.php on line 7 Ошибка при обработки фото![/PHP] |
|
|
Apay |
18.8.2009, 12:29;
Ответить: Apay
Сообщение
#6
|
|
1) <input type="file" name="img" /> в форме не существует или через поле него ничего не было переданно или ошибка в форме
2) вместо $dest пишите $destination (мой глюк, сорри) |
|
|
dimjan4
|
Сообщение
#7
|
|
Насчёт $dest,
где его писать? [PHP]$make1 = $_FILES['img']['tmp_name']; $make2 = time().rand(100,9999); $make3 = 110; $make4 = 150; $foto = makeSmallImage ($make1, $make2, $make3, $make4);[/PHP] |
|
|
Apay |
18.8.2009, 14:05;
Ответить: Apay
Сообщение
#8
|
|
[PHP]if( file_exists( $destination ) ) return true; [/PHP]
но эту строчку можно вообще убрать, она гласит что если такой файл уже есть, то ничего не делаем (не перезаписываем его) и еще хорошо бы было вам о расширениях тоже подумать, например так:[PHP]$make2 = time().rand(100,9999).'.jpg'; [/PHP] |
|
|
dimjan4
|
Сообщение
#9
|
|
Вот что на данный момент есть:
[PHP]<?php #################################### function makeSmallImage( $source, $destination, $dest_x, $dest_y,$dest_type = IMAGETYPE_JPEG) { $attr = @getimagesize( $source ); if( file_exists( $destination ) ) return true; if( $attr === false ) return false; switch( $attr[2] ){ case IMAGETYPE_JPEG: $imgs = @imagecreatefromjpeg( $source ); break; case IMAGETYPE_GIF: $imgs = @imagecreatefromgif( $source ); break; case IMAGETYPE_PNG: $imgs = @imagecreatefrompng( $source ); break; default: return false; } if( !$imgs ) return false; $result = false; $imgd = @imagecreatetruecolor( $w, $h ); if( $imgd ){ $w = $attr[0]; $h = $attr[1]; if( $w > $dest_x ){ $h = (int) round( $h / $w * $dest_x ); $w = $dest_x; } if( $h > $dest_y ){ $w = (int) round( $w / $h * $dest_y ); $h = $dest_y; } $result = imagecopyresized( $imgd, $imgs, 0, 0, 0, 0, $w, $h, $attr[0], $attr[1] ); if( $result ) switch( $dest_type ){ case IMAGETYPE_JPEG: $result = @imagejpeg( $imgd, $destination ); break; case IMAGETYPE_GIF: $result = @imagegif( $imgd, $destination ); break; case IMAGETYPE_PNG: $result = @imagepng( $imgd, $destination ); break; default: $result = false; } imagedestroy( $imgd ); } imagedestroy( $imgs ); return $result; } ############################ ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1251"> <title></title> <style> body { font-family:Arial, Helvetica, sans-serif; color:#646464; font-size:12px; background-image:url(../st/img/bg.gif); } </style> </head> <body> <?php ################################ if (empty($_POST['name']) or empty($_POST['lname']) or empty($_POST['old']) or empty($_POST['dd']) or empty($_POST['mm']) or empty($_POST['gggg']) or empty($_POST['email']) or empty($_POST['town']) or empty($_POST['sity']) or empty($_POST['obrazovanie']) or empty($_POST['img'])) { print "Не все поля заполненны!"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } if (strlen($_POST['name']) > 25 or strlen($_POST['name']) < 3) { print "Имя должно содержать от 3 до 25 символов"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } if (strlen($_POST['lname']) > 25 or strlen($_POST['lname']) < 3) { print "Фамилия должна содержать от 3 до 25 символов"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } if (!eregi("^([A-Za-z0-9А])", $_POST['sity']) and $_POST['sity'] == "" or !eregi("^([A-Za-z0-9А])", $_POST['town']) and $_POST['town'] == "" or !eregi("^([A-Za-z0-9А])", $_POST['obrazovanie']) or $_POST['obrazovanie'] == "" or !eregi("^([0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-wyz][a-z](fo|g|l|m|mes|o|op|pa|ro|seum|t|u|v|z)?)$", $_POST['email']) or $_POST['email'] == "") { print "Некорректно заполнена форма!"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } ################################ $make1 = $_FILES['img']['tmp_name']; $make2 = time().rand(100,9999).'.jpg'; $make3 = 110; $make4 = 150; $foto = makeSmallImage ($make1, $make2, $make3, $make4); if ($foto == false) { print "Ошибка при обработки фото!"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } else { //Начинаем регистрацию $root = $_SERVER['DOCUMENT_ROOT']."/foto/"; if (copy($foto,"$root".$foto)) { print "Ошибка при загрузки фото!"; print"<script type=\"text/javascript\">window.setTimeout(\"document.location.href='add.php'\", 5000);</script>"; exit(); } else { print "Далее"; //end registration } } ?> </body> </html>[/PHP] теперь проблема в том, что при правильно заполненной форме пишет: Некорректно заполнена форма! |
|
|
Apay |
18.8.2009, 14:25;
Ответить: Apay
Сообщение
#10
|
|
разбейте длинное условие перед "Некорректно заполнена форма!" на части и посмотрите какое из условий не проходит
|
|
|
|
Похожие темы
Тема | Ответов | Автор | Просмотров | Последний ответ | |
---|---|---|---|---|---|
Скрипт поисковика видео StrongTube | 3 | 3josoft | 1575 | 14.8.2023, 14:45 автор: 3josoft |
|
Скрипт приема платежей p2p с карты на карту card2card Скрипт приема платежей p2p с карты на карту card2card |
15 | zladey1986 | 7839 | 26.3.2023, 8:54 автор: Palundra |
|
Продам скрипт перевода постов и комментариев | 4 | Tutich | 788 | 19.1.2023, 17:23 автор: Tutich |
|
Битрикс скрипт нативной установки | 3 | Nemo | 2454 | 20.11.2022, 10:09 автор: Webmaster24 |
|
Посоветуйте скрипт интернет-магазина (партнерская программа - критична!) |
9 | Aloof | 7365 | 2.12.2021, 15:03 автор: Ilonek |
Текстовая версия | Сейчас: 23.4.2024, 13:35 |