Simple Problem...

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
duhasteme
Forum Commoner
Posts: 25
Joined: Fri Jun 29, 2007 4:24 am
Contact:

Simple Problem...

Post by duhasteme »

Hello, I have a small but wierd problem which I am already furstrated with..

Here is the code in the html page..

Code: Select all

<td colspan="8" class="naviaddlinks">
    <p align="right">
    <a href="index.php?file=register">
    <font color="FFFFFF" type="Verdana">Sign up</font></a> <font color="FFFFFF">|</font>
   <font color="FFFFFF">[b]$loginorout[/b]</font> <font color="FFFFFF">|</font> <a href="index.php?file=help" target="_self"><font color="FFFFFF" type="Verdana">Help</font></a>&nbsp;
</td>

And here is the code in the php file which links to $loginorout in the html page.

Code: Select all

if(is_user()){
    $loginorout="<a href=index.php?file=logout>Logout</a>";
}else{
    $loginorout="<a href=index.php?file=login>Login</a>";
}
 
Now look at the page here..

http://www.supepages.com.ng/

You will notice that all the text on the top is white expect the Login text, which I want to change to white.

So I edited the php file a bit to something like this.....

Code: Select all

if(is_user()){
    $loginorout="<a href=index.php?file=logout><font color="FFFFFF" type="Verdana" size="3">Logout</font></a>";
}else{
    $loginorout="<a href=index.php?file=login><font color="FFFFFF" type="Verdana" size="3">Login</font></a>";
}
I thought what I did was write, coz I have just included some bit of html within the html. But when I do that I get an error...

Parse error: syntax error, unexpected T_STRING in /home/super/public_html/mainfile.php on line 34

Line No. 34 is ...

Code: Select all

$loginorout="<a href=index.php?file=logout><font color="FFFFFF" type="Verdana" size="3">Logout</font></a>";
Can anyone help me change that to white ?
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: Simple Problem...

Post by mickeyunderscore »

Code: Select all

$loginorout="<a href=index.php?file=logout><font color="FFFFFF" type="Verdana" size="3">Logout</font></a>";
Your problem here is that you are using " as your string delimiter, but also as a character within your string. You either need to escape the " within the string, or use ' as a delimiter instead:

Code: Select all

$loginorout="<a href=index.php?file=logout><font color=\"FFFFFF\" type=\"Verdana\" size=\"3\">Logout</font></a>";
//or
$loginorout='<a href=index.php?file=logout><font color="FFFFFF" type="Verdana" size="3">Logout</font></a>';
ne0_dev
Forum Newbie
Posts: 3
Joined: Tue Feb 03, 2009 5:27 am

Re: Simple Problem...

Post by ne0_dev »

I think it would make more sense to take the html formatting out of the php code and put it into a separate css file. That way you can assign a css class the a:link and then just edit the css styles to your desired look.

e.g.

Css class would be something like:

Code: Select all

 
.loginorout a:link, a:visited {
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:3pt;
    color:#ffffff;
    text-decoration:underline;
}
.loginorout a:hover {
    font-family:Verdana, Arial, Helvetica, sans-serif;
    font-size:3pt;
    color:#ffffff;
    text-decoration:none;
}
 
php code would be:

Code: Select all

 
 if(is_user()){
     $loginorout="<a class='loginorout' href=index.php?file=logout>Logout</a>";
 }else{
     $loginorout="<a class='loginorout' href=index.php?file=login>Login</a>";
 }
 
duhasteme
Forum Commoner
Posts: 25
Joined: Fri Jun 29, 2007 4:24 am
Contact:

Re: Simple Problem...

Post by duhasteme »

Thanks a lot. I'll try that out. :)
User avatar
Skoalbasher
Forum Contributor
Posts: 147
Joined: Thu Feb 07, 2008 8:09 pm

Re: Simple Problem...

Post by Skoalbasher »

Use CSS.

Edit: Already posted.
Post Reply