Posted by windandwaves on 09/04/05 01:15
monomaniac21 wrote:
> Hi i'm trying to write a piece of code which writes the message on
> screen "access denied" telling the user he can't access this page
> without logging in and then offering a hyperlink to the login page.
>
> Like this:
>
> if ($queryrows)
> {
> echo("Welcome to the birthdays page");
> }
> else
> {
> echo("Access denied<br>");
> echo("<a href="index.php">click here to access the login page</a>");
> }
>
> //this code works perfect until I type in the line with the hyperlink
> ( beginning echo("<a href...)). PHP won't accept this code.
>
> My question is how can i insert a hyperlink (or equivalent link) to
> another page in the above if...else statement?
I always use single quotes first. Having a rule like that make it easy.
Often you will have html between your quotes (e.g. $s = '<a
href="..."></a>';). In HTML, you use double-quotes most of time, so it
works out perfectly. Then when you have the occasional javascript line, use
the escape character \
e.g.
$s = '
<a href="..." onmouseover="rollover(\'image.jpg\')"></a>';
Easy.
BTW, I dont think you need the brackets wtih echo
try
echo 'hello world';
- Nicolaas
[Back to original message]
|