Newbie begginer Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
friendlygiraffe
Forum Newbie
Posts: 6
Joined: Mon Oct 28, 2002 5:00 pm
Location: UK

Newbie begginer Question

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

can you post one of those first lines? (maybe some more or even a complete script if not too long) ;)
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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)
friendlygiraffe
Forum Newbie
Posts: 6
Joined: Mon Oct 28, 2002 5:00 pm
Location: UK

Post 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
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

some possible issues

Post 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
friendlygiraffe
Forum Newbie
Posts: 6
Joined: Mon Oct 28, 2002 5:00 pm
Location: UK

Post by friendlygiraffe »

oops - Thanks for that. i've added your script, but it still comes up with same error...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

and you're sure that you do not see a somehow cached page?
try another (a new) filename for the script ;)
friendlygiraffe
Forum Newbie
Posts: 6
Joined: Mon Oct 28, 2002 5:00 pm
Location: UK

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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.....
friendlygiraffe
Forum Newbie
Posts: 6
Joined: Mon Oct 28, 2002 5:00 pm
Location: UK

Post by friendlygiraffe »

It says it has PHP Version 4.0.4pl1 on it. I dunno, I'll speak with my domain people.

Cheers
User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

hob_goblin, you're reading the last post only, don't you? ;)
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

CAn we see ALL the code of test.php
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
friendlygiraffe
Forum Newbie
Posts: 6
Joined: Mon Oct 28, 2002 5:00 pm
Location: UK

Post 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
Post Reply