mysql_connect() error

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
beckbapegeneral
Forum Newbie
Posts: 19
Joined: Mon May 08, 2006 8:59 pm

mysql_connect() error

Post by beckbapegeneral »

there is something wrong with my coding.. i am trying to create an connect in another .php file and to include it in my main .php file. but when i run in on the browser, there is a fatal error saying undefined call function mysql_connect(). anyone can help me please :cry:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Please post the relevant code so we can see what is going wrong (obviously do not include connection username/password info).
(#10850)
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: mysql_connect() error

Post by RobertGonzalez »

beckbapegeneral wrote:there is something wrong with my coding.. i am trying to create an connect in another .php file and to include it in my main .php file. but when i run in on the browser, there is a fatal error saying undefined call function mysql_connect(). anyone can help me please :cry:
If you are getting a call to an undefined function using mysql_connect then you do not have the mysql extension installed. Search these forums for how to install the mysql or mysqli extension by editing your php.ini file.
beckbapegeneral
Forum Newbie
Posts: 19
Joined: Mon May 08, 2006 8:59 pm

Post by beckbapegeneral »

can you be kind enough to provide me url where i can learn how to configure my php.ini? thanks alot in advance
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

There should be plenty of threads and posts here about enableing extensions in php.ini. Do a quick search. It is usually something as simple as removing a semicolon from the front of a line in php.ini that looks like

Code: Select all

;extension=php_mysql.dll
beckbapegeneral
Forum Newbie
Posts: 19
Joined: Mon May 08, 2006 8:59 pm

Post by beckbapegeneral »

guys.. i think there is some serious problem.. it is that i have uncommented the extensions=php_mysql.dll but the browser is now displaying this error to me
Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\opendb.php on line 2
PHP Warning: PHP Startup: Unable to load dynamic library './php_mssql.dll' - The specified module could not be found. in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library './php_msql.dll' - The specified module could not be found. in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library './php_mysql.dll' - The specified module could not be found. in Unknown on line 0
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's not a serious problem. Just make sure your extension_dir directive is set correctly.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

beckbapegeneral wrote:guys.. i think there is some serious problem.. it is that i have uncommented the extensions=php_mysql.dll but the browser is now displaying this error to me
Fatal error: Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\opendb.php on line 2
PHP Warning: PHP Startup: Unable to load dynamic library './php_mssql.dll' - The specified module could not be found. in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library './php_msql.dll' - The specified module could not be found. in Unknown on line 0 PHP Warning: PHP Startup: Unable to load dynamic library './php_mysql.dll' - The specified module could not be found. in Unknown on line 0
Look at the errors you are getting. That means that PHP cannot find your extensions. Either the extension folder entry in php.ini is incorrect or the .dll's are not in that folder. One or the other.
beckbapegeneral
Forum Newbie
Posts: 19
Joined: Mon May 08, 2006 8:59 pm

Post by beckbapegeneral »

i am using php installer to install my php and i downloaded the zip file and copied the ext folder to my php folder in c:\php . The extension_dir="C:\php" and the .dll files are in the ext folder. can someone please help me with the installation? :cry:
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

...

Post by ok »

First of all, look at the PHP manual (http://www.php.net/manual/en/install.windows.php).
Secondly, the best thing to do is to install manually (with Apache): http://www.php.net/manual/en/install.windows.manual.php .

If you don't want to install again, just change your ext dir to extension_dir=C:\php\extensions, and check that the mysql ext is in the extensions dir.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

beckbapegeneral,

You know, we may have been going about this all wrong. What version of PHP are you installing? Take a look at the Installation of extensions on Windows page of the PHP manual. It mentions extensions that are pre-built into the Windows distibution and how to install extensions that are not already in the distro.
Post Reply