corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » PHP People


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author PHP People
luca2020
Member

Registered: 26th May 02
Location: Maidstone, Kent
User status: Offline
21st Mar 04 at 00:11   View User's Profile U2U Member Reply With Quote

need alittle help, really basic stuff, but dont understand why im getting this error on line 8:

<html>
<head> <title> Arrays 1 </title>
</head>

<body>

<?php

// 1st method

$array_1[0] = 56;
$array_1[1] = 74;
$array_1[2] = 52;
$array_1[3] = 90;
$array_1[4] = 88;

// 2nd method

$array_2 = array(56, 74, 52, 90, 88);

// 3rd method

$array_3[] = 56;
$array_3[] = 74;
$array_3[] = 52;
$array_3[] = 90;
$array_3[] = 88;

// Display each array

echo '<H1> The content of $array_1 is: </H1>';

for ($i = 0;$i <count ($array_1); $i++
{
echo "array_1 [$i]= ".$array_1 [$i}. "<BR>";
}

echo '<H1> The content of $array_2 is: </H1>';

for ($i = 0;$i <count ($array_2); $i++
{
echo "array_2 [$i]= ".$array_2 [$i}. "<BR>";
}

echo '<H1> The content of $array_3 is: </H1>';

for ($i = 0;$i <count ($array_3); $i++
{
echo "array_3 [$i]= ".$array_3 [$i}. "<BR>";
}

?>

</body>
</html>

any help?
si_reading
Member

Registered: 5th Apr 03
Location: Macclesfield, Cheshire
User status: Offline
21st Mar 04 at 00:25   View User's Profile U2U Member Reply With Quote

aint got a clue sorry!
luca2020
Member

Registered: 26th May 02
Location: Maidstone, Kent
User status: Offline
21st Mar 04 at 00:51   View User's Profile U2U Member Reply With Quote

lol no worries
Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Online
21st Mar 04 at 00:52   View Garage View User's Profile U2U Member Reply With Quote

Line 8 is a blank line?
ed
Member

Registered: 10th Sep 03
User status: Offline
21st Mar 04 at 00:55   View User's Profile U2U Member Reply With Quote

Doesn't the PHP scripting engine ignore all the blank lines and comments though. The same happens with HTML in a wheb browser, but you can still see the comments...
luca2020
Member

Registered: 26th May 02
Location: Maidstone, Kent
User status: Offline
21st Mar 04 at 01:08   View User's Profile U2U Member Reply With Quote

yer i know line 8 is blank, thats the porblem i cant understand

this is the error message:

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in W:\www\B144_Lab\Lab_5\Arrays_2.php on line 8

Parse error: parse error, unexpected T_STRING in W:\www\B144_Lab\Lab_5\Arrays_2.php on line 8


[Edited on 21-03-2004 by luca2020]
Tim
Site Administrator

Avatar

Registered: 21st Apr 00
User status: Offline
21st Mar 04 at 01:13   View Garage View User's Profile U2U Member Reply With Quote

Um, error isn't line 8 (just ran it though php parser)... You have the following errors...

On all three for loops you're missing a final ')'...

code:
for ($i = 0;$i <count ($array_1); $i++


...should be...

code:
for ($i = 0;$i <count ($array_1); $i++)


...and...

When you use the array in the code, you've got [} around the array index instead of []...

code:
echo "array_1 [$i]= ".$array_1 [$i}. "<BR>";


..should be...

code:
echo "array_1 [$i]= ".$array_1 [$i]. "<BR>";




[Edited on 21-03-2004 by Tim]
luca2020
Member

Registered: 26th May 02
Location: Maidstone, Kent
User status: Offline
21st Mar 04 at 01:21   View User's Profile U2U Member Reply With Quote

Tim u a legend, but still comes up with the same error

could u run the following script to see if it works again:

<html>
<head> <title> Arrays 2 </title>
</head>

<body>

<?php

// 1st method

$array_1[0] = 56;
$array_1[1] = 74;
$array_1[2] = 52;
$array_1[3] = 90;
$array_1[4] = 88;

// 2nd method

$array_2 = array(56, 74, 52, 90, 88);

// 3rd method

$array_3[] = 56;
$array_3[] = 74;
$array_3[] = 52;
$array_3[] = 90;
$array_3[] = 88;

// Display each array

echo '<H1> The content of $array_1 is: </H1>';

for ($i = 0;$i <count ($array_1); $i++)
{
echo "array_1 [$i]= ".$array_1 [$i]. "<BR>";
}

echo '<H1> The content of $array_2 is: </H1>';

for ($i = 0;$i <count ($array_2); $i++)
{
echo "array_2 [$i]= ".$array_2 [$i]. "<BR>";
}

echo '<H1> The content of $array_3 is: </H1>';

for ($i = 0;$i <count ($array_3); $i++)
{
echo "array_3 [$i]= ".$array_3 [$i]. "<BR>";
}

?>

</body>
</html>
Tim
Site Administrator

Avatar

Registered: 21st Apr 00
User status: Offline
21st Mar 04 at 01:22   View Garage View User's Profile U2U Member Reply With Quote

Yup

http://www.corsasport.co.uk/timtim.php

(I just copy pasted your last post ^--)
luca2020
Member

Registered: 26th May 02
Location: Maidstone, Kent
User status: Offline
21st Mar 04 at 01:23   View User's Profile U2U Member Reply With Quote

how anoying, my server on my computer wont run it, must have a bug or something

grrrrrr thats been pissing me off all night! lol

cheers tim, mucho appreachiatedo
Tim
Site Administrator

Avatar

Registered: 21st Apr 00
User status: Offline
21st Mar 04 at 01:28   View Garage View User's Profile U2U Member Reply With Quote

Your code does have spaces in it where convention wouldn't normally put them... like count ($array_1) should just be count($array_1), but I'm positive the parser doesn't mind...

Could be version specific (php version) or the fact you're running it on Windoze
Tim
Site Administrator

Avatar

Registered: 21st Apr 00
User status: Offline
21st Mar 04 at 01:31   View Garage View User's Profile U2U Member Reply With Quote

Oh, and btw... if that's IIS running on your local machine... then try turning magic_quotes_gpc on/off...

If you're ftp'ing the file to a server, make sure you're transferring it in ASCII mode...
luca2020
Member

Registered: 26th May 02
Location: Maidstone, Kent
User status: Offline
21st Mar 04 at 01:34   View User's Profile U2U Member Reply With Quote

ok im now going to headbut a wall, ive just realised what ive been doing wrong

ive been writing the code in notepad, but in Rich Text Doc, instead of just Text Doc, Rich Text Doc has got formatting in and thats whats been screwing everything up

GRRRRRRRRRRRRRRRR

thanx again Tim, if u were a girl id kiss u
Tim
Site Administrator

Avatar

Registered: 21st Apr 00
User status: Offline
21st Mar 04 at 01:37   View Garage View User's Profile U2U Member Reply With Quote

Yeah figured it was a text conversion prob hence the ascii ftp comment... cos there aren't any backslashes in ya file!

Glad tis sorted anyhows

 
New Topic

New Poll

Corsa Sport » Message Board » Off Day » PHP People 23 database queries in 0.0979831 seconds