| | |
Parse error, unexpected T_STRING, expecting T_CASE
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Solved Threads: 0
Hello,
I am new to Daniweb and am I glad I found it, there is so much helpful information here for a newbie programer.
This is my error message:
Parse error: parse error, unexpected T_STRING, expecting T_CASE or T_DEFAULT or '}' in C:\wamp\www\helen\upload.php on line 17
This is my story:
I am building a database for a realestate agent and it needs to be able to upload images to the database. Being green at this I have had a heck of a time finding tutorials that make sense to me regarding uploading files to the database so this is what I have done, please tell me if there is a better way. I am using PHP and I have an 'add.php' page where you would fill in your information and there is a browse button to browse to your image file,
here is the code for the button,
I have another page called 'upload.php' that apparently is the page that processes the file information and places it in the database? (I think this is right?)
Here is the code:
I have been reading posts from others that have been having similar problems and it seems that it is usually a spelling error or a semicolon is missing but I can't seem to find the error.
And I am wondering if this is even the right way about uploading images.
Incase it is important the information in the data base for the image field is:
Field:thumb1
Type:mediumblob
Attributes:binary
Null:no
Thanks for your help, I feel like this php sql stuff will never make sense.
Cheers!
I am new to Daniweb and am I glad I found it, there is so much helpful information here for a newbie programer.
This is my error message:
Parse error: parse error, unexpected T_STRING, expecting T_CASE or T_DEFAULT or '}' in C:\wamp\www\helen\upload.php on line 17
This is my story:
I am building a database for a realestate agent and it needs to be able to upload images to the database. Being green at this I have had a heck of a time finding tutorials that make sense to me regarding uploading files to the database so this is what I have done, please tell me if there is a better way. I am using PHP and I have an 'add.php' page where you would fill in your information and there is a browse button to browse to your image file,
here is the code for the button,
PHP Syntax (Toggle Plain Text)
<td><input type="hidden" name="MAX_FILE_SIZE" value="100000" size="32" /> <input name="userfile" type="file" /></td>
I have another page called 'upload.php' that apparently is the page that processes the file information and places it in the database? (I think this is right?)
Here is the code:
PHP Syntax (Toggle Plain Text)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>uploading</title> </head> <body> <h1>Uploading file</h1> <?php if ($_FILES['userfile']['error'] > 0) { echo 'Problem: '; switch ($_FILES['userfile']['error']) { case1: echo 'File exceeded upload_max_filesize'; break; ->THIS IS LINE 17<- case2: echo 'File exceeded max_filesize'; break; case3: echo 'File only partially uploaded'; break; case4: echo 'No file uploaded'; break; } exit; } if ($_FILES['userfile']['type'] != 'image/gif''image/jpg') { echo 'Problem:image must be .gif or .jpg'; exit; } $upfile= '/uploads/'.$_FILES['userfile']['name']; if (is_uploaded_file($_FILES['userfile']['tmp_name'])) if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $upfile)) { echo 'Problem: Could not move file to destination directory'; exit; } } else { echo 'Problem: Possible file upload attack. Filename: '; echo $_FILES['userfile']['name']; exit; } echo 'File uploaded successfully<br><br>'; $fp = fopen($upfile, 'r'); $contents = fread ($fp, filesize ($upfile)); fclose ($fp); $contents = strip_tags($contents); $fp = fopen($upfile, 'w'); fwrite($fp, $contents); fclose($fp); echo 'Preview of uploaded images:<br><br>'; echo $contents; echo '<br><br>'; ?> </body> </html>
And I am wondering if this is even the right way about uploading images.
Incase it is important the information in the data base for the image field is:
Field:thumb1
Type:mediumblob
Attributes:binary
Null:no
Thanks for your help, I feel like this php sql stuff will never make sense.
Cheers!
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Solved Threads: 0
HI thanks,
but that didn't work, I tried it both ways and now my error is:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\helen\upload.php on line 29
Line 29 is:
Is this in your opinions the way to upload image files using a browse button?
I appreciate your time so far, please don't leave me yet!!!
Thanks
but that didn't work, I tried it both ways and now my error is:
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\wamp\www\helen\upload.php on line 29
Line 29 is:
PHP Syntax (Toggle Plain Text)
if ($_FILES['userfile']['type'] != 'image/gif''image/jpg')
Is this in your opinions the way to upload image files using a browse button?
I appreciate your time so far, please don't leave me yet!!!
Thanks
•
•
Join Date: Sep 2006
Posts: 13
Reputation:
Solved Threads: 1
Your switch problem is fixed.
You just have a bug online 29
trie
You just have a bug online 29
trie
PHP Syntax (Toggle Plain Text)
if(strpos('*image/gif image/jpg', $Files[' file1']['type'])) {
•
•
Join Date: Sep 2007
Posts: 3
Reputation:
Solved Threads: 0
Thanks but it hasn't worked so far,
Here are the new error messages:
At least I am getting the uploading file message?
Any further help is still greatly appreciated.
Here are the new error messages:
PHP Syntax (Toggle Plain Text)
Uploading file Warning: move_uploaded_file(/uploads/Lake View.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in C:\wamp\www\helen\upload.php on line 39 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'c:/wamp/tmp\php24A.tmp' to '/uploads/Lake View.jpg' in C:\wamp\www\helen\upload.php on line 39 Problem: Could not move file to destination directory
At least I am getting the uploading file message?
Any further help is still greatly appreciated.
![]() |
Similar Threads
- Parse error: syntax error, unexpected T_STRING in c:/.......... (PHP)
- parse error, unexpected T_STRING in (PHP)
- Parse error: parse error, unexpected T_STRING on line 12 (PHP)
- parse error (PHP)
- Please Help! parse error, unexpected T_STRING (PHP)
- Parse error: parse error, unexpected T_STRING (PHP)
- PHP Parse error: parse error, unexpected T_STRING (PHP)
- Parse error: parse error, unexpected T_STRING in /home/thei2k9/public_html/includes/f (PHP)
Other Threads in the PHP Forum
- Previous Thread: Need help!! Error message :Parse error T_String...
- Next Thread: how to capture data from variable after redirect to another page
| Thread Tools | Search this Thread |
apache api array autocomplete beginner binary body broken cakephp class cms code cron curl database dataentry date date/time display duplicates dynamic ebooks email emptydisplayvalue error execute explodefunction file firstoptioninphpdroplist folder form forms function functions google href htaccess html image include ip javasciptvalidation javascript joomla keywords limit link list login matching mediawiki menu msqli_multi_query multiple mycodeisbad mysql navigation number oop parameter paypal pdf php phpincludeissue query random recourse recursive regex script search seo server sessions shot source sp space speed sql static subdomain subscription system table tag tutorial tutorials update upload url validator variable vbulletin video web webdesign white xml youtube





