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] problema con le date
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
Dodo
lunatico

User info:
Registered: Jul 2002
Posts: 2340 (0.27 al dì)
Location: in una fibra ottica
Corso: Com Dig
Anno: 3+1 :P
Time Online: 42 Days, 7:55:56 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Question [PHP] problema con le date

premesso che ho provato di tutto per fare un semplicissimo confronto di due date.. qualcuno mi spiega perchè mai non funziona il codice che ho scritto, ovvero l'if mi da sempre false....

voglio semplicemente controllare se l'evento a cui mi sto registrando è già passato o meno... qualcuno può helparmi

code:
\\riceve delle variabili via POST ............ $queryanno = "SELECT anno_incontro FROM lista_incontri WHERE id = $required_incontro"; $querymese = "SELECT mese_incontro FROM lista_incontri WHERE id = $required_incontro"; $querygiorno = "SELECT giorno_incontro FROM lista_incontri WHERE id= $required_incontro"; $anno_corrente = date("y"); $mese_corrente = date("m"); $giorno_corrente = date ("d"); settype($anno_corrente, "integer"); settype($mese_corrente, "integer"); settype($giorno_corrente, "integer"); $anno_incontro = mysql_query($queryanno) or die(mysql_error()); $mese_incontro = mysql_query($querymese) or die(mysql_error()); $giorno_incontro = mysql_query($querygiorno) or die(mysql_error()); if ($anno_corrente <= $anno_incontro) { if ($mese_corrente <= $mese_incontro) { if ($giorno_corrente < $giorno_incontro) { $query = "INSERT INTO accrediti (nome, cognome, email, telefono, attività, città, età, incontro) VALUES ('$required_nome', '$required_cognome', '$required_email', '$telefono', '$required_attivita', '$required_citta', '$required_eta', '$required_incontro')"; if (mysql_query($query, $db)) echo "La tua partecipazione è stata registrata correttamente, ti è stata inviata una conferma di registrazione nella tua casella email"; else echo "Erorre durante l'inserimento"; $from="******@*****.**"; $titolo="Conferma registrazione incontro"; $testo="Ciao $required_nome. Ti Confermiamo l'avvenuta iscrizione all'incontro da te selezionato, ti invieremo pochi giorni prima un promemoria con tutti i dettagli dell'incontro ."; mail($required_email, $titolo, $testo, "From: $from"); } }} else { echo "Non è possibile accreditarsi a questo incontro, in quanto scaduto"; }

__________________
E' meglio essere ottimisti ed avere torto piuttosto che pessimisti ed avere ragione.

Albert Einstein

02-11-2004 16:07
Click Here to See the Profile for Dodo Click Here to See the Blog of Dodo Click here to Send Dodo a Private Message Find more posts by Dodo Add Dodo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.52 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Perché hai convertito a integer la data?
Nel DB le date sono inserite come integer?
Sicuro che le query per ottenere i dati della data dell'incontro vadano a buon fine?

Forse fai prima a convertire le date in timestamp unix e a confrontarli fra loro. Così avresti un solo if da gestire e non dovresti fare conversioni di tipo.

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

02-11-2004 16:27
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Dodo
lunatico

