AHH MY CODE IS MESSED UP HELP!

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

I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

AHH MY CODE IS MESSED UP HELP!

Post by I3lade »

My code is:

Code: Select all

<?php
session_start(); 
if($logged==1)&#123; 
?> 

<? 
mysql_connect("localhost","bladegames", "*****"); 
mysql_select_db("bladegames");
echo "<table>
<tr><td>Number</td><td>Username</td><td>Email</td></tr>
";
$query = mysql_query("SELECT * FROM members ORDER BY id");
while($row=mysql_fetch_array($query))
&#123;
echo "<tr><td>$row&#1111;id]</td><td>$row 
<a href="lookup.php?id=<?=row->id>" target="right"> $row &#1111;login] </a></td><td>
$row&#1111;email] </td></tr>";
&#125;else&#123; 
printf("Your not logged in, plz login again");  
&#125;
?>
Whats wrong? i keep getting erros please help!!!
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

Someone anyone?
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

what errors are you getting?

is $logged supposed to be a session variable? if so it should be $_SESSION['logged']
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

Im getting some errors with the }else{ dont know why, it says prase error to
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I reformated your code a bit, so you'll the error more clearly

Code: Select all

<?php
session_start();
if($logged==1) {
	mysql_connect("localhost","bladegames", "*****");
	mysql_select_db("bladegames");
	echo "---some output---";
	$query = mysql_query("SELECT * FROM members ORDER BY id");
	while($row=mysql_fetch_array($query))
	{
		echo "---some output---";
	}else{
		printf("Your not logged in, plz login again"); 
	}
?>
Last edited by volka on Thu Jun 05, 2003 2:56 am, edited 1 time in total.
User avatar
r337ard
Forum Commoner
Posts: 29
Joined: Tue Apr 15, 2003 6:14 am
Contact:

Post by r337ard »

looks like your missing semicolon at the end of that statement in my amature opintion.

Code: Select all

}else{
printf("Your not logged in, plz login again"); 
};
?>
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

volka wrote:I reformated your code a bit, so you'll the error more clearly

Code: Select all

<?php
session_start();
if($logged==1) {
	mysql_connect("localhost","bladegames", "*****");
	mysql_select_db("bladegames");
	echo "---some output---";
	$query = mysql_query("SELECT * FROM members ORDER BY id");
	while($row=mysql_fetch_array($query))
	{
		echo "---some output---";
	}else{
		printf("Your not logged in, plz login again"); 
	}
?>
Hint mode: it's a }
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

So what do i add?
Galahad
Forum Contributor
Posts: 111
Joined: Fri Jun 14, 2002 5:50 pm

Post by Galahad »

Come on. Look at the {}'s. Volka's indenting shows what matches up with what pretty well.
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

use the force
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

Ok ill try, im really new to php like 1 week lol thats why im havin so much problems with simple code, so its going to be hard for me to see where the error is :(
+EIDIT+
Oh i think i see it, is it a { before echo?
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

Can someone help me out, which {} i cant tell im new to this
User avatar
delorian
Forum Contributor
Posts: 223
Joined: Sun May 04, 2003 5:20 pm
Location: Olsztyn, Poland

Post by delorian »

Count { and then } you have one missing. :D

BTW: Like JPlush76 said "use the force" :lol:

OK, and I will give you the clue, the one that is missing fits perfect before "else" clause
I3lade
Forum Commoner
Posts: 70
Joined: Wed Jun 04, 2003 4:20 pm

Post by I3lade »

I finnaly got it ! Thanks everyone for your help!
JPlush76
Forum Regular
Posts: 819
Joined: Thu Aug 01, 2002 5:42 pm
Location: Los Angeles, CA
Contact:

Post by JPlush76 »

you're welcome :)

I'm glad "the force" was able to help you
Post Reply