Erorr syntax error, unexpected T_STRING

Discussion in 'PHP' started by PHP Boy, Jul 4, 2011.

  1. #1
    Hi :)

    What is problem in my code ??

    My code:
    copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); //line 12
    copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);
    copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);
    PHP:
    Sorry , My language is weak :(
     
    PHP Boy, Jul 4, 2011 IP
  2. ker

    ker Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Can You give us more lines?
    It may be problem in line 11...
     
    ker, Jul 4, 2011 IP
  3. vruvishal

    vruvishal Member

    Messages:
    22
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #3
    could you put whole file code?
     
    vruvishal, Jul 4, 2011 IP
  4. PHP Boy

    PHP Boy Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    OK!! OK!!

    multiple_upload.php
    
    <table width="500" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
    <tr>
    <form action="multiple_upload_ac.php" method="post" enctype="multipart/form-data" name="form1" id="form1">
    <td>
    <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
    <tr>
    <td><strong>multiple Files Upload </strong></td>
    </tr>
    <tr>
    <td>1.Select file
    <input name="ufile[]" type="file" id="ufile[]" size="50" /></td>
    </tr>
    <tr>
    <td>2.Select file
    <input name="ufile[]" type="file" id="ufile[]" size="50" /></td>
    </tr>
    <tr>
    <td>3.Select file
    <input name="ufile[]" type="file" id="ufile[]" size="50" /></td>
    </tr>
    <tr>
    <td align="center"><input type="submit" name="Submit" value="Upload" /></td>
    </tr>
    </table>
    </td>
    </form>
    </tr>
    </table>
    
    PHP:
    multiple_upload_ac.php
    
    <?php
    
    //تعيين المجلد الذي تريد تخزين الصور عليه
    //في هذا المثال سنحفظ الملف في مجلد upload
    //$HTTP_POST_FILES['ufile']['name']; = اسم الملف المرفوع
    //على سبيل المثال رفعنا ملف باسم test.gif فسوف يكون مسار الصورة upload/test.gif
    $path1= "upload/".$HTTP_POST_FILES['ufile']['name'][0];
    $path2= "upload/".$HTTP_POST_FILES['ufile']['name'][1];
    $path3= "upload/".$HTTP_POST_FILES['ufile']['name'][2]
    
    //نسخ الملف الى حيث تريد تخزين الملف
    copy($HTTP_POST_FILES['ufile']['tmp_name'][0], $path1); //line 12
    copy($HTTP_POST_FILES['ufile']['tmp_name'][1], $path2);
    copy($HTTP_POST_FILES['ufile']['tmp_name'][2], $path3);
    
    //$HTTP_POST_FILES['ufile']['name'] = اسم الملف
    //$HTTP_POST_FILES['ufile']['size'] = حجم الملف
    //$HTTP_POST_FILES['ufile']['type'] = نوع الملف
    echo "File Name :".$HTTP_POST_FILES['ufile']['name'][0]."<BR/>";
    echo "File Size :".$HTTP_POST_FILES['ufile']['size'][0]."<BR/>";
    echo "File Type :".$HTTP_POST_FILES['ufile']['type'][0]."<BR/>";
    echo "<img src=\"$path1\" width=\"150\" height=\"150\">";
    echo "<P>";
    
    echo "File Name :".$HTTP_POST_FILES['ufile']['name'][1]."<BR/>";
    echo "File Size :".$HTTP_POST_FILES['ufile']['size'][1]."<BR/>";
    echo "File Type :".$HTTP_POST_FILES['ufile']['type'][1]."<BR/>";
    echo "<img src=\"$path2\" width=\"150\" height=\"150\">";
    echo "<P>";
    
    echo "File Name :".$HTTP_POST_FILES['ufile']['name'][2]."<BR/>";
    echo "File Size :".$HTTP_POST_FILES['ufile']['size'][2]."<BR/>";
    echo "File Type :".$HTTP_POST_FILES['ufile']['type'][2]."<BR/>";
    echo "<img src=\"$path3\" width=\"150\" height=\"150\">";
    
    ///////////////////////////////////////////////////////
    
    // يستخدم هذا الكود لعرض نجاح الرفع او فشله
    
    $filesize1=$HTTP_POST_FILES['ufile']['size'][0];
    $filesize2=$HTTP_POST_FILES['ufile']['size'][1];
    $filesize3=$HTTP_POST_FILES['ufile']['size'][2];
    
    if($filesize1 && $filesize2 && $filesize3 != 0)
    {
    echo "تم رفع الملف بنجاح";
    }
    
    else {
    echo "فشل رفع الملف";
    }
    
    //////////////////////////////////////////////
    
    // الملفات التي لديها مشاكل ان وجدت
    
    if($filesize1==0) {
    echo "هناك خطأ في الملف الاول";
    echo "<BR />";
    }
    
    if($filesize2==0) {
    echo "هناك خطأ في الملف الثاني";
    echo "<BR />";
    }
    
    if($filesize3==0) {
    echo "هناك خطأ في الملف الثالث";
    echo "<BR />";
    }
    
    ?>
    
    PHP:
     
    PHP Boy, Jul 4, 2011 IP
  5. ker

    ker Peon

    Messages:
    97
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #5
    You didn't put ; at end of line 9.
    Should work now...
     
    ker, Jul 5, 2011 IP
  6. PHP Boy

    PHP Boy Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Yes :)
    thank you for help me :)
     
    PHP Boy, Jul 5, 2011 IP