Pagina 2 di 4 primaprima 1 2 3 4 ultimoultimo
Visualizzazione dei risultati da 11 a 20 su 32
  1. #11
    esce fuori ciò:
    query: select user from utenti where user='b' and password='b'
    [/PHP]

    a cosa serve questa stampa??
    vola come una farfalla, pungi come un'ape

  2. #12
    Utente di HTML.it L'avatar di kodode
    Registrato dal
    Sep 2002
    Messaggi
    1,896
    ma se tu su phpMyAdmin esegui

    select user from utenti where user='b' and password='b'

    ti ritorna qualche risultato?

  3. #13
    mah sinceramente non so usare phpmyadmin.. però il problema di fondo è che proprio la funzione fetch_row che non va... ho provato anche con num row, ma non va manco quella, mi dice sempre la stessa cosa
    vola come una farfalla, pungi come un'ape

  4. #14
    Utente di HTML.it L'avatar di kodode
    Registrato dal
    Sep 2002
    Messaggi
    1,896
    sembrerebbe tutto ok....
    prova cosi:
    Codice PHP:

    $db
    =mysql_connect("localhost""root"""); 
    mysql_select_db("utenti"); 
    $user=$_POST['user']; 
    $pass=$_POST['pass']; 
    $sql="select user from utenti where user='$user' and password='$pass'"

    $resultmysql_query$sql $db) ;

    echo 
    "<pre>";
    print_r($result) ;
    echo 
    "</pre>"
    che stampa??

  5. #15
    Utente bannato
    Registrato dal
    Apr 2008
    Messaggi
    146

    prova questo

    <?php
    $db=mysql_connect("localhost", "root", "");
    mysql_select_db("utenti");
    $user=$_POST['user'];
    $pass=$_POST['pass'];
    $sql="select user from utenti where user='$user' and password='$pass'";

    $query= mysql_query( $sql , $db) ;



    if ( !mysql_fetch_array($query))
    echo "accesso negato" ;
    else
    echo "accesso effettuato";
    ?>

    in poche parole mysql_fetch_array trasforma il risultato in array se vi è un risultato altrimenti restituisc false

  6. #16
    Utente di HTML.it L'avatar di dararag
    Registrato dal
    Jan 2008
    Messaggi
    434
    usa questo:
    [PHP]
    <?php
    $db=mysql_connect("localhost", "root", "");
    mysql_select_db("utenti");
    $user=$_POST['user'];
    $pass=$_POST['pass'];
    $sql="select user from utenti where user='" . $user . "' and password='" . $pass . "'";
    $query=mysql_query($sql, $db);
    if (!mysql_fetch_row($sql)
    echo "accesso negato";
    else
    echo"accesso effettuato";
    ?>
    [PHP]
    prima di tutto bisogna fare la mysql_query, quindi le variabili non vanno direttamente tra apici.
    Consiglierei a tutti e due di leggere questa: Guida PHP-MySql su Html.it

  7. #17
    Utente bannato
    Registrato dal
    Apr 2008
    Messaggi
    146

    una domanda

    Originariamente inviato da dararag
    usa questo:
    [PHP]
    <?php
    $db=mysql_connect("localhost", "root", "");
    mysql_select_db("utenti");
    $user=$_POST['user'];
    $pass=$_POST['pass'];
    $sql="select user from utenti where user='" . $user . "' and password='" . $pass . "'";
    $query=mysql_query($sql, $db);
    if (!mysql_fetch_row($sql)
    echo "accesso negato";
    else
    echo"accesso effettuato";
    ?>
    [PHP]
    prima di tutto bisogna fare la mysql_query, quindi le variabili non vanno direttamente tra apici.
    Consiglierei a tutti e due di leggere questa: Guida PHP-MySql su Html.it

    scusa un'attimo ma che differenza c'è tra questo ed il tuo

    <?php
    $db=mysql_connect("localhost", "root", "");
    mysql_select_db("utenti");
    $user=$_POST['user'];
    $pass=$_POST['pass'];
    $sql="select user from utenti where user='$user' and password='$pass'";

    $query= mysql_query( $sql , $db) ;



    if ( !mysql_fetch_array($query))
    echo "accesso negato" ;
    else
    echo "accesso effettuato";
    ?>

    apparte '" . $user . "' and password='" . $pass . "'"; che non serve a nulla?

  8. #18
    Utente di HTML.it L'avatar di dararag
    Registrato dal
    Jan 2008
    Messaggi
    434
    lo dici tu che non serve a niente, come è lì, gli passi esattamente la stringa $user ed $pass, che nel database non esistono, come ho fatto io, invece, passi i valori delle variabili e non i nomi.

  9. #19
    Utente bannato
    Registrato dal
    Apr 2008
    Messaggi
    146

    nonono

    Originariamente inviato da dararag
    lo dici tu che non serve a niente, come è lì, gli passi esattamente la stringa $user ed $pass, che nel database non esistono, come ho fatto io, invece, passi i valori delle variabili e non i nomi.
    no no il php quando racchiudi una stringa in "" ttrasforma automaticamente tutte le variabili precedute da $, quindi in questo caso $user verra avvalorato con il suo valore reale

  10. #20
    Utente di HTML.it L'avatar di kodode
    Registrato dal
    Sep 2002
    Messaggi
    1,896
    quoto pienamente quanto detto dakiller-gio e mi dispiace molto per giozh perchè secondo me quanto detto da dararag gli farà solo confusione...
    per dararag prima di postare o di "consigliare" guide ad altri pensaci bene

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