?
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,937 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

762 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