Page 1 of 1

Newbie begginer Question

Posted: Mon Oct 28, 2002 5:00 pm
by friendlygiraffe
Hello,

i'm completely new to PHP, so excuse me if this is a stupid question.

After I uploaded a simple php info script, which displays that my server has PHP 4 installed on it, i've been uploading example PHP scripts on my domian, but every time it comes up with the same error:

Parse error: parse error in mydomain/php/test.php on line 1

Am i doing something wrong??

Thanks in advance

Posted: Mon Oct 28, 2002 5:06 pm
by volka
can you post one of those first lines? (maybe some more or even a complete script if not too long) ;)

Posted: Mon Oct 28, 2002 5:08 pm
by m3mn0n
line 1 eh? that's usually just "<?" or "<html>"

so i don't know how it could be a parse error...

But who knows until we see 8)

Posted: Mon Oct 28, 2002 5:20 pm
by friendlygiraffe
Hi,

This is the html:

<form action="upload.php" method="post" ENCTYPE="multipart/form-data">
   <input type="file" size=40 name="file"><br>
   <input type="hidden" name="MAX_FILE_SIZE" value="100000">
   <input type="submit" value="upload">
   </form>

This is the php:

<?
        if ($file == "none") {
            print "You must specify a file to upload";
        }
        else {
        copy($file,http://www.falmouthphotos.co.uk/php/uploads);
        unlink($file);
        }
    ?>



Thanks

some possible issues

Posted: Mon Oct 28, 2002 5:56 pm
by phpScott
I can see several reasons why the script could be dieing but not on line one.
Try this.

Code: Select all

&lt;?php

        if ($file == "") {
            print "You must specify a file to upload";
        }
        else {
        $upLoadDir="http://www.falmouthphotos.co.uk/php/uploads";
        copy($file,$upLoadDir);
        unlink($file);
        }
 ?&gt;
part of the problem was that you where trying to use a string without quotes around it. The url line was being read in but it either needed to be quoted or placed in a seperate variable such as I have done.

phpScott

Posted: Mon Oct 28, 2002 6:14 pm
by friendlygiraffe
oops - Thanks for that. i've added your script, but it still comes up with same error...

Posted: Mon Oct 28, 2002 6:30 pm
by volka
and you're sure that you do not see a somehow cached page?
try another (a new) filename for the script ;)

Posted: Mon Oct 28, 2002 6:38 pm
by friendlygiraffe
It's definately not cached - I've tried numerous scripts too:

Same error for all of them, maybe php is not installed correctly??

http://www.falmouthphotos.co.uk/php/calculater/

does it work for you guys? - Thanks for your time

Posted: Mon Oct 28, 2002 6:45 pm
by volka
Parse error: parse error in /WebSites/thestoryworks/falmouthphotos.co.uk/php/calculater/calculater.php3 on line 1
:(
something is trying to handle it but fails.
why has it .php3 as extension? shouldn't matter but.....

Posted: Mon Oct 28, 2002 6:51 pm
by friendlygiraffe
It says it has PHP Version 4.0.4pl1 on it. I dunno, I'll speak with my domain people.

Cheers

Posted: Mon Oct 28, 2002 9:53 pm
by hob_goblin
friendlygiraffe wrote:It says it has PHP Version 4.0.4pl1 on it. I dunno, I'll speak with my domain people.

Cheers
php4?

why do you name your files php3 then?

Posted: Tue Oct 29, 2002 1:36 am
by volka
hob_goblin, you're reading the last post only, don't you? ;)

Posted: Tue Oct 29, 2002 1:41 am
by Takuma
CAn we see ALL the code of test.php

Posted: Tue Oct 29, 2002 1:47 am
by volka
if the script is a bigger one and php source code highlighting is enabled at your server a link to the .phps file would be great

Posted: Tue Oct 29, 2002 3:20 am
by friendlygiraffe
It's just a sample script I got off evilWalrus, i've taken the '3' off, but it's still the same:

Html:

<form action="calculater.php" method="post">
<center><input type="text" name="num">&nbsp;&nbsp;&nbsp;<select name="by"><option value="add">Add<option value="minus">Minus<option value="times">Multiply<option value="divide">Divide</select>&nbsp;&nbsp;&nbsp;<input type="text" name="num2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="Calculate"></center>
</form>

php:

<?

 if($by == "add"){
  echo $num   $num2;
 } elseif($by == "minus"){
  echo $num - $num2;
 } elseif($by == "times"){
  echo $num * $num2;
 } elseif($by == "divide"){
  echo $num / $num2;
 }

?>

Thanks