Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Forum De Bell Tolls > [PHP/MySQL] Cos'ho sbagliato??
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Hamelin
.pifferaio.magico.

User info:
Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno:
Time Online: 7 Days, 7:19:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Unhappy [PHP/MySQL] Cos'ho sbagliato??

Mi spiegate perché con il seguente form e la seguente pagina che dovrebbe raccogliere gli input del form non riesco ad ottenere il risultato desiderato? Viene inserito un nuovo record nel database, ma i campi "nome" e "cognome" rimangono vuoti... non NULL... vuoti... mah...

<html>
<head>
<title>Modulo</title>
</head>
<body>
<p>Inserisci nome e cognome</p>
<form method="POST" action="inserisci.php">
<p>Nome:</p>
<input type="text" name="nome">
<br />
<p>Cognome:</p>
<input type="text" name="cognome">
<br />
<input type="submit" value="Invia">
</body>
</html>

___________________________


<html>
<head>
<title>Inserimento record</title>
</head>
<body>
<p>Con questa pagina inserisco un nuovo record nella tabella "prova"</p>
<?php
$idconn = mysql_connect('localhost', '', '') or die("Connessione non riuscita " . mysql_error());
mysql_select_db('fibo', $idconn) or die("Selezione database non riuscita " . mysql_error());
$query = "INSERT INTO prova (nome, cognome) VALUES ('$nome', '$cognome')";
mysql_query($query, $idconn) or die("Inserimento record non riuscito " . mysql_error());
mysql_close($idconn);
?>
</body>
</html>

__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."

15-03-2004 16:31
Click Here to See the Profile for Hamelin Click here to Send Hamelin a Private Message Visit Hamelin's homepage! Find more posts by Hamelin Add Hamelin to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
korn
SET FIRE!

