Visualizzazione dei risultati da 1 a 4 su 4

Discussione: codice completo

  1. #1
    Utente di HTML.it
    Registrato dal
    Feb 2005
    Messaggi
    43

    codice completo

    Scusa è che l'errore è sempre lo stesso, te lo posto

    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 's &PHPSESSID=96ofhosoukfudspt3dlf7g0dn3')' at line 1

    Ho scritto pippo's e il ritorno è questo.

    Mi sa che renderei tutto più semplice se postassi l'intero codice della mia pagina...

    Codice PHP:
    if (isset($_POST['testo'])) {
        
    $oggi date("l, j F  Y");
        
    $testo $_POST['testo'];
        
    $testo_con_escape mysql_real_escape_string($testo);
        
    $focus $_POST['focus'];
           if (
    is_uploaded_file($_FILES["img"]["tmp_name"])){
                        
    $img "allegati/" $_FILES["img"]["name"];
                        
    move_uploaded_file($_FILES["img"]["tmp_name"], $img);                
                        
    chmod ($img0777);
                    }
        if (
    $_POST["focus"]==""){
          
    $sql "INSERT INTO news (nw_titolo, nw_testo, nw_img, nw_stato, nw_data) values ('" str_replace("'","'\ ",$_POST['titolo']) . "', '$testo_con_escape', '$img', 1,CURDATE())";
        } else {
          
    $sql "INSERT INTO news (nw_focus,nw_titolo, nw_testo, nw_img, nw_stato, nw_data) values ('" $_POST["focus"] . "','" $_POST["titolo"] . "', '$testo_con_escape', '$img', 2,CURDATE())";
                }

               if (
    mysql_query($sql)){
        echo 
    '<table align=\"center\"><tr><td class="testo_b_12"> News inserita correttamente</td></tr>';
        echo 
    "<tr><td><a href=\"gestione_news.php?"session_name() . "=" session_id() ."\"><font color=\"#000000\">prosegui</font></a></td></tr></table>";
        } else {
           echo 
    '

     Errore news non inserita!!!' 
    mysql_error() . '

    '
    ;
            }        
    }    

    ?> 
    oh yes...!

  2. #2
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    secondo me l'errore è qui
    '$img', 1,CURDATE())";
    prova così
    '$img', 1,".CURDATE().")";

  3. #3
    Il tuo problema è questo:
    codice:
    str_replace("'","' ",$_POST['titolo'])
    non ci devono essere ' nella stringa li passata xkè otterresti qualcosa del genere:

    codice:
    INSERT INTO tablella (campo1, campo2, campo3) VALUES ('Oggi all' indomani di ieri', '...', '...');
    che come puoi vedere darebbe problemi qui:
    all'
    devi usare:
    addslashes($_POST['titolo']);
    oppure
    mysql_real_escape_string($_POST['titolo']);

    perchè altrimenti non ti funzionerà mai!

    P.S. per bstefano79 CURDATE() è una funzione stesso di MySQL e non di PHP quindi così come l'ha scritta va bene!
    Administrator of NAMDesign.Net

  4. #4
    Utente di HTML.it L'avatar di bstefano79
    Registrato dal
    Feb 2004
    Messaggi
    2,520
    Vero, credevo fosse funzione php
    scusate

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.