Re: any ideas : Unexpected character
| From: | Will Hives | Date: | Thu, 14 Feb 2002 16:57:30 +0000 |
| Subject: | Re: any ideas : Unexpected character | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-84763@lists.php.net to get a copy of this message | ||
If you can spot any more mistakes please feel free to amend.
Cheers
Will
___> THIS IS LINE 14-> // OK, this should work with your form, it now keys
on picture, and looks for image MIME types.
// If it doesn't, feel free to hack the upload function however you wish
// upload file function - returns $path, which tells us where the image
lives on the filesystem.
function fileUpload($name,$type,$file) { // v0.9.1 13.02.02
if (is_uploaded_file($file)){ // successful upload.
if ($type == "image/jpg" || $type == "image/gif" || $type ==
"image/pjpeg" || $type == "image/jpeg"){ // is this a valid image?
$time_tmp = time();
$time_tmp = substr("$time_tmp", -4);
$filename = $time_tmp._.$name; // just in case someone
uploads matched filenames.
$savepath = "/home/*********/*******/php/".$filename; //
change the path here. make sure the directory it is going to can be written
to by the web user.
$moved = move_uploaded_file($file, $savepath); // place the
file on the server's filesystem
$path = $filename;
} else { // wrong file type
$path = "Sorry, but the file type of this file is not
recognised. Please check and try again.<p>";
}
} else { // upload failed.
$path ="Sorry, but the upload failed. Please try again in a
short while.<p>";
}
return $path;
}
// uploaded file info-zone - prepare variables to be passed to the upload
function
$name = $HTTP_POST_FILES['picture']['name']; // orginal name
$type = $HTTP_POST_FILES['picture']['type']; // get MIME type of file
$path = fileUpload($name,$type,$picture); // yer actual upload function call
// I'd recommend you check the value of $path here - if it contains a text
string starting with "Sorry" then something has failed.
// and off to the database it goes.
$sql = "INSERT INTO $table_name (id, name, email, picture_name)
VALUES ('$id', '$name', '$email', '$path') ";
$result = mysql_query($sql, $connection) or die ("couldn't execute query");
in article 005301c1b576$31479df0$0a00000a@AERIS, Girish Nath at
girishn@btinternet.com wrote on 2/14/2002 4:39 PM:
> Hi
>
> I got this error :
>
> Warning: Unexpected character in input: ' in
> /home/altdesign/public_html/php/new admin/do_addauthor.php on line 14
>
> Can you post the section around Line 14 from do_addauthor.php so we can take
> a look at it ?
>
> Regards
>
>
> Girish
> --
> www.girishnath.co.uk
>
>
> ----- Original Message -----
> From: "Will Hives" <will@colemanmoore.com>
> To: <php-general@lists.php.net>
> Sent: Thursday, February 14, 2002 4:34 PM
> Subject: [PHP] any ideas : Unexpected character
>
>
>
> I have put together this script with the help of some of you kind members
> here. It seems to do what I set out for it to do, but when it finished the
> upload it comes up with the following error:
>
> Unexpected character
>
> try for yourself:
> http://www.alt-design.net/php/new%20admin/add.php
>
> I would be very grateful for any ideas.
>
> Cheers
> Will
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>