PHP Parser Error. Is PHP going crazy??

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
ZeroFear
Forum Newbie
Posts: 14
Joined: Tue Feb 14, 2006 10:47 pm

PHP Parser Error. Is PHP going crazy??

Post 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]
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Line 79 of the PHP code. Check your includes and such.
ZeroFear
Forum Newbie
Posts: 14
Joined: Tue Feb 14, 2006 10:47 pm

Post 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!!!
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

what is on lines 70-90? if the error is there then lets see the code
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post 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
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post 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.
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

I'm pretty sure that he got it working :P
Post Reply