Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

MySQL - connect

  • mysql_connect
  • mysql_error
  • mysql_select_db
<?php

$db = mysql_connect('localhost', 'username');
if (! $db) {
    die ("Could not connect" . mysql_error());
}

$selected = mysql_select_db('db_name', $db);
if (! $selected) {
    die("Could not select: " . mysql_error());
}