Kleine Vragen Topic #1

Gestart doorLennard4.284 reacties15.585 weergaven

4.285 berichten · pagina 204 van 286

Berichten
1.644
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
In de vak waar het moet staan zegt die nu: Resource id #10

ipv van: Jordy: Erg leuk huisje!
0
Lennard

Lid · Topicstarter

Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Ja ik bedoel wat je qua code hebt.
0
Berichten
1.644
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
mysql_connect("Localhost", "naam", "pass");
mysql_select_db("db");

$comment = mysql_query("SELECT naam, bericht FROM comment ORDER BY RAND() LIMIT 1");
?>

Heb db enzo eff weggehaald

En ik haal het op met

ik dacht zelf aan

SELECT naam, bericht FROM comment where commentid = "Hier random commentid ophalen"

Mijn php is bijna nihil
0
Berichten
8.602
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Je moet het ook eerst fetchen, daarna kun je het pas weergeven.
0
Berichten
1.644
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien

while($show = mysql_fetch_array($comment))
{
echo $show[naam]
echo $show[bericht]
} ?>

zoiets? ik ben echt dramatisch wat php betreft
0
Lennard

Lid · Topicstarter

Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Probeer het eens voor de grap. thumbsup
Dan krijg je errors en daar kun je misschien weer mee verder, en zo niet dan zal ik alvast hinten dat je een ; achter je echo-regels moet zetten. yummie
0
Berichten
1.644
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Het is me gelukt! OWYEAHH
0
Berichten
4.912
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
vergeet htmlentities niet sadley
0
Berichten
480
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
help!

mijn smudge tool in photoshop werkt ineens niet meer confusediemand die mij kan helpen? kan ook niks op google vinden... cry
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Vdvoort schreef:
help!

mijn smudge tool in photoshop werkt ineens niet meer confusediemand die mij kan helpen? kan ook niks op google vinden... cry
herinstaleren?
Repair runnen?

Wat is beter? Alle links standaard op no follow hebben of juist niet? Ik heb te tag weg gelaten maar ik kan m wel via UBB toevoegen
0
Berichten
14.025
Reputatie
1
Punten
0,01
Lid sinds
Laatst gezien
Ik ben weer bezig met een nieuwe class. Maar ik kom er nu niet uit omdat ik alle errors in een array wil hebben, en als er een error in de array zit weergeven.
Ik heb nu dit:

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/*
Powerd by TinyClass 1.0
Copyright 2013 by Dylanproductions.nl
*/

// mysql settings[/COLOR]

[COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]host[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]localhost[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]port[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]3306[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]root[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]password[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]database[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]database[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #FF8000]// all errors in a array[/COLOR]
[COLOR= #0000BB]$aError[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]

[COLOR= #FF8000]// now we start tinyclass[/COLOR]
[URL="http://www.php.net/class"]class[/URL] Tinyclass [COLOR= #007700]{[/COLOR]
    
    [COLOR= #FF8000]// first we connect to the mysql server[/COLOR]
    

    [COLOR= #007700]function[/COLOR] __construct[COLOR= #007700]() {[/COLOR]
        [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]connect [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]host[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]:[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]port[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]);[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]connect[COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$aError[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Oops, could not connect to mysql host. Please wait a minute.[/COLOR][COLOR= #007700];[/COLOR]
            [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]();
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]db [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]connect[COLOR= #007700],[/COLOR] [COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]database[/COLOR][COLOR= #007700]]);[/COLOR]
            
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]db[COLOR= #007700]) {[/COLOR]
                [COLOR= #0000BB]$aError[/COLOR][COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Oops, could not found the database. Please wait a minute.[/COLOR][COLOR= #007700];[/COLOR]
                [URL="http://www.php.net/exit"]exit[/URL][COLOR= #007700]();
            }
        }[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aError[/COLOR][COLOR= #007700])) {[/COLOR]
            [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$aError[/COLOR][COLOR= #007700];
        }
    }
}[/COLOR]

[COLOR= #0000BB]$class[/COLOR] [COLOR= #007700]= new[/COLOR] Tinyclass[COLOR= #007700]();[/COLOR]

?>


Maar ik krijg nu geen errors uit de array?
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Als ik dat script draai, komen er sowieso al errors.
$aConnection staat buiten de class gedefinieerd, dus binnen de class kun je niet zomaar $aConnection doen..
Zelfde geldt voor $aError, $aError is gedefinieerd buiten de class, dus binnen de class kan je het niet zomaar gebruiken.

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/*
Powerd by TinyClass 1.0
Copyright 2013 by Dylanproductions.nl
*/

// mysql settings[/COLOR]
[COLOR= #0000BB]$aConnection[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]host[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]localhost[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]port[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]3306[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]root[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]password[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]database[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]database[/COLOR][COLOR= #007700];[/COLOR]


[COLOR= #FF8000]// now we start tinyclass[/COLOR]
[URL="http://www.php.net/class"]class[/URL] Tinyclass [COLOR= #007700]{[/COLOR]

    [URL="http://www.php.net/public"]public[/URL] [COLOR= #0000BB]$aError[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/array"]array[/URL][COLOR= #007700]();[/COLOR]
    [URL="http://www.php.net/private"]private[/URL] [COLOR= #0000BB]$connect[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/private"]private[/URL] [COLOR= #0000BB]$db[/COLOR][COLOR= #007700];[/COLOR]
    [COLOR= #FF8000]// first we connect to the mysql server[/COLOR]
    

    [COLOR= #007700]function[/COLOR] __construct[COLOR= #007700]([/COLOR][COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700]) {[/COLOR]
        [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]connect [COLOR= #007700]= @[/COLOR][URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]host[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]:[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]port[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]);[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]connect[COLOR= #007700]) {[/COLOR]
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]aError[COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Oops, could not connect to mysql host. Please wait a minute.[/COLOR][COLOR= #007700];
            
        }[/COLOR] [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
            
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]db [COLOR= #007700]= @[/COLOR][URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]connect[COLOR= #007700],[/COLOR] [COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]database[/COLOR][COLOR= #007700]]);[/COLOR]
            
            [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]db[COLOR= #007700]) {[/COLOR]
                [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]aError[COLOR= #007700][] =[/COLOR] [COLOR= #DD0000]Oops, could not found the database. Please wait a minute.[/COLOR][COLOR= #007700];
                
            }
        }[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/count"]count[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]aError[COLOR= #007700])) {[/COLOR]
            [URL="http://www.php.net/return"]return[/URL] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]aError[COLOR= #007700];
        }
    }
}[/COLOR]

[COLOR= #0000BB]$class[/COLOR] [COLOR= #007700]= new[/COLOR] Tinyclass[COLOR= #007700]([/COLOR][COLOR= #0000BB]$aConnection[/COLOR][COLOR= #007700]);[/COLOR]

?>


Zoiets zou eerder moeten werken. Zo stuur je de $aConnection mee naar de __construct, zodat die functie ze kan gebruiken. De errors zet je in de class zelf, dus die kun je bereiken via $class->aError ..
De exit()s heb ik ook weggehaald, want hij voegt bij jou gewoon een error toe en stopt het script daarna direct..
0
Berichten
3.000
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Iemand hier die een beetje verstand heeft van CuteNews, heb namelijk een paar kleine vragen?
0
Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Mikek schreef:
Iemand hier die een beetje verstand heeft van CuteNews, heb namelijk een paar kleine vragen?
Cutenews is lek als ik het me goed kan herinneren

toevoeging op 21 december 2012, 15:02:53:
Sevvlor schreef:
Wat is beter? Alle links standaard op no follow hebben of juist niet? Ik heb te tag weg gelaten maar ik kan m wel via UBB toevoegen
0
Berichten
3.000
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Sevvlor schreef:
Cutenews is lek als ik het me goed kan herinneren
Hmm zou best kunnen het is maar voor een klein project dus als iemand kan helpen?
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