Simple Question - Simple Answer???

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
mjjk91
-


Joined: 03 Feb 2004
Posts: 75
Location: Australia

PostPosted: Wed May 26, 2004 7:35 am    Post subject: Simple Question - Simple Answer??? Reply with quote

G'Day All,

This could well be the easiest question ever, but it is giving me no end of problems, as i have tried SOOOOOOO many combinations. This code is straightout of a textbook, and everytime i try to run it, im getting an Error 200 message, which i know is because of a syntax error in my code. Im having problems closing the IF statement. As you can see, i need to close the IF statement at the end, but am not sure how. It shows:

<?
}

But this has proven to be incorrect. I would have thought it was:

<?php
}
?>

But when i try this, it is also incorrect. I know the rest of the code works, so how do i close the IF statement at the end? Here is the entire script:

-------------------------------------------------------------------------------------

<?php
if($_SESSION['admin_access'] == true){
?>
<table width="160" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#000066">
<td width="5" height="10"><font color="#FFFFFF">&nbsp;</font></td>
<td width="150"><div align="center"><font color="#FFFFFF" size"2"
face="Verdana, Arial, Helvetica, sans-serif"><strong>Admin
Links</strong></font></div></td>
<td width="5">&nbsp;</td>
</tr>
<tr>
<td height="5">&nbsp;</td>
<td align="left" valign="top">
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<a href="/admin/newscategory.php">Create News Article
Categories</a></font></p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <a
href="/admin/mod_news_category.php">Modify/Delete
News Article Categories</a></font></p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a
href="/admin/news_insert.php">Add
News Article</a></font></p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a
href="/admin/mod_news_article.php">Modify/Delete
News Article</a></font></p>
<p>&nbsp;</p>
</td>
<td>&nbsp;</td>
</tr>
</table>
<hr size="1">
<?
}

-------------------------------------------------------------------------------------

Cheers Everyone.

Mick Koch
Back to top View user's profile Send private message Visit poster's website MSN Messenger
eznetlinks
-


Joined: 27 Sep 2003
Posts: 144

PostPosted: Wed May 26, 2004 1:22 pm    Post subject: Reply with quote

The closing php tag cannot be used before the if statement is executed . Therefore the html must be between { and }.
example:
<?
if(statement)
{
echo '<html>';
}
?>

<?php
if($_SESSION['admin_access'] == true){
echo'<table width="160" border="0" cellspacing="0" cellpadding="0">
<tr bgcolor="#000066">
<td width="5" height="10"><font color="#FFFFFF">&nbsp;</font></td>
<td width="150"><div align="center"><font color="#FFFFFF" size"2"
face="Verdana, Arial, Helvetica, sans-serif"><strong>Admin
Links</strong></font></div></td>
<td width="5">&nbsp;</td>
</tr>
<tr>
<td height="5">&nbsp;</td>
<td align="left" valign="top">
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif">
<a href="/admin/newscategory.php">Create News Article
Categories</a></font></p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> <a
href="/admin/mod_news_category.php">Modify/Delete
News Article Categories</a></font></p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a
href="/admin/news_insert.php">Add
News Article</a></font></p>
<p><font size="2" face="Verdana, Arial, Helvetica, sans-serif"><a
href="/admin/mod_news_article.php">Modify/Delete
News Article</a></font></p>
<p>&nbsp;</p>
</td>
<td>&nbsp;</td>
</tr>
</table>
<hr size="1">';
}
?>
Back to top View user's profile Send private message Visit poster's website
Motionmaster
-


Joined: 21 Mar 2003
Posts: 5

PostPosted: Thu May 27, 2004 2:30 pm    Post subject: Reply with quote

Well, it is possible.

<? if(() == true) { ?>
<html>
<? } ?>

Must work.
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group