?
Solved

A simple connection script not working why?

Posted on 2004-08-08
15
Medium Priority
?
197 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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:Umesh
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
 
LVL 7

Accepted Solution

by:
zac_charles earned 2000 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

WordPress Tutorial 3: Plugins, Themes, and Widgets

The three most common changes you will make to your website involve the look (themes), the functionality (plugins), and modular elements (widgets).

In this article we will briefly define each again, and give you directions on how to install them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

800 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