473,385 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Error connecting mysql database...

vikas1111
122 100+
Hi All

I installed PHP 5.2.5 and MySQL 5.0.51 versions. I am trying to establish the database connection with MySQL through PHP, I got the fatal error of the below message. I am using the IIS server of Windows XP systems with Service pack S2.

Fatal error: Call to undefined function mysql_connect()

This is my program, please check it and suggest it.
Expand|Select|Wrap|Line Numbers
  1. <? 
  2. $hostname="localhost"; 
  3. $user="root"; 
  4. $pass="root";  
  5. $connection = mysql_connect("$hostname" , "$user" , "$pass"); 
  6. $db = mysql_select_db($dbase , $connection); 
  7. echo "got the connection"; 
  8. ?>
  9.  
May 6 '08 #1
12 2083
ronverdonk
4,258 Expert 4TB
You most probably have simply installed the 2 applications apart from each other and you not installed the MySQL extension in PHP. See your PHP and MySQL installation guidelines on this.

Ronald
May 6 '08 #2
Atli
5,058 Expert 4TB
Like Ronald says, your PHP installation is missing the MySQL extension.

A common reason for extensions failing to load on Windows is that the PHP install directory is missing from the PATH env variable.

Try adding that, reboot and try again.
May 7 '08 #3
vikas1111
122 100+
Hi All

I installed PHP and MySQL . I am trying to establish the database connection with MySQL through PHP, I got the fatal error of the below message. I am using the MySQL server of Windows XP systems with Service pack S2.

Fatal error: Call to undefined function mysql_connect()

This is my program, please check it and suggest it.
Expand|Select|Wrap|Line Numbers
  1. <?
  2. $hostname="localhost";
  3. $user="root";
  4. $pass="root"; 
  5. $connection = mysql_connect("$hostname" , "$user" , "$pass");
  6. $db = mysql_select_db($dbase , $connection);
  7. echo "got the connection";
  8. ?>
  9.  
May 7 '08 #4
ronverdonk
4,258 Expert 4TB
This has nothing to do with your php code! It is your iunstallation of the PHP and MySQL packages where the problem is.

See Atli's and my previous posts on this problem. And check your installation of both applications.

Ronald
May 7 '08 #5
vikas1111
122 100+
Like Ronald says, your PHP installation is missing the MySQL extension.

A common reason for extensions failing to load on Windows is that the PHP install directory is missing from the PATH env variable.

Try adding that, reboot and try again.



Fine.. How can i set path to mysql in PHP or how to check that PHP is missing MySQL extension or not ??.. Should i reinstall PHP ???
May 13 '08 #6
rpnew
188 100+
Fine.. How can i set path to mysql in PHP or how to check that PHP is missing MySQL extension or not ??.. Should i reinstall PHP ???
Hi,
i think you'll get the information regarding MySql extension in phpinfo()

Regards,
RP
May 13 '08 #7
vikas1111
122 100+
Hi,
i think you'll get the information regarding MySql extension in phpinfo()

Regards,
RP

Thanks.. But how can i make changes ?
May 13 '08 #8
Atli
5,058 Expert 4TB
Thanks.. But how can i make changes ?
Try this...
  1. Right click on My Computer -> Select Properties
  2. Select the Advanced tab and click the Environmental Variables button
  3. Find and double-click the PATH variable in the System Variables list
  4. Add the absolute path to your PHP installation directory to the the Variable Value. Remember to separate it from the previous item with a semi-colon (;)
  5. Click OK -> OK and reboot your computer.
  6. Check if the MySQL extension is working now.
May 13 '08 #9
vikas1111
122 100+
Try this...
[*]Find and double-click the PATH variable in the System Variables list[*]Add the absolute path to your PHP installation directory to the the Variable Value. Remember to separate it from the previous item with a semi-colon (;)
[/list]


Thanks..
This.. %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN..
Is already there in the Variable Value field.. Is it correct ???
May 13 '08 #10
rpnew
188 100+
Thanks..
This.. %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\Sy stem32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN..
Is already there in the Variable Value field.. Is it correct ???
Hi,
Leave them as it is you just need to append your mysql path as 'Atli' has suggested.

Regards,
RP
May 13 '08 #11
vikas1111
122 100+
Try this...
  1. Right click on My Computer -> Select Properties
  2. Select the Advanced tab and click the Environmental Variables button
  3. Find and double-click the PATH variable in the System Variables list
  4. Add the absolute path to your PHP installation directory to the the Variable Value. Remember to separate it from the previous item with a semi-colon (;)
  5. Click OK -> OK and reboot your computer.
  6. Check if the MySQL extension is working now.


Hi tried but still not working...
May 13 '08 #12
Atli
5,058 Expert 4TB
Hi tried but still not working...
Check the ext folder in your PHP install dir.
"C:\Program Files\PHP\ext" by default.

There should be a file called 'php_mysql.dll'.
If it is missing you need to run the PHP installer again and have it install the MySQL extension.

If that doesn't work, try opening your php.ini file and locate the line starting with 'extension_dir'...
Make sure that this contains the full path to your PHP extension directory.
Which, by default, is:
Expand|Select|Wrap|Line Numbers
  1. extension_dir ="C:\Program Files\PHP\ext"
  2.  
And always remember to restart your HTTP server after making changes.
If your using IIS, you will probably have to reboot for the changes to take effect.
May 14 '08 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Pugi! | last post by:
On a freshly installed Fedora C3 (incl. webserver apache php mysql) i get the following problem when connecting to mysql through a browser (phpMyAdmin): : #2002 Can't connect to local MySQL...
0
by: ngiven | last post by:
Hello All, I'm running mysql 4.0.21 on an HP-UNIX machine and I am getting the following error: Got error 12 from Table Handler After looking up this error in the MySQL manual,...
3
by: kamilla | last post by:
I have a mysql 3.5 server installed on a suse linux 8.1, with address 10.0.0.100. Now I want to access that db from a W2K pc, address 10.0.0.200. I am able to ping 10.0.0.100, but I cannot connect...
4
by: 21novembre | last post by:
Hi all, I got a quite strange problem when I tried to setup a database backup shell. I put it this way: "bin/mysqldump --opt --user=xxx --password=xxx DB > DB.bak" However, error 1045 came to...
3
by: dstewart | last post by:
Situation: One common MySQL database server on SuSE 9.1 with all updates. Uses 'rinetd'. Has entries for the appropriate IP addresses of all servers. NOTE: If the appropirate entries are NOT in...
2
by: news | last post by:
We currently have our mySQL server on the same box as the Apache server. For security and load balancing, we're going to be moving the mySQL server to another box. We're already using a single...
3
by: Jeremy Dillinger | last post by:
I am trying to design a program that will use data from a MySQL database. Currently all the data is being used with PHP scripts from a website. I am also trying to build a software solution that...
2
by: arsisthesis | last post by:
Hi all, I have a curious problem with the ERROR 1044 and 1045: -system: OS X 10.4.3 (bash shell) -bash schell prompt: /~ kssun$ -I have set passwd to 'kssun' -I set path:...
8
by: Ananthu | last post by:
Hi I have done all the codings part for connecting mysql with java in eclipse environment. Coding Part: import java.sql.Connection; import java.sql.DriverManager; public class...
8
n8kindt
by: n8kindt | last post by:
hi guys, i am also posting this question in the MySQL forum but am putting the detailed post on here. here is the message i am having problems with: ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.