Hi there guys,

I am trying to create an RSS feed and for the life of me I can't get it to create working hyperlinks. Any help would be so massively appreciated.

<?php

session_start();	

$connection = mysql_connect("******", "******", "*****") or die (mysql_error());

$db = mysql_select_db("****", $connection) or die (mysql_error());

$q18 = "select * from settings where settingid = '1'";
$r18 = mysql_query($q18) or die(mysql_error(Error5));
$a18 = mysql_fetch_array($r18);

require_once 'rss_class.inc.php';

function stripchars($str)
{
	$body = htmlentities("$str");
    $body = ereg_replace(128, "&euro;", $body); // Euro symbol
    $body = ereg_replace(133, "&#133;", $body); // ellipses
    $body = ereg_replace(8226, "&#8243;", $body); // double prime
    $body = ereg_replace(8216, "&#039;", $body); // left single quote
    $body = ereg_replace(145, "&#039;", $body); // left single quote
    $body = ereg_replace(8217, "&#039;", $body); // right single quote
    $body = ereg_replace(146, "&#039;", $body); // right single quote
    $body = ereg_replace(8220, "&#034;", $body); // left double quote
    $body = ereg_replace(147, "&#034;", $body); // left double quote
    $body = ereg_replace(8221, "&#034;", $body); // right double quote
    $body = ereg_replace(148, "&#034;", $body); // right double quote
    $body = ereg_replace(8226, "&#149;", $body); // bullet
    $body = ereg_replace(149, "&#149;", $body); // bullet
    $body = ereg_replace(8211, "&#150;", $body); // en dash
    $body = ereg_replace(150, "&#150;", $body); // en dash
    $body = ereg_replace(8212, "&#151;", $body); // em dash
    $body = ereg_replace(151, "&#151;", $body); // em dash
    $body = ereg_replace(8482, "&#153;", $body); // trademark
    $body = ereg_replace(153, "&#153;", $body); // trademark
    $body = ereg_replace(169, "&copy;", $body); // copyright mark
    $body = ereg_replace(174, "&reg;", $body); // registration mark
    $final = htmlentities("$body");
	
	return $final;
	
}

  $rss_channel = new rssGenerator_channel();

  $rss_channel->title = 'Latest Jobs from *******';

  $rss_channel->link = 'http://www.******.co.uk/';

  $rss_channel->description = 'The latest jobs from ********.co.uk';

  $rss_channel->language = 'en-uk';

 

    $selQry  = "SELECT * FROM jobs where status = '0' order by jobid desc limit 15";
  $a = mysql_query($selQry);
  while($b = mysql_fetch_array($a))
  {
  	$itemTitle =  strip_tags($b[position]);
	$itemTitle =  str_replace('"','',$itemTitle);
	$itemTitle =  str_replace("'",'',$itemTitle);
	$itemTitle =  str_replace("&",' and ',$itemTitle);
	$itemTitle =  str_replace('/&nbsp;/', ' ',$itemTitle);
	$itemTitle =  str_replace("/&apos;/", "'",$itemTitle);
	$itemTitle =  str_replace('151', "&#151;",$itemTitle);

	
	
	$itemDesc =  strip_tags($b[description]);
	$itemDesc =  substr($itemDesc,0,150);
	$itemDesc = stripchars($itemDesc) ;
	$itemDesc =  str_replace("&",' and ',$itemDesc);
	$itemDesc =  str_replace('/&nbsp;/', ' ',$itemDesc);
	$itemDesc =  str_replace("/&apos;/", "'",$itemDesc);
	$itemDesc =  str_replace('151', "&#151;",$itemDesc);
	
	
	if(strlen($itemDesc)>150){$dots='...';}
	$descTemp = $itemDesc . $dots;
	$itemDesc = $descTemp ;
	$itemLink  = $fullurl.'/info.php?jobid='.$b[jobid].'';
	
	$EXmonth3 = substr("$b[postdate]",0,2);
	$EXday3 = substr("$b[postdate]",3,2);
	$EXyear3 = substr("$b[postdate]",6,4);
	$itemDate =  "$EXday3/$EXmonth3/$EXyear3";
  
	  $item = new rssGenerator_item();
	  $item->title = $itemTitle;
	  $item->description = $itemDesc;
	  $item->link = $itemLink;
	  $item->pubDate = $itemDate;
	  $rss_channel->items[] = $item;
   }	 
  $rss_feed = new rssGenerator_rss();
  $rss_feed->encoding = 'UTF-8';
  $rss_feed->version = '2.0';
  header('Content-Type: text/xml');
  echo $rss_feed->createFeed($rss_channel);
?>

Where is $fullurl set? Also, $b[jobid] should be $b["jobid"] or $b[$jobid] depending on what you meant.

$fullurl is referenced in the database. $b[jobid] was in the original working feed. Any other suggestions??? It works properly in Safari, not in IE, Firefox or Chrome. Does this make a difference??

alright i do not see $fullurl defined in your script and for a hyperlink to be active for a web link you'll need a http:// at the start of the link so i figure the problem is with the non defined $fullurl variable with in the script so your going to need to define it as so

// Dynamic Chosen url as so
$fullurl = $b['fullurl']; // $b['fullurl'] or $b['CHOOSE THE COLUMN OF THE URL']

// OR

// your site url as so
$fullurl = 'http://'.$_SERVER['HTTP_HOST'].'/';

this should fix you problem you having here
do you have any questions if so message me and ill try to help

ps: $b[jobid] should be $b

so there you go

also on the questions on the type of browser no it should not make no difference alright the changes in the browser you asked about only have changes in the CSS part not the php that is all compiled on your server when the users points to the page then is printed out on the screen after being compiled the browser dose not compile the script that is the point of the server so no there is no difference alrighty

Thank you very much.

That worked and now it works fine.

your welcome

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.