رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
مشکل این کد چیه؟
#1
سلام، آقا این کد رو ببینید :
کد:
case'updateUser':{
        $fileName=$_FILES['file']['name'];
        $tmp=$_FILES['file']['tmp_name'];
        $type=$_FILES['file']['type'];

        $arr=array('image/png','image/jpeg','image/gif');
        $mime = array('image/png' => 'png', 'image/jpeg' => 'jpg', 'image/gif' => 'gif');

        if(in_array($type,$arr)){

            if(is_uploaded_file($tmp)){

                $newName = md5($fileName . time() . rand(1, 99999));
                if (move_uploaded_file($tmp,'Uploads/'.$newName.'.'.$mime[$type])){

                    echo "<div style='font-family:Segoe UI'>Your File Uploaded !</div>";}}}

        $objUser=new User();
        $result=$objUser->updateAvatar($_POST['id'],$newName.'.'.$mime[$type]);
        $result=$objUser->updateAuthorAvatar($_POST['id'],$newName.'.'.$mime[$type]);
        $result=$objUser->updateCommentAvatar($_POST['id'],$newName.'.'.$mime[$type]);
        if($result==0){
            echo "<div style='font-family:Segoe UI'>Your Row Updated !</div>";
            header('Refresh:5;Location:DashBoard.php');}
        else{
            echo "<div style='font-family:Segoe UI'>A Problem !</div>";
            header('Refresh:5;Location:DashBoard.php');}}

        $objUser=new User();
        $result=$objUser->updateUser($_POST['id'],$_POST['firstName'],$_POST['lastName'],$_POST['userName'],$_POST['passWord'],$_POST['mail'],$newName.'.'.$mime[$type],$_POST['biography']);
        if($result==0){
            echo "<div style='font-family:Segoe UI'>Your Row Updated !</div>";
            header('Refresh:5;Location:GetUsers.php');}
        else{
            echo "<div style='font-family:Segoe UI'>A Problem !</div>";
            header('Refresh:5;Location:GetUsers.php');}}
    break;

    case'updateProduct':{

        list($file, $psd) = array($_FILES['file'], $_FILES['psdAttachment']);

        $newFileName = '';
        $newPSDName = '';

        $fileMimes = array(
            'image/gif' => 'gif',
            'image/jpeg' => 'jpg',
            'image/png' => 'png',
        );

        $psdMimes = array(
            'image/vnd.adobe.photoshop' => 'psd',
        );

        if($file['error'] == 0 && in_array($file['type'], array_keys($fileMimes))) {
            $newFileName = md5($file['name'] . time() . rand(1, 99999));
            if(move_uploaded_file($file['tmp_name'], 'uploads/' . $newFileName . '.' . $fileMimes[$file['type']])) {
                echo '<div style="font-family:Segoe UI;">Your File Uploaded!</div>';
            }
        }

        if($psd['error'] == 0 && in_array($psd['type'], array_keys($psdMimes))) {
            $newPSDName = md5($psd['name'] . time() . rand(1, 99999));
            if(move_uploaded_file($psd['tmp_name'], 'uploads/' . $newPSDName . '.' . $psdMimes[$psd['type']])) {
                echo '<div style="font-family:Segoe UI;">Your PSD Uploaded!</div>';
            }
        }

        $objUser=new User();
        $result=$objUser->updateProduct($_POST['id'],$_POST['name'],$_POST['explanation'],$_POST['tutorial'],$newFileName.'.'.$fileMimes[$file['type']],$newPSDName.'.'.$psdMimes[$psd['type']]);
        if($result==0){
            echo "<div style='font-family:Segoe UI'>Your Row Updated !</div>";
            header('Refresh:5;Location:GetProducts.php');}
        else{
            echo "<div style='font-family:Segoe UI'>A Problem !</div>";
            header('Refresh:5;Location:GetProducts.php');}}
    break;
موقعی که می خوام لاگین کنم، به این قسمت case'updateProduct (که اصلا ربطی به این قسمت نداره) خطا می گیره، این هم ارورش :

( ! ) Parse error: syntax error, unexpected 'case' (T_CASE) in D:WampwwwdribbbleInitial.php on line 181

