Kleine Vragen Topic #2

Gestart doorKingunit3.067 reacties11.764 weergaven

3.068 berichten · pagina 81 van 205

Berichten
4.367
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Zal het aanpassen.
0
Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Iemand die weet hoe ik MB naar GB omzet in PHP? Het moet hele GBs zijn, en altijd naar boven afgerond.

Bijvoorbeeld:
256MB is 1GB
1536MB is 2GB
1024MB is 1GB
15616MB is 16GB

Alvast bedankt smile
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Wouterr schreef:
Iemand die weet hoe ik MB naar GB omzet in PHP? Het moet hele GBs zijn, en altijd naar boven afgerond.

Bijvoorbeeld:
256MB is 1GB
1536MB is 2GB
1024MB is 1GB
15616MB is 16GB

Alvast bedankt smile
Is toch gewoon wiskunde? Heeft niks te maken met PHP
0
Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Raaoul schreef:
Eerdere citaten tonen
Wouterr schreef:
Iemand die weet hoe ik MB naar GB omzet in PHP? Het moet hele GBs zijn, en altijd naar boven afgerond.
Bijvoorbeeld:
256MB is 1GB
1536MB is 2GB
1024MB is 1GB
15616MB is 16GB

Alvast bedankt smile
Is toch gewoon wiskunde? Heeft niks te maken met PHP
Jep, sorry x). Is opgelost, ty! This laat, volgensmij
Afbeelding
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Antonn schreef:
Eerdere citaten tonen
Desire schreef:
Eerdere citaten tonen
Aarclay schreef:
Eerdere citaten tonen
Desire schreef:
Eerdere citaten tonen
Aarclay schreef:
Gooi nou foutafhandeling in je script. En mysql_query() kan je NIET echoen.
Vertel eens hoe ik hem dan laat doorsturen naar de in database geplaatste url..
Voeg eerst maar eens dat toe.
Ik heb het zo opgelost en het werkt.

