SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2009
    Location
    Wenatchee, WA
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP/PEAR error_log?

    Hello,

    I'm working through some examples in the PHP Anthology from Sitepoint, with the examples slightly modified for my purposes. In this case, I am trying to query a database and display the info in a data grid using various PEAR modules (Structured_DataGrid and company) as per the example. A couple of the modules are still beta, so I had to change the preferences for my PEAR installation (XAMPP on a thumb drive) accordingly to be able to install them at all.

    Anywho, apparently there is an error somewhere early on in the first simple query of the info which is causing my data grid to not appear. The auth credentials for the db are the same ones I've used in working through the last few examples so I don't think they are screwed up. The book code just returns a blank page with a header at top, and shunts the error messages to an error_log... which I have been unable to find, either on my drive or via the 'Net, which is a bit frustrating. If someone could take a look at this code and either tell me what is wrong with it or better yet, point me in the direction of this error log so I can see what the output was... that'd be awesome

    PHP Code:
    <?php
      
    // Include the DB access credentials
      
    require 'dbcred.php';
      
    // Include the PEAR Structures_DataGrid class
      
    require 'Structures/DataGrid.php';
      
      
    // instantiate grid for 2 records per page
      
    $datagrid = new Structures_DataGrid(2);
      
    // Define our Datasource options, in this case MDB2 MySQL
      
    $options = array('dsn' => "mysql://$user:$password@$db_host/$db_name");
      
      
    // Define the Query
      
    $sql "SELECT * FROM test";
      
      
    // Bind the Query to our Datagrid
      
    $bind $datagrid->bind($sql$options);
      
    // Test for Errors
      
    if (PEAR::isError($bind))
      {
        
    error_log('DataGrid Error: '$bind->getMessage());
        
    $gridsource '';
      }
      else
      {...

  2. #2
    SitePoint Zealot
    Join Date
    Apr 2009
    Location
    Wenatchee, WA
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The auth credentials for the db are the same ones I've used in working through the last few examples so I don't think they are screwed up.
    Actually... thats not entirely true. Looking back, the *credentials* are the same, but previous examples used PDO, not MDB2. I have a sneaking hunch thats where my trouble lies... but I really need to be able to read the error_log to know what the messages are!

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2009
    Location
    Wenatchee, WA
    Posts
    101
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay... after enough digging around on the 'Net I finally found a couple places that kind of alluded to this - though it seemed like no one actually came out and *said* it in a straightforward manner (at least that I saw)... by default the error logging is *turned off* in php.ini, and you have to go in and edit that file to turn it on. In my case, it was as simple as un-commenting a line:

    PHP Code:
    Log errors to specified filePHP's default behavior is to leave this value
    ; empty.
    ; http://php.net/error-log
    ; Example:
    ;error_log = php_errors.log
    ; Log errors to syslog (Event Log on NT, not valid in Windows 95).
    ;error_log = syslog
    error_log = "\xampplite\apache\logs\php_error.log" 
    I actually figured out how to have the php script just dump the error directly to the browser for the purposes of testing (faster that way than having to go check a log file) so the above is a somewhat moot point for me now. I thought I'd put the info out there for the next guy


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
  •