i have this script :
<?php
// remplacer par vos valeurs de connexion
$host="*****";
$user="*****";
$pwd="******";
$base="*****";
$mysql_link = mysql_connect($host,$user,$pwd);
mysql_select_db($base);
$dbsite="arfooo"; // prefixe de votre table sans "_" par exemple : "arfooo"
echo "TRUNCATE TABLE `".$dbsite."_categoryparents`;<br>\n";
$sql = "SELECT * FROM ".$dbsite."_categories";
$result=mysql_query($sql);
while ($row=mysql_fetch_object($result)) {
$depth=0;
echo "INSERT INTO `".$dbsite."_categoryparents` (`parentId`, `childId`, `depth`) VALUES ($row->categoryId,$row->categoryId,$depth);<br>\n";
$parentId = $row->parentCategoryId;
while ($parentId<>0){
$sql2 = "SELECT * FROM ".$dbsite."_categories WHERE categoryId = $parentId";
$result2=mysql_query($sql2);
while ($row2=mysql_fetch_object($result2)) {
$depth=$depth+1;
echo "INSERT INTO `".$dbsite."_categoryparents` (`parentId`, `childId`, `depth`) VALUES ($row2->categoryId,$row->categoryId,$depth);<br>\n";
$parentId = $row2->parentCategoryId;
}
}
$depth=$depth+1;
echo "INSERT INTO `".$dbsite."_categoryparents` (`parentId`, `childId`, `depth`) VALUES (0,$row->categoryId,$depth);<br>\n";
}
?>
I have the following error:
TRUNCATE TABLE `arfooo_categoryparents`;
PHP Error Message
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/******/public_html/genereParentChildDepth.php on line 14