Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code Check pls

Status
Not open for further replies.

martinb7

Programmer
Joined
Jan 5, 2003
Messages
235
Location
GB
Hi, I have this code that was working fine yesterday and now it comes up with a parse error:


Parse error: parse error in /home/hph/public_html/b/mjb3000/members/main.php on line 218



//code

Code:
<?php
session_start();

$IsMember = false;

if(isset($_SESSION['username'])){

$DB = mysql_connect(&quot;$host&quot;, &quot;$user&quot;, &quot;$pass&quot;);
mysql_select_db(&quot;$db&quot;, $DB);

$query = mysql_query(&quot;SELECT * FROM members WHERE username = '&quot;.$_SESSION['username'].&quot;'&quot;);

$result = mysql_fetch_row($query);

if($result){
$IsMember = true;
}
}

$conn=@mysql_connect(&quot;$host&quot;, &quot;$user&quot;, &quot;$pass&quot;)
		 or die(&quot;Could not connect&quot;);

#select the specified database
$rs = @mysql_select_db(&quot;$db&quot;, $conn) 
		or die(&quot;Could not select database&quot;);
 
#create the query 

$query = mysql_query(&quot;SELECT * FROM members WHERE username = '&quot;.$_SESSION['username'].&quot;'&quot;);


?>

<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<link href=&quot;../site.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;>
</head>

<body topmargin=&quot;0&quot; leftmargin=&quot;0&quot;>
<?php
	
	while ($row = mysql_fetch_array($query) )
{ 
?>
<table width=&quot;500&quot;  border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
  <!--DWLayoutTable-->
  <tr> 
    <td width=&quot;500&quot; height=&quot;19&quot; valign=&quot;top&quot; class=&quot;site&quot;>
<div align=&quot;center&quot;>
	<?php echo(&quot;Welcome &quot;.$row[&quot;username&quot;].&quot; Your user level is &quot;.$row[&quot;rights&quot;]); ?>

</div></td>
  </tr>
  <tr> 
    <td height=&quot;128&quot; valign=&quot;top&quot; class=&quot;site&quot;>
<div align=&quot;center&quot;><br><b><a href=&quot;../logout.php&quot; target=&quot;content&quot;>Logout</a></b><br><br>
        <u><strong>.:Control Panel:.</strong></u><br><br>
        <?php 
			$num = $row[&quot;rights&quot;];
			
			switch($num)
			{
				case 1 : echo(&quot;Case 1 code							&quot;); break;
				
				case 2 : echo(&quot;Case 2 code
        &quot;); break;
								
				case 3 : echo(&quot;Case 3 code
        &quot;); break;

<u><b>.:Your Control Panel:.</b></u>
									<br>Change Password
									<br>Change Change Email Address
								
								&quot;); break;
			}
			?>
		
		</div></td>
  </tr>
</table>
</body>
</html> <-- problem line!!

It says </html> is the problem??

Any Ideas

Thnx

Martin
 
after your case statement you go straight back into html without a ?>, there's your problem.
 
Can you edit the code for me please because I can't see where you mean sorry.

Thnx

Martin
 
&quot;); break;

<u><b>.:Your Control Panel:.</b></u>
<br>Change Password
<br>Change Change Email Address


&quot;); break;
}
?>

</div>


The section in red is html in the php section, it looks like you're missing a case (you've got the end bit, but not the start)
 
The bit in red is meant to be part of case 3. I have tryed it and it still comes up with an error??

Any other ideas??

Thnx

Martin
 
Look at your code, case 3 ends before that. Case 3 has stopped, ended, done all it's going to do.
 
I still cant get it to work!! I checked the code and cant find a problem with it

What to do???

Thnx Martin
 
Look, minus your insane indenting, you have:

case 3 : echo(&quot;Case 3 code&quot;); break;

<u><b>.:Your Control Panel:.</b></u>
<br>Change Password
<br>Change Change Email Address&quot;); break;


When it gets to the bit in red, case 3 has finished. After that you've gone straight into html, you can't do that.

What you want is probably

case 3 : echo(&quot;Case 3 code&quot;); break;

case 4 : echo(&quot;<u><b>.:Your Control Panel:.</b></u>
<br>Change Password
<br>Change Change Email Address&quot;); break;


Got it yet?
 
I figured it out!!

I had a missing &quot;}&quot; in the code, when i put that in it all worked!!

All i need to do now is fix the login page...

Thnx for your help

Martin
 
You should probably sort out your indenting, it makes tracking problems down a lot easier
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top