یکم داشتم رو کد هام کار می کردم که این اتفاق افتاد ... :-/
پاسخ
تشکر شده توسط:
#2
case'updateUser':

        $fileName=$_FILES['file']['name'];
        $tmp=$_FILES['file']['tmp_name'];
        $type=$_FILES['file']['type'];

        $arr=array('image/png','image/jpeg','image/gif');
        $mime = array('image/png' => 'png', 'image/jpeg' => 'jpg', 'image/gif' => 'gif');

        if(in_array($type,$arr)){

            if(is_uploaded_file($tmp)){

                $newName = md5($fileName . time() . rand(1, 99999));
                if (move_uploaded_file($tmp,'Uploads/'.$newName.'.'.$mime[$type])){

                    echo "<div style='font-family:Segoe UI'>Your File Uploaded !</div>";}}}

        $objUser=new User();
        $result=$objUser->updateAvatar($_POST['id'],$newName.'.'.$mime[$type]);
        $result=$objUser->updateAuthorAvatar($_POST['id'],$newName.'.'.$mime[$type]);
        $result=$objUser->updateCommentAvatar($_POST['id'],$newName.'.'.$mime[$type]);
        if($result==0){
            echo "<div style='font-family:Segoe UI'>Your Row Updated !</div>";
            header('Refresh:5;Location:DashBoard.php');}
        else{
            echo "<div style='font-family:Segoe UI'>A Problem !</div>";
            header('Refresh:5;Location:DashBoard.php');}

        $objUser=new User();
        $result=$objUser->updateUser($_POST['id'],$_POST['firstName'],$_POST['lastName'],$_POST['userName'],$_POST['passWord'],$_POST['mail'],$newName.'.'.$mime[$type],$_POST['biography']);
        if($result==0){
            echo "<div style='font-family:Segoe UI'>Your Row Updated !</div>";
            header('Refresh:5;Location:GetUsers.php');}
        else{
            echo "<div style='font-family:Segoe UI'>A Problem !</div>";
            header('Refresh:5;Location:GetUsers.php');}
    break;

    case'updateProduct':

        list($file, $psd) = array($_FILES['file'], $_FILES['psdAttachment']);

        $newFileName = '';
        $newPSDName = '';

        $fileMimes = array(
            'image/gif' => 'gif',
            'image/jpeg' => 'jpg',
            'image/png' => 'png',
        );

        $psdMimes = array(
            'image/vnd.adobe.photoshop' => 'psd',
        );

        if($file['error'] == 0 && in_array($file['type'], array_keys($fileMimes))) {
            $newFileName = md5($file['name'] . time() . rand(1, 99999));
            if(move_uploaded_file($file['tmp_name'], 'uploads/' . $newFileName . '.' . $fileMimes[$file['type']])) {
                echo '<div style="font-family:Segoe UI;">Your File Uploaded!</div>';
            }
        }

        if($psd['error'] == 0 && in_array($psd['type'], array_keys($psdMimes))) {
            $newPSDName = md5($psd['name'] . time() . rand(1, 99999));
            if(move_uploaded_file($psd['tmp_name'], 'uploads/' . $newPSDName . '.' . $psdMimes[$psd['type']])) {
                echo '<div style="font-family:Segoe UI;">Your PSD Uploaded!</div>';
            }
        }

        $objUser=new User();
        $result=$objUser->updateProduct($_POST['id'],$_POST['name'],$_POST['explanation'],$_POST['tutorial'],$newFileName.'.'.$fileMimes[$file['type']],$newPSDName.'.'.$psdMimes[$psd['type']]);
        if($result==0){
            echo "<div style='font-family:Segoe UI'>Your Row Updated !</div>";
            header('Refresh:5;Location:GetProducts.php');}
        else{
            echo "<div style='font-family:Segoe UI'>A Problem !</div>";
            header('Refresh:5;Location:GetProducts.php');}
    break;

این را بجاش بگذار

خطای syntax خطای نحوی است که اشتباه برنامه نویس است.

مثلا در خط 2 مثال زیر سمیکالن( ; ) گذاشته نشده است :


$a = 1;
$b = 2
$c = 3
پاسخ
تشکر شده توسط:
#3
آقا واقعا ممنونم ازتون ...
پاسخ
تشکر شده توسط:




کاربران در حال بازدید این موضوع: 2 مهمان