zhangy Posted June 23, 2009 Share Posted June 23, 2009 Hello, the following code is giving me a bit of trouble. It is supposed to output tags associated with blog entries from a mysql database table. However it only seems to grab one of the tags out of the several that are in the table row. Not only that, but the text on the blog site immediately following this code's output is somehow turned into a link with the value of one of the tags that didn't get outputted. <?php require_once('load_data.php'); if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); $id = (int) $_GET['id']; $sql = "SELECT * FROM $table WHERE id=$id"; $result = mysql_query($sql) or die("Error ". mysql_error(). " with query ". $sql); if(mysql_num_rows($result) == 1){ $row = mysql_fetch_array($result); echo 'Tags: '; $tags = $row['tags']; $tags_array = explode(",", $tags); foreach($tags_array as $value) { $value = trim($value); echo '<a href="mysite.com/tag.php?tag='.$value.'>'.$value ."</a><br />"; } } ?> Link to comment https://forums.phpfreaks.com/topic/163335-solved-this-script-is-spilling-into-the-next-script/ Share on other sites More sharing options...
kickstart Posted June 23, 2009 Share Posted June 23, 2009 Hi You are missing a closing quote for the link address. All the best Keith Link to comment https://forums.phpfreaks.com/topic/163335-solved-this-script-is-spilling-into-the-next-script/#findComment-861777 Share on other sites More sharing options...
zhangy Posted June 23, 2009 Author Share Posted June 23, 2009 If you listen real hard you might hear my head banging against the wall. Thanks for that. Link to comment https://forums.phpfreaks.com/topic/163335-solved-this-script-is-spilling-into-the-next-script/#findComment-861780 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.