|
-
Mar 19th, 2007, 06:59 AM
#1
Thread Starter
Lively Member
mysql_connect() error
Hi all,
I'm try to run my php code to connect to mysql but it is showing an error
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\helloSQL.php on line 7
This the code in my file
------------------------------------------------------------------------
<html>
<head><title>PHP and SQL Integration Test</title></head>
<body>
<?php
$link = mysql_connect("localhost", "", "") or die("Could not connect");
print "Connected successfully";
$query = "SELECT now()";
$result = mysql_query($query)
or die("Query failed");
print "<table>\n";
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
print "\t<tr>\n";
foreach ($line as $col_value) {
print "\t\t<td>$col_value</td>\n";
}
print "\t</tr>\n";
}
print "</table>\n";
mysql_close($link);
?>
</body>
</html>
------------------------------------------------------------------------
can sombody plz help on this,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Thanks & Regards
manoj
-
Mar 19th, 2007, 07:22 AM
#2
Re: mysql_connect() error
Please use the [code] or [php] tags to post code.
It appears you have not enabled the php_mysql extension.
-
Mar 20th, 2007, 12:58 AM
#3
Thread Starter
Lively Member
Re: mysql_connect() error
Hi
Thanks for the suggestion and sorry for not posting my code properly.
I've enabled this extension in config file
extension=php_mysql.dll
extension_dir = "C:/Program Files/PHP/ext/"
but I'm facing same problem I've tried both back slash and forward slash in my path but nothing worked at all.
my Apache and PHP are running MYSQL is also running I just cann't connect with MYSQL from PHP the error I receive is
Fatal error: Call to undefined function mysql_connect() in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\helloSQL.php on line 6
Thanks & Regards
Manoj
-
Mar 20th, 2007, 01:44 AM
#4
Re: mysql_connect() error
yes, and just like penagate said -- you don't have the extension enabled. so, since you seem to be pointing at the right directory and have the line uncommented, here are some potential solutions:
first, make sure that your php.ini's path is correctly set in the apache configuration file. if it can't be found, php will still run -- but everything will be default. if you're unsure on how to do this, read "install.txt" in the PHP directory.
second, if the above doesn't work, look at apache's error log (default: 'apache/logs/error.log') when you start the web server and make sure that it is finding the extension in the first place. if the extension isn't being found, it will usually cause an error saying some extension couldn't be loaded, and usually includes the entire file path that it thinks the extension is in. if you can copy and paste that file path into windows explorer and get a prompt to download the DLL file, then you might have an issue with the fact that you're using "program files" as the root directory for PHP. as a general rule, and in my opinion, you should never install apache or php (or even mysql) in any directory that has a space in its name. make a new partition and install everything on that, or if that's too complex for you, just make a directory on your "C:" drive and install everything there. apache and php both seem to have issues with file paths with spaces (or at least they have had them in the past).
-
Mar 20th, 2007, 04:40 AM
#5
Thread Starter
Lively Member
Re: mysql_connect() error
Hi,
I've done all this
I installed PHP in C:\PHP (without spaces in path)
nothing helped at all ................I'm still getting same error
I know PHP could not recognize mysql_connect() function
it may not getting dll path but I specified it
I wanted to know the possible cause for such errors.
even if I try to install php through installer and activate mysql it display a failure notice in installation. I don't know what's going wrong with it or me
bye
manoj
-
Mar 20th, 2007, 04:47 AM
#6
Re: mysql_connect() error
If you've installed PHP in C:\PHP then your extension_dir directive should be:
Code:
extension_dir = "C:\PHP\ext"
In future I recommend C:\php rather than C:\PHP but don't change it now that you've installed it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|