By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,823 Members | 756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,823 IT Pros & Developers. It's quick & easy.

HTTP Error 500 when calling mysql_connect from php script

P: n/a
Hello!

I have installed PHP and MySql 5.0 on Win XP.
Database created ok. Installation ok.
PHP scripts runs ok.
But when I am trying some mysql calls in the script I get an "Error 500"
from explorer.

// Connect to the database server
echo ('Trying to connect to db');

$dbcnx = mysql_connect('localhost', 'root', ''xxxx');

The php.ini file in c:/windows has extension_dir = "C:\php\ext" and
extension = php_mysql.dll and
doc_root: "c:\inetpub\wwwroot

What should I look for?

Kp


Aug 7 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
Kjell Pettersen schrieb:
Hello!

I have installed PHP and MySql 5.0 on Win XP.
IIs or Apache?
Database created ok. Installation ok.
PHP scripts runs ok.
Ok.
But have you set:
cgi.force_redirect = 0
in php.ini?
But when I am trying some mysql calls in the script I get an "Error 500"
from explorer.
>
// Connect to the database server
echo ('Trying to connect to db');

$dbcnx = mysql_connect('localhost', 'root', ''xxxx');
Do not use root. Create an extra user.
Give the user the rights to the db and check again.
>
The php.ini file in c:/windows has extension_dir = "C:\php\ext" and
The only php.ini in the system?
"C:\php\ext" has rights for the webserver?
extension = php_mysql.dll and
doc_root: "c:\inetpub\wwwroot
And there is your script?

Aug 7 '08 #2

P: n/a

"Olaf Schinkel" <tr***@schinkel.tvskrev i melding
news:48***********************@newsspool4.arcor-online.net...
Kjell Pettersen schrieb:
>Hello!

I have installed PHP and MySql 5.0 on Win XP.
IIs or Apache?
>Database created ok. Installation ok.
PHP scripts runs ok.
Ok.
But have you set:
cgi.force_redirect = 0
in php.ini?
>But when I am trying some mysql calls in the script I get an "Error 500"
from explorer.
>>
// Connect to the database server
echo ('Trying to connect to db');

$dbcnx = mysql_connect('localhost', 'root', ''xxxx');
Do not use root. Create an extra user.
Give the user the rights to the db and check again.
>>
The php.ini file in c:/windows has extension_dir = "C:\php\ext" and
The only php.ini in the system?
"C:\php\ext" has rights for the webserver?
>extension = php_mysql.dll and
doc_root: "c:\inetpub\wwwroot
And there is your script?
Web server is IIs.
No, I didn't have cgi.force_redirect = 0 in php.ini.
So I edit the file php.ini in c:\windows and put cgi.force_redirect = 0 in
the file.
Restartet my computer, but I still get the HTTP error 500.

And I have create a new user in the datebase. Using that name instead of
root.
But still the error 500.....

Yes, my script is in doc_root c:\inetpub\wwwroot

There is only one php.ini in the computer.

How do I set rights for the webserver to the c:\php\ext directory?
I believed everyone could read files from that directory.

Isn't there a log file from PHP to study?

Kp



Aug 7 '08 #3

P: n/a
Kjell Pettersen wrote:
"Olaf Schinkel" <tr***@schinkel.tvskrev i melding
news:48***********************@newsspool4.arcor-online.net...
>Kjell Pettersen schrieb:
>>Hello!

I have installed PHP and MySql 5.0 on Win XP.
IIs or Apache?
>>Database created ok. Installation ok.
PHP scripts runs ok.
Ok.
But have you set:
cgi.force_redirect = 0
in php.ini?
>>But when I am trying some mysql calls in the script I get an "Error 500"
from explorer.
// Connect to the database server
echo ('Trying to connect to db');

$dbcnx = mysql_connect('localhost', 'root', ''xxxx');
Do not use root. Create an extra user.
Give the user the rights to the db and check again.
>>The php.ini file in c:/windows has extension_dir = "C:\php\ext" and
The only php.ini in the system?
"C:\php\ext" has rights for the webserver?
>>extension = php_mysql.dll and
doc_root: "c:\inetpub\wwwroot
And there is your script?

Web server is IIs.
No, I didn't have cgi.force_redirect = 0 in php.ini.
So I edit the file php.ini in c:\windows and put cgi.force_redirect = 0 in
the file.
Restartet my computer, but I still get the HTTP error 500.

And I have create a new user in the datebase. Using that name instead of
root.
But still the error 500.....

Yes, my script is in doc_root c:\inetpub\wwwroot

There is only one php.ini in the computer.

How do I set rights for the webserver to the c:\php\ext directory?
I believed everyone could read files from that directory.

Isn't there a log file from PHP to study?

Kp
The error isn't coming from PHP - it's coming from IIS.

The fact you're getting phpinfo() OK indicates that PHP itself is
working. It also means the php extensions listed in the phpinfo() are
loading. Check to ensure your mysql extension is loading; I suspect it
is or you would get a "function not found".

Do you have PHP installed as a CGI or ISAPI?

Also, do you know if MySQL is working? Can you access it and perform
operations from the command line?

Otherwise, it sounds like you might have permission problems - this can
cause 500 errors. You would want to follow up with a Windows newsgroup
on the permissions issue.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 7 '08 #4

P: n/a
Kjell Pettersen schrieb:
>
Web server is IIs.
No, I didn't have cgi.force_redirect = 0 in php.ini.
So I edit the file php.ini in c:\windows and put cgi.force_redirect = 0 in
the file.
Restartet my computer, but I still get the HTTP error 500.

And I have create a new user in the datebase. Using that name instead of
root.
But still the error 500.....

Yes, my script is in doc_root c:\inetpub\wwwroot

There is only one php.ini in the computer.

How do I set rights for the webserver to the c:\php\ext directory?
Right Click on Folder -Properties -Security
I believed everyone could read files from that directory.

Isn't there a log file from PHP to study?
Jetzt.
C:\WINDOWS\system32\LogFiles
You can set the settings for the logfile at
Standard-Website->Properties->Website

Error 500 is normaly "Internal Server Error".
That can be a lot :-( Also right problems.
Something is wrong with your MySQL installation.
But so far here, i canĀ“t say much more.
Aug 7 '08 #5

P: n/a

"Jerry Stuckle" <js*******@attglobal.netskrev i melding
news:g7**********@registered.motzarella.org...
Kjell Pettersen wrote:
>"Olaf Schinkel" <tr***@schinkel.tvskrev i melding
news:48***********************@newsspool4.arcor-online.net...
>>Kjell Pettersen schrieb:
Hello!

I have installed PHP and MySql 5.0 on Win XP.
IIs or Apache?

Database created ok. Installation ok.
PHP scripts runs ok.
Ok.
But have you set:
cgi.force_redirect = 0
in php.ini?

But when I am trying some mysql calls in the script I get an "Error
500" from explorer.
// Connect to the database server
echo ('Trying to connect to db');

$dbcnx = mysql_connect('localhost', 'root', ''xxxx');
Do not use root. Create an extra user.
Give the user the rights to the db and check again.

The php.ini file in c:/windows has extension_dir = "C:\php\ext" and
The only php.ini in the system?
"C:\php\ext" has rights for the webserver?

extension = php_mysql.dll and
doc_root: "c:\inetpub\wwwroot
And there is your script?

Web server is IIs.
No, I didn't have cgi.force_redirect = 0 in php.ini.
So I edit the file php.ini in c:\windows and put cgi.force_redirect = 0
in the file.
Restartet my computer, but I still get the HTTP error 500.

And I have create a new user in the datebase. Using that name instead of
root.
But still the error 500.....

Yes, my script is in doc_root c:\inetpub\wwwroot

There is only one php.ini in the computer.

How do I set rights for the webserver to the c:\php\ext directory?
I believed everyone could read files from that directory.

Isn't there a log file from PHP to study?

Kp

The error isn't coming from PHP - it's coming from IIS.

The fact you're getting phpinfo() OK indicates that PHP itself is working.
It also means the php extensions listed in the phpinfo() are loading.
Check to ensure your mysql extension is loading; I suspect it is or you
would get a "function not found".

Do you have PHP installed as a CGI or ISAPI?
It is installed as ISAPI
>
Also, do you know if MySQL is working? Can you access it and perform
operations from the command line?
Yes, I can connect with mysql from command line, and do a select from the
db.
>
Otherwise, it sounds like you might have permission problems - this can
cause 500 errors. You would want to follow up with a Windows newsgroup on
the permissions issue.
Now, I am a bit lost. The log file does not tell me anything.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 7 '08 #6

P: n/a
Kjell Pettersen wrote:
"Jerry Stuckle" <js*******@attglobal.netskrev i melding
news:g7**********@registered.motzarella.org...
>Kjell Pettersen wrote:
>>"Olaf Schinkel" <tr***@schinkel.tvskrev i melding
news:48***********************@newsspool4.arco r-online.net...
Kjell Pettersen schrieb:
Hello!
>
I have installed PHP and MySql 5.0 on Win XP.
IIs or Apache?

Database created ok. Installation ok.
PHP scripts runs ok.
Ok.
But have you set:
cgi.force_redirect = 0
in php.ini?

But when I am trying some mysql calls in the script I get an "Error
500" from explorer.
// Connect to the database server
echo ('Trying to connect to db');
>
$dbcnx = mysql_connect('localhost', 'root', ''xxxx');
Do not use root. Create an extra user.
Give the user the rights to the db and check again.

The php.ini file in c:/windows has extension_dir = "C:\php\ext" and
The only php.ini in the system?
"C:\php\ext" has rights for the webserver?

extension = php_mysql.dll and
doc_root: "c:\inetpub\wwwroot
And there is your script?

Web server is IIs.
No, I didn't have cgi.force_redirect = 0 in php.ini.
So I edit the file php.ini in c:\windows and put cgi.force_redirect = 0
in the file.
Restartet my computer, but I still get the HTTP error 500.

And I have create a new user in the datebase. Using that name instead of
root.
But still the error 500.....

Yes, my script is in doc_root c:\inetpub\wwwroot

There is only one php.ini in the computer.

How do I set rights for the webserver to the c:\php\ext directory?
I believed everyone could read files from that directory.

Isn't there a log file from PHP to study?

Kp
The error isn't coming from PHP - it's coming from IIS.

The fact you're getting phpinfo() OK indicates that PHP itself is working.
It also means the php extensions listed in the phpinfo() are loading.
Check to ensure your mysql extension is loading; I suspect it is or you
would get a "function not found".

Do you have PHP installed as a CGI or ISAPI?
It is installed as ISAPI
>Also, do you know if MySQL is working? Can you access it and perform
operations from the command line?
Yes, I can connect with mysql from command line, and do a select from the
db.
>Otherwise, it sounds like you might have permission problems - this can
cause 500 errors. You would want to follow up with a Windows newsgroup on
the permissions issue.

Now, I am a bit lost. The log file does not tell me anything.

>--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================


The PHP log file won't show you anything. The IIS log file may or may
not - depending on your configuration.

But you also need to ensure the IIS user has access to the MySQL client
libraries.

I really don't think this is a PHP problem - which is why I suggested a
Windows newsgroup to follow up on why the server is returning a 500 error.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 7 '08 #7

P: n/a
I have now tried the Apache web server instead of IIs

But I have the same problem.

Kp
"Kjell Pettersen" <kj***@kjellpettersen.comskrev i melding
news:qc*********************@telenor.com...
Hello!

I have installed PHP and MySql 5.0 on Win XP.
Database created ok. Installation ok.
PHP scripts runs ok.
But when I am trying some mysql calls in the script I get an "Error 500"
from explorer.

// Connect to the database server
echo ('Trying to connect to db');

$dbcnx = mysql_connect('localhost', 'root', ''xxxx');

The php.ini file in c:/windows has extension_dir = "C:\php\ext" and
extension = php_mysql.dll and
doc_root: "c:\inetpub\wwwroot

What should I look for?

Kp




Aug 7 '08 #8

P: n/a
Kjell Pettersen wrote:
I have now tried the Apache web server instead of IIs

But I have the same problem.

Kp
"Kjell Pettersen" <kj***@kjellpettersen.comskrev i melding
news:qc*********************@telenor.com...
>Hello!

I have installed PHP and MySql 5.0 on Win XP.
Database created ok. Installation ok.
PHP scripts runs ok.
But when I am trying some mysql calls in the script I get an "Error 500"
from explorer.

// Connect to the database server
echo ('Trying to connect to db');

$dbcnx = mysql_connect('localhost', 'root', ''xxxx');

The php.ini file in c:/windows has extension_dir = "C:\php\ext" and
extension = php_mysql.dll and
doc_root: "c:\inetpub\wwwroot

What should I look for?

Kp





As I've told you repeatedly. Ask in the correct forum and you'll get
good answers.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 7 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.