Lotterij problemen

Gestart doorDylan6 reacties33 weergaven

7 berichten · pagina 1 van 1

Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Ik heb een lotterij script maar ik heb 2 problemen.

Script:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/include"]include[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]global.php[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR]checklogin[COLOR= #007700]()) {[/COLOR]
    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR]getinfo[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #DD0000]vip[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal[/COLOR][COLOR= #007700]])) {[/COLOR]
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/is_numeric"]is_numeric[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal[/COLOR][COLOR= #007700]])) {[/COLOR]
                [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: index.php?bericht=Ongeldig getal![/COLOR][COLOR= #007700]);
            }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR]getinfo[COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #DD0000]points[/COLOR][COLOR= #007700]) <[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal[/COLOR][COLOR= #007700]]) {[/COLOR]
                    [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: index.php?bericht=Je hebt niet genoeg punten![/COLOR][COLOR= #007700]);
            }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            
                    [COLOR= #0000BB]$days[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]1[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]6[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]5[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]4[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]3[/COLOR][COLOR= #007700],[/COLOR][COLOR= #0000BB]2[/COLOR][COLOR= #007700]);[/COLOR]
                    [COLOR= #0000BB]$today[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]N[/COLOR][COLOR= #007700]);[/COLOR]
                    
                    [COLOR= #0000BB]$over[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$days[/COLOR][COLOR= #007700][[/COLOR][COLOR= #0000BB]$today[/COLOR][COLOR= #007700]];[/COLOR]  
                    
                [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE users SET points = points - "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" WHERE username = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM lotto WHERE userid = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]))) {[/COLOR]
                    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE lotto SET aantal = aantal +  "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]" WHERE userid = "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]userid[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);
                    
                    
                }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
                    [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"INSERT INTO lotto (userid, aantal) VALUES ("[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]", "[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]aantal[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]")"[/COLOR][COLOR= #007700]);
                }[/COLOR]
                
                [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: index.php?bericht=Je doet mee! Over [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$over[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] dagen is de uitslag! (Als er genoeg aanmeldingen zijn)[/COLOR][COLOR= #007700]);
                
            }
        }
    }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
        [URL="http://www.php.net/header"]header[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Location: index.php?bericht=Ongeldig deelname![/COLOR][COLOR= #007700]);
    }
    
    }
}[/COLOR]
?>


Probleem 1 (fixed)
Als ze -999 doen kunnen ze 999 punten uit de pot halen en krijgen ze dat zelf.


Probleem 2
Over x dagen. Werkt niet perfect, hoe kan ik dit beter doen?

Hoe kan ik dit oplossen?
Alvast bedankt.
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Fanorg schreef:
Probleem 1 kan je toch oplossen door te controleren of het getal negatief is?

Zo ja: Error
Zo nee: Doorgaan

Hoop dat je er wat aan hebt omdat ik niets in het script heb veranderd yummie
Oh, gwn zo:

if($getal < 0){
echo het getal is negatief;
}


Oh, als dat de fix is... Nu probleem 2 nog.
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
Eerdere citaten tonen
Fanorg schreef:
Probleem 1 kan je toch oplossen door te controleren of het getal negatief is?
Zo ja: Error
Zo nee: Doorgaan

Hoop dat je er wat aan hebt omdat ik niets in het script heb veranderd yummie
Oh, gwn zo:

if($getal < 0){
echo het getal is negatief;
}


Oh, als dat de fix is... Nu probleem 2 nog.
Beter kijk je ook of het wel getal is...
0
Berichten
6.356
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
En of het een geheel getal is dus niet 0.1 ofzo
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Antonn schreef:
Eerdere citaten tonen
Dylanh schreef:
Eerdere citaten tonen
Fanorg schreef:
Probleem 1 kan je toch oplossen door te controleren of het getal negatief is?
Zo ja: Error
Zo nee: Doorgaan

Hoop dat je er wat aan hebt omdat ik niets in het script heb veranderd yummie
Oh, gwn zo:

if($getal < 0){
echo het getal is negatief;
}


Oh, als dat de fix is... Nu probleem 2 nog.
Beter kijk je ook of het wel getal is...
Dat doe ik al (regel 6)
Mikeb schreef:
En of het een geheel getal is dus niet 0.1 ofzo
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]( (int)[/COLOR] [COLOR= #0000BB]$getal[/COLOR] [COLOR= #007700]==[/COLOR] [COLOR= #0000BB]$getal[/COLOR] [COLOR= #007700]) {[/COLOR] 
    [COLOR= #FF8000]/* Heel */[/COLOR]
[COLOR= #007700]}[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [COLOR= #FF8000]/* Met decimalen */[/COLOR]
[COLOR= #007700]}[/COLOR]

?>


Zo?
0
Berichten
6.356
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb geen idee hoe dat moet, maar dit vond ik op internet:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// Typecast $variabele met (string)[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/ctype_digit"]ctype_digit[/URL][COLOR= #007700]( (string)[/COLOR] [COLOR= #0000BB]$variabele[/COLOR][COLOR= #007700]))
{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]het is een geheel getal[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]het is geen geheel getal[/COLOR][COLOR= #007700];
}[/COLOR]
?>
0
Dylan

Lid · Topicstarter

Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Ja, die zag ik ook. Maar welke moet ik nou kiezen? Heb nog geen één getest, zal binnenkort wel ff testen.

toevoeging op 17 november 2012, 10:24:29:
Mikeb schreef:
Ik heb geen idee hoe dat moet, maar dit vond ik op internet:
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// Typecast $variabele met (string)[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/ctype_digit"]ctype_digit[/URL][COLOR= #007700]( (string)[/COLOR] [COLOR= #0000BB]$variabele[/COLOR][COLOR= #007700]))
{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]het is een geheel getal[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
[COLOR= #007700]{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]het is geen geheel getal[/COLOR][COLOR= #007700];
}[/COLOR]
?>


Die werkt, thanks!

Nu alleen probleem 2 nog.. Weet iemand de oplossing?
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren