What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 133 Stack Exchange communities.

This question already has an answer here:

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

  • 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() . "
    "; 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

    ?>

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 :-)

share|improve this question

marked as duplicate by Patrick Hofman, Braiam, Martijn Pieters, gnat, Shadow Wizard Nov 21 at 22:05

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
definitely check out the editing help, which covers this in some detail meta.stackoverflow.com/editing-help –  Jeff Atwood Jul 17 '09 at 5:46

1 Answer 1

up vote 6 down vote accepted

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
    
    ?>
    
share|improve this answer
2  
FAQ perhaps? Seems like this would be helpful. –  Jeff Yates Jul 9 '09 at 15:51
    
OK, I added the FAQ tag to the original post. –  Kyle Cronin Jul 9 '09 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. :-) –  Ivan Vučica Jul 9 '09 at 18:05

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