rlb1 Posted November 5, 2007 Share Posted November 5, 2007 I am attempting to 'hide' a URL with the following code. I have done this with this code being on another PHP page, but I would like to have the code on the same page if possible. // Here is my attempt: $path = array( 'Product' => '{$row['Manufacturer']}', ); if (array_key_exists($_GET['Product'],$path)) header('Location:'.$path[$_GET['Product']]); print " " http://www.domain.com/id=Product ; // Here is the one that worked (installed on another page) <?php $path = array( 'apparel' => 'http://www.amazon.com/b?%....', 'cameras' => 'http://www.amazon.com/b?%....', 'computers' => 'http://www.amazon.com/b?%....', 'electronics' => 'http://www.amazon.com/b?%....', 'jewelry' => 'http://www.amazon.com/b?%....', 'watches' => 'http://www.amazon.com/b?%....', 'toys' => 'http://www.amazon.com/b?%....', 'musicalinst' => 'http://www.amazon.com/b?%....', ); if (array_key_exists($_GET['product'],$path)) header('Location:'.$path[$_GET['product']]); ?> // Here is the full page code Print " <DIV align=left> "; Print " <A title="; echo " ".$row['Name']; Print " href="; echo " ".$row['URL_Product']; // This shows the URL of the 'actual' store, would like to hide this Print " target=_blank> "; Print " <H1> "; echo " ".$row['Name']; Print " </H1></A>"; Print " <TABLE cellSpacing=5 cellPadding=0 width=100% border=0> "; Print " <TBODY> "; Print " <TR> "; Print " <TD> "; Print " <TABLE cellSpacing=0 cellPadding=0 width=100% border=0> "; Print " <TBODY> "; Print " <TR> "; Print " <TD vAlign=top align=middle width=300> "; Print " <DIV align=center> "; Print " <A title="; echo " ".$row['Name']; Print " href="; echo " ".$row['URL_Product']; Print " target=_blank> "; Print " <IMG src="; echo " ".$row['URL_Image_Large']; Print " alt= "; echo " ".$row['Name']; Print " border=0></A> "; Print " <BR> "; Print " <SPAN class=text_9px>Retailer is responsible for this image.</SPAN> "; Print " </BR> "; Print " </DIV></TD> "; Print " <TD vAlign=top height=200> "; Print " <TABLE cellSpacing=0 cellPadding=0 width=100% align=left border=0> "; Print " <TBODY> "; Print " <TR> "; Print " <TD> "; Print " <DIV class=text_11px style=PADDING-LEFT: 15px> "; Print " <A title="; echo " ".$row['Name']; Print " href="; echo " ".$row['URL_Product']; Print " target=_blank> "; Print " <H4>"; Print " SKU: "; echo " ".$row['SKU']; Print " </H4></A>"; Print " <A title="; echo " ".$row['Name']; Print " href="; echo " ".$row['URL_Product']; Print " target=_blank> "; Print " <H4>"; Print " Manufacturer: "; echo " ".$row['Manufacturer']; Print " </H4></A>"; Print " <DIV class=text_11px style=PADDING-BOTTOM: 5px> "; echo " ".$row['Description']; Print " </DIV><BR> "; Print " <DIV style=PADDING-BOTTOM: 5px; PADDING-TOP: 5px>"; Print " </DIV> "; Print " <TABLE cellSpacing=0 cellPadding=0 width=100% border=0> "; Print " <TBODY> "; Print " <TR> "; Print " <TD> "; Print " <DIV><span class=textprice><STRONG>Price:</STRONG></span> "; Print " <span class=textpricered><STRONG> $"; echo " ".$row['Price']; Print " </STRONG> "; Print " </SPAN></DIV><BR></TD></TR><TR> "; Print " <TD vAlign=center align=left> "; Print " <A title="; echo " ".$row['Name']; Print " href="; echo " ".$row['URL_Product']; Print " target=_blank> "; Print " <IMG src=addtocartbutton.gif align=bottom border=0></A> "; Print " </TD></TR> "; Print " <TR> "; Print " <TD><BR> "; Print " <DIV class=text_11px><STRONG>Tell a Friend</STRONG></DIV> "; Print " </TD></TR><TR><TD><BR> "; Print " <DIV class=text_11px><STRONG>Bookmark this Page</STRONG></DIV> "; Print " </TD></TR> "; Print " </TBODY></TABLE></DIV> "; Print " </TD></TR></TBODY></TABLE> "; Print " </TD></TR></TBODY></TABLE> "; Print " </TD></TR></TBODY></TABLE> "; Print " </DIV> "; Print " <!-- end content --><!-- start footer --> "; Print " <BR><BR> "; Print " <HR> "; Print " <DIV class=text_12px align=left>"; Print "<B>More Popular Products from"; echo " ".$row['Manufacturer']; Print " </B> "; Print " </DIV> "; Print " <BR> "; Link to comment https://forums.phpfreaks.com/topic/76076-solved-path-array/ Share on other sites More sharing options...
Psycho Posted November 5, 2007 Share Posted November 5, 2007 I think your problem is that you are trying to use a variable when setting the value of the array index, but you are enclosing it in single quotes. Variables are only interpreted within double quotes. Try this: 'Product' => "{$row['Manufacturer']}", Also, always enclose your code in CODE tags in the forum. Link to comment https://forums.phpfreaks.com/topic/76076-solved-path-array/#findComment-385103 Share on other sites More sharing options...
rlb1 Posted November 5, 2007 Author Share Posted November 5, 2007 The code is not working... I am thinking that their is something wrong with the array key?? I would like to have the "$path = array" code on the same page if possible? If I put it on a different page, will the "{$row['URL_Product']}", variable carry over? Thanks for your help!! $path = array( 'Product' => "{$row['URL_Product']}", ); if (array_key_exists($_GET['id'],$path)) header('Location:'.$path[$_GET['id']]); Print " <DIV align=left> "; Print " <A title="; echo " ".$row['Name']; Print " href="; echo " ".$path['Product']; Print " target=_blank> "; Print " <H1> "; echo " ".$row['Name']; Print " </H1></A>"; Print " <TABLE cellSpacing=5 cellPadding=0 width=100% border=0> "; Print " <TBODY> "; Print " <TR> "; Print " <TD> "; Print " <TABLE cellSpacing=0 cellPadding=0 width=100% border=0> "; Print " <TBODY> "; Print " <TR> "; Print " <TD vAlign=top align=middle width=300> "; Print " <DIV align=center> "; Print " <A title="; echo " ".$row['Name']; Print " href="; Print "domain.com/music.php?id=Product"; // Here is the link Print " target=_blank> "; Print " <IMG src="; echo " ".$row['URL_Image_Large']; Print " alt= "; echo " ".$row['Name']; Print " border=0></A> "; Print " <BR> "; Print " <SPAN class=text_9px>Retailer is responsible for this image.</SPAN> "; Print " </BR> "; Print " </DIV></TD> "; Print " <TD vAlign=top height=200> "; Print " <TABLE cellSpacing=0 cellPadding=0 width=100% align=left border=0> "; Print " <TBODY> "; Print " <TR> "; Print " <TD> "; Print " <DIV class=text_11px style=PADDING-LEFT: 15px> "; Print " <A title="; echo " ".$row['Name']; Print " href="; Print "domain.com/music.php?id=Product"; // Here is the link Print " target=_blank> "; Print " <H4>"; Print " SKU: "; echo " ".$row['SKU']; Print " </H4></A>"; Print " <A title="; echo " ".$row['Name']; Print " href="; Print "domain.com/music.php?id=Product"; // Here is the link Print " target=_blank> "; Print " <H4>"; Print " Manufacturer: "; echo " ".$row['Manufacturer']; Print " </H4></A>"; Print " <DIV class=text_11px style=PADDING-BOTTOM: 5px> "; echo " ".$row['Description']; Print " </DIV><BR> "; Print " <DIV style=PADDING-BOTTOM: 5px; PADDING-TOP: 5px>"; Print " </DIV> "; Print " <TABLE cellSpacing=0 cellPadding=0 width=100% border=0> "; Print " <TBODY> "; Link to comment https://forums.phpfreaks.com/topic/76076-solved-path-array/#findComment-385211 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.