Re: Re: [mysql]Problem with PHP5
| From: | linux@e75.com | Date: | Mon, 19 Jul 2004 09:53:53 +0000 |
| Subject: | Re: Re: [mysql]Problem with PHP5 | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-190990@lists.php.net to get a copy of this message | ||
Ciprian,
I may have missed whether or not you were able to resolve your problem from a couple days ago.
In one of my development environments (Win2K), I decided to install PHP 5.0 with MySQL(i) 4.1.x support in IIS5.0 and Apache 2 (running on different ports). It took a bit more work than I intended, but here's what I did:
FOR IIS (port 80):
1. downloaded and unzipped php-5.0.0-Win32.zip to c:\php
2. installed php as ISAPI
3. edited php-ini-recommended, tailored it to my environment, and copied it as php.ini into c:\winnt
NOTE: extension_dir = c:\php\ext
4. tested phpinfo() without extensions
5. edited php.ini enabling needed extensions.
NOTE: when uncommenting the line: extension=mysql.dll, changed line to read: extension=mysqli.dll
6. downloaded and unzipped mysql-4.1.3b-beta-win-noinstall.zip to c:\
7. configured mysql per www.mysql.com install instructions
8. copied c:\mysql\bin\libmysql.dll to c:\winnt\system32
9. restarted IIS, and IIS started successfully,
10. reloaded phpinfo(), and noticed that mysqli was properly loaded, but now my old mysql_connect_db scripts don't work!
Refer to the new mysqli PHP code: http://us3.php.net/manual/en/ref.mysqli.php
11. Here's a VERY basic example of the old mysql VS. new mysqli PHP code:
OLD mysql:
<?php
// connect to the database
mysql_connect("localhost", "wong", "password") or die ("Could not connect to mySQL server");
// select the database
mysql_select_db("music") or die ("Could not connect to database");
// store result
$result = mysql_query("SELECT * FROM artists") or die (mysql_error());
// display returned results
while ($row = mysql_fetch_array($result))
{
echo $row["artist"], " ", $row["album"];
echo "<BR />";
}
// free result
mysql_free_result($result);
?>
========
NEW mysqli:
<?php
// connect to the database
$link = mysqli_connect("localhost", "wong", "password", "music");
// check connection
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
// store query
$query = "SELECT * FROM artists";
// store result
$result = mysqli_query($link, $query);
// loop thru rows using associative array
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC))
{
echo $row["artist"], " ", $row["album"];
echo "<BR />";
}
// free the result
mysqli_free_result($result);
// close the link
mysqli_close($link);
?>
Additionally, for Apache 2 on Win2k (running on port 82):
1. Copied php.ini to c:\Apache Groups\Apache2
2. edited httpd.conf:
- added LoadModule php5_module "c:/php/php5apache2.dll"
- added AddType application/x-httpd-php .php
3. Restarted Apache server
Hopes this helps.
Dan
Ciprian Constantinescu wrote:
I have included the extension. Now I get "Unable to load dynamic library 'C:\php\ext\php_mysql.dll' - The specified procedure could not be found" I have in Windows\System32 the file libmysql.dll. I have also put it in the php\ext directory without any result.