Help: Easy mysql php connection problem.

Installation and configuration iussues

Moderators: macek, egami, gesf

jjensen347
New php-forum User
New php-forum User
Posts: 3
Joined: Sat Jul 12, 2014 12:50 pm

Help: Easy mysql php connection problem.

Postby jjensen347 » Sat Jul 12, 2014 1:28 pm

I'm trying to make a test connection to mysql in PHP but think I'm missing something obvious. (Do I need to include a module/library in my php source code??) I'm trying to use PDO or mysqli (mysql/mysql_connect is deprecated but also fails). The database is running (on 33060 -with the extra zero) and I'm able to make a connection to it using telnet 127.0.0.1 33060.

PDO:

Hello World 1

Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\hello.php:14 Stack trace: #0 C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\hello.php(14): PDO->__construct('mysql:host=loca...', 'script', 'Eshon') #1 {main} thrown in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\hello.php on line 14

PHP.INI
extension=php_pdo_mysql.dll
extension_dir = "ext"
extension=php_mysql.dll
extension=php_mysqli.dll


The php_pdo_mysql.dll is in the ext dir (and I copied it in the main PHP folder so I'm confused if/why it wouldn't be finding the file.)

MYSQLI:
Hello World 1

Fatal error: Class 'mysqli' not found in C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\hello.php on line 13



SOURCE CODE (commenting out mysqli to try PDO):
<html>
<head>
<title>PHP test</title>
</head>
<body>
<?php echo '<p>Hello World 1</p>';

//info
//phpinfo();


//("example.com", "user", "password", "database")
$dbconn = new mysqli("localhost:33060", "script", "Eshon", "mytest") or die (mysqli_error() );
$pdo = new PDO('mysql:host=localhost:33060;dbname=mytest', 'script', 'Eshon');
//line 15

//irrelevant code follows.



I've enabled everything I can think of in php.ini I'm QUITE confused as to why I'm missing and am not quite sure how to proceed. HELP.

Apache 2.2, Windows, PHP 5.4.30, Mysql 5.6.19.

jjensen347
New php-forum User
New php-forum User
Posts: 3
Joined: Sat Jul 12, 2014 12:50 pm

Re: Help: Easy mysql php connection problem.

Postby jjensen347 » Sat Jul 12, 2014 1:49 pm

Here is my Apache config. As I was looking through my config (again) I don't see anything telling PHP what directory to find the various mysqli/dpo dll's from. Am I missing something??

###PHP####
LoadModule php5_module "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\modules\php-5.4.30-vc9\php5apache2_2.dll"
AddHandler application/x-httpd-php .php
PHPIniDir "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\modules\php-5.4.30-vc9\"
####

jjensen347
New php-forum User
New php-forum User
Posts: 3
Joined: Sat Jul 12, 2014 12:50 pm

Re: Help: Easy mysql php connection problem.

Postby jjensen347 » Sun Jul 13, 2014 6:48 pm

I fixed the issue. I seemed to have incompatible php 5.4 libraries vs the apache build. Also my extentsion_dir in php.ini needed to be an absolute path.


Return to “MySQL Installation”

Who is online

Users browsing this forum: No registered users and 0 guests