Kleine Vragen Topic #1

Gestart doorLennard4.284 reacties15.585 weergaven

4.285 berichten · pagina 237 van 286

Berichten
3.112
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
- Haal eerst de gegevens op (via mysql_fetch_array of dergelijke)
- Daarna if($rank >= 5) {
0
Berichten
3.532
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dus zo:

[COLOR= #0000BB]<?php
$rank[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT rank FROM users WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR]
[COLOR= #0000BB]$rank2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rank[/COLOR][COLOR= #007700])[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rank2[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]5[/COLOR][COLOR= #007700]){[/COLOR]
            

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="menuitems"><a href="ase/login">Housekeeping</a></div>[/COLOR][COLOR= #007700];
}[/COLOR] ?>
0
Berichten
3.112
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Alleen achter regel 3 nog een ;
0
Berichten
3.532
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Parse error: syntax error, unexpected $rank2 (T_VARIABLE) in C:xampphtdocsapptplskinshabbzome.php on line 46

toevoeging op 27 januari 2013, 10:56:24:
laatmaar

toevoeging op 27 januari 2013, 10:57:32:
maar nu heb ik rank 1
en dat is gebruiker en hij staat er nog.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
- Foutafhandeling mist
- Inconsistente naamgeving $rank en $rank1 zegt niet over de inhoud. Is verwarrend...
- *_fetch_assoc is sneller.
- Je hebt een array, haal het juiste veld als key op....
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Jespar schreef:
Dus zo:

[COLOR= #0000BB]<?php
$rank[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT rank FROM users WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR]
[COLOR= #0000BB]$rank2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rank[/COLOR][COLOR= #007700])[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rank2[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]5[/COLOR][COLOR= #007700]){[/COLOR]
            

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="menuitems"><a href="ase/login">Housekeeping</a></div>[/COLOR][COLOR= #007700];
}[/COLOR] ?>
RevCMS? Maak je een Habbo Retro?
0
Berichten
3.532
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Dylanh schreef:
Eerdere citaten tonen
Jespar schreef:
Dus zo:
[COLOR= #0000BB]<?php
$rank[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT rank FROM users WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]user[/COLOR][COLOR= #007700]][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR]
[COLOR= #0000BB]$rank2[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_array"]mysql_fetch_array[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rank[/COLOR][COLOR= #007700])[/COLOR]
[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$rank2[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]5[/COLOR][COLOR= #007700]){[/COLOR]
            

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div class="menuitems"><a href="ase/login">Housekeeping</a></div>[/COLOR][COLOR= #007700];
}[/COLOR] ?>

RevCMS? Maak je een Habbo Retro?

ja en?

toevoeging op 27 januari 2013, 111632:
Aarclay schreef:
- Foutafhandeling mist
- Inconsistente naamgeving $rank en $rank1 zegt niet over de inhoud. Is verwarrend...
- *_fetch_assoc is sneller.
- Je hebt een array, haal het juiste veld als key op....
hoe moet het anders dan
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Staat er toch?
Foutafhandeling: if-je om $rank te controleren. Bij false een mysql_error tonen, en anders de rest.

Naamgeving: Zorgvoor duidelijke verschillende namen. $result wordt vaak gebruiktvoor een query, en $sql voor een string daarin.

Array: $array[iets] (pseudocode)
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Kortom: terug naar PHPtuts.nl!
0
Marv

Lid

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Hoe genereer ik een random woord van 6 letters a-z ?
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Marvinguich schreef:
Hoe genereer ik een random woord van 6 letters a-z ?
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// Making an random hash with php[/COLOR]
[COLOR= #0000BB]$hash[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$alfa[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/range"]range[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]a[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]z[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]6[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$a[/COLOR][COLOR= #007700]++) {[/COLOR]

[COLOR= #0000BB]$hash[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #0000BB]$alfa[/COLOR][COLOR= #007700][[/COLOR][URL="http://www.php.net/array_rand"]array_rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$alfa[/COLOR][COLOR= #007700])];

}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$hash[/COLOR][COLOR= #007700];[/COLOR]
?>


Als het goed is.
0
Marv

Lid

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Dylanh schreef:
Eerdere citaten tonen
Marvinguich schreef:
Hoe genereer ik een random woord van 6 letters a-z ?
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// Making an random hash with php[/COLOR]
[COLOR= #0000BB]$hash[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000][/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$alfa[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/range"]range[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]a[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]z[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/for"]for[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$a[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]6[/COLOR][COLOR= #007700];[/COLOR] [COLOR= #0000BB]$a[/COLOR][COLOR= #007700]++) {[/COLOR]

[COLOR= #0000BB]$hash[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #0000BB]$alfa[/COLOR][COLOR= #007700][[/COLOR][URL="http://www.php.net/array_rand"]array_rand[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$alfa[/COLOR][COLOR= #007700])];

}[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$hash[/COLOR][COLOR= #007700];[/COLOR]
?>


Als het goed is.
Thanx wink
///

Ander probleem, de DirectAdmin API haalt wel dingen op, bijvoorbeeld alle webhosting packages, maar ik kan geen user aanmaken:

[COLOR= #0000BB]<?php
$sock[/COLOR][COLOR= #007700]->[/COLOR]query[COLOR= #007700]([/COLOR][COLOR= #DD0000]/CMD_API_ACCOUNT_USER[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]action=create&add=Submit&username=marvin&email=test@test.nl&passwd=test123&passwd2=test123&domain=hotmail.com&package=Starter-400_00EUR&ip=77.72.147.113&notify=yes[/COLOR][COLOR= #007700]);[/COLOR]
?>


hoe kan dit?
0
Lennard

Lid · Topicstarter

Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Welke output krijg je?
0
Marv

Lid

Berichten
3.092
Reputatie
1
Punten
0,21
Lid sinds
Laatst gezien
Niks dus. Niet op het scherm.
0
Berichten
10.421
Reputatie
4
Punten
0,00
Lid sinds
Laatst gezien
Je moet ook fetchen?
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