troubleshooting Question

Errors in links opening

Avatar of sanchit gupta
sanchit gupta asked on
PHP
13 Comments1 Solution70 ViewsLast Modified:
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.

<?php
 include ("./inc/header.inc.php");
$userid="";
$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">
    <?php
header('Location: echo $links;'); ?>
 </div>
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 13 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros