0

I have MySQL running such that I can open a client command line and log on and make databases, tables, etc.

I wanted to do some AJAX. Doing AJAX with ASP, SQL Server, etc is not advisable since both places where I am hosting my websites do not use the Microsoft products. So I am forced to do my development with PHP and MySQL.

I just about have everything set up. I have set up IIS so that I can go to my localhost and I can test out web pages. I have PHP installed so that I can pull up the PHP setting pages.

The problem occurs when I try to bring up the MySQL database in PHP. I use this very simple PHP command:

<?php

$con = mysql_connect('localhost', 'testuser', 'testpassword');

?>


When I try to connect to the mysql database through PHP, I get this error:
Click Here

I figure the problem must be in the settings that are in the php.ini. But it seems that my php.ini is set up for MySQL although it is not mentioned in the output when I query the phpinfo page with this code

<?php phpinfo(); ?>

Here is the result from this:

Click Here

4
Contributors
8
Replies
9
Views
8 Years
Discussion Span
Last Post by Robert Plant
0

Why don't you install xampp. Installing this software does not require any updation in any of the config files.
But in case of XAMPP you'll be using apache server and not IIS.
I recommend you using XAMPP.

0

So, MySQL is no longer enabled by default, so the php_mysql.dll DLL must be enabled inside of php.ini. How is this done? I searched php.ini and I did not find php_mysql.dll.

In my php.ini file I found this section under [MySQL]

[MySQL]
; Allow or prevent persistent links.
mysql.allow_persistent = On

; Maximum number of persistent links. -1 means no limit.
mysql.max_persistent = -1

; Maximum number of links (persistent + non-persistent). -1 means no limit.
mysql.max_links = -1

; Default port number for mysql_connect(). If unset, mysql_connect() will use
; the $MYSQL_TCP_PORT or the mysql-tcp entry in /etc/services or the
; compile-time value defined MYSQL_PORT (in that order). Win32 will only look
; at MYSQL_PORT.
mysql.default_port =

; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket =

; Default host for mysql_connect() (doesn't apply in safe mode).
mysql.default_host =

; Default user for mysql_connect() (doesn't apply in safe mode).
mysql.default_user =

; Default password for mysql_connect() (doesn't apply in safe mode).
; Note that this is generally a *bad* idea to store passwords in this file.
; *Any* user with PHP access can run 'echo get_cfg_var("mysql.default_password")
; and reveal this password! And of course, any users with read access to this
; file will be able to reveal the password as well.
mysql.default_password =

; Maximum time (in seconds) for connect timeout. -1 means no limit
mysql.connect_timeout = 60

; Trace mode. When trace_mode is active (=On), warnings for table/index scans and
; SQL-Errors will be displayed.
mysql.trace_mode = Off

0

I went back and redid the php installation from scratch and did the extra steps you mentioned. Now it works.

0

Well, I spoke to soon. Now I get a different kind of error.
pritaeas, I have added these two lines to PHP.ini :
extension=php_mysql.dll
extension_dir="/ext"

I have done all the steps in http://nl.php.net/manual/en/mysql.installation.php
to enable mysql with php. I have included c:\php in the system path. I have added the removed the semi colon on extension=php_mysql.dll in php.ini I have even copied the libraries into the c:\windows\system32 directories just to be sure.
But when I run a php script with this <?php phpinfo(); ?> from a php file, the result does not mention mysql.

The new problem I have is when I run a php file with
$con = mysql_connect('localhost', 'testuser', 'testpassword') or die("Could not connect");

The error I get in my browser says:

Fatal error: Call to undefined function mysql_connect() in C:\inetpub\wwwroot\getuser.php

0

Hi Experts,

I am getting this error message, "Error connecting to mysql"
whenever i am running the below scripts:

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');

$dbname = 'petstore';
mysql_select_db($dbname);
?>

I've just set-up everything and still getting such error...

By the way, I am using Windows Vista ans IIS 7.0, Could you please help me? suggestions please, recommendations...

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.