A simple connection script not working why?

Why would I get a screwed up error like below for such a simple script
Call to undefined function mysql_connect() in c:\Inetpub\wwwroot\simple_connection.php on line 11


<?php

$connection = mysql_connect("localhost","","")
or die ("Sorry unable to connect to MYSQL");
echo("Hey you have been connected with MYSQL");
?>
LVL 1
smphilAsked:
Who is Participating?
 
zac_charlesCommented:
You dont need to do re-install anything....I know what this problem is and how to fix it because i got the same thing the other day while upgrading to PHP5...

1. You will have a file called libmysql.dll in your root PHP directory (commonly C:\PHP), copy that into C:\Windows\System32.
2. Edit your PHP.ini file (C:\WIndows\php.ini), make sure you have a uncommented line that looks like this (uncommented means no ;)...

       extension=ext\php_mysql.dll

3. Restart your server

That will do the trick :)
If it doesn't, then post what version of PHP you are running and what server you are using and i will give you more direct steps to take.

Zac Charles
0
 
sajuksCommented:
try using ip address instead of localhost
0
 
sajuksCommented:
$connection = mysql_connect('localhost', 'username', 'password') or die ('error connecting, MySQL said this:- <br>')
if (!$connection)
{
     echo mysql_error();
}


0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
smphilAuthor Commented:
nope still the same but thanks
0
 
smphilAuthor Commented:
now i get this error with that script
Parse error: parse error, unexpected T_IF in c:\Inetpub\wwwroot\simple_connection.php on line 11
0
 
sajuksCommented:
the error you are getting might be cos  of
The statement wasn't ended with a semicolon (;) or A quote was not properly escaped (' instead of \' or " instead of \") in a string.
0
 
UmeshMySQL Principle Technical Support EngineerCommented:
Hi,

In your case It seems php installation does not support MySQL. You can
 confirm this by running a phpinfo() script. You may need to
 reinstall/recompile PHP/mySQL.
0
 
smphilAuthor Commented:
ZAC CHARLES HELPPPPPPPPPPPPPPPPPPP!!!!!!!!!!!!!

Im still having a problem I m running PHP5.0 and IIS V5.1

Thanks Phil
0
 
zac_charlesCommented:
Hi, lol, i will help you, we will get through this :)

Are you online at the moment? I am installing IIS as we speak, so i will be able to go through the installation process with that and php5 and tell you exactly what you need to do! I use apache normally, i think it is a better choice, but  each to his own :P

Zac Charles
0
 
zac_charlesCommented:
ok, another thing that would be really helpfull is how you installed it...did you use the zipped files? or the windows installer?

Zac Charles
0
 
zac_charlesCommented:
Ok phil, here we go:

Ignore my previous question...i just installed IIS 5.1 under WindowsXP with PHP5 (installed by the windows installer downloaded from php.net). At the beginning i had the same problem as you, afterwards i did exactly what i said in my first comment on this thread (copying the file and then changing php.ini to say extension=ext\php_mysql.dll).

I think the best thing you could do, is uninstall php and then re-install it, like a fresh install, and then follow the steps i said to do before. If that does not fix your problem, then i would like details on what OS you are running and how you installed PHP on your server. If you are willing to change to apache then i will be able to guide you EXACTLY how to get it up, running and most importantly WORKING!

Try that and let my know how it goes and i will help as soon as possible :)

Zac Charles
0
 
jahnksCommented:
Hello,

I am running Windows NT 4 SP 6 with Apache 2, PHP 5 and MySQL 4 and am running into the same problems.

Apache is running without any problems
MySQL is running without any problems
PHP is running without any problems

However, apparently I cannot get MySQL and PHP to worktogether.  I downloaded the Windows Binary ZIP install and unzipped the file and placed it at C:\PHP
 
I have placed the PHP.ini file in c:\winnt40\system32 and at c:\winnt40\

I have uncommented the extension line for php_mysql.dll and have also changed it to be ext\php_mysql.dll

I have copied the libMySQL.dll file from c:\mysql\bin to c:\winnt40\system32

And now after writing all this i moved c:\winnt40\system32\php.ini to c:\winnt40\php.ini and it works.
0
 
zac_charlesCommented:
>>And now after writing all this i moved c:\winnt40\system32\php.ini to c:\winnt40\php.ini and it works.

Thats because it was meant to go in c:\winnt40 not system32

Zac Charles
0
 
jahnksCommented:
Well I thought I had it working because I wasn't getting the message anymore, but then I realized I copied over the wrong php.ini file, and after i copied the correct one over to there it now does not work again.  Any help would be greatly appreciated in this.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.