473,811 Members | 2,979 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hyperlinks in PHP anyone?

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?

Sep 3 '05 #1
5 22334
On Sat, 03 Sep 2005 13:59:40 -0700, monomaniac21 wrote:
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.


You may want to prefix the inner quotes with a backslash, like this:

echo("<a href=\"index.ph p\">click here to access the login page</a>");
or, you may want to use single quotes:
echo('<a href="index.php ">click here to access the login page</a>');
--
http://www.mgogala.com

Sep 3 '05 #2
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?


echo('<a href="index.php ">click here to access the login page</a>');
^ ^

Or

echo("<a href=\"index.ph p\">click here to access the login page</a>");

Read up on using quotes in strings...

--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attgl obal.net
=============== ===
Sep 3 '05 #3
monomaniac21 wrote:
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.
The problem is the above line. If you enclose the string in double
quotes you can not use double quotes inside the string without escaping
them because they end the string.

PHP thinks that your string is "<a href=" and expects either a comma and
another string to output or the closing bracket and a semicolon,
according to the echo syntax, but gets index.php">... instead.
My question is how can i insert a hyperlink (or equivalent link) to
another page in the above if...else statement?


You are doing it the right way, basically. You just have to watch how
you enclose strings.

Read the section in the manual, which explains that really well:
http://www.php.net/manual/en/language.types.string.php

Bye!
Sep 3 '05 #4
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="ro llover(\'image. jpg\')"></a>';

Easy.

BTW, I dont think you need the brackets wtih echo

try

echo 'hello world';

- Nicolaas
Sep 3 '05 #5
Thanks guys you have fixed my problem.

Sep 4 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6164
by: scoop_77 | last post by:
I'm looking for some software that would allow me to point to a folder in Windows Explorer, and have it output an html file with hyperlinks to all of the files within that folder and all of the sub-folders. I have many folders with several dozen files and sub-folders and would like to avoid hand-coding all of the hyperlinks. Does anyone know if such software exists? Thanks in advance.
2
5837
by: gboissiere | last post by:
Hello 'contentEditable' gurus, The example code below uses contentEditable to let the user edit the <div> element directly in their browser. Works also using designMode for the document. However, if the user edits the <div> by typing: "john@doe.com is listed on the www.yahoo.com webpage" IE 5.5+ automatically detects the email address and the URL and creates those 2 hyperlinks automatically.
6
3967
by: Colleyville Alan | last post by:
I have an application that has an Access table that stores the locations of slides in a Powerpoint file. This used to work fine when there were about 4 files and 200 slides. The database would open all four PPT files at once, and would loop through queriers for ever client and create custom presentations. Now there are 8 files, nearly 500 slides and the computer is bogging down with trying to open them all at once. I know that Access...
5
3784
by: John Warner | last post by:
I have a wierd problem that I can't find any reference to in the knowledge base. I develop simple databases at the company where I work, and many of them are used by hundreds of employees. We all have the same basic computers with the same base image. The problem is, whenever I create a hyperlink object in the database, I'm able to click on it from my PC and it works just fine. All other users click on it and Access just sits there...
0
1311
by: acconrad | last post by:
We're trying to make it such that you can change the color for hyperlinks in RichTextBox controls. Currently VS.NET '03 does not allow one to do this. We tried this --> http://pluralsight.com/wiki/default.aspx/Craig/RichTextBox2.html and it did not work at all. Does anyone know of any RELIABLE programs/code that allow one to edit RichTextBox controls in C# Windows applications (NOT ASP.NET), including editing the color of hyperlinks?...
1
1450
by: Jason L James | last post by:
Hi all, I have datagrid with a column that is to contain hyperlinks to other documents. The is in the columns from a bound data source but I would like to format them as hyperlinks so that I can jump to the correct page when the link is clicked. Does anyone have any ideas about how I could go about doing this?
4
4259
by: Seefor | last post by:
Hi, I want my text hyperlinks to have a dotted border underneath, so I did this which works fine: a, a:link, a:visited, a:hover, a:active { color: #000; text-decoration: none;
1
2380
by: Robin | last post by:
Hello! I'm having trouble with links and hyperlinks in MS Access 2003 - any help would be great! Question 1! The "insert hyperlink" icon opens a browser window, allows the user to browse to the desired file and paste the hyperlink on the form (which obviously remains for on all the records). I am trying to create a
1
3653
by: Janna | last post by:
Hello tech savvy gurus! I hope someone can help me! THE PROBLEM: "Cannot open specified file" when I click on a hyperlink in an Access database when it is located on our server. THE BACKGROUND: I created a folder "Document Library" on my local drive, which contains document sub-folders and the database. For referential integrity, I designed the database with relative hyperlinks (e.g. Folder\File.pdf). The hyperlinks worked perfectly...
1
3816
by: vidhya17 | last post by:
I find that hyperlinks created and active in Microsoft Word are still looking like hyperlinks, but no longer active. That is to say when the Adobe Reader grasping hand mouse-pointer is over the link in the PDF version of the document it doesn't change to a pointing finger, and clicking on the link has no effect. I know it's possible to have active links in PDF documents. Question is: how is it done? Anyone able to help?
0
9724
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10644
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10394
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7665
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6882
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5552
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4336
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3015
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.