Forum Moderators: coopster
I have one hardcoded variable which is easy to pass, but the second variable is causing problems, I think my syntax is wrong. I am using Postgres, which has slight differences to MySQL.
The following line in my code shows that the second variable is indeed available:
echo $carryaddressid; // shows the value 16
Here are 2 variations of code I have tried in order to to create a hyperlink to another PHP page, taking with it the 2 variables:
echo '<a href="addressadd.php?postcodeid=123&$carryaddressid"/>Link</a>';
echo '<a href="addressadd.php?postcodeid=123&carryaddressid=<? php echo $carryaddressid;?>"/>Link</a>';
The first variation simply carries the variable name rather than the code as follows:
[192.x.x.x...]
The second variation similarly carries the whole php enclosed line of code, rather than an echoed value.
I thought the second method would be correct, but as the echo statement is already inside a php section, perhaps the additional php statement is causing problems.
I realise I could use a form, but I'd prefer to do it this way if possible. I feel I must be close to getting it to work. Thanks.
echo "<a href='addressadd.php?postcodeid=123&carryaddressid=$carryaddressid' />Link</a>";
Good luck!
<?php
$name = 'Jill';
echo 'hello $name';
echo '<br>';
echo "hello $name";
?>
It may help you to understand your issue. More on this in the manual [nl2.php.net].
Change it to this:echo "<a href='addressadd.php?postcodeid=123&carryaddressid=$carryaddressid' />Link</a>";
Good luck!
This is not W3C compliant. The ampersand (&) will cause you an error. Change it to,
echo "<a href='addressadd.php?postcodeid=123&carryaddressid=$carryaddressid' />Link</a>";
Also, whenever I use a variable inside a string, I add brackets to be on the safe side,
echo "<a href='addressadd.php?postcodeid=123&carryaddressid={$carryaddressid}' />Link</a>";
Very small things, but good to do for safer programming.
Please see this example,
<snip>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>[/pre]<body>With normal &<br />
<a href="http://www.mydomain.com/index.php?
vara=test&varb=test">http://www.mydomain.com/index.php?vara=test&varb=test</a> <br /><br />With HTML code &amp;<br />
<a href="http://www.mydomain.com/index.php?
vara=test&varb=test">http://www.mydomain.com/index.php?vara=test&varb=test</a>Validate the document and you'll see which produces an error<br />
<a href="http://validator.w3.org/check?uri=http%3A%2F%2Fprojects.example.co.uk%2Ftest%2Ftest.html">W3C Validator</a></body>
</html>
Validate this.
The first link will produce an error because you used "&" and not "&".
[edited by: jatar_k at 3:35 pm (utc) on July 19, 2006]
[edit reason]
[1][edit reason] sidescroll and urls [/edit] [/edit][/1]
.com/page.php?page=wid%20get&filename.php
is this safe for search engines? if not how do I get rid of the %20
@ the OP not trying to steal the thread but my question is similar and could help someone else :)
edit reason: formatting URL string