?
Solved

Call to undefined function mysql_connect() with PHP 5.3, Apache2.2., MySQL5 on Window

Posted on 2010-01-09
9
Medium Priority
?
2,959 Views
Last Modified: 2013-12-13
Hi, I tried a tough thing for 3 days. I am currently setting the php to mysql environment. I run

mysql_connect('127.0.0.1', 'user', 'password');

then, the error is:
Fatal error: Call to undefined function mysql_connect() in D:\Program Files\Apache Software Foundation\Apache2.2\htdocs\index.php on line 3

I looked up my phpinfo() which got the following:
====================================================
SERVER_SOFTWARE       Apache/2.2.11 (Win32) PHP/5.3.1
Server API       Apache 2.0 Handler
Configuration File (php.ini) Path       C:\windows

mysqlnd      enabled
Version       mysqlnd 5.0.5-dev - 081106 - $Revision: 289630 $
Command buffer size       4096
Read buffer size       32768
Read timeout       31536000
Collecting statistics       Yes
Collecting memory statistics       No
====================================================

I also tried PHP5.2, Apache 2.2.11, Apache 2.2.12, Apache 2.2.13, Apache 2.2.14, MySQL5.0 with all no luck of them.
I already set the environment variables Path to C:/PHP5/ext.
php.ini also rewrite extension_dir and un-comment php_mysql.dll

Everything I did is what still get the same "Call to undefined function mysql_connect()"

I would appreciate any possible solution !!!!
Help me out!
0
Comment
Question by:ddlam
9 Comments
 
LVL 19

Accepted Solution

by:
v2Media earned 2000 total points
ID: 26273086
On your phpinfo page, is php using the expected php.ini config file? What does phpinfo say about mysql in the list of extensions? It should list a dozen or so mysql directives and values...
0
 
LVL 9

Author Comment

by:ddlam
ID: 26273132
The location of the php.ini is correct since I can make some error by erasing php.ini

but the directives doesn't look good. phpInfo() just gives below:

mysqlnd
mysqlnd      enabled
Version       mysqlnd 5.0.5-dev - 081106 - $Revision: 289630 $
Command buffer size       4096
Read buffer size       32768
Read timeout       31536000
Collecting statistics       Yes
Collecting memory statistics       No

I expected phpinfo() page giving more detail but it doesn't do
0
 
LVL 9

Author Comment

by:ddlam
ID: 26273152
I use MySQL 5.1

phpinfo() gives
mysqlnd Version: mysqlnd 5.0.5-dev - 081106 - $Revision: 289630 $

is that right?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26273197
In order to have these functions available, you must compile PHP with MySQL support.  It is NOT a native part of PHP any more (used to be, but not now).

See the man pages here:
http://us3.php.net/manual/en/mysql.installation.php
http://us3.php.net/manual/en/mysql.configuration.php

Hope that helps, ~Ray
0
 
LVL 9

Author Comment

by:ddlam
ID: 26273267
above two links mention about php_mysql.dll and libmysql.dll. I think I got them being loaded because I didn't get what the notes said.

Note: If when starting the web server an error similar to the following occurs: "Unable to load dynamic library './php_mysql.dll'", this is because php_mysql.dll and/or libmysql.dll cannot be found by the system.

It also say 'In order to include MySQL support, You can download headers and libraries from www.mysql.com "

Should I follow this statement?
0
 
LVL 9

Author Comment

by:ddlam
ID: 26273403
oh wait, some document say phpinfo() returning
Configuration File (php.ini) Path       C:\windows

is wrong, it should be C:\windows\php.ini

I am trying to figure out
0
 
LVL 82

Expert Comment

by:hielo
ID: 26274375
Have you considered installing WAMP:
http://www.wampserver.com/en/download.php

It already includes php 5.3
0
 
LVL 9

Author Comment

by:ddlam
ID: 26275933
Finally, I figure out. The php.ini should be placed in C:\PHP5.
It is better than directing to the path of %system32%.

Now, window can deploys php.ini in PHP itself. Nothing to do the business with %system32%.
The php archives which are available from snap.php.net, by default, do not enable short tags inside php-development.ini
After renaming php-development.ini to php.ini, it used to enable short tag by turning open_tag to 'ON'

short_open_tag = Off
;it does not recognise '<?', only '<? php' or '<script>'



At the moment, I also tried WAMP. After installing WAMP, I wonder if there is a way to upgrade the whole bundle(PHP, MYSQL, APACHE) or not, it seems I will have difficulty to update PHP, MYSQL or APACHE individually or update the whole bundle to newer WAMP version.
Let me know if WAMP is better than separately installations between 3 of them. Is it worth to spend 3 days to enable PHP manually?
0
 
LVL 9

Author Closing Comment

by:ddlam
ID: 31674984
Also read author comment
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses four methods for overlaying images in a container on a web page
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

609 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question