luca2020
Member
Registered: 26th May 02
Location: Maidstone, Kent
User status: Offline
|
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
|
aint got a clue sorry!
|
luca2020
Member
Registered: 26th May 02
Location: Maidstone, Kent
User status: Offline
|
lol no worries
|
Ian
Site Administrator
Registered: 28th Aug 99
Location: Liverpool
User status: Offline
|
Line 8 is a blank line?
|
ed
Member
Registered: 10th Sep 03
User status: Offline
|
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
|
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
Registered: 21st Apr 00
User status: Offline
|
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
|
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
Registered: 21st Apr 00
User status: Offline
|
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
|
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
Registered: 21st Apr 00
User status: Offline
|
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
Registered: 21st Apr 00
User status: Offline
|
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
|
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
Registered: 21st Apr 00
User status: Offline
|
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
|