Solved

A simple connection script not working why?

Posted on 2004-08-08
15
187 Views
Last Modified: 2013-12-12
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");
?>
0
Comment
Question by:smphil
  • 5
  • 4
  • 3
  • +2
15 Comments
 
LVL 33

Expert Comment

by:sajuks
ID: 11749809
try using ip address instead of localhost
0
 
LVL 33

Expert Comment

by:sajuks
ID: 11749822
$connection = mysql_connect('localhost', 'username', 'password') or die ('error connecting, MySQL said this:- <br>')
if (!$connection)
{
     echo mysql_error();
}


0
 
LVL 1

Author Comment

by:smphil
ID: 11749823
nope still the same but thanks
0
 
LVL 1

Author Comment

by:smphil
ID: 11749832
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
 
LVL 33

Expert Comment

by:sajuks
ID: 11749843
0
 
LVL 33

Expert Comment

by:sajuks
ID: 11749852
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
 
LVL 26

Expert Comment

by:ushastry
ID: 11750337
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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 7

Accepted Solution

by:
zac_charles earned 500 total points
ID: 11751371
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
 
LVL 1

Author Comment

by:smphil
ID: 11780200
ZAC CHARLES HELPPPPPPPPPPPPPPPPPPP!!!!!!!!!!!!!

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

Thanks Phil
0
 
LVL 7

Expert Comment

by:zac_charles
ID: 11781788
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
 
LVL 7

Expert Comment

by:zac_charles
ID: 11781868
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
 
LVL 7

Expert Comment

by:zac_charles
ID: 11781974
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
 

Expert Comment

by:jahnks
ID: 11998091
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
 
LVL 7

Expert Comment

by:zac_charles
ID: 12002997
>>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
 

Expert Comment

by:jahnks
ID: 12009803
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

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Encode a password 2 38
creating 2 user ID's 5 26
comparing strings that contain line breaks 18 35
PHP JSON Clean up 5 0
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now