Error code

Gestart doorOne2xs13 reacties40 weergaven

14 berichten · pagina 1 van 1

One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Wie weet er de code van de error op one2xs?
Dus dat er automatisch een mail word verzonden naar mijn email als er een error op treed?
Hierzo is het:
Er is een fout opgetreden, de beheerders zijn op de hoogte gesteld
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Komt heel erg versimpeld op zoiets neer:
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/set_error_handler"]set_error_handler[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]errhandler[/COLOR][COLOR= #007700]);

function[/COLOR] errhandler[COLOR= #007700]([/COLOR][COLOR= #0000BB]$errno[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$errstr[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$errfile[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]onbekend[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$errline[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [URL="http://www.php.net/mail"]mail[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]lala@po.nl[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Fout[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Fout "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$errstr[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" (nr [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$errno[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]) in [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$errfile[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] op regel [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$errline[/COLOR][COLOR= #007700]);
    
}[/COLOR]
?>
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Okej, werkt die?
En hoe kan ik hem testen yummie
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Fskpro:
Okej, werkt die?
Ga testen dan. emo
Fskpro:
En hoe kan ik hem testen yummieZorgen dat dr een fout in je systeem staat. yummie
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Okej, ik kreeg 88 emails binnen yummie
Quote:
Fout "Undefined variable: head" (nr 8) in /home/fskpro/domains/fskproductie.nl/public_html/test2.php op regel 22

Maar hoe doe je, als er een fout is, dat er staat:
De beheerders zijn op de hoogte gesteld?
0
Berichten
2.396
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Een echo voor de mail functie?
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Is er ook een functie voor mysql fouten?
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
Ja, mysql_query() icm mysql_error().

