Saving Full URL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
SheDesigns
Forum Commoner
Posts: 42
Joined: Tue Nov 18, 2008 9:51 am
Location: Buffalo, NY

Saving Full URL

Post by SheDesigns »

My problem is that I need to save a full URL into a database, however, the full address doesn't save.

/?pg=6&function=View&album=Products

Only saves in the database as /?pg=6
It displays it correctly as the full URL when I print it on the page.

Here's the link I provide for them.

Code: Select all

$pageURL = $_SERVER["REQUEST_URI"];
<a href=\"?pg=49&add=$pageURL\">Add this page to Pages I Like</a>
And this is where it's processed.

Code: Select all

$add = $_GET['add'];
$query = "insert into favorites values('', '$add')";
$result = mysql_query($query);
 
Why does it stop at the "&"?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Saving Full URL

Post by RobertGonzalez »

Try escaping the ampersands (or better yet, run all variables that are going to be inserted through an escape function, a la mysql_real_escape_string()).
Post Reply