Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1816
  • Last Modified:

Internal Error 500. PHP and MySQL

I have a serious problem. I have IIS 6 webserver and I just configured PHP 5 on windows server 2003 and also MySQL database. Now my installation went fine for PHP, as I can see the information back from phpino(). However I wanted to see if everything was ok with PHP and mysql to work in combination, and when I use a script to insert data into mysql using php, I get Internal Error 500. Does anyone know why is it happening and how to fix it.

Thanks
0
syedasimmeesaq
Asked:
syedasimmeesaq
  • 13
  • 8
  • 4
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
can you try a minimal php file with connection code, and error handling to see if that works?
and maybe post some of the relevant code here?
0
 
syedasimmeesaqAuthor Commented:
I am trying it with minimal code.
Here is the insert file and this one comes up just fine
XXXXXXXXXXInsert.phpXXXXXXXXXXXXXX
<table width="300" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td><form name="form1" method="post" action="insert_ac.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td colspan="3"><strong>Insert Data Into mySQL Database </strong></td>
</tr>
<tr>
<td width="71">Name</td>
<td width="6">:</td>
<td width="301"><input name="FirstName" type="text" id="name"></td>
</tr>
<tr>
<td>Lastname</td>
<td>:</td>
<td><input name="LastName" type="text" id="lastname"></td>
</tr>

<tr>
<td colspan="3" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
XXXXXXXXXXXXXinsert_ac.phpXXXXXXXXXXXXXXXXXXXXXXXX
Here is other file that has problem
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
<?php

$host = "localhost";
$user = "root";
$password ="password";
$db = "test2";
$tbl_name = "sample_table";

mysql_connect("$host","$user","password") or die("Couldnt Connect");
mysql_select_db("$db") or die("Could not select db");
$FirstName = $_Post['FirstName'];
$LastName = $_Post['LastName'];
$sql = insert into $tbl_name("FirstName", "LastName") Value("$FirstName, $LastNae");

$result = mysql_query($sql);
if($result){
echo"Success";
echo"<BR>";
echo"<a href='insert.php'>";
}
else
echo"Error";
mysql_close();
?>

XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Thanks in advance for your help
0
 
PhatzerCommented:
An error 500 can point to too many things, the only thing I can suggest is the same as angelIIl, or alternatively try these:

1. Make sure MySQL is correctly configured
2. Make sure you have 'php_mysql.dll' in the 'ext' folder in your 'PHP' directory
3. Make sure you have 'extension=php_mysql.dll' uncommented (without the ; at the front) within the 'Dynamic Extensions' in your php.ini file.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
syedasimmeesaqAuthor Commented:
I just fixed a typo but still no progress..
Typo was
$sql = insert into $tbl_name("FirstName", "LastName") Value("$FirstName, $LastNae");

I changed it to
$sql = insert into $tbl_name("FirstName", "LastName") Value("$FirstName, $LastName");

as m was missing in $LastName
0
 
PhatzerCommented:
It may be an idea to have your sql statement like this instead:

$sql = "insert into '$tbl_name' ('FirstName', 'LastName') values ('$FirstName', '$LastName')";
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
ok, I assume you get more than only HTTP 500, but some more text ... please post that.

did you already go through:  http://support.microsoft.com/kb/311766
0
 
syedasimmeesaqAuthor Commented:
Basically, I think I configured PHP just fine. Its in my C drive. The files for mysql sit in my F drive. I checked php.ini and php_mysql.dll is uncommented and its also in ext dir.

The page in the title bar shows HTTP 500 error and in the body it shows that the page can not be displayed.
Thats all it shows.
Thanks
0
 
PhatzerCommented:
Did you replace your sql query with the one i posted last?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
then, it is time for you to start to read this page:
http://www.phpfreaks.com/phpmanual/page/ref.errorfunc.html

start with error_reporting setting, what is it right now, and try setting it to E_ALL to find out what is going wrong.
0
 
syedasimmeesaqAuthor Commented:
Here is more what it shows in body

The page cannot be displayed
The page you are looking for is currently unavailable. The Web site might be experiencing technical difficulties, or you may need to adjust your browser settings.

--------------------------------------------------------------------------------

Please try the following:

Click the  Refresh button, or try again later.

If you typed the page address in the Address bar, make sure that it is spelled correctly.

