Wednesday, February 27, 2013

Connecting to MySQL from PHP


Connecting to MySQL from PHP
Open the php.ini configuration file in a text editor.
Find the line ; extension_dir = "ext" and change it to:
extension_dir = "c:\php\ext\"
Find the line ;extension=php_pdo_mysql.dll and uncomment it by removing the semicolon.
Restart the Apache server.


Copy the following listing into a new file under your htdocs directory.
<?php
header('Content-type:text/plain');
$dbh = new PDO('mysql:host=localhost;dbname=test', 'root', 'PASSWORD');
$st = $dbh->prepare('select bar from foo');
$st->execute();
var_dump($st->fetch(PDO::FETCH_ASSOC));
?>

http://www.vbforums.com/showthread.php?651576-Installing-MySQL-Server-5.5-on-Windows-7

No comments:

Post a Comment