PowWeb Forums - The Perfect Community for the Perfect Host  

Register now to interact with over 11,000 members! Registered users have Posting Privileges, free access to Private Messaging, Email Notifications and more.

Go Back   PowWeb Community Forums > The PowWeb Platform > MySQL
User Name
Password
Register FAQ Members List Search Today's Posts Mark Forums Read

Closed Thread
 
Thread Tools Search this Thread
Old 1-13-05, 02:33 AM   #1
bobo
 
Posts: n/a
mysql_connect()

I just installed mysql4.1.8 and php 5.03 on windowxp. I made a simple code to connect to mysql server, but I didnot work.Here is the error message and the code:
Fatal error: Call to undefined function mysql_connect() in d:\Inetpub\wwwroot\mysqltest.php on line 4

<html>
<head>
<body>
<?php
$linkID = mysql_connect("localhost","root","911");
if ($linkID != FALSE)
{ echo 'successfully';}
else
{ echo 'failed'; }
mysql_close($linkID);
?>


</body>
</html>
 
Old 1-13-05, 02:39 AM   #2
det1smc
 
Posts: n/a
Look at your php info page and see if mysql is enabled:
Code:
<html> <head> <body> <?php echo phpinfo(); ?> </body> </html>

I don't think mysql enabled by default in php5, not sure about that...
 
Old 1-13-05, 02:54 AM   #3
det1smc
 
Posts: n/a
sure enough...
Quote:

In PHP 5, MySQL is no longer enabled by default, nor is the MySQL library bundled with PHP. Read this FAQ for details on why.

Note: Windows users will need to enable php_mysql.dll inside of php.ini and either copy libmysql.dll into the Windows system directory, or make it available to the PATH.

This will fix "Unable to load dynamic library './php_mysql.dll'" errors.

For compiling, simply use --with-mysql=[DIR] where [DIR] points to your MySQL installation directory.

If you don't plan on running your scripts from a powweb server in the near future... you should use the mysqli extension instead of mysql.
 
Old 1-13-05, 12:05 PM   #4
riskynil
 
Join Date: Jul 2004
Location: West Coast
Posts: 120
Reputation: 5
Boy, howdy, I know exactly the problem you're facing. =) I recently upgraded to PHP 5 and suffered the same issues. This are the changes I made to make them work:

In php.ini, I had to add these two lines:
extension=php_mysql.dll
extension=php_mysqli.dll

(I'm setting it up so both the mysql_* functions and mysqli_* functions will work.)

In the httpd.conf for Apache, I added these two lines:
LoadFile C:/php/libmysql.dll
LoadFile C:/php/libmysqli.dll

I added them right before the line of:
LoadModule php5_module c:/php/php5apache2.dll

Then make sure you have a copy of libmysql.dll, libmysqli.dll, php_mysql.dll, and php_mysqli.dll in the correct directory. (I put all of them in my main php directory.)

Also, this doesn't apply to you, but for anyone who unfortunately upgraded to PHP 5.0.2 on Windows--such as myself--an old API was bundled into that version and it'll display errors if you use the mysql_* functions. You'll have to pick up the PHP 5.0.3 version to get the new API. That little problem is ONLY associated with the Windows binary version of PHP 5.0.2, however, not other systems or versions.

Happy trails!

-- Ryan
riskynil is offline  
Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 09:30 AM.


Contents ©PowWeb, Inc. ~ vBulletin, Copyright © 2000-2007 Jelsoft Enterprises Limited.