Click here to get back home

Please help me connect PHP to MySql - Newbie problem

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Please help me connect PHP to MySql - Newbie problem Alan Silver 07-16-2008
Posted by Alan Silver on July 16, 2008, 9:16 am
Please log in for more thread options
Hello,

I'm a newbie at PHP and MySql, although I have wads of experience of
ASP, ASP.NET, SQL Server, etc.

I have just installed PHP 5.2.3 on a server (Windows Server 2003), as
well as MySql 5.0.45. Both of these work fine independently, but I can't
get PHP to connect to MySql.

The first (and probably most basic) problem is that when I run phpinfo()
I don't see any mention of MySql. I suspect that this is the cause of
the lack of connectivity.

I have removed the comments from the following two lines in php.ini
(which is in C:\Windows)...

extension=php_mysql.dll
extension=php_mysqli.dll

I've also got the following line in there...

extension_dir = "C:\Program Files\PHP\ext\"

which points to the folder containing the two DLLs mentioned above.

I've rebooted the machine a couple of times since making these changes.

As I said, when I run phpinfo(), it doesn't mention MySql at all.

Anyone any ideas? If I try to connect, nothing happens. No errors,
nothing. I tried the following sample script from
http://uk.php.net/manual/en/function.mysql-connect.php to test it...

<?php
$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>

(where I changed the user name and password obviously), but this didn't
produce anything. No message, no error, just a blank page.

TIA for any help

--
Alan Silver
(anything added below this line is nothing to do with me)

Posted by macca on July 16, 2008, 9:44 am
Please log in for more thread options
You should read the manual here:

http://uk.php.net/manual/en/mysql.installation.php

Note this bit:

"MySQL is no longer enabled by default, so the php_mysql.dll DLL must
be enabled inside of php.ini. Also, PHP needs access to the MySQL
client library. A file named libmysql.dll is included in the Windows
PHP distribution and in order for PHP to talk to MySQL this file needs
to be available to the Windows systems PATH. See the FAQ titled "How
do I add my PHP directory to the PATH on Windows" for information on
how to do this. Although copying libmysql.dll to the Windows system
directory also works (because the system directory is by default in
the system's PATH), it's not recommended."

Posted by Alan Silver on July 16, 2008, 12:25 pm
Please log in for more thread options
In article
>You should read the manual here:
>
>http://uk.php.net/manual/en/mysql.installation.php

Read it several times...

>Note this bit:
>
>"MySQL is no longer enabled by default, so the php_mysql.dll DLL must
>be enabled inside of php.ini.

As noted in my original post, this was done

> Also, PHP needs access to the MySQL
>client library. A file named libmysql.dll is included in the Windows
>PHP distribution and in order for PHP to talk to MySQL this file needs
>to be available to the Windows systems PATH. See the FAQ titled "How
>do I add my PHP directory to the PATH on Windows" for information on
>how to do this. Although copying libmysql.dll to the Windows system
>directory also works (because the system directory is by default in
>the system's PATH), it's not recommended."

Ah, I added the ext folder to the PATH variable, but didn't spot that I
needed to add the PHP installation folder as well.

Seems to work now. Thanks a lot

--
Alan Silver
(anything added below this line is nothing to do with me)

Similar ThreadsPosted
help w/ php mysql connect problem!! August 30, 2005, 1:12 pm
PHP MySQL Connect Problem December 18, 2006, 5:43 pm
I have problem with connect to MySQL server please help me!! October 16, 2007, 2:13 pm
Newbie problem with HTML forms and PHP/MySQL... September 2, 2004, 4:56 am
Re: Newbie problem with HTML forms and PHP/MySQL... September 2, 2004, 11:33 am
Newbie mysql problem understanding result and id? May 29, 2005, 2:17 pm
Can't connect to local MySQL server through socket '/tmp/mysql.sock' PDO exception August 29, 2006, 1:40 pm
Can't connect to mysql from php August 13, 2004, 4:51 am
Mysql can connect, but PHP can't? May 9, 2005, 2:36 pm
How to connect to MySQL October 26, 2005, 5:47 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap