0

I want to insert "http//" link with comma-separated in database in this form are:

https://stackoverflow.com/questions/ask, 
https://stackoverflow.com/questions/ask,
https://stackoverflow.com/questions/ask,

That is my insert query

$url = array($_REQUEST[url_name]);
$arr = implode(',', $url);
mysql_query("insert into url(url_name)values('$arr')"); 

How is it possible with an http link save in database with comma-separated?

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
  • 3
    that isn't a very good idea – Funk Forty Niner Jun 15 '17 at 14:38
  • 2
    You are opening yourself to SQL injections and bad table design. Update your driver, use parameterized queries, and only store one value per row. See https://stackoverflow.com/questions/3653462/is-storing-a-delimited-list-in-a-database-column-really-that-bad – chris85 Jun 15 '17 at 14:41
  • 2
    Using comma-separated lists in a database column creates a myriad of problems; sensible normalization of your database eliminates those problems – Mark Baker Jun 15 '17 at 14:42
  • 1
    Don't use the deprecated and insecure `mysql_*`-functions. They have been deprecated since PHP 5.5 (in 2013) and were completely removed in PHP 7 (in 2015). Use MySQLi or PDO instead. – M. Eriksson Jun 15 '17 at 14:42

1 Answers1

0

This is not good practice to store value.

Use base64_encode:

$a = "https://stackoverflow.com/questions/ask,https://stackoverflow.com/questions/ask,https://stackoverflow.com/questions/ask"

base64_encode($a);

To get your original Value : base64_decode

base64_decode($a);