convert the url & hashtag into link

18
January 13, 2019, at 04:20 AM

In my code I have #hashtag standing but also Iframe + URL but It shows only the hashtag further it does not show the Iframe + URL

I don`t have any clue what I could do for this problem

<?php
 // connect to the "tests" database
$conn = new mysqli('127.0.0.1', 'Politics', '123456', 'Politics');
 //function to convert the url & hashtag into link
 function convert_to_links($msg){
  $final_message = preg_replace(array('/(?i)\b((?:https?:\/\/|www\d{0,3}[.]| 
  [a- 
  z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s() 
<>]+\)))*\))+ 
 (?:\ 
 (([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))/', 
 '/(^| 
   [^a-z0-9_])@([a-z0-9_]+)/i', '/(^|[^a-z0-9_])#([a-z0-9_]+)/i'), 
 array('<a 
 href="$1" target="_blank">$1</a>', '$1<a href="">@$2</a>', '$1<a 
 href="http://145.53.93.209/hashtag/index.php?hashtag=$2">#$2</a>'), $msg);
 return $final_message;
 }

 if(isset($_GET['hashtag']) && !empty($_GET['hashtag'])){
$hashtag = mysqli_real_escape_string(strip_tags(trim($_GET['hashtag'])));
 $query = mysqli_query("SELECT * FROM politicsnucleus_item WHERE imore LIKE 
'%$hashtag%' ORDER BY inumber DESC");
   }
 /* change character set to utf8 */
 if (!mysqli_set_charset($conn, "utf8")) {
  printf("", mysqli_error($link));
   exit();
 } else {
 }
  // check connection
  if (mysqli_connect_errno()) {
  exit('Connect failed: '. mysqli_connect_error());
  }
  // SELECT sql query
  $sql = "SELECT * FROM `politicsnucleus_item`  WHERE  inumber='$id' ORDER BY 
`inumber` DESC LIMIT 1"; 
// perform the query and store the result
$result = $conn->query($sql);
// if the $result contains at least one row
if ($result->num_rows > 0) {
   // output data of each row from $result
   while($row = $result->fetch_assoc()) {
  $row['imore'] = convert_to_links($row['imore']);  
  echo ' 
  <p>'. $row['imore']. '</p>' ;
  }
  }
 else {
 echo 'No-one added yet a @1';
 }
$conn->close();
?>

In '. $row['imore']. ' I hope to see clickable #hashtags + IFrame + Urls but it only shows the #hashtag

READ ALSO
INNER JOIN with Condition - Mysql

INNER JOIN with Condition - Mysql

I'm trying to make an inner join if a condition is true but it does not work, I've tried these 2 ways:

29
How do I preserve a UTF8 character set when doing an update into MySQL, from a Google Sheet?

How do I preserve a UTF8 character set when doing an update into MySQL, from a Google Sheet?

I have an app to upload a spreadsheet into my MySQL databaseSome of the fields contain Unicode characters from Northwest Indian languages

45