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

    problema del parametro insert in un database MySql

    salve non è da molto che programmo in Php, e non riesco a capire il perchè il parametro insert in questa pagina non mi funsiona, mentre invece il parametro modifica funziona.

    Vi mostro il codice così lo vedete e mi potete dare una mano a farmi capire dove sta il mio errore.
    Codice PHP:
    elseif ($_GET['parametro']=="insert") {     $res=mysql_query("insert into hotel values (NULL,'".$_POST['nome']."','".$_POST['stelle']."','".$_POST['localita']."','".$_POST['descr']."','".$_POST['listino']."','".$_POST['gmapLat']."','".$_POST['gmapLong']."','".$_POST['gmapTxt']."','".$_POST['ntel']."','".$_POST['nfax']."','".$_POST['sito']."','".$_POST['mail']."','".$_POST['foto1']."','".$_POST['foto2']."','".$_POST['foto3']."','".$_POST['foto4']."','".$_POST['foto5']."','".$_POST['foto6']."','".$_POST['foto7']."','".$_POST['foto8']."','".$_POST['foto9']."','".$_POST['foto10']."','".$_POST['attivo'].",'".$_POST['cbenessere']."','".$_POST['ctermale']."','".$_POST['vsbarchi']."','".$_POST['movida']."','".$_POST['ordine']."','".$_POST['vmare']."','".$_POST['vistamare']."','".$_POST['vcentro']."','".$_POST['id_blog']."','".$_POST['acond']."','".$_POST['barc']."','".$_POST['tvc']."','".$_POST['telcam']."','".$_POST['phono']."','".$_POST['lavatr']."','".$_POST['fstiro']."','".$_POST['lstoviglie']."','".$_POST['lavhot']."','".$_POST['pcop']."','".$_POST['pscop']."','".$_POST['pal']."','".$_POST['parc']."','".$_POST['parcop']."','".$_POST['rist']."','".$_POST['ipoint']."','".$_POST['wifi']."','".$_POST['sgcart']."','".$_POST['scaf']."','".$_POST['svpro']."','".$_POST['handicap']."','".$_POST['natale']."','".$_POST['anima']."','".$_POST['animn']."','".$_POST['ccred']."','".$_POST['sattr']."','".$_POST['custbag']."','".$_POST['cambm']."','".$_POST['tennis']."','".$_POST['spiaggia']."','".$_POST['bsitt']."','".$_POST['ascensore']."')");          echo "<script>location.href='index.php?mod=hotel'</script>"; }  elseif ($_GET['parametro']=="update") {     $res=mysql_query("update hotel set nome='".$_POST['nome']."',stelle='".$_POST['stelle']."',localita='".$_POST['localita']."',descr='".$_POST['descr']."',listino='".$_POST['listino']."',gmapLat='".$_POST['gmapLat']."',gmapLong='".$_POST['gmapLong']."',gmapTxt='".$_POST['gmapTxt']."',ntel='".$_POST['ntel']."',nfax='".$_POST['nfax']."',sito='".$_POST['sito']."',mail='".$_POST['mail']."',foto1='".$_POST['foto1']."',foto2='".$_POST['foto2']."',foto3='".$_POST['foto3']."',foto4='".$_POST['foto4']."',foto5='".$_POST['foto5']."',foto6='".$_POST['foto6']."',foto7='".$_POST['foto7']."',foto8='".$_POST['foto8']."',foto9='".$_POST['foto9']."',foto10='".$_POST['foto10']."',ordine='".$_POST['ordine']."',vmare='".$_POST['vmare']."',vistamare='".$_POST['vistamare']."',vcentro='".$_POST['vcentro']."',cbenessere='".$_POST['cbenessere']."',ctermale='".$_POST['ctermale']."',vsbarchi='".$_POST['vsbarchi']."',movida='".$_POST['movida']."',acond='".$_POST['acond']."',barc='".$_POST['barc']."',tvc='".$_POST['tvc']."',telcam='".$_POST['telcam']."',phono='".$_POST['phono']."',lavatr='".$_POST['lavatr']."',lstoviglie='".$_POST['lstoviglie']."',lavhot='".$_POST['lavhot']."',fstiro='".$_POST['fstiro']."',pcop='".$_POST['pcop']."',pscop='".$_POST['pscop']."',pal='".$_POST['pal']."',parc='".$_POST['parc']."',parcop='".$_POST['parcop']."',rist='".$_POST['rist']."',ipoint='".$_POST['ipoint']."',wifi='".$_POST['wifi']."',sgcart='".$_POST['sgcart']."',scaf='".$_POST['scaf']."',sriunioni='".$_POST['sriunioni']."',svpro='".$_POST['svpro']."',handicap='".$_POST['handicap']."',natale='".$_POST['natale']."',ccred='".$_POST['ccred']."',anima='".$_POST['anima']."',animn='".$_POST['animn']."',sattr='".$_POST['sattr']."',custbag='".$_POST['custbag']."',cambm='".$_POST['cambm']."',tennis='".$_POST['tennis']."',spiaggia='".$_POST['spiaggia']."',bsitt='".$_POST['bsitt']."',ascensore='".$_POST['ascensore']."',id_blog='".$_POST['id_blog']."',attivo='".$_POST['attivo']."' where id=".$_GET['id']);     echo "<script>location.href='index.php?mod=hotel'</script>"; } 
    Roberto

  2. #2
    la sintassi corretta di INSERT INTO è

    INSERT INTO(nome_campo1, nome_campo2, ecc...) VALUES (valore_campo1, valore_campo2, ecc)

    quiindi tu hai sbagliato perchè prima dei valori non hai ionserito fra parentesi i nomi dei campi nell'ordine esatto in cui appaiono i seguenti valori.

  3. #3
    già lo avevo fato, ma adesso l'ho rifatto ma comunque non va ti mando il codice controlla
    Codice PHP:
    $res=mysql_query("insert into hotel (`id`, `nome`, `stelle`, `localita`, `descr`, `listino`, `gmap`, `gmapLat`, `gmapLong`, `gmapTxt`, `gmapZum`, `ntel`, `nfax`, `sito`, `mail`, `foto1`, `foto2`, `foto3`, `foto4`, `foto5`, `foto6`, `foto7`, `foto8`, `foto9`, `foto10`, `attivo`, `cbenessere`, `ctermale`, `vsbarchi`, `movida`, `ordine`, `vmare`, `vistamare`, `vcentro`, `id_blog`, `acond`, `barc`, `tvc`, `pcop`, `pscop`, `pal`, `parc`, `parcop`, `rist`, `ipoint`, `wifi`, `sgcart`, `scaf`, `sriunioni`, `svpro`, `handicap`, `natale`, `ccred`, `anima`, `animn`, `sattr`, `custbag`, `phono`, `lavatr`, `fstiro`, `lstoviglie`, `lavhot`, `cambm`, `tennis`, `spiaggia`, `bsitt`, `telcam`, `ascensore`) values (NULL,'".$_POST['nome']."','".$_POST['stelle']."','".$_POST['localita']."','".$_POST['descr']."','".$_POST['listino']."','".$_POST['gmapLat']."','".$_POST['gmapLong']."','".$_POST['gmapTxt']."','".$_POST['ntel']."','".$_POST['nfax']."','".$_POST['sito']."','".$_POST['mail']."','".$_POST['foto1']."','".$_POST['foto2']."','".$_POST['foto3']."','".$_POST['foto4']."','".$_POST['foto5']."','".$_POST['foto6']."','".$_POST['foto7']."','".$_POST['foto8']."','".$_POST['foto9']."','".$_POST['foto10']."','".$_POST['attivo'].",'".$_POST['cbenessere']."','".$_POST['ctermale']."','".$_POST['vsbarchi']."','".$_POST['movida']."','".$_POST['ordine']."','".$_POST['vmare']."','".$_POST['vistamare']."','".$_POST['vcentro']."','".$_POST['id_blog']."','".$_POST['acond']."','".$_POST['barc']."','".$_POST['tvc']."','".$_POST['telcam']."','".$_POST['phono']."','".$_POST['lavatr']."','".$_POST['fstiro']."','".$_POST['lstoviglie']."','".$_POST['lavhot']."','".$_POST['pcop']."','".$_POST['pscop']."','".$_POST['pal']."','".$_POST['parc']."','".$_POST['parcop']."','".$_POST['rist']."','".$_POST['ipoint']."','".$_POST['wifi']."','".$_POST['sgcart']."','".$_POST['scaf']."','".$_POST['svpro']."','".$_POST['handicap']."','".$_POST['natale']."','".$_POST['anima']."','".$_POST['animn']."','".$_POST['ccred']."','".$_POST['sattr']."','".$_POST['custbag']."','".$_POST['cambm']."','".$_POST['tennis']."','".$_POST['spiaggia']."','".$_POST['bsitt']."','".$_POST['ascensore']."')");          echo "<script>location.href='index.php?mod=hotel'</script>"; }  elseif ($_GET['parametro']=="update") {     $res=mysql_query("update hotel set nome='".$_POST['nome']."',stelle='".$_POST['stelle']."',localita='".$_POST['localita']."',descr='".$_POST['descr']."',listino='".$_POST['listino']."',gmapLat='".$_POST['gmapLat']."',gmapLong='".$_POST['gmapLong']."',gmapTxt='".$_POST['gmapTxt']."',ntel='".$_POST['ntel']."',nfax='".$_POST['nfax']."',sito='".$_POST['sito']."',mail='".$_POST['mail']."',foto1='".$_POST['foto1']."',foto2='".$_POST['foto2']."',foto3='".$_POST['foto3']."',foto4='".$_POST['foto4']."',foto5='".$_POST['foto5']."',foto6='".$_POST['foto6']."',foto7='".$_POST['foto7']."',foto8='".$_POST['foto8']."',foto9='".$_POST['foto9']."',foto10='".$_POST['foto10']."',ordine='".$_POST['ordine']."',vmare='".$_POST['vmare']."',vistamare='".$_POST['vistamare']."',vcentro='".$_POST['vcentro']."',cbenessere='".$_POST['cbenessere']."',ctermale='".$_POST['ctermale']."',vsbarchi='".$_POST['vsbarchi']."',movida='".$_POST['movida']."',acond='".$_POST['acond']."',barc='".$_POST['barc']."',tvc='".$_POST['tvc']."',telcam='".$_POST['telcam']."',phono='".$_POST['phono']."',lavatr='".$_POST['lavatr']."',lstoviglie='".$_POST['lstoviglie']."',lavhot='".$_POST['lavhot']."',fstiro='".$_POST['fstiro']."',pcop='".$_POST['pcop']."',pscop='".$_POST['pscop']."',pal='".$_POST['pal']."',parc='".$_POST['parc']."',parcop='".$_POST['parcop']."',rist='".$_POST['rist']."',ipoint='".$_POST['ipoint']."',wifi='".$_POST['wifi']."',sgcart='".$_POST['sgcart']."',scaf='".$_POST['scaf']."',sriunioni='".$_POST['sriunioni']."',svpro='".$_POST['svpro']."',handicap='".$_POST['handicap']."',natale='".$_POST['natale']."',ccred='".$_POST['ccred']."',anima='".$_POST['anima']."',animn='".$_POST['animn']."',sattr='".$_POST['sattr']."',custbag='".$_POST['custbag']."',cambm='".$_POST['cambm']."',tennis='".$_POST['tennis']."',spiaggia='".$_POST['spiaggia']."',bsitt='".$_POST['bsitt']."',ascensore='".$_POST['ascensore']."',id_blog='".$_POST['id_blog']."',attivo='".$_POST['attivo']."' where id=".$_GET['id']);     echo "<script>location.href='index.php?mod=hotel'</script>"; } 
    Roberto

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.