rondog Posted April 9, 2008 Share Posted April 9, 2008 Hi I am creating an XML file with PHP but some of the entries in the DB have " marks (quotation marks) and is truncating the XML. Is their a way to not include quotes when I am selecting from the DB...this is what I have right now: <?php include 'mssqlconnect.php'; $state = $_POST['state']; //$state = "NJ"; if($state != "") { $query = mssql_query("SELECT * FROM DE_Events WHERE state = '$state' AND displayOnSite = 'true'") or die(mssql_get_last_message()); } else { $query = mssql_query("SELECT * FROM DE_Events WHERE displayOnSite = 'true'") or die(mssql_get_last_message()); } $build = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $build .= "<events>\n"; while($row = mssql_fetch_array($query)) { $build .= "\t<item date=\"$row[event_date]\" starthour=\"$row[start_hour]\" start_minute=\"$row[start_minute]\" startampm=\"$row[start_ampm]\" endhour=\"$row[end_hour]\" endminute=\"$row[end_minute]\" endampm=\"$row[end_ampm]\" name=\"$row[name]\" location=\"$row[location]\" address=\"$row[address]\" city=\"$row[city]\" state=\"$row[state]\" zip=\"$row[zip]\" phone=\"$row[phone]\" description=\"$row[description]\" />\n"; } $build .= "</events>"; echo $build; ?> Link to comment https://forums.phpfreaks.com/topic/100254-solved-strip-quotes/ Share on other sites More sharing options...
discomatt Posted April 9, 2008 Share Posted April 9, 2008 Use CDATA syntax, use htmlentities to replace " with ", or use $output = str_replace('"', '\'', $output) Link to comment https://forums.phpfreaks.com/topic/100254-solved-strip-quotes/#findComment-512610 Share on other sites More sharing options...
darkfreaks Posted April 9, 2008 Share Posted April 9, 2008 try stripslashes or addslashes Link to comment https://forums.phpfreaks.com/topic/100254-solved-strip-quotes/#findComment-512617 Share on other sites More sharing options...
rondog Posted April 9, 2008 Author Share Posted April 9, 2008 I dont want to do cdata, str_replace worked Link to comment https://forums.phpfreaks.com/topic/100254-solved-strip-quotes/#findComment-512618 Share on other sites More sharing options...
darkfreaks Posted April 9, 2008 Share Posted April 9, 2008 click solve topic please ??? Link to comment https://forums.phpfreaks.com/topic/100254-solved-strip-quotes/#findComment-512622 Share on other sites More sharing options...
rondog Posted April 9, 2008 Author Share Posted April 9, 2008 oh didnt know it was back Link to comment https://forums.phpfreaks.com/topic/100254-solved-strip-quotes/#findComment-512656 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.