[ kelja @ 22.12.2007. 11:09 ] @
Napravio sam neku shopping cart skripticu, medjutim imam problem sa njom na jednom serveru, dobijam interesantne vrednosti session varijable, pogledajte i sami: http://www.sinisake.com/projects/courses/ PhP verzija je 4.4.7 Offline (WAMP) i na drugom serveru sve funkcionise dobro: http://www.sinisa.milicevici.com/courses/ Evo koda(bitnih delova): course.php Code: $_SESSION[price]=$rows[5]; cart.php Code: if($_GET[action]=="add"){ if(!isset($_SESSION[cid])){ $_SESSION[in_cart]=''; $_SESSION[total]=0; } else { //Check if item exists in basket!!// if(!eregi($_SESSION[cid],$_SESSION[in_cart])){ $_SESSION[in_cart].="$_SESSION[cid],"; $_SESSION[total]+=$_SESSION[price]; echo"<script>alert('$_SESSION[total]');</script>"; } else { die ("<script>alert('You have that item already in Basket.'); location.href='index.php';</script>"); } if($_SESSION[in_cart]==""){echo ("<tr><td colspan='5'><h3>No Items in Basket!</h3></td></tr>");} $check_array=explode(",",$_SESSION[in_cart]); for($i=0;$i<count($check_array)-1;$i++){ if($check_array[$i]!="") select("*","course","WHERE id=$check_array[$i]"); echo "<tr> <td align='left' style='padding-left:6px;'>\n <input name='del[]' type='checkbox' value='$rows[0]||$rows[5]' /></td>\n <td align='left' style='padding-left:6px;'>$rows[1]</td>\n <td align='left' style='padding-left:6px;'>$rows[2]</td>\n <td align='left' style='padding-left:6px;'>$rows[4]</td>\n <td align='left' style='padding-left:6px;'>$ $rows[5]</td>\n </tr>"; } } } ?> Ovde je problem(cart.php) Potpuno blesavo, otkud ona jedinica?!? Session varijabla vraca vrednost ''true"?!? [Ovu poruku je menjao kelja dana 22.12.2007. u 12:33 GMT+1] |