Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 19
  1. #1

    Strani Warning relativi allo script

    Ho uno script che mi da i seguenti Warning. Essendo un argomento non valido di MySQL-Link, ho subito pensato che potesse essere un errore relativa alla connessione, ma questa avviena correttamente.
    Che tipo di errori possono essere ?

    Di seguito vi allego i Warning riportati:


    codice:
    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in c:\programmi\easyphp1-8\www\ecommerce - shop\mysql.php on line 44
    
    Warning: mysql_error(): supplied argument is not a valid MySQL-Link resource in c:\programmi\easyphp1-8\www\ecommerce - shop\mysql.php on line 46
    
    Notice: Query fallita: SQL: SELECT * FROM prodotti ORDER BY id in c:\programmi\easyphp1-8\www\ecommerce - shop\mysql.php on line 47
    
    Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\programmi\easyphp1-8\www\ecommerce - shop\mysql.php on line 64
    
    Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in c:\programmi\easyphp1-8\www\ecommerce - shop\mysql.php on line 79

    Ah..tengo a precisare che eseguo tutto in locale.
    Potrebbe essere che devo abilitare qualcosa in php.ini ?

    Grazie

  2. #2
    Postare il codice sarebbe di aiuto

  3. #3
    Utente di HTML.it L'avatar di Razorblade
    Registrato dal
    Feb 2002
    Messaggi
    1,308
    La variabile in cui contieni la risorsa di connessione non è valida:

    Codice PHP:
    Warningmysql_query(): supplied argument is not a valid MySQL-Link resource 
    I restanti errori sono causati tutti dalla stessa cosa.
    Ciao

  4. #4
    il codice è questo:

    codice:
    <?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;
      var $query;
      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();
      }
    }
    ?>

  5. #5
    Secondo voi dove sta l'errore ?

  6. #6
    Ho anche provato ad upparlo su un server ad esempio netsons... ma nada

    Mi aiutate xfavore ?

  7. #7
    Utente di HTML.it L'avatar di Razorblade
    Registrato dal
    Feb 2002
    Messaggi
    1,308
    Posta il codice dove esegui la query.
    Ciao

  8. #8
    questo è il codice dove viene eseguita la query

    codice:
    <?php
    function usaCarrello()
    {
      $carrello = $_SESSION['carrello'];
      if (!$carrello)
      {
        return 'Il carrello è vuoto.
    ';
      }else{
        $prodotti = @explode(',',$carrello);
        return 'Ci sono <a href="carrello.php">'.
        @count($prodotti). ' prodotti nel carrello.</a>
    ';
      }
    }
    
    function mostraCarrello()
    {
      global $db;
      $carrello = $_SESSION['carrello'];
      $somma = 0;
      if ($carrello)
      {
        $prodotti = @explode(',',$carrello);
        $acquisti = array();
        foreach ($prodotti 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 prodotti WHERE id = '.$id;
          $res = $db->query($sql);
          $f = $res->fetch();
          @extract($f);
          $result[] = '<tr>';
          $result[] = '<td>Cancella</td>';
          $result[] = '<td>'.$nome.' by '.$marca.'</td>';
          $result[] = '<td>&euro;'.$prezzo.'</td>';
          $result[] = '<td><input type="text" name="quantita'.$id.'" value="'.$quantita.'" size="3"></td>';
          $result[] = '<td>&euro;'.($prezzo * $quantita).'</td>';
          $somma += $prezzo * $quantita;
          $result[] = '</tr>';
        }
    
        $result[] = '</table>';
        $result[] = 'Totale: &euro;'.$somma.'</br>';
        $result[] = '<button type="submit">Aggiorna il carrello</button>';
        $result[] = '</form>';
      }else{
        $result[] = 'Il carrello è vuoto.
    ';
      }
      return @join('',$result);
    }
    ?>

  9. #9
    Utente di HTML.it L'avatar di Razorblade
    Registrato dal
    Feb 2002
    Messaggi
    1,308
    A parte il fatto che non hai inserito la numerazione delle righe e quindi è ancora difficile aiutarti, un mio primo consiglio è quello di inserire le variabili sempre tra apici quando scrivi le query:

    Questo

    Codice PHP:
    $sql "SELECT * FROM prodotti WHERE id = '".$id."' "
    invece di

    Codice PHP:
    $sql 'SELECT * FROM prodotti WHERE id = '.$id
    Un altro consiglio, prova a stampare a video la query che ti sta dando problemi ed eseguirla ad esempio su phpmyadmin, è un ottimo metodo per trovare gli errori.
    Ciao

  10. #10
    Utente di HTML.it L'avatar di luca200
    Registrato dal
    Apr 2002
    Messaggi
    4,120

    Re: Strani Warning relativi allo script

    Originariamente inviato da Traxsung
    Essendo un argomento non valido di MySQL-Link, ho subito pensato che potesse essere un errore relativa alla connessione, ma questa avviena correttamente.
    Cosa te lo fa pensare? L'evidenza dice il contrario...

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.