RE: Error I dont understand

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am wondering if it would easier/more of a learning experience if I ditched
the  canned code page I am using and started over writing my own shopping
cart script. I am fairly a newbie to PHP. I am wondering just how hard this
would be.

 

From: php-objects@xxxxxxxxxxxxxxx [mailto:php-objects@xxxxxxxxxxxxxxx] On
Behalf Of Pete
Sent: Monday, June 11, 2007 5:29 PM
To: php-objects@xxxxxxxxxxxxxxx
Subject: Re:  Error I dont understand

 

In message <1997.201.246.38.137.1181595064.squirrel@xxxxxxxxxxxxxxxxx
<mailto:1997.201.246.38.137.1181595064.squirrel%40webmail.nivel5.cl> >,
=?iso-8859-1?Q?Jos=E9_Miguel_Santib=E1=F1ez_A. ?= <jms@xxxxxxxxx
<mailto:jms%40nivel5.cl> > writes
>
>> I am getting an error on a line of code that I don't understand and I
>> am hoping that someone can explain it to me. I will include the error
>> and line of code that it is telling me is the problem.
>>
>> Weeks
>>
>> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
>> result resource.
>>
>> while($row = mysql_fetch_array($result)){
>> // Increment the total cost of all items
>> $totalCost += ($row["qty"] * $row["itemPrice"]);
>>
>>
>
>99%: Your query, has an SQL error...

I would disagree, but it depends on his error settings on the server. I
would have expected it to stop before reaching this line if it were a
SQL error.

100% <G> It's an error on the line
$result=...

...which, teech, you haven't shown us.

also you have the code, 
> // Increment the total cost of all items
> $totalCost += ($row["qty"] * $row["itemPrice"]); 

why? you could at least SELECT (qty*itemPrice) as totalitemprice.

Or, you may even be able to (depending on the rest of the page)
SELECT sum(qty*itemPrice) as totalcost
and save yourself a lot of code (and processing time)!

-- 
Pete Clark

Sunny Andalucia
http://www.hotcosta.com/comm_1.htm

 



[Non-text portions of this message have been removed]


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux