Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Problema con PHP + SQL !

    Ciao a tutti, sono nuovissimo di questo forum...
    Ho un problemone con una pagina web del sito che sto ultimando e confido nella vostra eccellente competenza in materia sperando di trovare una soluzione!

    Ringraziandovi anticipatamente della vostra disponibilità, vi sottopongo il mio problema:

    Ho creato una pagina con 2 righe da compilare e un tasto per inviare i dati con il seguente codice:

    <div class="column1-unit" align="center">
    <div class="contactform" align="center">
    <form method="post" action="{$script_url}?act=key">
    <fieldset><legend> {$user.name}'s MALL POINTS DELIVERING SISTEM </legend>


    Please enter here the key gonna active now:</p>


    <input type="text" name="act_key" class="bigfield" value="" tabindex="1" /></p>


    Please enter here the point's quantity:</p>


    <input type="text" name="points" class="bigfield" value="" tabindex="2" /></p>


    <input type="submit" name="a_key" value="Submit"></p>
    </fieldset>
    </form>
    </div>
    </div>


    Riferito alla seguente pagina key.php che dovrebbe prendere i dati inseriti in precedenza e scriverli in un database sql (database WEBSITE, tabella item_key)

    qui vi posto il codice relativo nel key.php:

    ....
    if (isset($_SESSION['aid']))
    {
    if (isset($a_key)) {

    $actkey = doQuery("INSERT INTO item_key (act_key,wasted,points) VALUES ('.$act_key.','0','.$points.')", DATABASE_WEBSITE);
    $row = mssql_fetch_array($actkey);

    if(mssql_num_rows($actkey) == 0)
    {
    $oSmarty->assign('message', array( 'type' => 'error',
    'messages' => array( 'Error key' ) ) );
    }
    else
    {
    $oSmarty->assign('message', array( 'type' => 'ok',
    'messages' => array( 'Your key has been succesful actived!' ) ) );
    }
    }
    }
    ....

    Quando compilo i campi nella pagina web non mi da nessun errore... però non mi aggiunge la riga al database... Spero di essere stato abbastanza chiaro.


    In attesa del vostro prezioso aiuto... Saluti, Matteo.

  2. #2
    Utente di HTML.it L'avatar di Laxus
    Registrato dal
    Oct 2010
    Messaggi
    251
    Ora non so' se hai la direttiva register_globals impostata su on, ma se vuoi recuperare i dati inviati devi utilizzare $_POST

    if (isset($a_key)) diventa quindi if (isset($_POST['a_key'])) (stesso lavoro per le altre variabili)

    byez

    p.s, quel $row = mssql_fetch_array($actkey); si potrebbe anche togliere e utilizzare mssql_rows_affected al posto di mssql_num_rows

  3. #3
    Perdonami l'ignoranza...
    con questo codice:

    // Include needed files
    if (isset($_SESSION['aid']))
    {
    if (isset($_POST['a_key'])) {

    $actkey = doQuery("INSERT INTO item_key (act_key,wasted,points) VALUES ('$act_key','0','.$points.')", DATABASE_WEBSITE); LINEA 31


    if(mssql_num_rows($actkey) == 0) LINEA 34
    {
    $oSmarty->assign('message', array( 'type' => 'error',
    'messages' => array( 'Error key' ) ) );
    }
    else
    {
    $oSmarty->assign('message', array( 'type' => 'ok',
    'messages' => array( 'Your key has been succesful actived!' ) ) );
    }
    }
    }
    else
    {
    $oSmarty->assign('message', array( 'type' => 'error',
    'messages' => array( 'Please log-in to acces this feature!.' ) ) );
    }

    ottengo il seguente errore:

    Notice: Undefined variable: act_key in C:\xampp\htdocs\sitopower\pages\mall\inc.key.php on line 31

    Notice: Undefined variable: points in C:\xampp\htdocs\sitopower\pages\mall\inc.key.php on line 31

    Warning: mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in C:\xampp\htdocs\sitopower\pages\mall\inc.key.php on line 34

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.