Jump to content

urber

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

urber's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi guys, thanks for reply but it doesn't seem to work.. I got a script to draw out title from the mysql database and write to xml. But when it met sentence with - it will change to ? and than xml will give me this error: line 96, column 41: title contains bad characters [help] <title>Going to shopping ? in the afternoon</title>.. my code: [quote] <?php $select = "SELECT * FROM table1 ORDER BY id DESC LIMIT 18"; $query = mysql_query($select) or die(mysql_error()); $file = fopen("feed.xml", "w"); fwrite($file, "<?xml version='1.0'?> <rss version='2.0'> <channel> <title>Whatever</title> <link>http://www.domain.com</link> <description>my desc</description> <language>en-us</language>"); function chopSent($varb,$num) { $dnum = intval($num); if (strlen($varb) > $dnum) { $nvarb = substr($varb, 0, $dnum); $nvarb .= "..." ; } elseif (strlen($varb) < $dnum) { $nvarb = $varb; } return $nvarb; } while($array = mysql_fetch_array($query)){ extract($array); $sentence2 = $content; $sentence2 = str_replace("-"," ",$sentence2); $sentence2 = stripslashes($sentence2); $sentence2 = strip_tags($sentence2); $sentence2 = chopSent($sentence2, 150); $new = $maintitle; // Going to shopping - in the afternoon << this is the title $new = str_replace("-"," ",$new); // $content and $maintitle are drawn from my database both have this - problem when print to xml, // tried using the code but still printing ? instead of blank. fwrite($file, "<item> <title>$new</title> <link>http://www.domain.com/index.php?id=$id</link> <description>$sentence2</description> </item>"); } //end of while loop fwrite($file, "</channel></rss>"); fclose($file); [/quote] Xml print out results: -<rss version="2.0"> −<channel> <title>Whatever</title> <link>http://www.domain.com</link> <description>my desc</description> <language>en-us</language> <title> Going to shopping ? in the afternoon <<< --- this ? cause error. </title> −<link> http://www.domain.com/index.php?id=69630 </link> −<description> Story description </description> Any helps? Thanks
  2. Hi, I got a problem here, how to replace - to space (empty). I got a sentence for example: Going to shopping - in the afternoon I want to replace the - and the sentence will become: Going to shopping in the afternoon PLease kindly help thank you.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.