Page 1 of 1

PHP Parser Error. Is PHP going crazy??

Posted: Sun Aug 27, 2006 10:00 pm
by ZeroFear
Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?php 
		//grab all of the league_ids and names from the database
		$query = "SELECT league_id, league_name FROM league";
		$result = pg_query( $query );
		$num_leagues = pg_numrows( $result );
								
		// build a select box that containes the names of all the different leauges
		echo "<select name='league_id'>";
		for ( $i = 0; $i < $num_leagues; $i++ ) {
				$id = pg_result( $result, $i, "league_id" );
				$name = pg_result( $result, $i, "league_name" );
				echo "<option value='". $id . "'>" . $name . "</option>";
		}
		echo "</select>";
?>
I am getting a "Parse error: parse error, unexpected '}' in /home/btcamp2/public_html/fantasykickoff/v1/register.php on line 79"

First off, there is NO line 79 in my file. The <?php starts on line 159 and the ?> is on line 173. When i remove the echo that is inside the for loop, i dont get that error. Is there something wrong with my echo??


Everah | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Sun Aug 27, 2006 10:07 pm
by RobertGonzalez
Line 79 of the PHP code. Check your includes and such.

Posted: Sun Aug 27, 2006 10:28 pm
by ZeroFear
i know where the error is happening but i dont understand why. If you remove the echo that i have inside that forloop, then the parser error dosnt come up, but if i put it back, it says unexpected }. WTF!!!

Posted: Sun Aug 27, 2006 11:38 pm
by shiznatix
what is on lines 70-90? if the error is there then lets see the code

Posted: Sun Aug 27, 2006 11:48 pm
by RobertGonzalez
Trying changing this line...

Code: Select all

echo "<option value='". $id . "'>" . $name . "</option>";
To this

Code: Select all

echo '<option value="'. $id . '">' . $name . '</option>';
Or to this

Code: Select all

echo "<option value='$id'>$name</option>";
Of the two, I like my first one.

Posted: Mon Aug 28, 2006 1:43 am
by dibyendrah
Tried this

Code: Select all

<?php

                echo "<select name='league_id'>";
                for ( $i = 0; $i < 10; $i++ ) {
                                $id = $i;
                                $name = $i;
                                echo "<option value='". $id . "'>" . $name . "</option>";
                }
                echo "</select>";
?>
and the output was

Code: Select all

X-Powered-By: PHP/5.1.1

Content-type: text/html



<select name='league_id'><option value='0'>0</option><option value='1'>1</option><option value='2'>2</option><option value='3'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option></select>
worked ! no parse error ! tried with zend studio

Cheers,
Dibyendra

Posted: Mon Aug 28, 2006 1:47 am
by Benjamin
Can you please post the complete /home/btcamp2/public_html/fantasykickoff/v1/register.php file and the complete url in your browser window.

Posted: Mon Aug 28, 2006 1:58 am
by mickd
I'm pretty sure that he got it working :P