PDA

View Full Version : Beginner Needs Help!


Narz
12-01-2002, 05:06 AM
Hi. I am super new to PHP. Just bought a book on it and am trying to learn today. I know my website is capable of running it due to the success of this test...

http://www.narcity.com/1phpTest/11testph.php

However the other programs I copied from the book (and even got the error-proof source code from) don't work. :mad:

Here's an example one...
------------------------------
<?php
__$start_num_=_1;
__$end_num_=_10;
?>
<HTML>
<HEAD>
<TITLE>A_division_table</TITLE>
</HEAD>
<BODY>
<H2>A_division_table</H2>
<TABLE_BORDER=1>
<?php
__print("<TR>");
__print("<TH>_</TH>");
__for_($count_1_=_$start_num;
_______$count_1_<=_$end_num;
_______$count_1++)
____print("<TH>$count_1</TH>");
__print("</TR>");
__for_($count_1_=_$start_num;
_______$count_1_<=_$end_num;
_______$count_1++)
__{
____print("<TR><TH>$count_1</TH>");
____for_($count_2_=_$start_num;
_________$count_2_<=_$end_num;
_________$count_2++)
______{
________$result_=_$count_1_/_$count_2;
________printf("<TD>%.3f</TD>",
_______________$result);__//_see_Chapter_9
______}
____print("</TR>\n");
__}
?>
</TABLE>
</BODY>
</HTML>
------------------------------
What is the problem here? :confused:

Here is the error messege I get : "Parse error: parse error in /home3/www/narcity/1phpTest/divis.php on line 2"

Thanks alot for your help!
:thumbsup:

By the way, if you are curious what I ideally plan to do with PHP and have any advice for me check out the page of my game (not yet in exsistance) : http://www.narcity.com/WorldConquest/WCMain.html

Thanks again!

- Narz http://www.narcity.com/ZDownloads/Smileys/king.gif

Phip
12-01-2002, 05:46 AM
what is with all the "_"? if those are in your code, that would be your issue...

Narz
12-01-2002, 06:07 AM
No, no, thats not the issue. For some reason when I pasted it here it added the ___ lines, those are just spaces... it just doesn't like the code for some reason.

firepages
12-01-2002, 10:16 AM
I suspect those '_' 's are coming from somewhere and causing some issues ? , I just stripped them and the code ran fine.


<?php
$start_num = 1;
$end_num = 10;
?>
<HTML>
<HEAD>
<TITLE>A division table</TITLE>
</HEAD>
<BODY>
<H2>A division table</H2>
<TABLE BORDER=1>
<?php
print("<TR>");
print("<TH>_</TH>");
for($count_1=$start_num;
$count_1<=$end_num;
$count_1++)
print("<TH>$count_1</TH>");
print("</TR>");
for($count_1=$start_num;
$count_1<=$end_num;
$count_1++)
{
print("<TR><TH>$count_1</TH>");
for($count_2=$start_num;
$count_2<=$end_num;
$count_2++)
{
$result=$count_1/$count_2;
printf("<TD>%.3f</TD>",
$result); //_see_Chapter_9
}
print("</TR>\n");
}
?>
</TABLE>
</BODY>
</HTML>

Narz
12-01-2002, 06:25 PM
I got it to work! :thumbsup: Thanks for your help.

Ökii
12-01-2002, 06:59 PM
Subnote of slight interest:

A large number of members at another forum (not that I go to other forums than this one) have been noticing that copy-pasteing from the forum threads straight into notepad doesn't result in proper spaces in the code - [they look like spaces, just php won't parse them]. A search-replace tend to cure it.