TextLinkGravity.com
TextLinkGravity.com

Reputation: 21

How to Insert Link to Mysql database using PHP

I need help please, I'm having problem inserting a link into my Mysql Database using PHP like this: Example: http://www.textlinkgravity.com/link.php?id=8781&title=Deerpages.co-Free-Online-Business-Directory.html

In Mysql Database upon insert would be: http://www.textlinkgravity.com/link.php?id=8781

My problem is that the & symbol is being cut. I'm using mysql_real_escape_string.

Here is my code:

$link = mysql_real_escape_string($_POST['link']);   
//INSERT NEW ROW
mysql_query("INSERT INTO table (link) VALUES ('$link') ");

My apology for my question cause I don't know how to insert it having complete strings as of this moment.

Thanks to all.

Upvotes: 1

Views: 12017

Answers (1)

Zoltan Toth
Zoltan Toth

Reputation: 47667

You should encode your URL before inserting

$link = mysql_real_escape_string( urlencode($_POST['link']) ); 

Upvotes: 4

Related Questions