Jump to content

Help php form submission


Go to solution Solved by requinix,

Recommended Posts

 

<?php

if ($_FILES["file"]["error"] > 0)

  {

  echo "Error: " . $_FILES["file"]["error"] . "<br>";

  }

else

  {

  echo "Thank You For Your Submission, Please Come To Our Next Discssuion To Recieve Your Answer" . $_FILES["file"]["name"] . "<br>";

  }

 

 

 

 

 

$temp = explode(".", $_FILES["file"]["name"]);

$extension = end($temp);

  {

  if ($_FILES["file"]["error"] > 0)

    {

    echo "Return Code: " . $_FILES["file"]["error"] . "<br>";

    }

  else

    {

    echo "Upload: " . $_FILES["file"]["name"] . "<br>";

    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

 

    if (file_exists("upload/" . $_FILES["file"]["name"]))

      {

      echo $_FILES["file"]["name"] . " already exists. ";

      }

    else

      {

      move_uploaded_file($_FILES["file"]["tmp_name"],

      "upload/" . $_FILES["file"]["name"]);

      echo "Stored in: " . "upload" . $_FILES["file"]["name"];

      }

    }

    <?php

 

 

 

 

 

 

i keep getting an error on my closing php

"PHP: Parse error: parse error  on line 39"
Link to comment
https://forums.phpfreaks.com/topic/282448-help-php-form-submission/
Share on other sites

When you say "the error" it makes it sound like you're saying you get the exact same error message but on a different line. That is not the case.

 

Unexpected end generally means that you have a { somewhere that isn't closed with a }. Can you find where it is? Does it belong there?

You're still getting a parse error. Is it still an "unexpected

 

So let's try this over again:

1. What is the exact and entire error message?

2. What is your current code? Don't forget about the

 tags I mentioned before.

Sorry im still new to php

<?php
if ($_FILES["file"]["error"] > 0)
  {
  echo "Error: " . $_FILES["file"]["error"] . "<br>";
  }
else
  {
  echo "Thank You For Your Submission, Please Come To Our Next Discssuion To Recieve Your Answer" . $_FILES["file"]["name"] . "<br>";
  }





$temp = explode(".", $_FILES["file"]["name"]);
$extension = end($temp);
  {
  if ($_FILES["file"]["error"] > 0)
    {
    echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
    }
  else
    {
    echo "Upload: " . $_FILES["file"]["name"] . "<br>";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

    if (file_exists("upload/" . $_FILES["file"]["name"]))
      {
      echo $_FILES["file"]["name"] . " already exists. ";
      }
    else
      {
      move_uploaded_file($_FILES["file"]["tmp_name"],
      "upload/" . $_FILES["file"]["name"]);
      echo "Stored in: " . "upload" . $_FILES["file"]["name"];
      }
    }

"PHP: Parse error: parse error  on line 38"

 

The curly braces { and }  do not match up. This could be what is causing the parse error.

 

The brace is see that doesn't matchup is highlighted bellow:

$extension = end($temp);
  { <--- THIS DOES NOT MATCH UP WITH A }
  if ($_FILES["file"]["error"] > 0)

That could be the issue.

 

A good tip to making sure the braces matches up is to always indent your code example

for(someting)
{
	if (condition)
	{
		// do something
	}
	else
	{
		if (condition)
		{
			// true
		}
		else
		{
			// false
		}
	}
}

Notice how each opening { and closing } brace all match up. It makes the code more easier to read and identify an issues like this.

Edited by Ch0cu3r
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.