Hi all,
I currently have a drop down menu where I select the iTunes category and sub-category for my podcast feed, which then populates the xml file. As of right now, my script supports only one podcast feed, so it uses the selection to update the flat file. However, I'm trying to update the script so that I can support multiple podcast feeds. To do that, I want to add the podcast feed information into a MySQL table.
I've created a two-part script that wants to update the table using $_POST variables. As of right now I'm getting an error msg:
Warning: mysql_real_escape_string() expects parameter 1 to be string, array given in /media/CHATEAU/robertjm/www/xmlerator-0.7.5/podcast_config2.php on line 166
If I understand that correctly, it's because the Cat/subCat information forms an array. However, the mysql_real_escape_string() is looking for everything in one table field.
There could, hypothetically, be up to three Cat/subCat entries in my .xml file. Example:
<itunes:category text="Government & Organizations">
<itunes:category text="Local"/>
</itunes:category>
<itunes:category text="Health">
<itunes:category text="Alternative Health"/>
</itunes:category>
<itunes:category text="Health">
<itunes:category text="Fitness & Nutrition"/>
</itunes:category>
If I'm going to support only one Cat/SubCat, I could simply implode the array, right?
However, I'd like to be able to support up to three, per the iTunes standard. Should I run an implosion inside a loop statement, or would it be more expeditious to break it into different arrays, one for Categories, one for sub-Catagories?
The cat/sub-cat stuff is in an include file, which is then reference by the first of two pages.
Page one's iTunes category section:
$_POST['itunes_categories'] = array();
foreach ($vsf->config->itunes->categories->category as $cat) {
$_POST['itunes_categories'][] = (string)$cat;
}
}
// AND THEN LATER DOWN THE SAME PHP PAGE:
<td>
<!-- Code for browser detection. DO NOT REMOVE. -->
<SCRIPT src="resources/Treeview/ua.js"></SCRIPT>
<!-- Infrastructure code for the TreeView. DO NOT REMOVE. -->
<SCRIPT src="resources/Treeview/ftiens4.js"></SCRIPT>
<script language="JavaScript">
<?php include('itunes-categories.php'); ?>
</script>
<DIV><TABLE border=0><TR><TD><FONT size=-2><A style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank>Javascript Tree Menu by Treemenu.net</A></FONT></TD></TR></TABLE></DIV>
<SCRIPT>initializeDocument()</SCRIPT>
<NOSCRIPT>
A tree for category selection will open here if you enable JavaScript in your browser.
</NOSCRIPT>
</td>
page two's iTune's category section:
$vsf->config->itunes->categories = '';
if ($_POST['itunes_categories']){
foreach ($_POST['itunes_categories'] as $cat) {
#print "$cat<br>\n";
if (method_exists($vsf->config->itunes->categories,'addChild')) {
$vsf->config->itunes->categories->addChild("category",htmlentities($cat));
}
else {
//$vsf->config->itunes->categories = "need custom method";
//dieWithError("Need PHP 5.1.3 or newer");
addCategory($cat);
}
}
#print_r($vsf->config);
} // close foreach
} // close if itunes_categories
else {
$vsf->config->itunes->enable = 'No';
}
//AND THEN LATER TRY TO INSERT IT INTO MY TABLE'S itunes_categories COLUMN WITH...
"'" . mysql_real_escape_string($_POST['itunes_categories']) . "', " .
Robert