[COLOR= #0000BB]<?php[/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][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #DD0000]1[/COLOR][COLOR= #007700]) {[/COLOR]
                
                [COLOR= #0000BB]$uQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM codes WHERE code = "[/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]code[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
            
                
                    
                [COLOR= #0000BB]$uFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uQuery[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]URL: <a href="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tURL[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">Klik hier</a>[/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]code is onjuist[/COLOR][COLOR= #007700];
            }[/COLOR]
?>

Even ter info: mysql_result is sneller en beter. Om het je makkelijk te maken:

[COLOR= #0000BB]<?php[/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][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
                [COLOR= #0000BB]$uQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tURL FROM codes WHERE code = "[/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]code[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
                [COLOR= #0000BB]$url[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_result"]mysql_result[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uQuery[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]URL: <a href="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$url[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]">Klik hier</a>[/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]code is onjuist[/COLOR][COLOR= #007700];
            }[/COLOR]
?>

wat je nu doet is dom. dit is enorm onoverzichtelijk, gebruik fetch_assoc
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Raaoul schreef:
Eerdere citaten tonen
Antonn schreef:
Eerdere citaten tonen
Desire schreef:
Eerdere citaten tonen
Aarclay schreef:
Eerdere citaten tonen
Desire schreef:
Eerdere citaten tonen
Aarclay schreef:
Gooi nou foutafhandeling in je script. En mysql_query() kan je NIET echoen.
Vertel eens hoe ik hem dan laat doorsturen naar de in database geplaatste url..
Voeg eerst maar eens dat toe.
Ik heb het zo opgelost en het werkt.

[COLOR= #0000BB]<?php[/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][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #DD0000]1[/COLOR][COLOR= #007700]) {[/COLOR]
                
                [COLOR= #0000BB]$uQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM codes WHERE code = "[/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]code[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
            
                
                    
                [COLOR= #0000BB]$uFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uQuery[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]URL: <a href="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tURL[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">Klik hier</a>[/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]code is onjuist[/COLOR][COLOR= #007700];
            }[/COLOR]
?>

Even ter info: mysql_result is sneller en beter. Om het je makkelijk te maken:

[COLOR= #0000BB]<?php[/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][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
                [COLOR= #0000BB]$uQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tURL FROM codes WHERE code = "[/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]code[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
                [COLOR= #0000BB]$url[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_result"]mysql_result[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uQuery[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]URL: <a href="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$url[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]">Klik hier</a>[/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]code is onjuist[/COLOR][COLOR= #007700];
            }[/COLOR]
?>

wat je nu doet is dom. dit is enorm onoverzichtelijk, gebruik fetch_assoc
Die is minder snel toch? redface
Wat is hier dan dom aan ofzo? Iets van details.
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wouterr schreef:
Eerdere citaten tonen
Raaoul schreef:
Eerdere citaten tonen
Wouterr schreef:
Iemand die weet hoe ik MB naar GB omzet in PHP? Het moet hele GBs zijn, en altijd naar boven afgerond.
Bijvoorbeeld:
256MB is 1GB
1536MB is 2GB
1024MB is 1GB
15616MB is 16GB

Alvast bedankt smile
Is toch gewoon wiskunde? Heeft niks te maken met PHP
Jep, sorry x). Is opgelost, ty! This laat, volgensmij
Afbeelding
Delen door 1024 en dan afronden met ceil()
0
Berichten
473
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wat is de regex als ik admin/user wil matchen en dan user er uit wil halen?

Ik heb /(.*?)/(.*?)/ al geprobeerd, matched hij user niet.

Edit: noodoplossing door een slash toe te voegen, als iemand een betere manier weet?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Antonn schreef:
Eerdere citaten tonen
Raaoul schreef:
Eerdere citaten tonen
Antonn schreef:
Eerdere citaten tonen
Desire schreef:
Eerdere citaten tonen
Aarclay schreef:
Eerdere citaten tonen
Desire schreef:
Eerdere citaten tonen
Aarclay schreef:
Gooi nou foutafhandeling in je script. En mysql_query() kan je NIET echoen.
Vertel eens hoe ik hem dan laat doorsturen naar de in database geplaatste url..
Voeg eerst maar eens dat toe.
Ik heb het zo opgelost en het werkt.

[COLOR= #0000BB]<?php[/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][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #DD0000]1[/COLOR][COLOR= #007700]) {[/COLOR]
                
                [COLOR= #0000BB]$uQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM codes WHERE code = "[/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]code[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
            
                
                    
                [COLOR= #0000BB]$uFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uQuery[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]URL: <a href="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]tURL[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]">Klik hier</a>[/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]code is onjuist[/COLOR][COLOR= #007700];
            }[/COLOR]
?>

Even ter info: mysql_result is sneller en beter. Om het je makkelijk te maken:

[COLOR= #0000BB]<?php[/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][COLOR= #0000BB]$result[/COLOR][COLOR= #007700]) ==[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
                [COLOR= #0000BB]$uQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT tURL FROM codes WHERE code = "[/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]code[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700]);[/COLOR]
                [COLOR= #0000BB]$url[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_result"]mysql_result[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uQuery[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]);[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]URL: <a href="[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$url[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]">Klik hier</a>[/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]code is onjuist[/COLOR][COLOR= #007700];
            }[/COLOR]
?>

wat je nu doet is dom. dit is enorm onoverzichtelijk, gebruik fetch_assoc
Die is minder snel toch? redface
Wat is hier dan dom aan ofzo? Iets van details.
minder snel? 0.01 nanoseconde? boeit geen reet

en ja dat is dom want: onoverzichtelijk. stel je wilt een rij naar een andere plaats verplaatsen, dan zit je met andere waarden en dan klopt niks meer
0
Berichten
8.649
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bartw schreef:
Wat is de regex als ik admin/user wil matchen en dan user er uit wil halen?

Ik heb /(.*?)/(.*?)/ al geprobeerd, matched hij user niet.

Edit: noodoplossing door een slash toe te voegen, als iemand een betere manier weet?
Details?
Wil je dit matchen?

iets(slash)iets

Dat kan inderdaad met bovenstaande regex. Beter zou zijn als je de [func]explode[/func] functie.
0
Berichten
473
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ja, maar ik wou juist proberen geen explode te gebruiken, want Regex leek mij hier makkelijker. Btw, details staan er in hoor...
0
Berichten
5.274
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien

Eindhoven, Nederland

Milan schreef:
Eerdere citaten tonen
Wouterr schreef:
Eerdere citaten tonen
Raaoul schreef:
Eerdere citaten tonen
Wouterr schreef:
Iemand die weet hoe ik MB naar GB omzet in PHP? Het moet hele GBs zijn, en altijd naar boven afgerond.
Bijvoorbeeld:
256MB is 1GB
1536MB is 2GB
1024MB is 1GB
15616MB is 16GB

Alvast bedankt smile
Is toch gewoon wiskunde? Heeft niks te maken met PHP
Jep, sorry x). Is opgelost, ty! This laat, volgensmij
Afbeelding
Delen door 1024 en dan afronden met ceil()
Jep, heb precies hetzelfde. smile
0
Berichten
7.307
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wat gebruiken jullie bij het maken van een php bestand? Bij html gebruik ik altijd notepad++, dan kan die hem makkelijk openen en zie ik preview via internet, maar dat kan via php niet, hoe kan ik een preview zien zonder steeds op mijn host te moeten zetten?
0
Berichten
11.263
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Jordyt schreef:
Wat gebruiken jullie bij het maken van een php bestand? Bij html gebruik ik altijd notepad++, dan kan die hem makkelijk openen en zie ik preview via internet, maar dat kan via php niet, hoe kan ik een preview zien zonder steeds op mijn host te moeten zetten?
http://writecodeonline.com/php/

Dit, je kan het dan wel niet saven.
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Ik wil een map maken, dus heb ik dit script:

[COLOR= #0000BB]<?php    
            $map[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]/home/x/domains/x.s2.one2xs.com/[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$path[/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/ftp_chdir"]ftp_chdir[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ftp_server[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$map[/COLOR][COLOR= #007700])) {[/COLOR]
                    [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/ftp_mkdir"]ftp_mkdir[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$ftp_server[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]map2[/COLOR][COLOR= #007700]])) {[/COLOR]
                        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]OK[/COLOR][COLOR= #007700];
                    }
                }[/COLOR]


Hij zegt OK maar de map is niet aangemaakt?
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