[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]new[/COLOR] mysql
[COLOR= #007700]{[/COLOR]
    
    [URL="http://www.php.net/private"]private[/URL] [COLOR= #0000BB]$verbinding[/COLOR][COLOR= #007700];[/COLOR]
    
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] __construct[COLOR= #007700]([/COLOR][COLOR= #0000BB]$host[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$user[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$pass[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$db[/COLOR][COLOR= #007700])
    {[/COLOR]
        
        [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]verbinding [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$host[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$user[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$pass[/COLOR][COLOR= #007700]);[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/is_resource"]is_resource[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]verbinding[COLOR= #007700]))
        {[/COLOR]
            
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]error[COLOR= #007700]();
            
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR]
            
            [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$db[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]verbinding[COLOR= #007700]);
            
        }
        
    }[/COLOR]
    
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] query[COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])
    {[/COLOR]
        
        [COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]verbinding[COLOR= #007700]);[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/is_resource"]is_resource[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700]))
        {[/COLOR]
            
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]error[COLOR= #007700]();
            
        }
        
    }[/COLOR]
    
    [URL="http://www.php.net/private"]private[/URL] [COLOR= #007700]function[/COLOR] error[COLOR= #007700]()
    {[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Fout <strong>[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]().[/COLOR][COLOR= #DD0000]</strong> (#[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_errno"]mysql_errno[/URL][COLOR= #007700]().[/COLOR][COLOR= #DD0000])[/COLOR][COLOR= #007700];
        
    }
    
}[/COLOR]
?>


Je kunt alleen geen regelnummertje en bestand achterhalen waar de fout vandaan kwam, omdat de fout altijd uit je mysql class komt (dus __FILE__ geeft de locatie van je class aan, en __LINE__ het regelnummer van je mysql_query()).
0
Erik

Lid

Berichten
7.109
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
En als je geen classes doet?
Gewoon een functie error_mysql() en dan de fout in de database zetten?
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Yeuh, hij werkt biggrin
0
Berichten
747
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Lennard schreef:
Ja, mysql_query() icm mysql_error().
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]new[/COLOR] mysql
[COLOR= #007700]{[/COLOR]
    
    [URL="http://www.php.net/private"]private[/URL] [COLOR= #0000BB]$verbinding[/COLOR][COLOR= #007700];[/COLOR]
    
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] __construct[COLOR= #007700]([/COLOR][COLOR= #0000BB]$host[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$user[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$pass[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$db[/COLOR][COLOR= #007700])
    {[/COLOR]
        
        [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]verbinding [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$host[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$user[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$pass[/COLOR][COLOR= #007700]);[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/is_resource"]is_resource[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]verbinding[COLOR= #007700]))
        {[/COLOR]
            
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]error[COLOR= #007700]();
            
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR]
            
            [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$db[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]verbinding[COLOR= #007700]);
            
        }
        
    }[/COLOR]
    
    [URL="http://www.php.net/public"]public[/URL] [COLOR= #007700]function[/COLOR] query[COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700])
    {[/COLOR]
        
        [COLOR= #0000BB]$res[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]verbinding[COLOR= #007700]);[/COLOR]
        
        [URL="http://www.php.net/if"]if[/URL][COLOR= #007700](![/COLOR][URL="http://www.php.net/is_resource"]is_resource[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$res[/COLOR][COLOR= #007700]))
        {[/COLOR]
            
            [COLOR= #0000BB]$this[/COLOR][COLOR= #007700]->[/COLOR]error[COLOR= #007700]();
            
        }
        
    }[/COLOR]
    
    [URL="http://www.php.net/private"]private[/URL] [COLOR= #007700]function[/COLOR] error[COLOR= #007700]()
    {[/COLOR]
        
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Fout <strong>[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]().[/COLOR][COLOR= #DD0000]</strong> (#[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/mysql_errno"]mysql_errno[/URL][COLOR= #007700]().[/COLOR][COLOR= #DD0000])[/COLOR][COLOR= #007700];
        
    }
    
}[/COLOR]
?>


Je kunt alleen geen regelnummertje en bestand achterhalen waar de fout vandaan kwam, omdat de fout altijd uit je mysql class komt (dus __FILE__ geeft de locatie van je class aan, en __LINE__ het regelnummer van je mysql_query()).

Ik heb in mijn error handler wel bij mysql fouten de bestandsnaam:
$_SERVER[REQUEST_URI]

Werkt dmv een functie:
mysql_query($query) or die(report_mysql(hier zet ik een functieomschrijving neer zodat ie snel terug is te vinden en waar die voor dient));

Als er dan een fout is kan ik alleen regelnummer niet zien.
0
One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Alleen ik heb nu deze code:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/set_error_handler"]set_error_handler[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]errhandler[/COLOR][COLOR= #007700]);

function[/COLOR] errhandler[COLOR= #007700]([/COLOR][COLOR= #0000BB]$errno[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$errstr[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$errfile[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]onbekend[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$errline[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700])
{[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL][COLOR= #DD0000]"Er is een fout opgetreden, de beheerders zijn op de hoogte"[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/mail"]mail[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]nick@fskproductie.nl[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Fout[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]Fout "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$errstr[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]" (nr [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$errno[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000]) in [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$errfile[/COLOR][COLOR= #007700].[/COLOR][COLOR= #DD0000] op regel [/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$errline[/COLOR][COLOR= #007700]);
    
}[/COLOR]
?>


en als ik de fout
include"sahhuaudahsadsdahsdaadsd.php";
?>
doe dan krijg ik 5 errors ;S
0
Berichten
13.482
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
dan moet je dat gewoon niet doen emo
0
Berichten
35.796
Reputatie
1
Punten
0,00
Lid sinds
Laatst gezien
@ Arjan: Hier op o2x sturen we ook een hele bubs informatie mee zodat je de fout kunt herleiden; oa de request uri. smile
@ Erik: Kan ook, maar is wel veel meer typewerk dan per query, dan krijg je namelijk dat wat Arjan heeft
Je kunt mijn methode ook naar niet-OOP omzetten, maar dit is het handigst. biggrin
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