Avatar of sanchit gupta
sanchit gupta

asked on 

Errors in links opening

I have made a code which selects url and title from links table in database. I want links to the respective urls. For eg: if url on the page says "www.google.com" upon clicking on it it should redirect to google.com. The below code displays an error of headers already sent.

 include ("./inc/header.inc.php");
$dblinks = DB::query('SELECT url, title FROM links WHERE user_id!=:userid ORDER BY id DESC', array(':userid'=>$userid));
$links = "";
$links_t = "";
foreach ($dblinks as $u) {
    $links .= $u['url'].'<br>'.$u['title'].'<hr>' ;
<div class="links">
header('Location: echo $links;'); ?>

Open in new window


Avatar of undefined
Last Comment

8/22/2022 - Mon