Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 12

Discussione: Aiuto con query

  1. #1

    Aiuto con query

    Salve a tutti.

    Sto installando un script in pagine php che prevede l'interazione con un db mysql versione 4.0.27 client 5.0.37 in hosting!
    Il servizio in oggetto è del provider Tiscali, sul quale ho attivato ovviamente ancheil servizio in PHP.

    Interagisco perfettamente con il mio server gestendo nel mio sito gli utenti con permessi e non.

    Il problema sta, come prima detto, in uno script, precisamente il web3news per la gestione del newsletter. Nello specifico interrogando determinate funzioni mi restituisce i seguenti errori (effettuati dallo script):

    - Se cerco di modificare una tabella:
    Error: Unable to fetch data from query: select * from w3n_sec_pages where id='' :

    - Se cerco di entrare nel setup (sempre dello script)

    Error: Unable to perform query: select * from order by id :You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by id' at line 1


    E' possibile che il problema stia nella versione del mysql offerto dall'hosting?
    Posso apporre dello modifiche allo script affinche funzioni anche con la versione mysql del provider?

    Grazie infinite, Matteo

  2. #2
    Utente di HTML.it L'avatar di Threepwood
    Registrato dal
    Feb 2003
    Messaggi
    2,107
    A me pare ci sia un chiaro errore:

    select * from order by id

    Manca la tabella (select * from TABELLA order by id)
    Guybrush Threepwood

  3. #3
    Originariamente inviato da Threepwood
    A me pare ci sia un chiaro errore:

    select * from order by id

    Manca la tabella (select * from TABELLA order by id)
    Cioè pensi che lo script non richiami la tabella? Non credo che uno script come web3news abbaino dimenticato una cosa simile..cmq controllo..

  4. #4

    Re: Aiuto con query

    - Se cerco di modificare una tabella:
    Error: Unable to fetch data from query: select * from w3n_sec_pages where id='' :
    se non specifichi il valore dell'id ti da errore si il mysql..si aspetta un valore intero
    - Se cerco di entrare nel setup (sempre dello script)
    Error: Unable to perform query: select * from order by id :You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by id' at line 1
    qui se non ci metti il nome della tabella vai poco in la mi sa....

    questi due errori mi sembrano causati da fatto che nel primo caso una varibile del tipo $id e nel secondo caso una variabile tipo $tabella non prendano il valore
    quindi quando vai a formare la query non vengono stampati... controlla che prendano il valore

    $query = "select * from w3n_sec... where id=".$id --> se $id="" ecco l'erroe stessa cosa per la query dopo

  5. #5
    Aspettate un secondo.

    Nel file config.php che allego:

    Codice PHP:
    <?php
    error_reporting
    (E_ALL^E_NOTICE);
    $dbaddress        "*******";
    $dbuname        "*******";
    $pwd                "*******";
    $dbname         "********";


    //######################
    //Dati ftp
    //######################

     
    $ftpaddress    "*********";
     
    $ftpuser        "*********";
     
    $ftppass        "********";
      
      
        
    // === NEW === 
    //######################
    //Password per autorizzare l'invio automatico
    //######################
    $passw="*********";

    //######################
    //Directory di sistema
    //######################
       //Directory dove trovare gli allegati
       
    $root             dirname(__FILE__)."/";     // Modificare solo se necessario (in genere e' ok
       
    $web                "http://www.derapataclub.com/";            //URL del sito con  / finale
        //URL del sito con  / finale
       
    $sottocartella    "web3news";                                  //Senza / iniziale e finale finale
                                                                   //Es: $sottocartella="web3news";

       
    $sotto_allegati  "allegati/";                                 //Sottocartella per gli allegati Es: allegati/
                                                                   //intende /web3news/allegati
        
    $sotto_import  "import/";
        
    $refresh $web.$sottocartella."/web/refresh.php";

    /**************ESEMPIO************
       $root = "/www/prova.com/";
       $web="http://www.nomecliente.com/";
       $sottocartella="web3news";
       $sotto_allegati="allegati";
    **********************************/

       
    $imgdir    "img";    //Direcory delle immagini (al di sotto della directory principale
       
    $fimg        "gif";    //Formato immagini (jpg o png) SPECIFICARE IN MINUSCOLO
        
    $embedimg=true//Indica se le immagini da mostrare nell'html del messaggio sono da allegare o da far puntare al webserver
        
      //URL per la rimozione del file
      //La struttura della pagina e' del Vs. sito all'interno della quale
      //ci sara' un include del tipo: include ("web3news/rimuovi.php");
      
    $url        $web.$sottocartella."/rimuovi.php";
      
      
    $conferma1r="Ciao!";
      
    $conferma2r="Grazie di esserti iscritto alla nostra Newsletter";
      
    $conferma3r="A presto!";
      
        
    $att_conferma1r="Ciao!";
        
    $att_conferma2r=" Per poter ultimare il processo di iscrizione devi confermare cliccando su questo link:";
        
    $att_conferma3r="Grazie.";
     
      
      
    $mitt        "Staff DerapataClub"//Mittente del messaggio automatico di segnalazione rimozione utente
      
    $mittemail "staff@derapataclub.com";
      
    $segnala    "jfkevo@derapataclub.com";              // Email per informare il Webmaster

    //attiva email di conferma
      
    $aedc="1";  //Setta a zero per non spedire email
    //attiva email al webmaster
      
    $mmaw="1";  //Setta a zero per non spedire email


    //#############################
    //Numero di utenti visualizzati
    //#############################
      
    $ininvio    "100";        //IN FASE DI INVIO
      
    $inmodifica    "50";        //IN FASE DI MODIFICA

      
      
      // === NEW === 

    //#############################
    //Numero di secondi per il refresh
    //#############################
      
    $sec_refresh 3;

       
    // === NEW === 
      
    //######################
    //Testi
    //######################
    //Messaggio di rimozione inserito in fondo al testo
      
    $nota        "Se vuoi rimuoverti da questa lista di informazioni clicca qui:\n";

    // Subject nel messaggio di benvenuto
    //(il testo e' inserito nel database modificabile direttamente online)
    $subjecttnx "Grazie di esserti iscritto alla nostra mailing list";

    //Segnalazione al webmaster quando un utente si  iscrive alla newsletter
    $subjsegn="Web3news: Nuovo utente iscritto!";



        
    //######################
        //Nomi delle tabelle
        //Consigliato lasciare
        //il default
        //######################
      
    $prefix="w3n_";
      
    $tbl["sendings"] =  $prefix."sendings";
      
    $tbl["newsletters"]        = $prefix."newsletters";
      
    $tbl["identities"]         =  $prefix."identities";
      
    $tbl["subcriptions"]        =  $prefix."subscriptions";
      
    $tbl["templates"]        =  $prefix."templates";
      
    $tbl["users"]        =  $prefix."sec_users";
      
    $tbl["profiles"]        =  $prefix."sec_profiles";
      
    $tbl["settings"]        =  $prefix."sec_settings";
      
    $tbl["pages"]        =  $prefix."sec_pages";
      
    $tbl["activations"]    =  $prefix."activations";
      
    $tbl["urls"] = $prefix."urls";
      
    $tbl["logs"] = $prefix."logs";
      
    $tbl["images"] = $prefix."images";
      
    $tbl["images_folder"] = $prefix."images_folder";

        
    $fileconferma "/web/conferma.php";
      
    // === NEW === 
     
    ?>

  6. #6
    ....mi sembra correttamente dichiarata la posizione del mio db e i suoi parametri di connessione.

    Inoltre in quest'altro, che è il setup_include.php

    Codice PHP:
    <?php
    //error_reporting(E_ALL);
    include "../connect.inc.php";


    //==================================================================

    $cfgExecTimeLimit         300;    // maximum execution time in seconds (0 for no limit)

    function sostituisci($sql){
            
                
    preg_match_all('/\{([^}]*)\}/'$sql$matches);
                
    $risultati $matches[1];
                foreach (
    $risultati as $ris){
                    
    $key="\{".$ris."\}";
                    
                    
    // per i tag template nell'oggetto, mostra il tag per quelli protetti
                    // per gli altri invece mostra una text area. 
                    
                    
                  
    global $tbl,$sottocartella;
      
      
                    switch (
    $ris){
                        case 
    "w3kml";
                            
    $sql eregi_replace("$key",$tbl["newsletters"],$sql);
                        break;
                        case 
    "identities";
                            
    $sql eregi_replace("$key",$tbl["identities"],$sql);
                        break;
                        case 
    "w3kutenti";
                            
    $sql eregi_replace("$key",$tbl["subcriptions"],$sql);
                        break;
                        case 
    "w3ktmpl";
                            
    $sql eregi_replace("$key",$tbl["templates"],$sql);
                        break;
                        case 
    "sec_users";
                            
    $sql eregi_replace("$key",$tbl["users"],$sql);
                        break;
                            case 
    "sec_profiles";
                            
    $sql eregi_replace("$key",$tbl["profiles"],$sql);
                        break;
                        case 
    "sec_pages";
                            
    $sql eregi_replace("$key",$tbl["pages"],$sql);
                        break;
                        case 
    "sec_settings";
                            
    $sql eregi_replace("$key",$tbl["settings"],$sql);
                        break;
                        case 
    "w3kinvii";
                            
    $sql eregi_replace("$key",$tbl["sendings"],$sql);
                        break;
                        case 
    "w3kattivazioni";
                            
    $sql eregi_replace("$key"$tbl["activations"],$sql);
                        break;
                        case 
    "w3kurl";
                            
    $sql eregi_replace("$key"$tbl["urls"],$sql);
                        break;
                        case 
    "w3klog";
                            
    $sql eregi_replace("$key"$tbl["logs"],$sql);
                        break;
                        case 
    "images";
                            
    $sql eregi_replace("$key"$tbl["images"],$sql);
                        break;
                        case 
    "images_folder";
                            
    $sql eregi_replace("$key"$tbl["images_folder"],$sql);
                        break;
                        
                        case 
    "subdir";
                            if (
    $_POST["overw3s"]==true)
                                
    $sottoc="administration/".$sottocartella;
                            else 
                                
    $sottoc=$sottocartella;
                            
    $sql eregi_replace("$key"$sottoc,$sql);
                        break;
                        case 
    "permissions";
                            
    $sqlx="select max(id) as biggest from ".$tbl["pages"]."";
                            
    $resx=mysql_query($sqlx);
                            
    $bigger=mysql_fetch_array($resx);
                            
    $permissions="a:".$bigger["biggest"].":{";
                            for (
    $i=1;$i<=$bigger["biggest"];$i++){
                                
    $permissions.="i:".$i.";s:1:\"1\";";
                            }
                            
    $permissions.="}";
                            
    $sql eregi_replace("$key",$permissions,$sql);
                        break;
                    }
                }

                return 
    $sql;
    }

    function 
    PMA_splitSqlFile(&$ret$sql$release){
        
    $sql          trim($sql);
        
    $sql_len      strlen($sql);
        
    $char         '';
        
    $string_start '';
        
    $in_string    FALSE;
        
    $time0        time();

        for (
    $i 0$i $sql_len; ++$i) {
            
    $char $sql[$i];

            
    // We are in a string, check for not escaped end of strings except for
            // backquotes that can't be escaped
            
    if ($in_string) {
                for (;;) {
                    
    $i         strpos($sql$string_start$i);
                    
    // No end of string found -> add the current substring to the
                    // returned array
                    
    if (!$i) {
                        
    $ret[] = $sql;
                        return 
    TRUE;
                    }
                    
    // Backquotes or no backslashes before quotes: it's indeed the
                    // end of the string -> exit the loop
                    
    else if ($string_start == '`' || $sql[$i-1] != '\\') {
                        
    $string_start      '';
                        
    $in_string         FALSE;
                        break;
                    }
                    
    // one or more Backslashes before the presumed end of string...
                    
    else {
                        
    // ... first checks for escaped backslashes
                        
    $j                     2;
                        
    $escaped_backslash     FALSE;
                        while (
    $i-$j && $sql[$i-$j] == '\\') {
                            
    $escaped_backslash = !$escaped_backslash;
                            
    $j++;
                        }
                        
    // ... if escaped backslashes: it's really the end of the
                        // string -> exit the loop
                        
    if ($escaped_backslash) {
                            
    $string_start  '';
                            
    $in_string     FALSE;
                            break;
                        }
                        
    // ... else loop
                        
    else {
                            
    $i++;
                        }
                    } 
    // end if...elseif...else
                
    // end for
            
    // end if (in string)

            // We are not in a string, first check for delimiter...
            
    else if ($char == ';') {
                
    // if delimiter found, add the parsed part to the returned array
                
    $ret[]      = substr($sql0$i);
                
    $sql        ltrim(substr($sqlmin($i 1$sql_len)));
                
    $sql_len    strlen($sql);
                if (
    $sql_len) {
                    
    $i      = -1;
                } else {
                    
    // The submited statement(s) end(s) here
                    
    return TRUE;
                }
            } 
    // end else if (is delimiter)

            // ... then check for start of a string,...
            
    else if (($char == '"') || ($char == '\'') || ($char == '`')) {
                
    $in_string    TRUE;
                
    $string_start $char;
            } 
    // end else if (is start of string)

            // ... for start of a comment (and remove this comment if found)...
            
    else if ($char == '#'
                     
    || ($char == ' ' && $i && $sql[$i-2] . $sql[$i-1] == '--')) {
                
    // starting position of the comment depends on the comment type
                
    $start_of_comment = (($sql[$i] == '#') ? $i $i-2);
                
    // if no "\n" exits in the remaining string, checks for "\r"
                // (Mac eol style)
                
    $end_of_comment   = (strpos(' ' $sql"\012"$i+2))
                                  ? 
    strpos(' ' $sql"\012"$i+2)
                                  : 
    strpos(' ' $sql"\015"$i+2);
                if (!
    $end_of_comment) {
                    
    // no eol found after '#', add the parsed part to the returned
                    // array if required and exit
                    
    if ($start_of_comment 0) {
                        
    $ret[]    = trim(substr($sql0$start_of_comment));
                    }
                    return 
    TRUE;
                } else {
                    
    $sql          substr($sql0$start_of_comment)
                                  . 
    ltrim(substr($sql$end_of_comment));
                    
    $sql_len      strlen($sql);
                    
    $i--;
                } 
    // end if...else
            
    // end else if (is comment)

            // ... and finally disactivate the "" syntax if MySQL < 3.22.07
            
    else if ($release 32270
                     
    && ($char == '!' && $i 1  && $sql[$i-2] . $sql[$i-1] == '/*')) {
                
    $sql[$i] = ' ';
            } 
    // end else if

            // loic1: send a fake header each 30 sec. to bypass browser timeout
            
    $time1     time();
            if (
    $time1 >= $time0 30) {
                
    $time0 $time1;
                
    header('X-pmaPing: Pong');
            } 
    // end if
        
    // end for

        // add any rest to the returned array
        
    if (!empty($sql) && ereg('[^[:space:]]+'$sql)) {
            
    $ret[] = $sql;
        }

        return 
    TRUE;
    // end of the 'PMA_splitSqlFile()' function

    function importaSql ($sql_file=""){
        
        
        
    /**
         * Increases the max. allowed time to run a script
         */
        
    @set_time_limit($cfgExecTimeLimit);
        
    $goto 'setup.php';
        
    $err_url $goto."?errore=1";
        
        
    /**
         * Set up default values for some variables
         */
        
    $view_bookmark 0;
        
    $sql_bookmark  = isset($sql_bookmark) ? $sql_bookmark '';
        
    $sql_query     = isset($sql_query)    ? $sql_query    '';
        
    $sql_file      = !empty($sql_file)    ? $sql_file     'none';
        
        
    /**
         * Prepares the sql query
         */
         
        // Gets the query from a file if required
        
    if ($sql_file != 'none') {
            if (
    file_exists($sql_file)) {
                
    $open_basedir     '';
                if (
    PMA_PHP_INT_VERSION >= 40000 ) {
                    
    $open_basedir = @ini_get('open_basedir');
                }
                if (empty(
    $open_basedir)) {
                    
    $open_basedir = @get_cfg_var('open_basedir');
                }
            
                
    // If we are on a server with open_basedir, we must move the file
                // before opening it. The doc explains how to create the "./tmp"
                // directory
            
                
    if (!empty($open_basedir)) {
                
    // check if '.' is in open_basedir
                
    $pos strpos(' ' $open_basedir'.');
            
                
    // from the PHP annotated manual
                
    if (!$pos) {
                    
    // if no '.' in openbasedir, do not move the file, force the
                    // error and let PHP report it
                    
    error_reporting(E_ALL);
                    
    $sql_query fread(fopen($sql_file'r'), filesize($sql_file));
                } else {
                        
                    
    $sql_file_new './tmp/' basename($sql_file);
                    if (
    PMA_PHP_INT_VERSION 40003) {
                        
    copy($sql_file$sql_file_new);
                    } else {
                        
    move_uploaded_file($sql_file$sql_file_new);
                    }
                    
    $sql_query fread(fopen($sql_file_new'r'), filesize($sql_file_new));
                    
    unlink($sql_file_new);
                }
                } else {
                
    // read from the normal upload dir
                
    $sql_file;
                
    $sql_query fread(fopen($sql_file'r'), filesize($sql_file));
                
                }
            
              if (
    get_magic_quotes_runtime() == 1) {
                        
    $sql_query stripslashes($sql_query);
              }
            }
        } else if (empty(
    $id_bookmark) && get_magic_quotes_gpc() == 1) {
            
    $sql_query stripslashes($sql_query);
        }
        
        
    $sql_query trim($sql_query);
        
    $pieces = array();
        
    PMA_splitSqlFile($pieces$sql_queryPMA_MYSQL_INT_VERSION);
        
    $pieces_count count($pieces);
        
        for (
    $i 0$i $pieces_count$i++) {
            
    $a_sql_query $pieces[$i];
            
    $a_sql_query =  sostituisci($a_sql_query);            
            
    $result mysql_query($a_sql_query);
                
             if (
    $result == FALSE) { // readdump failed
            
    $my_die $a_sql_query;
             print 
    "<div class='sqlerror'>".$a_sql_query."</div>\n";
           
    // break;
        
    }else{
            print 
    "<div class='sql'>".$a_sql_query."</div>\n";
        }
        if (!isset(
    $reload) && eregi('^(DROP|CREATE)[[:space:]]+(IF EXISTS[[:space:]]+)?(TABLE|DATABASE)[[:space:]]+(.+)'$a_sql_query)) {
            
    $reload 1;
        }     
        } 
    // end for
            
        
    unset($pieces);

    }


    //==================================================================
    if ($_POST["complete"]==true){
        
    importaSQL("web3news.sql");
    }elseif (
    $_POST["updateto098"]==true){
    echo 
    "QUO";
        
    importaSQL("update097-098.sql");
    }elseif (
    $_POST["overw3s"]==true){
        
    importaSQL("addw3s.sql");
    }


    ?>
    ..... vedete dove è richiamata la funzione..

    La tabella come vedete è richiamata!

  7. #7
    nessuna dritta?

  8. #8
    Originariamente inviato da Jfkevo
    nessuna dritta?
    up

  9. #9
    Originariamente inviato da Jfkevo
    up
    ragazxzi non ci credo che nessuno tra divoi ha lo script web3news....

    Oppure consigliarmene un altro??


  10. #10

    Re: Aiuto con query

    Originariamente inviato da Jfkevo
    Salve a tutti.

    Sto installando un script in pagine php che prevede l'interazione con un db mysql versione 4.0.27 client 5.0.37 in hosting!
    Il servizio in oggetto è del provider Tiscali, sul quale ho attivato ovviamente ancheil servizio in PHP.

    Interagisco perfettamente con il mio server gestendo nel mio sito gli utenti con permessi e non.

    Il problema sta, come prima detto, in uno script, precisamente il web3news per la gestione del newsletter. Nello specifico interrogando determinate funzioni mi restituisce i seguenti errori (effettuati dallo script):

    - Se cerco di modificare una tabella:
    Error: Unable to fetch data from query: select * from w3n_sec_pages where id='' :

    - Se cerco di entrare nel setup (sempre dello script)

    Error: Unable to perform query: select * from order by id :You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by id' at line 1


    E' possibile che il problema stia nella versione del mysql offerto dall'hosting?
    Posso apporre dello modifiche allo script affinche funzioni anche con la versione mysql del provider?

    Grazie infinite, Matteo
    non ho letto il seguito ma il problema sembra essere individuato dai due errori che riporti...

    nel primo caso:

    select * from w3n_sec_pages where id=1

    devi mettere un numero dopo id, ora non o quale fosse l'obbiettivo della query quindi non so quale numero devi inserire.

    nel secondo caso:

    Error: Unable to perform query: select * from order by id :You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'order by id' at line 1

    come già detto manca il nome della tabella da cui si vogliono estrarre le righe:

    select * from nome_tabella order by id
    Forex: forum dedicato al mercato del trading forex

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 © 2025 vBulletin Solutions, Inc. All rights reserved.