Jump to content

Whats Wrong With This


Mod-Jay

Recommended Posts

Cant Figure Out Whats Wrong With it..

Code:

			<?php
if(isset($_SESSION['user']))
{
$bb = mysql_query("SELECT * FROM main WHERE id=". $_SESSION['id']) or die ("An error has occured: " . mysql_error());
while($n=mysql_fetch_array($bb)) 
{
?>
                            <div class='cs_article'>
                            	
                                <div class='left'>
                                    <h2>User Control Panel</h2>
                                    <p><a href="usercp.php">User CP</a><?php 
								if($n['rights'] == 1)
								{
								echo ", <a href="modcp.php">Mod CP</a>";
								}?>
								<?php
								if($n['rights'] == 2)
								{
								echo ", <a href="aa/">Admin CP</a>";
								}?>
                                    
                                    <div class='button'><a href='usercp.php'>Read more</a></div>
                               	</div>
                                <div class='right'>
							<h1>User CP</h1>
							</div>
                                                                
                            </div>
<?php
}}
?>

 

What its doing: Mod-Justin Compared to Mod-Justin

Link to comment
https://forums.phpfreaks.com/topic/212527-whats-wrong-with-this/
Share on other sites

You should be get errors when you run this script. The errors will tell you where the problem is. Look at this line:

echo ", <a href="modcp.php">Mod CP</a>";

You are opening a string with quotes, then inside the string you are using the quotes again. This is a no-no, because PHP thinks you are ending the string, and so it throws an error. You need to either escape the quotes, or use single quotes on the inside or outside.

echo ", <a href=\"modcp.php\">Mod CP</a>";

or

echo ", <a href='modcp.php'>Mod CP</a>";

or

echo ', <a href="modcp.php">Mod CP</a>';

You do the same thing a few lines down. You really need to look at your errors and check the lines out, then do a quick search on Google for the error. Generally these syntax errors are very easy to fix.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.