To check your connection settings, click the Tools menu, and then click Internet Options. On the Connections tab, click Settings. The settings should match those provided by your local area network (LAN) administrator or Internet service provider (ISP).
See if your Internet connection settings are being detected. You can set Microsoft Windows to examine your network and automatically discover network connection settings (if your network administrator has enabled this setting).
Click the Tools menu, and then click Internet Options.
On the Connections tab, click LAN Settings.
Select Automatically detect settings, and then click OK.
Some sites require 128-bit connection security. Click the Help menu and then click About Internet Explorer to determine what strength security you have installed.
If you are trying to reach a secure site, make sure your Security settings can support it. Click the Tools menu, and then click Internet Options. On the Advanced tab, scroll to the Security section and check settings for SSL 2.0, SSL 3.0, TLS 1.0, PCT 1.0.
Click the  Back button to try another link.
 
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
just to be 100% sure:
is the file insert_ac.php in the same folder as Insert.php?
0
 
syedasimmeesaqAuthor Commented:
yes. It is

I am 100% sure that there is some problem with PHP and mysql configuration and thats why its not interacting. I am sure that my php installation went fine. However mysql is the problem here.

Thanks
0
 
PhatzerCommented:
As another possible thing to try... do this:

1. Start -> Run
2. Type services.msc and press Enter
3. Scroll down to 'MySQL' and make sure it is started, if not...
4. Right click and go properties, set statup type to 'Automatic', press 'Start', click OK and close Services.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>I am 100% sure that there is some problem with PHP

well, that can be checked immediately:
rename the file insert_ac.php to insert_ac.php.bck, and create a new file, with no php in it, but only a bit of text:
XXXXXXXXXXXXXinsert_ac.phpXXXXXXXXXXXXXXXXXXXXXXXX
FILE = insert_ac.php
XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

if now you click on the Submit button, does it show the text correctly, or still http 500?
0
 
syedasimmeesaqAuthor Commented:
PHP works fine. Its either IIS or MySQL configuration.
0
 
syedasimmeesaqAuthor Commented:
This is what phpinfo() spits out for mysql...does that look right to you guys?

mysql
MySQL Support enabled
Active Persistent Links  0  
Active Links  0  
Client API version  5.0.45  

Directive Local Value Master Value
mysql.allow_persistent On On
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off


mysqli
MysqlI Support enabled
Client API library version  5.0.45  
Client API header version  5.0.45  
MYSQLI_SOCKET  /tmp/mysql.sock  

Directive Local Value Master Value
mysqli.default_host no value no value
mysqli.default_port 3306 3306
mysqli.default_pw no value no value
mysqli.default_socket no value no value
mysqli.default_user no value no value
mysqli.max_links Unlimited Unlimited
mysqli.reconnect Off Off
0
 
syedasimmeesaqAuthor Commented:
Could it be because I chose a different port for mysql to run than the deafut port? I chose 8876 istead of 3306?
0
 
syedasimmeesaqAuthor Commented:
Mysql services were started and its set on automatic. so that isn't the problem
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
if the test with the "empty" file insert_ac.php does not give an error, add back 1 line after the other from the original, and see as from when the HTTP 500 comes back...
do you have a .htaccess file in the folder?
0
 
syedasimmeesaqAuthor Commented:
Angel this is windows server 2003 and does not have .htaccess.
0
 
syedasimmeesaqAuthor Commented:
Anyone?
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
>Angel this is windows server 2003 and does not have .htaccess.
actually, if you used apache and not IIS, you could use .htaccess also on windows system...
but, as you use IIS, .htaccess is indeed wrong idea, sorry


now, I repeat:
if the test with the "empty" file insert_ac.php does not give an error, add back 1 line after the other from the original, and see as from when the HTTP 500 comes back...
as from when does the http 500 come?
0
 
syedasimmeesaqAuthor Commented:
Angel this is what I have in insert_ac.php  file

<?php
FILE = insert_ac.php
?>

and it is giving me http 500 error

Thanks
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
well:
<?php
FILE = insert_ac.php
?>

thas is bad php code, so http-500 could be normal.

what about this:

<?php
$FILE = "insert_ac.php";
echo $FILE;
?>
0
 
syedasimmeesaqAuthor Commented:
Well I am not sure what the problem was however I solved it using a WIMP solution available. Thanks for your help.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 13
  • 8
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now