troubleshooting Question

Errors in links opening

Avatar of sanchit gupta
sanchit gupta asked on
PHP
13 Comments5 Solutions70 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>

Open in new window

ASKER CERTIFIED SOLUTION
gr8gonzo
Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 5 Answers and 13 Comments.
Start Free Trial
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 5 Answers 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