PHP Forum

PHP Forum (http://www.selfphp.de/forum/index.php)
-   PHP für Fortgeschrittene und Experten (http://www.selfphp.de/forum/forumdisplay.php?f=13)
-   -   Keine Funktion (http://www.selfphp.de/forum/showthread.php?t=10319)

Afrika 20.04.2005 18:13:52

Keine Funktion
 
Bei der Ausgabe bricht es genau hierdie
PHP-Code:

<?php $user_cart->showcart(); ?>

die Ausgabe ab. php4.3.10 Version. Bei anderen Serverkonfigurationen klappt das komischerweise.

Die Funktion:
PHP-Code:

  function showcart() {
                 
//dumps cart contents to screen
                
$current_url $_SERVER['PHP_SELF'];
                        foreach (
$this->items as $thekey => $thevalue)
                        {
                        
//print qty
                        
print "<tr bgcolor=#e9e9e9><td>";
                        print 
"<div align=center>" $this->items[$thekey]["qty"] . "</div>";
                        
//print item number
                                
if (!$this->items[$thekey]["product"])
                                {
                                print 
"</td><td>";
                                print 
"<div align=center></div>";
                                } else {
                                print 
"</td><td>";
                                print 
"<div align=center>" $thekey "</div>";
                                }
                        
//print product name
                        
print "</td><td>";
                        print 
"&nbsp;&nbsp;" ucfirst($this->items[$thekey]["product"]);
                        
//print total cost
                        
print "</td><td>";
                       print 
"<div align=right>$</div></td><td><div align=right>" number_format($this->items[$thekey]["total_cost"], 2'.''') . "</div>";
                        
//print action column
                        //print "</td><td>";
                        //print "<form name=form1 method=get action="../%20.%20$current_url%20.%20">";
                        //print "<input type=submit value=Delete name=Submit><input type=hidden name=delete value=1>";
                        //print "<input name=itemid type=hidden value=" . $thekey . "></form></tr>";
                        
print "</td><tr>";
                        } 


|Coding 20.04.2005 18:32:45

AW: Keine Funktion
 
Was heißt: "...bricht die Ausgabe ab."?
Wird da rein garnichts ausgegeben?

Afrika 20.04.2005 18:45:16

AW: Keine Funktion
 
Doch, die Ausgabe geht bis zu der Funktion:
PHP-Code:

<?php $user_cart->showcart(); ?>

Dannach wird aber nichts ausgegeben.
Habe das nun auf ein paar anderen Servern probiert, da klappt das einwandfrei.
Vielleicht ein Rechteproblem bei den Sessions?

PHP-Code:

<?php
         
require_once("/shopping_cart/cart.php");
     
session_start();
                 if(!isset(
$user_cart))
                 {
                          
$user_cart = new cart;
                          
session_register("user_cart");
                 }
         include(
"/shopping_cart/inc_globals.php");
     include(
"/shopping_cart/inc_functions.php");
    
$total_items $user_cart->num_items();
     
?>


|Coding 20.04.2005 19:03:04

AW: Keine Funktion
 
Hast Du dir mal das Objekt $user_cart ausgeben lassen?
Schimpft error_reporting(E_ALL)?

Afrika 20.04.2005 19:07:37

AW: Keine Funktion
 
Scheint irgendwie mit der Server_VAR zu tun zu haben. Wenn ic eingebe:
PHP-Code:

<?php
         
require_once("shopping_cart/cart.php");
     
session_start();
                 if(!isset(
$user_cart))
                 {
                          
$user_cart = new cart;
                          
session_register("user_cart");
                 }
         include(
"shopping_cart/inc_globals.php");
     include(
"shopping_cart/inc_functions.php");
    
$total_items $user_cart->num_items();
     
?>
        <?php
        $user_cart
->add_item(34"test1"7.50);
        
$user_cart->add_item(13"test2"5.25);
    
        
?>

Dann klappt diese Ausgabe und alles wird angezeigt.
Muss dann ja irgendwie mit der Übergabe der Form etwas nicht stimmen

|Coding 20.04.2005 19:31:30

AW: Keine Funktion
 
Zitat:

Zitat von |Coding
Hast Du dir mal das Objekt $user_cart ausgeben lassen?
Schimpft error_reporting(E_ALL)?

Und?

Afrika 20.04.2005 22:53:09

AW: Keine Funktion
 
Es passiert nichts.
Keine Ausgabe der Daten.
ich habe das error_reporting(E_ALL);
vielleicht auch falsch platziert.

xabbuh 20.04.2005 23:07:53

AW: Keine Funktion
 
Wo steht es denn in deinem Script?

Afrika 20.04.2005 23:18:22

AW: Keine Funktion
 
PHP-Code:

<?php
         
require_once("shopping_cart/cart.php");
     
session_start();
                 if(!isset(
$user_cart))
                 {
                          
$user_cart = new cart;
                          
session_register("user_cart");
                 }
         include(
"shopping_cart/inc_globals.php");
     include(
"shopping_cart/inc_functions.php");
    
$total_items $user_cart->num_items();
     
?>
        <?php
       $user_cart
->add_item(34"test"7.50);
         
error_reporting(E_ALL);
        
?>

Das ist der header der auch ausgeführt wird.
Wenn ich das nehme taucht der test auch auf, und das script wird bis zum Ende ausgeführt. Wenn ich den Testartikel rausnehme, passiert nichts im Warenkorb.
Wenn es woanders nicht klappen würde...

Afrika 20.04.2005 23:22:27

AW: Keine Funktion
 
Die Datei, die die Funktion macht:
Vielleicht funktioniert ja $HTTP_GET_VARS nicht?
PHP-Code:

if (isset($HTTP_GET_VARS['delete']))
{
  
$delete $HTTP_GET_VARS['delete'];
  
$itemno $HTTP_GET_VARS['itemid'];
} else {
  
$delete 0;
}
if (isset(
$HTTP_GET_VARS['additem']))
{
   
$additem $HTTP_GET_VARS['additem'];
   
$itemid  $HTTP_GET_VARS['itemid'];
   
$qty     $HTTP_GET_VARS['qty'];
   
$product $HTTP_GET_VARS['product'];
   
$price   $HTTP_GET_VARS['price'];
} else {
   
$additem 0;
}
if (isset(
$HTTP_GET_VARS['clear']))
{
   
$clear $HTTP_GET_VARS['clear'];
} else {
   
$clear 0;
}
        if (
$delete == "1")
        {
        
$user_cart->delete_item($itemno);
        
header("Location: " $current_url); /* Redirect browser */
        
exit;                                                 /* Make sure that code below does not get executed when we redirect. */
        
}
        if (
$additem == "1")
        {
        
$user_cart->add_item($itemid$qty$product$price);
        
header("Location: " $viewcart); /* Redirect browser */
                
exit;                                   /* Make sure that code below does not get executed when we redirect. */
        
}
        if (
$clear == "1")
        {
        
$user_cart->clear();
        
header("Location: " $viewcart); /* Redirect browser */
        
exit;                                   /* Make sure that code below does not get executed when we redirect. */
        
}
?> 



Alle Zeitangaben in WEZ +2. Es ist jetzt 09:53:04 Uhr.

Powered by vBulletin® Version 3.8.3 (Deutsch)
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.