3

Here's two examples (note that in first example, backticks also had no effect, for some reason):

  • include/db.php:

    $attribs = array( PDO::ATTR_PERSISTENT => $config['db']['persistent'], PDO::ATTR_ERRMODE => $config['db']['errormode'] ); $db = new PDO( $config['db']['uri'], $config['db']['user'], $config['db']['pass'], $attribs ); $db->query("SET NAMES 'utf8'"); $db->query("SET CHARACTER SET 'utf8'"); } catch (PDOException $e) { print "Error!: " . $e->getMessage() . "
    "; die(); } function dbGetEngine() { global $config; return substr($config['db']['uri'], 0, strpos($config['db']['uri'], ':')); } ?>
  • include/config.php:

It gets worse, try adding space prior to the asterisk :/

Just removing the asterisk fixes stuff up. Thing is, I believe it looks nicer with the asterisk ... and it's definitely a bug :-)

1

1 Answer 1

6

If you want to embed code in a list, you'll need to precede it with 8 spaces instead of the usual 4:

  • include/db.php:

    try {
    
            $attribs =  
                    array(
                            PDO::ATTR_PERSISTENT => $config['db']['persistent'],
                            PDO::ATTR_ERRMODE => $config['db']['errormode']
                    );
    
    
            $db = new PDO(
                    $config['db']['uri'],
                    $config['db']['user'],
                    $config['db']['pass'],
                    $attribs
            );
            $db->query("SET NAMES 'utf8'");
            $db->query("SET CHARACTER SET 'utf8'");
    
    } catch (PDOException $e) {
            print "Error!: " . $e->getMessage() . "<br/>";
            die();
    }
    
    function dbGetEngine() {
            global $config;
            return substr($config['db']['uri'], 0, strpos($config['db']['uri'], ':'));
    }
    ?>
    
  • include/config.php:

    //$config['db']['uri'] = 'sqlite:' . realpath('.') . '/site.db'; // PDO's database access URI
    $config['db']['uri'] = 'mysql:host=localhost;dbname=sitedb'; // server should be : 195.78.32.7
    //$config['db']['uri'] = 'pgsql:host=localhost;dbname=sitedb';
    $config['db']['user'] = 'user_goes_here'; // database username
    $config['db']['pass'] = 'pass_goes_here'; // database password
    $config['db']['persistent'] = false; // should the connection be persistent
    $config['db']['errormode'] = PDO::ERRMODE_EXCEPTION; // PDO's error mode
    
    ?>
    
3
  • 2
    FAQ perhaps? Seems like this would be helpful.
    – Jeff Yates
    Commented Jul 9, 2009 at 15:51
  • OK, I added the FAQ tag to the original post.
    – Kyle Cronin Mod
    Commented Jul 9, 2009 at 15:55
  • 2
    Interesting ... yet, I still believe that markdown breaking horribly like it does is not productive; I mean, it actually ate up a few lines of my code. Not here; hete it ate one out of config.php, but it looks worse in JS-generated preview, and confuses the hell out of someone not knowing what's wrong... Just saying. :-) Commented Jul 9, 2009 at 18:05

Not the answer you're looking for? Browse other questions tagged .