BAH! *RESOLVED*

freekin' unexpected ';' error!

Page 1 of 1

9 Replies - 903 Views - Last Post: 23 November 2008 - 02:16 AM Rate Topic: -----

#1 Andora  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 140
  • Joined: 18-August 08

BAH! *RESOLVED*

Posted 20 November 2008 - 08:28 PM

Quote

Parse error: syntax error, unexpected ';' in C:\wamp\www\index.php on line 32

line 32 is this:
if(move_uploaded_file($_FILES['upload1']['tmp_name'],'../uploads/'.basename($_FILES['upload1']['name']))){$uploads.='<a href="http://localhost/uploads/'.basename($_FILES['upload1']['name'].'" class="upload" target="_blank">'.basename($_FILES['upload1']['name'].'</a>';}


Please help! :(

P.S. I'm not aiming for security here, I just need help killing the error.

This post has been edited by Andora: 20 November 2008 - 09:11 PM


Is This A Good Question/Topic? 0
  • +

Replies To: BAH! *RESOLVED*

#2 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5191
  • View blog
  • Posts: 26,899
  • Joined: 10-May 07

Re: BAH! *RESOLVED*

Posted 20 November 2008 - 08:35 PM

Open : if(move_uploaded_file
Open : ($_FILES['upload1']['tmp_name'],'../uploads/'.basename
Open : ($_FILES['upload1']['name']
Close : )
Close : )
Close : ){$uploads.='<a href="http://localhost/uploads/'.basename
Open : ($_FILES['upload1']['name'].'" class="upload" target="_blank">'.basename
Open : ($_FILES['upload1']['name'].'</a>';}

You've got some parenthesis to close before you can end that statement. Unexpected semi-colon :)
Was This Post Helpful? 0
  • +
  • -

#3 Andora  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 140
  • Joined: 18-August 08

Re: BAH! *RESOLVED*

Posted 20 November 2008 - 08:42 PM

Woot! :bananaman:

And now I have a non-working file uploader! :) Any ideas on how I might fix it?

Clarification: The error is gone, but it still isn't working.

This post has been edited by Andora: 20 November 2008 - 08:45 PM

Was This Post Helpful? 0
  • +
  • -

#4 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5191
  • View blog
  • Posts: 26,899
  • Joined: 10-May 07

Re: BAH! *RESOLVED*

Posted 20 November 2008 - 08:46 PM

Here is a PHP Tutorial that I have used before.
Was This Post Helpful? 0
  • +
  • -

#5 Moonbat  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 36
  • View blog
  • Posts: 424
  • Joined: 30-June 08

Re: BAH! *RESOLVED*

Posted 20 November 2008 - 08:49 PM

I know this isn't related to your question, but I'd seriously suggest breaking up your statement into multiple lines and indenting lines inside of the blocks. It'll make it much more easier for you to debug.

To be honest, I didn't even bother reading your code after seeing it all on one line scrunched up together like that.
Was This Post Helpful? 0
  • +
  • -

#6 no2pencil  Icon User is online

  • Toubabo Koomi
  • member icon

Reputation: 5191
  • View blog
  • Posts: 26,899
  • Joined: 10-May 07

Re: BAH! *RESOLVED*

Posted 20 November 2008 - 08:50 PM

Hrm, hard to read code winds up with problems, go figure ;)
Was This Post Helpful? 0
  • +
  • -

#7 Andora  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 140
  • Joined: 18-August 08

Re: BAH! *RESOLVED*

Posted 20 November 2008 - 09:02 PM

This is just such a reliable code for me! I don't understand it.

And it shouldn't be that hard to read... The part having issues is here:
if(move_uploaded_file($_FILES['uploada']['tmp_name'],basename($_FILES['uploada']['name'])))

here is a previous version that has worked very well for me. I don't see the difference.
if(move_uploaded_file($_FILES['upload']['tmp_name'],$_POST['path'].basename($_FILES['upload']['name'])))


EDIT: oh, wait. Is it necessary to use enctype="multipart/form-data" in the form?
REDIT: un-be-lievable! Such a trivial error! So costly!

It appears to be resolved, thanks so much to everybody that helped. And to all those ragging on my one-line coding style: you are completely right, I just like to skimp on line breaks on well-proven codes, it makes it easier to read the code as a whole. It usually works.

This post has been edited by Andora: 20 November 2008 - 09:11 PM

Was This Post Helpful? 0
  • +
  • -

#8 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: BAH! *RESOLVED*

Posted 21 November 2008 - 01:56 AM

Makes it harder to debug though, if there are issues, as PHP does error reporting by line number. If it's all on one line, it'll give you the error on the one line you have, and make it a real pain.
Was This Post Helpful? 0
  • +
  • -

#9 Andora  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 140
  • Joined: 18-August 08

Re: BAH! *RESOLVED*

Posted 23 November 2008 - 12:30 AM

View PostValek, on 20 Nov, 2008 - 11:56 PM, said:

Makes it harder to debug though, if there are issues, as PHP does error reporting by line number. If it's all on one line, it'll give you the error on the one line you have, and make it a real pain.
I never disputed this. It's just that when you have hundreds of lines of code it is difficult to debug the overall picture, so I condense portions of it into single lines: the upload line, the validation line, the post line, etc... (only when I know that they work).

But I think we are both just repeating the same argument to each other. You have your opinion and I have mine. I'm going to go ahead and use mine. Please get off my back.

This post has been edited by Andora: 23 November 2008 - 12:33 AM

Was This Post Helpful? 0
  • +
  • -

#10 Valek  Icon User is offline

  • The Real Skynet
  • member icon

Reputation: 542
  • View blog
  • Posts: 1,713
  • Joined: 08-November 08

Re: BAH! *RESOLVED*

Posted 23 November 2008 - 02:16 AM

I just made one post, and was not at all being aggressive about it. Personally, I don't care how you do it, it's your script. I was just making a suggestion you can take or leave, nothing more. That's really all this forum is here for, anyway.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1