Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem accessing a URL variable

Status
Not open for further replies.

Sarky78

Programmer
Oct 19, 2000
878
GB
I started to play with PHP this morning and have managed to get data from a database and output that to the screen.

I am now trying to get pass a variable onto the url and have the same page check for the existance of that variable and perform a different function.

this is the code that i have got:

<?php
$conn = new COM(&quot;ADODB.Connection&quot;) or die(&quot;Cannot start ADO&quot;);
//creates the connection object

$conn->Open(&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\websites\\php\\daNew.mdb;Mode=ReadWrite;Persist Security Info=False&quot;);
if (! isset($URLAdviceID)) {
$rs = $conn->Execute(&quot;SELECT * FROM tblAdvice WHERE ID IN (SELECT AdviceID FROM tblLinkAssociate) ORDER BY Advice&quot;);
} else {
$rs = $conn->Execute(&quot;Select * from tblLinks ORDER BY LinkName ASC&quot;);
}
?>
<HTML>
<BODY bgcolor=#FFFFFF>
<Table border=0 cellpadding=0 cellspacing=0>
<?php
if (! isset($URLAdviceID)) {
while (!$rs->EOF) {
$AdviceName = $rs->Fields(&quot;Advice&quot;);
$AdviceID = $rs->Fields(&quot;ID&quot;);?>
<TR>
<TD><a href=&quot;index.php?URLAdviceID=<?php echo $AdviceID->value ?>&quot;><?php echo $AdviceName->value; ?></A></TD>
</TR>
<?php $rs->MoveNext();}
$rs->Close();
} else {
while (!$rs->EOF) {
$linkname = $rs->Fields(&quot;LinkName&quot;);
$linkVal = $rs->Fields(&quot;URLLink&quot;); ?>
<TR>
<TD><a href=&quot;<?php echo $linkVal->value ?>&quot;><?php echo $linkname->value; ?></A></TD>
</TR>
<?php $rs->MoveNext();}
$rs->Close();
}
?>
</Table>
</Body>
</HTML>

i am using the isset to check to see if the url variable is set and nothing happens. when i click on a link the url variable URLAdviceID is put onto the address bar but the same page is loaded again

any help appreciate
 
use phpversion() to check if you are using 4.1.0 or higher, if so you can probaly get round this by using

f (! isset($_GET[URLAdviceID])) {
<hr>
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top