logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



MySQL Problem!

 
Post new topic   Reply to topic    Apache Forum Index -> Other Software



View previous topic :: View next topic  
Author Message
Aznsilvrboy



Joined: 06 Jul 2006
Posts: 11

PostPosted: Sun 09 Jul '06 1:02    Post subject: MySQL Problem! Reply with quote

Well I'm following this book called "PHP and MySQL for Dummies 2nd Edition" and after I tested PHP with test.php (works), i added another line of code

phpinfo();" which displays all information associated with PHP on my system. Many tables were displayed upon running test.php meaning that phpinfo(); is working. The book tells me to check the listing if MySQL is enabled by going to the "MySQL" section. My first problem is that there exists no such section in the tables/information generated by phpinfo():. So how can check that MySQL support is On? Another thing I discovered that the configuration path of the php.ini is still C:\Windows\php.ini rather than C:\php\php.ini. How would I go about changing the configuration path of php.ini?

No big deal, so I go off to test a php program called mysql_up.php which is supposed to generate a long list of variable names and values to indicate that MySQL is working fine. However I get this error when I try to point my brower to mysql_up.php:

Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\mysql_up.php on line 10

The code for the program is as follows:

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

<html>
<head><title>Test MySQL</title></head>
<body>
<!-- mysql_up.php -->
<?php
$host="localhost";
$user="root";
$password="mysqlpassword";

mysql_connect($host,$user,$password);
$sql="show status";
$result = mysql_query($sql);
if ($result == 0)
{
echo "<b>Error " . mysql_errno() . ": "
. mysql_error() . "</b>";
}
else
{
?>
<!-- Table that displays the results -->
<table border="1">
<tr><td><b>Variable_name</b></td><td><b>Value</b>
</td></tr>
<?php
for ($i = 0; $i < mysql_num_rows($result); $i++) {
echo "<TR>";
$row_array = mysql_fetch_row($result);
for ($j = 0; $j < mysql_num_fields($result); $j++)
{
echo "<TD>" . $row_array[$j] . "</td>";
}
echo "</tr>";
}
?>
</table>
<?php } ?>
</body></html>

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

Now I dont think there's anything wrong with the code. What is wrong here? Thanks.

Working Environment:

Windows XP Pro
MySQL Server 5.0
Apache 2.2.2
PHP 5.1.4
Back to top
pnllan



Joined: 05 Dec 2005
Posts: 221

PostPosted: Sun 09 Jul '06 7:30    Post subject: Reply with quote

Is the MySQL extension 'uncommented' (the ; indicates a comment - meaning that anything after it on a line is ignored) in your PHP.INI?

If I remember, you are using Apache 2.2.2. Did you include the following directive in your HTTPD.CONF?

PHPIniDir "C:/php"
Back to top
Aznsilvrboy



Joined: 06 Jul 2006
Posts: 11

PostPosted: Sun 09 Jul '06 21:25    Post subject: Reply with quote

pnllan wrote:
Is the MySQL extension 'uncommented' (the ; indicates a comment - meaning that anything after it on a line is ignored) in your PHP.INI?

If I remember, you are using Apache 2.2.2. Did you include the following directive in your HTTPD.CONF?

PHPIniDir "C:/php"


No i did not include the PHPIniDir directive in the httpd.conf, which block should i add it in? Also both the MySQL extensions (mysql and mysqli) in php.ini is uncommented.
Back to top
pnllan



Joined: 05 Dec 2005
Posts: 221

PostPosted: Mon 10 Jul '06 3:45    Post subject: Reply with quote

You can use the PHPIniDir directive after the PHP Loadmodule directive.

After you add the PHPIniDir directive, restart Apache and then check your phpinfo.

You might have the MySQL tables listed in phpinfo now.
..
.
Back to top
Aznsilvrboy



Joined: 06 Jul 2006
Posts: 11

PostPosted: Mon 10 Jul '06 4:39    Post subject: Reply with quote

pnllan wrote:
You can use the PHPIniDir directive after the PHP Loadmodule directive.

After you add the PHPIniDir directive, restart Apache and then check your phpinfo.

You might have the MySQL tables listed in phpinfo now.
..
.


Added the PHPIniDir directive and restarted Apache, the only change i noticed was that the configuration path of the php.ini was now changed to c:\php\php.ini but still no MySQL tables...or i just dont recognize it. What does it look like? Thanks.
Back to top
tk



Joined: 27 Jun 2006
Posts: 10

PostPosted: Mon 10 Jul '06 10:34    Post subject: Reply with quote

Please don't be offended by this question, but.... have you actually installed, configured, and tested MySql on this machine? The reason that I ask is because you make no mention of it whatsoever in your post. If MySql is already installed and working, you should ensure that the MySql server is running as well. If this is on a Windows machine then you probably installed MySql as a service, which means you can start, stop, and restart it from the Services tab on your Apache Monitor.

Assuming that all of that is taken care of, you still have one more change to make in your php.ini file to get mysql_connect to work. Somewhere around line 500 or so you will see the following...

extension_dir= whatever it is set to

You need to ensure that this line is uncommented, and that the path is set to the ext directory of your PHP install. If you installed php directly on your C:\ drive, then it should read something like this...

extension_dir = "C:\php\ext"

The ext directory is where the actual mysql driver is located. Simply turning it on won't do you any good unless the path to the driver is set correctly.

Hope this helps.
Back to top
Aznsilvrboy



Joined: 06 Jul 2006
Posts: 11

PostPosted: Tue 11 Jul '06 3:29    Post subject: Reply with quote

tk wrote:
Please don't be offended by this question, but.... have you actually installed, configured, and tested MySql on this machine? The reason that I ask is because you make no mention of it whatsoever in your post. If MySql is already installed and working, you should ensure that the MySql server is running as well. If this is on a Windows machine then you probably installed MySql as a service, which means you can start, stop, and restart it from the Services tab on your Apache Monitor.

Assuming that all of that is taken care of, you still have one more change to make in your php.ini file to get mysql_connect to work. Somewhere around line 500 or so you will see the following...

extension_dir= whatever it is set to

You need to ensure that this line is uncommented, and that the path is set to the ext directory of your PHP install. If you installed php directly on your C:\ drive, then it should read something like this...

extension_dir = "C:\php\ext"

The ext directory is where the actual mysql driver is located. Simply turning it on won't do you any good unless the path to the driver is set correctly.

Hope this helps.


Ah...so that was I was missing, the extension_dir = "C:\php\ext" line in php.ini. Yes I have installed MySQL on this windows machine. As for test, not at the time (works now though) because the purpose of the mysql_up.php page i was trying to load was to test if MyQL works.
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Other Software
Page 1 of 1