+ Reply to Thread
Results 1 to 3 of 3

Thread: Bug testing and error finding

  1. #1
    Super Moderator crazybrumi crazybrumi's Avatar
    Join Date
    Jun 2007
    Location
    Birmingham, England
    Posts
    1,190
    Thanks
    4
    Thanked 7 Times in 6 Posts
    Rep Power
    0

    Default Bug testing and error finding

    is there some sort of software or whatever that can detect where errors are, and what can cause problems ie crashes. which = server load and slow responce on webpage?
    Want something coded email me at for a prices.




  2. #2
    Senior Member khan89 is on a distinguished road khan89's Avatar
    Join Date
    Dec 2009
    Location
    Bangladesh
    Posts
    288
    Thanks
    3
    Thanked 5 Times in 5 Posts
    Rep Power
    1

    Default

    i use php designer 2007. with debuger installed.

  3. #3
    Senior Member djlee
    Join Date
    Jun 2008
    Posts
    257
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Rep Power
    0

    Default

    n00bs should not apply in your own words ???

    anyway this is not a special software based solution

    1. Learn to optimise, queries in loops are forbidden, never do it, what i do is use a mysql query function on large sites to view queries, something like

    Code:
    function sql_query($query) {
     global $queries, $query_stat;
     if(!isset($queries))
      $queries = 0;
     if(!isset($query_stat))
      $query_stat = array();
     $queries++;
     $mtime = microtime(); // Get Current Time
     $mtime = explode (" ", $mtime); // Split Seconds and Microseconds
     $mtime = $mtime[1] + $mtime[0]; // Create a single value for start time
     $query_start_time = $mtime; // Start time
     $result = mysql_query($query); // do not change to sql_query
     $mtime = microtime();
     $mtime = explode (" ", $mtime);
     $mtime = $mtime[1] + $mtime[0];
     $query_end_time = $mtime; // End time
     $query_time = ($query_end_time - $query_start_time);
     $query_time = substr($query_time, 0, 8);
     $query_stat[] = array("seconds" => $query_time, "query" => $query);
     return $result;
     }
    
    then at the bottom of the page a box with all the queries in

    Code:
    if($userid == 1) {
          foreach($query_stat as $key => $value)
           print("[".($key+1)."] => <b>".($value["seconds"] > 0.01 ? "<font color=\"red\" title=\"I suggest you should optimize this query.\">".$value["seconds"]."</font>" : "<font color=\"green\" title=\"This query doesn't need's optimization.\">".$value["seconds"]."</font>" )."</b> [$value[query]]<br />\n");
    
    }
    
    What that will do it print out each query and the time it took to execute with a colour to tell you if its quick or slow (some queries will be inheriently slow and impossible to fix but most should be optimisable). Its a nifty bit of code and simple to use, just replace your mysql_query with sql_query

    2. enable slow query logging in my.cnf (mysqls config file). This will log any queries that take longer than x seconds (x is defined in my.cnf) to execute. Pretty much like above but more accurate and it never hurts to have extra logging

    3. in php.ini or at the start of one of your main include files like core.php add
    Code:
    error_reporting(E_ALL);
    ini_set("display_errors",1);
    
    That will simply tell php to output any warnings or errors to the screen, if you havent done this before be prepared for a boat load of warnings for undefined vars e.c.t. most of which are fixed by simply initiating the variable and/or using isset() ).

    4. if you have shell access you can use the top command to give you an idea of if its a mysql or apache issue (you can also tell if its a php issue if php is running in cgi, you run php as a apache module then php is part of the apache process so there not seperately shown). Soo you could either just type
    Code:
    top
    
    for a list of processes or type something like
    Code:
     top -u www-data
    
    to see all running processes under the www-data user which is the common username for apache

    thats more than enough to get you going, there is a hell of a lot more you could do but the above are usually enough to satisfy most people.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Help Finding Errors (PHP error messages off)
    By something else in forum Site / Script testing and error fixing
    Replies: 2
    Last Post: 05-06-09, 05:31
  2. Testing
    By subzero in forum Trash forum
    Replies: 3
    Last Post: 24-02-09, 15:16
  3. Testing
    By subzero in forum Site / Script testing and error fixing
    Replies: 7
    Last Post: 05-07-08, 05:37
  4. Testing Your Own Script
    By synergyx in forum Site / Script testing and error fixing
    Replies: 6
    Last Post: 29-06-08, 03:37
  5. Help With Hosting&/or Testing
    By allexclusive in forum Site / Script testing and error fixing
    Replies: 3
    Last Post: 26-08-07, 20:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO