English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have installed:
1- Windows XP
2- Wamp
3- Apache
4- MySQL
5- PHP
6- phpExpertEditor

When I run any php file in phpExpertEditor it works ok,
but when I try to connect php to mysql Im getting Error:

Fatal error: Call to undefined function mysql_connect() in C:\Program Files\PHP Expert Editor\php3A.tmp on line 9

the php code is:



$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>



I asked this question previously and someone said to check I checked it but mysql wasnt there.

=================================

my second question is that i can not run any php file (which is on my HardDisk) by my InternetExplorer !!
I have to upload them to my host (which supports php) and then only i can run them.
Is there any problem in Installation of PHP?

2006-07-06 08:21:41 · 5 answers · asked by QuestionAnswer 2 in Computers & Internet Programming & Design

I didnt install Apache,Php,MySQL seperately!
I just installed WAMP which contains them, does it need any arrangement?

2006-07-06 10:50:51 · update #1

I could open file by my IE < http://localhost/test1.php > So i got the answer of my second question.

but still i cant run a php file which is trying to connect to mysql !? i get this error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'peter'@'localhost' (using password: YES) in C:\wamp\www\bb.php on line 4
Could not connect: Access denied for user 'peter'@'localhost' (using password: YES)


and this is code of php file:


$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
?>



It seems that problem is in connection of php to mysql, but i have activated mysql by wamp...

2006-07-06 11:16:15 · update #2

5 answers

First, you should use mysql_pconnect, not mysql_connect, as mysql_pconnect is both recommended by Zend (the makers of PHP) and persists the connection for you, reducing load on the server.

Next, the user name and password you supply to connect to the MySQL database need to be the user name and password you assigned when creating the MySQL database. When you set up MySQL, you had to create a user and a password. Those are the values you should be supplying as arguments.

So, let's assume the following is true of your MySQL installation:

1. You are running it under the localhost (probably true);
2. Your MySQL user name is peter;
3. Your MySQL password is password

In that case, this should work:

$con = mysql_pconnect( "localhost", "peter", "password" ) or die( mysql_error());

2006-07-06 12:10:05 · answer #1 · answered by Anonymous · 0 1

Create a simple file, let's call it "test.php"

In that file, have a line like this...



Put it in a public directory on your server, and check out the statistics. If there is no information reported on the MySQL version and settings, then it definitely isn't enabled in your PHP executable.

Note: if the test file we just created is in a public place on your server, you'll want to delete it when you're through. Otherwise you're giving hackers a bunch of useful information about your server.

If it's NOT enabled, then the solution will depend on what version of PHP. The 2nd link below goes into detail.

For the 2nd question, it depends on how you're running the file. It sounds like you're trying to open the file directly via the file system. However since you appear to have Apache installed, you CAN run the PHP locally as long as it's in the folder that is available to the Apache server. For example, if you're using the default of...

c:\Apache2\htdocs

Then if you put the file "test.php" in the the above folder, the way you would point your web browser at the file is...

http://localhost/test.php

... or ...

http://127.0.0.1/test.php

The 2nd form works better if you're experimenting with sessions or cookies.

2006-07-06 09:40:24 · answer #2 · answered by Anonymous · 0 0

Repying to dhvrm's comment. You should not use mysql_pconnect instead of mysql_connect. mysql_pconnect causes apache to create a new and constant connect to mysql the entire time the user is on your website. It will increase server and database load. You should connect to the database and release it as soon as you’re done.

Plus, If you have limited mysql to only 50 connects this means only 50 people could use your website at once. Instead of 50 connections to the database at once.

2006-07-10 04:32:33 · answer #3 · answered by oc_surf 2 · 0 0

You problem is that your PHP installation doesn't have support for MySQL.

Look for a line that reads:

;extension=mysql.ddl

delete that ; so it reads:

extension=mysql.ddl

Then restart your web server
.
Also, you may want to check the extension_dir in your php.ini .

No, you can't run a php file in Internet Explorer. What appears in your browser when you point it to a php file in your host is the HTML output from the php program. Your webserver is the one that runs the php program, takes its output and sends it to your browser. Your browser only sees the HTML output.

2006-07-06 09:27:31 · answer #4 · answered by Locoluis 7 · 0 0

For your second question, if you have apache running on your local system, copy your php files to the document root of apache and use IE to go to http://localhost/phpFile.php

2006-07-06 09:39:47 · answer #5 · answered by John J 6 · 0 0

fedest.com, questions and answers