User info:
Registered: Jun 2002
Posts: 5793 (0.70 al dì)
Location: Milano
Corso: Comunicazione Digitale
Anno: 1°! ....fuori corso :(
Time Online: 37 Days, 5:56:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Non funziona perché leggi le variabili dalla pagina di input come globals, cosa che per default è disattivata nelle nuove versioni di php per motivi di sicurezza.

leggile così:

$HTTP_POST_VARS['nome']
$HTTP_POST_VARS['cognome']

o anche:

$_POST['nome']
$_POST['cognome']


quindi in definitiva:

$query = "INSERT INTO prova (nome, cognome) VALUES ('$HTTP_POST_VARS[nome]', '$HTTP_POST_VARS[cognome]')";

nota: gli apici dell'indice dell'array vanno tolti se è inserito all'interno di una stringa.

__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.

15-03-2004 16:35
Click Here to See the Profile for korn Click Here to See the Blog of korn Click here to Send korn a Private Message Visit korn's homepage! Find more posts by korn Add korn to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Hamelin
.pifferaio.magico.

User info:
Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno:
Time Online: 7 Days, 7:19:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Grazie mille!

__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."

15-03-2004 16:37
Click Here to See the Profile for Hamelin Click here to Send Hamelin a Private Message Visit Hamelin's homepage! Find more posts by Hamelin Add Hamelin to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
AlphaGamma
.piano ma pieni.

User info:
Registered: Jun 2002
Posts: 6732 (0.82 al dì)
Location:
Corso: Eh?
Anno: Io cosa?
Time Online: 21 Days, 21:22:01: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

L'ho scoperto anche io settimana scorsa. :)
Comunque non funziona nemmeno come dice Korn: non puoi fare una query utilizzando direttamente HTTP_POST_VARS. :sad:
Almeno, su Aruba non funge.

Quindi molto semplicemente faccio cosi'.
Supponiamo che HTTP_POST_VARS["pippo"] sia la nostra variabile. Dichiaro $pippo=HTTP_POST_VARS["pippo"], ed inserisco nella query $pippo. Questo inoltre ti da il vantaggio di non dover riscrivere il codice delle query.
Semplicemente

__________________
Attenzio', concentrazio', ritmo e VITALITÀ

15-03-2004 16:43
Click Here to See the Profile for AlphaGamma Click Here to See the Blog of AlphaGamma Click here to Send AlphaGamma a Private Message Visit AlphaGamma's homepage! Find more posts by AlphaGamma Add AlphaGamma to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
korn
SET FIRE!

User info:
Registered: Jun 2002
Posts: 5793 (0.70 al dì)
Location: Milano
Corso: Comunicazione Digitale
Anno: 1°! ....fuori corso :(
Time Online: 37 Days, 5:56:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by AlphaGamma
L'ho scoperto anche io settimana scorsa. :)
Comunque non funziona nemmeno come dice Korn: non puoi fare una query utilizzando direttamente HTTP_POST_VARS. :sad:
Almeno, su Aruba non funge.


Uhm io ho sempre fatto così e non ho avuto problemi, però non su Aruba.

__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.

15-03-2004 16:50
Click Here to See the Profile for korn Click Here to See the Blog of korn Click here to Send korn a Private Message Visit korn's homepage! Find more posts by korn Add korn to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Hamelin
.pifferaio.magico.

User info:
Registered: Feb 2003
Posts: 662 (0.08 al dì)
Location: ..tra i monti intorno ad Hamelin..
Corso: Ingegneria Informatica
Anno:
Time Online: 7 Days, 7:19:55 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Boh... io lo sto provando in locale e mi funziona benissimo... grazie ancora...

OT (parziale): a proposito... quali servizi di hosting con MySQL incluso consigliate?

__________________
Bjarne Stroustrup: "I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone."
Andrew S. Tanenbaum: "Never underestimate the bandwidth of a station wagon full of tapes hurtling down the highway."
Edsger Dijkstra: "Computer Science is no more about computers than astronomy is about telescopes."
Robert Firth: "One of the main causes of the fall of the Roman Empire was that, lacking zero, they had no way to indicate successful termination of their C programs."
Donald Knuth: "A mathematical formula should never be 'owned' by anybody! Mathematics belong to God."

15-03-2004 19:23
Click Here to See the Profile for Hamelin Click here to Send Hamelin a Private Message Visit Hamelin's homepage! Find more posts by Hamelin Add Hamelin to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
AlphaGamma
.piano ma pieni.

User info:
Registered: Jun 2002
Posts: 6732 (0.82 al dì)
Location:
Corso: Eh?
Anno: Io cosa?
Time Online: 21 Days, 21:22:01: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Aruba mi piace, tutto sommato. E' veloce come tempo di elaborazione script, hai spazio illimitato (50 mega di mysql), e costa poco.

Pero' farei a cambio con uno spazio postgres. :)

__________________
Attenzio', concentrazio', ritmo e VITALITÀ

15-03-2004 19:59
Click Here to See the Profile for AlphaGamma Click Here to See the Blog of AlphaGamma Click here to Send AlphaGamma a Private Message Visit AlphaGamma's homepage! Find more posts by AlphaGamma Add AlphaGamma to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
korn
SET FIRE!

User info:
Registered: Jun 2002
Posts: 5793 (0.70 al dì)
Location: Milano
Corso: Comunicazione Digitale
Anno: 1°! ....fuori corso :(
Time Online: 37 Days, 5:56:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by AlphaGamma
Comunque non funziona nemmeno come dice Korn: non puoi fare una query utilizzando direttamente HTTP_POST_VARS. :sad:
Almeno, su Aruba non funge.


Per curiosità, che errore ti dà?

Scusa se faccio un appunto apparentemente banale, ma anche tu saprai che spesso sono le più piccole sviste a minare i programmi: quando hai montato la query in quel modo, avevi tolto gli apici dal nome dell'indice dell'array?

__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.

15-03-2004 20:39
Click Here to See the Profile for korn Click Here to See the Blog of korn Click here to Send korn a Private Message Visit korn's homepage! Find more posts by korn Add korn to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
AlphaGamma
.piano ma pieni.

User info:
Registered: Jun 2002
Posts: 6732 (0.82 al dì)
Location:
Corso: Eh?
Anno: Io cosa?
Time Online: 21 Days, 21:22:01: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by korn
Per curiosità, che errore ti dà?


Non da errore. Semplicemente la variabile non la vede.
E quindi la query risulta sbagliata e mi da errore mysql.

Scusa se faccio un appunto apparentemente banale, ma anche tu saprai che spesso sono le più piccole sviste a minare i programmi: quando hai montato la query in quel modo, avevi tolto gli apici dal nome dell'indice dell'array?


Non ricordo, ma mi pare di si.
Ricordo anche di aver provato vari test prima di buttarla in query. :)

Adesso pero' mi fai venire qualche dubbio... :pensa:

__________________
Attenzio', concentrazio', ritmo e VITALITÀ

16-03-2004 01:11
Click Here to See the Profile for AlphaGamma Click Here to See the Blog of AlphaGamma Click here to Send AlphaGamma a Private Message Visit AlphaGamma's homepage! Find more posts by AlphaGamma Add AlphaGamma to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
korn
SET FIRE!

User info:
Registered: Jun 2002
Posts: 5793 (0.70 al dì)
Location: Milano
Corso: Comunicazione Digitale
Anno: 1°! ....fuori corso :(
Time Online: 37 Days, 5:56:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by AlphaGamma
Adesso pero' mi fai venire qualche dubbio... :pensa:


Te l'ho detto proprio perché per esperienza personale so che a volte scrivi centinaia di righe di codice tecnicamente corretto e magari non funziona per una minima svista come quella... infatti ormai quando ho problemi col codice le prime cose che controllo sono le cavolate :)

__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.

16-03-2004 09:37
Click Here to See the Profile for korn Click Here to See the Blog of korn Click here to Send korn a Private Message Visit korn's homepage! Find more posts by korn Add korn to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Cr34t|v3
Erasmus en Murcia

User info:
Registered: Jun 2002
Posts: 535 (0.06 al dì)
Location: Milano
Corso: oUt
Anno: 0
Time Online: 9 Days, 22:07:13 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Soluzione alternativa>
Nel file di configurazione del php(php.ini) setta:
register.global = on

__________________
Debian rules
Linux User #305560

cerchi una casa in affito x le tue vacanze? Casa Vacanze Sicilia http://www.marsala.sicilia.it

Last edited by Cr34t|v3 on 16-03-2004 at 13:46

16-03-2004 11:30
Click Here to See the Profile for Cr34t|v3 Click Here to See the Blog of Cr34t|v3 Click here to Send Cr34t|v3 a Private Message Find more posts by Cr34t|v3 Add Cr34t|v3 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
holylaw
.grande:maestro.

User info:
Registered: Feb 2003
Posts: 3142 (0.39 al dì)
Location: milano
Corso: Magistrale Informatica
Anno: bella domanda
Time Online: 88 Days, 5:30:09: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

guarda che deve essere:
register_globals = on , per settare le variabili globali :)

anche se non e' il massimo in termini di sicurezza......

__________________
La mia epoca ed io non siamo fatti l'uno per l'altro:questo è chiaro. Ma è da vedere chi di noi due vincerà il processo di fronte al tribunale dei posteri.
AV MJØDEN VART DU VIS OG KLOK, SÅ DREKKA MER!!!!
Le persone sagge parlano perché hanno qualcosa da dire.
Le persone sciocche perché hanno da dire qualcosa.

16-03-2004 12:50
Click Here to See the Profile for holylaw Click Here to See the Blog of holylaw Click here to Send holylaw a Private Message Find more posts by holylaw Add holylaw to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Cr34t|v3
Erasmus en Murcia

User info:
Registered: Jun 2002
Posts: 535 (0.06 al dì)
Location: Milano
Corso: oUt
Anno: 0
Time Online: 9 Days, 22:07:13 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

si scusa distrattamente ho scritto il contrario ....
:-D
cmq ho trovato in giro molti server configurati in questo modo

__________________
Debian rules
Linux User #305560

cerchi una casa in affito x le tue vacanze? Casa Vacanze Sicilia http://www.marsala.sicilia.it

16-03-2004 13:46
Click Here to See the Profile for Cr34t|v3 Click Here to See the Blog of Cr34t|v3 Click here to Send Cr34t|v3 a Private Message Find more posts by Cr34t|v3 Add Cr34t|v3 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
korn
SET FIRE!

User info:
Registered: Jun 2002
Posts: 5793 (0.70 al dì)
Location: Milano
Corso: Comunicazione Digitale
Anno: 1°! ....fuori corso :(
Time Online: 37 Days, 5:56:42 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by Cr34t|v3
si scusa distrattamente ho scritto il contrario ....
:-D
cmq ho trovato in giro molti server configurati in questo modo


Le vecchie versioni di PHP avevano le globals impostate su ON per default, quindi probabilmente molti server le tengono ON tutt'ora per non costringere gli utenti alla modifica di tutti gli script.

Ciononostante, se possibile sarebbe meglio evitare, gli sviluppatori le hanno messe OFF di default perché creano problemi di sicurezza...

__________________
» Collect some stars to shine for you, and start today ‘cause there are only a few. _ (In Flames)
» Don't stop for nothing, it's full speed or nothing! I'm taking down, you know, whatever is in my way! _ ('tallica)
» I am my own god, I do as I please. _ (Pain)
» Ninetynine, ninetynine knives! Ninetynine knives inside! Nobody gets out alive! _ (The Haunted)
Web: http://www.negativesignal.com - ICQ# 171585477 - Death to software patents! And TCPA too! "e uno!", diceva il boia.

16-03-2004 15:28
Click Here to See the Profile for korn Click Here to See the Blog of korn Click here to Send korn a Private Message Visit korn's homepage! Find more posts by korn Add korn to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 11:13.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.079 seconds (47.58% PHP - 52.42% MySQL) con 27 query.