Answer the question
In order to leave comments, you need to log in
PDO, I do not know how to do it right?
$localhost = 'localhost';
$dbname = 'us3456';
$username = 'root';
$password = '';
try {
$dbh = new PDO('mysql:host='.$localhost.';dbname='.$dbname.'', $username, $password);
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) { echo 'error_connected';}
$dbh->query("SET NAMES utf8");
$dbh->query("SET CHARACTER SET utf8");
$dbh->query("SET character_set_client = utf8");
$dbh->query("SET character_set_connection = utf8");
$dbh->query("SET character_set_results = utf8");
try {
$result = $pdo->query("SELECT 1 FROM us3456 LIMIT 1");
} catch (Exception $e) {
$sql = "CREATE TABLE us3456 (
`id` INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`value` int(11) NOT NULL
)";
$dbh->query($sql);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question