My problem is in the last line of code I’ve attached below. The variable is constructed validly and I am able to copy/paste it into my MySQL admin interface and run it without an error. However the mysql_query command at the end of this fails and I am not exactly sure why. Just out of curiosity I built the mysql_query line above it and when I process this script THAT line runs by the one right below doesn’t. I’m hoping someone here will spot what I am overlooking as I can’t seem to figure out exactly where the error resides.
Thanks in advance!
Greg
Snippet from my script
// We need to purge the old table data first
$CatNavDB = ‘TRUNCATE TABLE tbl_catnav;’;
// Now assemble the insert query to repopulate the table
$CatNavDB .= ‘INSERT INTO tbl_catnav (lastcatid, category_set) VALUES ‘;
while($row=mysql_fetch_array($GetMainCat, MYSQL_ASSOC))
{
if ($BaseCat != ($row[‘root_product_id’])) {
$Output = ($row[‘root_category_name’]);
$CatNavDB .= “(” . ($row[‘root_product_id’]) . “, '” . $Output . "’),";
}
if (($row[‘down1_product_id’] != $Lvl2Cat) AND ($row[‘down2_product_id’] != ‘’)) {
$Output = ($row[‘root_category_name’]) . " - " . ($row[‘down1_category_name’]);
$CatNavDB .= “(” . ($row[‘down1_product_id’]) . “, '” . $Output . "’),";
}
if (is_null($row[‘down2_product_id’])) {
$Output = ($row[‘root_category_name’]) . " - " . ($row[‘down1_category_name’]);
$CatNavDB .= “(” . ($row[‘down1_product_id’]) . “, '” . $Output . “'),”;
} else {
$Output = ($row[‘root_category_name’]) . " - " . ($row[‘down1_category_name’]) . " - " . ($row[‘down2_category_name’]);
$CatNavDB .= “(” . ($row[‘down2_product_id’]) . “, '” . $Output . “'),”;
}
$BaseCat = ($row[‘root_product_id’]);
$Lvl2Cat = ($row[‘down1_product_id’]);
}
// Add the closing ; to the insert query
$CatNavDB .= “(999999,‘RemoveThis’);”;
$CatNavDB .= “DELETE FROM tbl_catnav WHERE lastcatid = 999999;”;
// And then execute the query on the DB
$Test = (mysql_query(‘INSERT INTO tbl_catnav (lastcatid, category_set) VALUES (888888,\‘Test value\’);’));
$UpdateCatNavDB = mysql_query($CatNavDB);