Jump to content


linking in php


8 replies to this topic

#1 Spyder

    Jedi In Training

  • Members
  • PipPip
  • 438 posts
  • Gender:Male
  • Location:London, UK

Posted 12 November 2005 - 08:39 AM

I tried using an html link in my php but it comes up with an error:

my code is:

echo "Welcome $username." <a href="index.php"> $username </a>;
if(!empty($_SESSION['username'])){
echo " ";
}else{
echo " You do not appear to be logged in.";
}
?>
            You have <b><u>0</b></u> new messages, total 36</font></td>
              </tr>


#2 saferwaters

    Jedi In Training

  • Members
  • PipPip
  • 390 posts

Posted 12 November 2005 - 09:07 AM

Try:
echo "Welcome, $username. - <a href=\"index.php\">Home</a>";
if(!$_SESSION['username']){
echo "You aren't logged in";
}else{
echo "You have <b><u>0</b></u> new messages, total 36";
}
?>
           </td>
             </tr>


#3 c.designs

    Young Padawan

  • Members
  • Pip
  • 128 posts

Posted 12 November 2005 - 09:59 AM

When you have something like echo("...."); with the double quotes you need to put \" for value stuff (links, etc...). But if you use single ones like echo('.....'); you don't have to use \".

#4 Av-

    I Feel Left Out

  • Members
  • PipPipPipPip
  • 1,971 posts
  • Gender:Male
  • Location:10 ft. below sea level

Posted 12 November 2005 - 10:12 AM

backslash your quotes and it'll work

#5 HaloprO

    Requires Armed Escort

  • Members
  • PipPip
  • 310 posts
  • Gender:Male
  • Location:California, USA

Posted 12 November 2005 - 12:16 PM

Yes that, or use single quotes

#6 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 12 November 2005 - 12:41 PM

What darth had was just fine.
And the problem wasn't that he didn't escape the quotes in the <a>, it's that he put a quote before that, and it shouldn't have been there

Quote

echo "Welcome $username." <a href="index.php"> $username </a>;
And even though this was a simple problem, could you please provide an error report next time spyder?

#7 Spyder

    Jedi In Training

  • Members
  • PipPip
  • 438 posts
  • Gender:Male
  • Location:London, UK

Posted 12 November 2005 - 02:33 PM

kk thanks i will do next time rc69 if iu remember it said an expected T_string

#8 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 12 November 2005 - 03:26 PM

Check your post, it doesn't say anything, unless i'm blind ;)

#9 Spyder

    Jedi In Training

  • Members
  • PipPip
  • 438 posts
  • Gender:Male
  • Location:London, UK

Posted 12 November 2005 - 04:31 PM

lol, it does





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users