User info:
Registered: Jul 2002
Posts: 2340 (0.27 al dì)
Location: in una fibra ottica
Corso: Com Dig
Anno: 3+1 :P
Time Online: 42 Days, 7:55:56 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ho già provato con timestamp unix e mi da lo stesso problema, per questo mi sono ridotto ad una soluzione a tre colonne, ma nulla :(

le ho convertite in integer pensando potesse esserci un problema di formato, ma non è neanche quello il problema...

le ho provate veramente tutte (quasi)...

__________________
E' meglio essere ottimisti ed avere torto piuttosto che pessimisti ed avere ragione.

Albert Einstein

02-11-2004 16:32
Click Here to See the Profile for Dodo Click Here to See the Blog of Dodo Click here to Send Dodo a Private Message Find more posts by Dodo Add Dodo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
JaM
######

User info:
Registered: Jun 2002
Posts: 3604 (0.42 al dì)
Location: everywhere, anywhere, elsewhere...
Corso: ComDig
Anno: dott.??
Time Online: 62 Days, 16:55:46 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

quando non sai se i confronti vanno a buon fine metti un po' di echo sui risultati delle query e su quello che ti stampa la fnzione date...

in genere io i problemi li risolvevo all'80% in questo modo ;)

02-11-2004 16:39
Click Here to See the Profile for JaM Click Here to See the Blog of JaM Click here to Send JaM a Private Message Visit JaM's homepage! Find more posts by JaM Add JaM 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.67 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

code:
$querydata = "SELECT giorno_incontro,mese_incontro,anno_incontro FROM lista_incontri WHERE id = $required_incontro"; $row = mysql_fetch_array(mysql_query($querydata)); $dataincontro = mktime(0,0,0,$row[1],$row[0],$row[2]); $datadioggi = mktime(0,0,0,date("m"),date("d"),date("Y")); if ($dataincontro < $datadioggi) { $query = "INSERT INTO accrediti (nome, cognome, email, telefono, attività, città, età, incontro) VALUES ('$required_nome', '$required_cognome', '$required_email', '$telefono', '$required_attivita', '$required_citta', '$required_eta', '$required_incontro')"; if (mysql_query($query, $db)) echo "La tua partecipazione è stata registrata correttamente, ti è stata inviata una conferma di registrazione nella tua casella email"; else echo "Erorre durante l'inserimento"; $from="******@*****.**"; $titolo="Conferma registrazione incontro"; $testo="Ciao $required_nome. Ti Confermiamo l'avvenuta iscrizione all'incontro da te selezionato, ti invieremo pochi giorni prima un promemoria con tutti i dettagli dell'incontro ."; mail($required_email, $titolo, $testo, "From: $from"); } else { echo "Non è possibile accreditarsi a questo incontro, in quanto scaduto"; }


Attento, date("y") è diverso da date("Y"), forse è stato quello.

__________________
» 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.

02-11-2004 16:59
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
Dodo
lunatico

User info:
Registered: Jul 2002
Posts: 2340 (0.27 al dì)
Location: in una fibra ottica
Corso: Com Dig
Anno: 3+1 :P
Time Online: 42 Days, 7:55:56 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

si avevo notato e corretto... ma nulla ancora...

cmq grazie a tutti.. l'unica cosa è da controllare come giustamente ha detto JAM ogni query cosa stampa....

spero che il mio problema non rientri nel 20 % :D

__________________
E' meglio essere ottimisti ed avere torto piuttosto che pessimisti ed avere ragione.

Albert Einstein

02-11-2004 17:43
Click Here to See the Profile for Dodo Click Here to See the Blog of Dodo Click here to Send Dodo a Private Message Find more posts by Dodo Add Dodo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
yeah
.grande:maestro.

User info:
Registered: Nov 2003
Posts: 1644 (0.20 al dì)
Location: Cologno Monzese
Corso: Informatica Magistrale
Anno: II
Time Online: 12 Days, 21:36:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Scusa se magari ti mando fuori strada (di mysql ho letto qualche pag di un libro :)) ma in accordo con qui
mysql_query() ritorna una risorsa.

quindi devi elaborare con mysql_fetch*(), come fa korn.

__________________
?

03-11-2004 23:39
Click Here to See the Profile for yeah Click here to Send yeah a Private Message Find more posts by yeah Add yeah to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Dodo
lunatico

User info:
Registered: Jul 2002
Posts: 2340 (0.27 al dì)
Location: in una fibra ottica
Corso: Com Dig
Anno: 3+1 :P
Time Online: 42 Days, 7:55:56 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

dici?...sto andando proprio a lavoro... provo e ti dico :D

__________________
E' meglio essere ottimisti ed avere torto piuttosto che pessimisti ed avere ragione.

Albert Einstein

04-11-2004 07:32
Click Here to See the Profile for Dodo Click Here to See the Blog of Dodo Click here to Send Dodo a Private Message Find more posts by Dodo Add Dodo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Dodo
lunatico

User info:
Registered: Jul 2002
Posts: 2340 (0.27 al dì)
Location: in una fibra ottica
Corso: Com Dig
Anno: 3+1 :P
Time Online: 42 Days, 7:55:56 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

ma sono così rincoglionito da non essermi accorto che quello di korn era diverso dal mio?...

pensavo fosse un quote... oh mamma :oops:

__________________
E' meglio essere ottimisti ed avere torto piuttosto che pessimisti ed avere ragione.

Albert Einstein

04-11-2004 07:41
Click Here to See the Profile for Dodo Click Here to See the Blog of Dodo Click here to Send Dodo a Private Message Find more posts by Dodo Add Dodo to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
fabpicca
jesus robot d'acciaio

User info:
Registered: May 2002
Posts: 2166 (0.25 al dì)
Location: Pieve Emanuele
Corso: Ticom
Anno:
Time Online: 12 Days, 23:12:28 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Originally posted by JaM


in genere io i problemi li risolvevo all'80% in questo modo ;)


il restante 20% lo risolvevamo invece a bestemmie

__________________
my website?|ubuntu linux|get Firefox|grazie Polonia |bagdad sour

"Come va che non ha le corna e le zampe di Caprone?" gli opposi. "Oh, Giuvà", mi disse il prete "adesso non si usa più.Satana è furbo". (I.Silone, Fontamara)
"Al giorno d'oggi non bisogna essere intelligenti, perchè la gente si offende" (un ubriacone)
"close your eyes / pay the price / for your paradise" (DM) "whatever you want to change/you'd better start changing it in your mind" (Transatlantic)

04-11-2004 08:06
Click Here to See the Profile for fabpicca Click Here to See the Blog of fabpicca Click here to Send fabpicca a Private Message Visit fabpicca's homepage! Find more posts by fabpicca Add fabpicca to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 05:30.    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.253 seconds (27.82% PHP - 72.18% MySQL) con 25 query.