Iam problem with this :

Supplied argument is not a valid MySQL result resource in c:\apache\htdocs\cd_shop\funkcie_s_databazou.php on line 1039

this is code:

function zrataj_cenu($kosik)
//funkcia pocitajuca vyslednu sumu vsetkych poloziek v nakupnom kosiku
{
  $cena = 0.0;
  if(is_array($kosik))
  {
    $conn = db_connect();
    foreach($kosik as $EAN_kod => $qty)
    {  


//      $query = "select cena from albumy where EAN_kod='$EAN_kod'";


//$query = "select cena from albumy where EAN_kod='$EAN_kod'";
//$query1 = "select cena from ciste_media where EAN_kod='$EAN_kod'";

//$result=$query+$query1;

//      $result = mysql_query($query);


if (!$result = vyber_detaily_cd2($EAN_kod))
        $result = vyber_detaily_media2($EAN_kod);



      if ($result)
      {
        $cena_polozky = mysql_result($result, 0, "cena");     [B]this is line 1039[/B]
        $cena +=$cena_polozky*$qty;
      }
    }
  }
  return $cena;
}

Correct me if i am wrong but i thought mysql_result only accepted 2 parameters, not 3 ;)

No it accept 3, but problem is somewhere in array, because I need get to variable result array cena from two database tables.

if (!$result = vyber_detaily_cd2($EAN_kod))
$result = vyber_detaily_media2($EAN_kod);

this function select me array: cena of product in shoping basket using its primary key:EAN_kod and select it from two tables. And I must get final price in variable $cena

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.