Big mysql_result problem
| From: | J-F Mammet | Date: | Fri, 25 Feb 2000 08:59:19 +0000 |
| Subject: | Big mysql_result problem | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-10927@lists.php.net to get a copy of this message | ||
Hi Everyone.
I have a problem that is bugging me since the beginning of PHP4 betas.
Here is a sample of my script :
$request = "SELECT
Product_Ref.Version,Product_Ref.OS1,Product_Ref.OS2,Product_Ref.OS3,Country.Symbol_Product,Product_Ref.Price_Currency,Product.Name,Product_Ref.Product_Ref_SG,Product.*,Currency.*,C1.*,C2.*,C3.*,Publisher.Name,Product_Ref.Shipping,Product_Ref.Available,Country.VAT
FROM
Publisher,Product_Ref,Product,Country,Currency,Category as C1,Category
as C2,Category as C3
WHERE Product_Ref.Currency__ = Currency.Currency__ AND
Product.Product__ = Product_Ref.Product__ AND
Product_Ref.Country__ = Country.Country__ AND
Product_Ref.Visible = 1 AND
Product.Publisher__ = Publisher.Publisher__ AND
C1.Category__ = Product.Category1__ AND
C2.Category__ = Product.Category2__ AND
C3.Category__ = Product.Category3__ ";
$addrequest = "";
for ($i=0;$i<count($Param["Nom"]);$i++)
{
$Nom = $Param[Nom][$i];
$Val = $Param[Val][$i];
$addrequest .= " AND $Nom LIKE '$Val%' ";
}
$addrequest .= "ORDER BY ";
for ($i=0;$i<$NbTri;$i++)
{
$addrequest .= $Tri[$i];
if ($i < $NbTri-1)
$addrequest .= ",";
}
$request .= $addrequest;
$result = mysql_db_query($dbsgv3,"$request");
$nrows = mysql_num_rows($result);
for ($i=0;$i<$nrows;$i++)
{
for ($j=0;$j<$NbTri;$j++)
{
$Table_Tri[$i][$j] = mysql_result($result, $i, $Tri[$j]);
echo $Tri[$cnt] = $Tris[0].".".$Tris[1];
}
}
With $Tri[0] = C1.Name_FR
$Tri[1] = Publisher.Name
$Tri[2] = Product.Name
With php3 this script works perfectly well.
With PHP4 here is what I get :
0 0 Entreprise
0 1 Castlink
0 2 Business Finance
Warning: C1 not found in MySQL result index 6 in templates.inc on line
198
1 0
Warning: Publisher not found in MySQL result index 6 in templates.inc on
line 198
1 1
Warning: Product not found in MySQL result index 6 in templates.inc on
line 198
1 2
So basically it's working for the first line, then it does not work.
Normally I just put the column name, but as you can see here there are
name conflicts. I can't alias the column names because of the $Tri
variables comming from another part of the script and being
autogenerated from the Table/Column names. I can't easily use
mysql_fect_array (I don't know if this would work) because of some code
later in the script
I don't see any other way to go around this bug.
I think this one is really important, since the mysql/php group is the
most used I think.
Feel free to ask me any question
Thanks in advance !
J-F Mammet
webmaster@softgallery.com