hi folks,
I have installed PHP 5.2X on apache and mySQL 5.0.
PHP on apache is working fine.
can anyone tell what exactly are the steps to configure PHP to mySQL ?
thanks in advance,
nikhil
hi folks,
I have installed PHP 5.2X on apache and mySQL 5.0.
PHP on apache is working fine.
can anyone tell what exactly are the steps to configure PHP to mySQL ?
thanks in advance,
nikhil
wanna connect to mySQL or what? if you wanna configure mysql u gotta make connection first then inject the sql commands.
:) He means configuring apache to add mysql module.
By default, php5 doesnt support mysql. You need to add these lines in httpd.conf in apache/conf directory.
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3
LoadModule php5_module "c:/path/of/this/file/php5apache2_2.dll"
Uncomment mysql line from php.ini
Copy php5ts.dll in system32 folder.
Phew! I would suggest you to try WAMP, which does all these things for you.
Cheers,
Naveen
thanks for your reply nav.
php is working fine with apache. But i need to configure mySQL and php.
i have put extension=php_mysql.dll and made the extension directory correctly; but still it is not working!!. where may i went wrong?
also plz leave some hint to test php and mysql (code needed)
Did you add the lines I mentioned above ? Did you copy the file to system32 folder ? Dude! My suggestion for you is to uninstall apache, php and mysql and install wamp. It saves alot of your work.
hi naveen!!
Actually I need to install MediaWiki on our server. Media wiki needs these things to be installed priorly. I am totally unaware about WAMP or other alternatives available. Does that make the Mediawiki work fine?
What I did so far -
Installed Apache and PHP, configured - php is getting parsed - its fine.
installed mysql5.0 and configured.
for php 5.2.5 to mysql connection:
extracted extensions to C:\PHP\ext\
set path for extension
C:\PHP\ext\
added
extension=php5_mysql.dll
copied
libmysql.dll
to %apache\bin
copied
libmysql.dll
to %system32\
is there anything i would have missed?
when i am trying to configure MediaWiki, it says no driver found; recompile
-with -mysql
. Actually I am not sure about these terms.
and it will be helpful for me if you leave a snippet to test PHP is getting mysql - sample select querry
Well, I guess your server is a linux box. I dunno bout linux since I work on windows. And you can do a simple test this way.
<?php
$connection=mysql_connect("hostname","username","password");
echo $connection;
?>
If it prints a resource id, then you can connect to mysql. Another way to check if mysql is configured is, by using phpinfo function.
<?php
phpinfo();
?>
run this script. Search for mysql. If it says, mysql support enabled, then mysql is configured.
:)
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\index.php on line 4
Yes install wamp it saves a lot of trouble. Unless you enjoy wasting time.
try this..
$Server = "127.0.0.1";
$Port = ":"."3306";
$DataBase = "database";
$UserName = "user";
$PassWord = "pass";
$Flags = "MYSQL_CLIENT_SSL";
$Connection = mysql_connect($Server . $Port, $UserName, $PassWord, $Flags, 65536);
if(!$Connection)
{
die("Could not connect to server : " . mysql_error());
}
else
{
mysql_select_db($DataBase,$Connection) or die("Could not connect to database");
}
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.