Skip navigation links

MySQL Forums :: PHP :: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17


Advanced Search

Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17
Posted by: Heidi -- ()
Date: February 13, 2006 12:38PM

I am first time to use MySQL, Apache, and PHP.

I installed both of them. I was doing with the config of Apache include php. I installed MySQL 4.0 but uninstall it because I was not know how to until I was some learned.

I was tested PHP in Apache successfully but PHP is not work with MySQL. My active hard drives: F:\.
I have two hard drives, so
I put libmysql.dll, php_mysql.dll, and php_mysqli.dll to C:\WINDOWS\system32\
F:\WINDOWS\system32\
F:\WINDOWS\system\
C:\php\ext\

then I added php_mysql.dll and php_mysql.dll to php.ini in both C:\WINDOWS\ and F:\WINDOWS\.

;extension=php_mbstring.dll
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_ifx.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
;extension=php_mysql.dll <---------added.
;extension=php_mysqli.dll <---------added.
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll

I logged in MySQL command, so I used mysql database then I created table:

mysql> CREATE TABLE employees (
--->uname varchar(25) NOT NULL,
--->fname varchar(100) NOT NULL,
--->PRIMARY KEY (uname)
--->);

Query OK, 0 rows affected (0.13 sec)

then

mysql>INSERT INTO employees (uname, fname) VALUES ( 'john', 'John Doe');
Query OK, 1 row affected (0.00 sec)
mysql>INSERT INTO employees (uname, fname) VALUES ( 'sarah', 'Sarah Jane');
Query OK, 1 row affected (0.00 sec)
mysql>INSERT INTO employees (uname, fname) VALUES ( 'tim', 'Tim Shaw');
Query OK, 1 row affected (0.00 sec)
mysql>INSERT INTO employees (uname, fname) VALUES ( 'jane', 'Jane Smith');
Query OK, 1 row affected (0.00 sec)

mysql>SELECT * FROM employees;

+--------+--------------+
| uname | fname |
+----------+------------+
| john | John Doe |
| sarah | Sarah Jane |
| tim | Tim Shaw |
| jane | Jane Smith |
+-----------+-----------+
4 rows in set (0.00 sec)

I closed the my command, but MySQL is still started on.

After I modified with php.ini, I typed my html/php from MySQL book when I used dreamweaver. Here for I show you the code of php:
-----------------------------------------------------------
<html>
<head>
<basefont face="Arial">
</head>

<body>

<?php
// set server access variables
$host = "localhost";
$user = "joe";
$pass = "secret";
$db = "db123";

// open connection to database
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database to use
mysql_select_db($db) or die ("Unable to select database!");

// create SQL query string
$query = "SELECT * FROM employees";

// execute query and obtain result set
$result = mysql_query($query) or die ("Error in guery: $query. " . mysql_error());

// are there any rows in the result?
if (mysql_num_rows($result) > 0)
{
// yes
// iterate through result set
// format query results as table
echo "<table cellpadding=10 border=1>";
while($row = mysql_fetch_row($result))
{
echo "<tr>";
echo "<td>" . $row[0] . "</td>";
echo "<td>" . $row[1] . "</td>";
echo "</tr>";
}
echo "</table>";
}
else
{
// no
// print status message
echo "No rows found!";
}

// free result set memory
mysql_free_result($result);

// close connection
mysql_close($connection);

?>

</body>
</html>

----------------------------------------------------

After I finished type the code, I clicked to opened the Internet Explorer browser, and I typed "http://localhost/testsql.php"; but it's not work:

Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17

I found $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); in lines 17, but I have no idea how to fix it.


How to fix it? Or Where are installing from?
Or
How do php connect to MySQL?

Why are php connect to mysql are not work well?

Please help me. Thank you.

Heidi.

Options: ReplyQuote


Subject Written By Posted
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 Heidi -- 02/13/2006 12:38PM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 Georg Richter 02/13/2006 03:31PM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 Heidi -- 02/13/2006 08:28PM
Problem link PHP 5.1.2 + Mysql 5.0.18 + Apache 2.0.55 Rachman M Heryanto 02/14/2006 04:31AM
Re: Problem link PHP 5.1.2 + Mysql 5.0.18 + Apache 2.0.55 Georg Richter 02/15/2006 01:33AM
Re: Problem link PHP 5.1.2 + Mysql 5.0.18 + Apache 2.0.55 Ken Aubey 04/06/2006 12:01PM
Re: Problem link PHP 5.1.2 + Mysql 5.0.18 + Apache 2.0.55 Peter Brawley 04/06/2006 01:04PM
Re: Problem link PHP 5.1.2 + Mysql 5.0.18 + Apache 2.0.55 Ken Aubey 04/07/2006 01:09PM
Re: Problem link PHP 5.1.2 + Mysql 5.0.18 + Apache 2.0.55 Rodney Moore 07/11/2006 11:00AM
Re: Problem link PHP 5.1.2 + Mysql 5.0.18 + Apache 2.0.55 Rodney Moore 07/11/2006 01:19PM
Re: Problem link PHP 5.1.2 + Mysql 5.0.18 + Apache 2.0.55 cantankerous_bunch 01/26/2007 04:02PM
Problem link PHP 5.1.2 + Mysql 5.0.20 + IIS 6.0 Jason Gray 04/14/2006 07:53AM
Re: Problem link PHP 5.1.2 + Mysql 5.0.20 + IIS 6.0 William 04/14/2006 09:11AM
Re: Problem link PHP 5.1.2 + Mysql 5.0.20 + IIS 6.0 William 04/14/2006 09:13AM
Re: Problem link PHP 5.1.2 + Mysql 5.0.20 + IIS 6.0 Clint McCaskill 06/01/2006 08:57PM
Re: Problem link PHP 5.1.2 + Mysql 5.0.20 + IIS 6.0 William 06/02/2006 01:37AM
Re: Problem link PHP 5.1.2 + Mysql 5.0.20 + IIS 6.0 Jason Gray 04/14/2006 09:37AM
Re: Problem link PHP 5.1.2 + Mysql 5.0.18 + Apache 2.0.55 Sharad Sharma 09/03/2006 11:25PM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 zhang cunfu 04/16/2006 09:33PM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 nivtav 03/18/2007 06:14AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 Sharad Sharma 09/03/2006 11:35PM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 nirav shah 01/08/2007 12:17PM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 hetal patel 01/11/2007 10:31AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 Candy Ekangaki 01/11/2007 10:59AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 William 01/12/2007 11:14AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 Fran├žois Richard 01/17/2007 10:44PM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 Eugin Song 01/21/2007 08:23AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 arie budansyah 03/04/2007 11:42AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 Muhammd Abdul Mannan 01/27/2007 10:37AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 gafoor km 07/05/2007 12:08AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 kanchan doke 02/22/2008 02:39AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 Peter Brawley 02/22/2008 10:58AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 sanjeev thakur 02/22/2009 05:46AM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 Peter Brawley 02/22/2009 02:37PM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 hoang nguyen 02/22/2009 06:06PM
Re: Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Group\Apache2\practice\testsql.php on line 17 vahid kh 04/16/2008 08:54AM
Re: Fatal error: Call to undefined function mysql_connect() - Check DLL Version S Smith 05/16/2008 06:31AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.