Help me with this F**k error, I´ve no idea

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
DuffMAn
Forum Newbie
Posts: 17
Joined: Thu Apr 03, 2003 4:53 pm

Help me with this F**k error, I´ve no idea

Post by DuffMAn »

I was trying to upload a file and php show me this.

Parse error: parse error, unexpected T_STRING in C:\Php Ide\nusphere\PHPEd\Foro 2.0\up.php on line 6

This is the code:

up.php

Code: Select all

<?php
if (! is_uploaded_file($userfile))
       &#123;
      unlink($userfile);
      $error = "Nada";
               &#125;     // Line 6 --> Error???????????
else &#123;
    //a file was uploaded
        $maxfilesize=10240;
        if ($userfile_size > $maxfilesize) &#123;
        $error = "file is too large";
        unlink($userfile);
        // assign error message, remove uploaded file, redisplay form.
        &#125; else &#123;
                if ($userfile_type != "image/gif" AND $userfile_type != "image/pjpeg") &#123;
                $error = "This file type is not allowed";
                unlink($userfile);
                // assign error message, remove uploaded file, redisplay form.
                &#125; else &#123;
               //File has passed all validation, copy it to the final destination and remove the temporary file:
               @ move_uploaded_file($userfile_type,"prueba/".$userfile_name);

               unlink($userfile);
               print "File has been successfully uploaded!";
               exit;
                        &#125;
                &#125;
       &#125;

?>
and the upload.html

Code: Select all

<html>
<form action="up.php" method="POST" enctype="multipart/form-data">
submit this file: <input type=file name="userfile"><br>
<input type=submit><br>
</form>
</html>
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Try eliminating the space between the exclamation mark and the variable:

Code: Select all

<?php
if (! is_uploaded_file($userfile)) 
?>
so it reads

Code: Select all

<?php
if (!is_uploaded_file($userfile)) 
?>
User avatar
DuffMAn
Forum Newbie
Posts: 17
Joined: Thu Apr 03, 2003 4:53 pm

Post by DuffMAn »

I try it and give me the same error :(
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

Instead of $userfile, try $_POST["userfile"]
Image Image
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

try

Code: Select all

<?php
if (!(is_uploaded_file($userfile)))
?>
and check phice post
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I tried running your code and didn't get any parse errors - did you copy and paste the script in?

Mac
User avatar
DuffMAn
Forum Newbie
Posts: 17
Joined: Thu Apr 03, 2003 4:53 pm

Post by DuffMAn »

twigletmac wrote:I tried running your code and didn't get any parse errors - did you copy and paste the script in?

Mac
Yes, I copy and paste the code.
I run the code in PHPED and online and gave me the error. Where did you run the code?.
User avatar
DuffMAn
Forum Newbie
Posts: 17
Joined: Thu Apr 03, 2003 4:53 pm

Post by DuffMAn »

I solved the problem, thx
User avatar
AVATAr
Forum Regular
Posts: 524
Joined: Tue Jul 16, 2002 4:19 pm
Location: Uruguay -- Montevideo
Contact:

Post by AVATAr »

what was the problem!!?!?!?!?!?!?
User avatar
DuffMAn
Forum Newbie
Posts: 17
Joined: Thu Apr 03, 2003 4:53 pm

Post by DuffMAn »

I don´t know exactly. I just rewrite the script. Here it is.

Code: Select all

if(!empty($userfile)) &#123;
                     $maxfilesize=50000;
                     $tipo = $userfile_type;
                     $tam = $userfile_size;
                     $nombre = $userfile_name;
                     $copiado = FALSE;
                     $imagehw = GetImageSize($userfile);
                     $imagewidth = $imagehw&#1111;0];
                     $imageheight = $imagehw&#1111;1];
                     if (($tam <= $maxfilesize ) AND ($imageheight <= 100 ) AND ($imagewidth <= 100) AND (($tipo == "image/pjpeg") OR ($tipo == "image/gif") OR ($tipo == "image/jpeg") OR ($tipo == "image/bmp") ) ) &#123;
                     $nombre_avatar = "avatares/$USER_NOMBRE $nombre";
                     @ move_uploaded_file($userfile,$nombre_avatar);
                     $sql_change = mysql_query("UPDATE usuarios SET avatar='$nombre_avatar' WHERE nombre='$USER_NOMBRE'");
                     $copiado = TRUE;
Post Reply