cosa può essere? non ho ancora risolto il problema ma penso di aver individuato dov'è che lo script va "out".:
in pratica sul server in hosting, che ribadisco trattasi di un sistema LAMP, la variabile "$f" risulta proprio vuota, mentre sul mio pc (windows con apache e php solita versione) tutto regolare. posto il codice interessato nel caso qualcuno possa perlomeno intuire cosa è che provoca questa anomalia, perché proprio non ci levo le gambe.
<?php
function usaCarrello()
{
$carrello = $_SESSION['carrello'];
if (!$carrello)
{
return 'Il tuo carrello è vuoto.<br>';
}else{
$carrello = @explode(',',$carrello);
return 'Ci sono <a href="carrello/carrello.php">'.
@count($carrello). ' articoli nel carrello.</a><br>'."--".$carrello;
}
}
function mostraCarrello()
{
global $db;
$carrello = $_SESSION['carrello'];
$somma = 0;
if ($carrello)
{
$carrello = @explode(',',$carrello);
$acquisti = array();
foreach ($carrello as $prodotto)
{
$acquisti[$prodotto] = (@isset($acquisti[$prodotto])) ? $acquisti[$prodotto] + 1 : 1;
}
$result[] = '<form action="carrello.php?action=aggiorna" method="post" id="cart">';
$result[] = '<table>';
foreach ($acquisti as $id=>$quantita)
{
$sql = 'SELECT * FROM fotogallery where id = '.$id;
$res = $db->query($sql);
global $f;
$f = $res->fetch();
if (empty ($f)){
echo 'la variabile è vuota';
}else{
echo 'variabile piena';
}
----------------------------------------------------------------------------
da questo controllo sul server risulta vuota; al contrario sul mio pc tutto regolare
l'altra variabile interessata invece ($res) invece risulta regolarmente piena.
----------------------------------------------------------------------------
@extract($f);
$result[] = '<tr>';
$result[] = '<td><a href="carrello.php?action=cancella&id='.$id.'"><i>Cancella</i> </a></td>';
$result[] = '<td>'.'<i>cod.:</i>'.$codice.'  <i>desc:</i> '.'<b>'.$descrizione.'</b>'.' <i> tipologia:</i> '.$tipologia.'</td>';
$result[] = '<td>€'.$prezzo.'</td>';
$result[] = '<td><input type="text" name="<i>quantita</i>'.$id.'" value="'.$quantita.'" size="3"></td>';
$result[] = '<td>€'.($prezzo * $quantita).'</td>';
$somma += $prezzo * $quantita;
$result[] = '</tr>';
}
$result[] = '</table><br>';
$result[] = 'Totale: <b>€'.$somma.'</b></br><br>';
//$result[] = '<button type="submit">Aggiorna il carrello</button>';
$result[] = '</form>';
}else{
$result[] = 'Il carrello è vuoto.<br>';
}
return join($result);
}
?>
------------------------
--------------------------
sembra quindi che non svolga la funzione "fetch" che si trova nel file incluso (mysql) del quale posto il codice pure:
file mysql.php:
<?php
class MySQL
{
var $host;
var $user;
var $password;
var $database;
var $connessione;
var $errore;
function MySQL ($host,$user,$password,$database)
{
$this->host=$host;
$this->user=$user;
$this->password=$password;
$this->errore=$database;
$this->connessione();
}
function connessione()
{
if (!$this->connessione = @mysql_connect($this->host, $this->user, $this->password))
{
trigger_error('Impossibile connettersi a MySQL.');
$this->errore=true;
}
elseif (!@mysql_select_db($this->errore,$this->connessione))
{
trigger_error('Impossibile connettersi al database.');
$this->errore=true;
}
}
function notifica_errore()
{
if ($this->errore) return true;
$notifica=mysql_error($this->connessione);
if (empty($notifica)) return false;
else return true;
}
function query($sql)
{
if (!$qRes=mysql_query($sql,$this->connessione))
trigger_error (
'Query fallita: '.mysql_error($this->connessione).
' SQL: '.$sql);
return new MySQLResult($this,$qRes);
}
}
class MySQLResult
{
var $mysql;
function MySQLResult(& $mysql,$query)
{
$this->mysql=& $mysql;
$this->query=$query;
}
function fetch()
{
if ($f=mysql_fetch_array($this->query,MYSQL_ASSOC))
{
return $f;
}
else if ($this->size() > 0)
{
mysql_data_seek($this->query,0);
return false;
}else{
return false;
}
} function size()
{
return mysql_num_rows($this->query);
}
function insertID()
{
return mysql_insert_id($this->mysql->connessione);
}
function notifica_errore()
{
return $this->mysql->notifica_errore();
}
}
?>
ho controllato e fatto alcune modifiche sul php-phpcore sul server, sembrerebbe tutto regolare, ho confrontato anche con il php sul mio pc ma... niente
spero qualcuno mi possa dare un suggerimento. Grazie.
in pratica sul server in hosting, che ribadisco trattasi di un sistema LAMP, la variabile "$f" risulta proprio vuota, mentre sul mio pc (windows con apache e php solita versione) tutto regolare. posto il codice interessato nel caso qualcuno possa perlomeno intuire cosa è che provoca questa anomalia, perché proprio non ci levo le gambe.
<?php
function usaCarrello()
{
$carrello = $_SESSION['carrello'];
if (!$carrello)
{
return 'Il tuo carrello è vuoto.<br>';
}else{
$carrello = @explode(',',$carrello);
return 'Ci sono <a href="carrello/carrello.php">'.
@count($carrello). ' articoli nel carrello.</a><br>'."--".$carrello;
}
}
function mostraCarrello()
{
global $db;
$carrello = $_SESSION['carrello'];
$somma = 0;
if ($carrello)
{
$carrello = @explode(',',$carrello);
$acquisti = array();
foreach ($carrello as $prodotto)
{
$acquisti[$prodotto] = (@isset($acquisti[$prodotto])) ? $acquisti[$prodotto] + 1 : 1;
}
$result[] = '<form action="carrello.php?action=aggiorna" method="post" id="cart">';
$result[] = '<table>';
foreach ($acquisti as $id=>$quantita)
{
$sql = 'SELECT * FROM fotogallery where id = '.$id;
$res = $db->query($sql);
global $f;
$f = $res->fetch();
if (empty ($f)){
echo 'la variabile è vuota';
}else{
echo 'variabile piena';
}
----------------------------------------------------------------------------
da questo controllo sul server risulta vuota; al contrario sul mio pc tutto regolare
l'altra variabile interessata invece ($res) invece risulta regolarmente piena.
----------------------------------------------------------------------------
@extract($f);
$result[] = '<tr>';
$result[] = '<td><a href="carrello.php?action=cancella&id='.$id.'"><i>Cancella</i> </a></td>';
$result[] = '<td>'.'<i>cod.:</i>'.$codice.'  <i>desc:</i> '.'<b>'.$descrizione.'</b>'.' <i> tipologia:</i> '.$tipologia.'</td>';
$result[] = '<td>€'.$prezzo.'</td>';
$result[] = '<td><input type="text" name="<i>quantita</i>'.$id.'" value="'.$quantita.'" size="3"></td>';
$result[] = '<td>€'.($prezzo * $quantita).'</td>';
$somma += $prezzo * $quantita;
$result[] = '</tr>';
}
$result[] = '</table><br>';
$result[] = 'Totale: <b>€'.$somma.'</b></br><br>';
//$result[] = '<button type="submit">Aggiorna il carrello</button>';
$result[] = '</form>';
}else{
$result[] = 'Il carrello è vuoto.<br>';
}
return join($result);
}
?>
------------------------
--------------------------
sembra quindi che non svolga la funzione "fetch" che si trova nel file incluso (mysql) del quale posto il codice pure:
file mysql.php:
<?php
class MySQL
{
var $host;
var $user;
var $password;
var $database;
var $connessione;
var $errore;
function MySQL ($host,$user,$password,$database)
{
$this->host=$host;
$this->user=$user;
$this->password=$password;
$this->errore=$database;
$this->connessione();
}
function connessione()
{
if (!$this->connessione = @mysql_connect($this->host, $this->user, $this->password))
{
trigger_error('Impossibile connettersi a MySQL.');
$this->errore=true;
}
elseif (!@mysql_select_db($this->errore,$this->connessione))
{
trigger_error('Impossibile connettersi al database.');
$this->errore=true;
}
}
function notifica_errore()
{
if ($this->errore) return true;
$notifica=mysql_error($this->connessione);
if (empty($notifica)) return false;
else return true;
}
function query($sql)
{
if (!$qRes=mysql_query($sql,$this->connessione))
trigger_error (
'Query fallita: '.mysql_error($this->connessione).
' SQL: '.$sql);
return new MySQLResult($this,$qRes);
}
}
class MySQLResult
{
var $mysql;
function MySQLResult(& $mysql,$query)
{
$this->mysql=& $mysql;
$this->query=$query;
}
function fetch()
{
if ($f=mysql_fetch_array($this->query,MYSQL_ASSOC))
{
return $f;
}
else if ($this->size() > 0)
{
mysql_data_seek($this->query,0);
return false;
}else{
return false;
}
} function size()
{
return mysql_num_rows($this->query);
}
function insertID()
{
return mysql_insert_id($this->mysql->connessione);
}
function notifica_errore()
{
return $this->mysql->notifica_errore();
}
}
?>
ho controllato e fatto alcune modifiche sul php-phpcore sul server, sembrerebbe tutto regolare, ho confrontato anche con il php sul mio pc ma... niente
spero qualcuno mi possa dare un suggerimento. Grazie.