473,385 Members | 1,730 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

500 internal server error

17
Hi all,

The below code should be allowing me to modify entries which i choose from the script before hand, however it give the 500 error code.

it generates ......

http://tramp-space.co.uk/edittest/te...hp?master_id=1

where 1 is the record number (which exists)

Im baffled. can anybody help me please?




Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if ((!$_POST) || (isset($_GET["master_id"] !=" ")) {
  3.     //haven't seen the form, so show it
  4.     $display_block = "
  5.     <form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
  6.  
  7.     if (isset($_GET["master_id"])) {
  8.         //connect to database
  9.         $mysqli = mysqli_connect("localhost", "web88-farmer", "whitep8", "web88-farmer");
  10.  
  11.         //get first, last names for display/tests validity
  12.         $get_names_sql = "SELECT concat_ws('', f_name, l_name) AS display_name
  13.                           FROM master_name WHERE id = '".$_GET["master_id"]."'";
  14.         $get_names_res = mysqli_query($mysqli, $get_names_sql)
  15.                          or die(mysqli_error($mysqli));
  16.  
  17.         if (mysqli_num_rows($get_names_res) == 1) {
  18.             while ($name_info = mysqli_fetch_array($get_names_res)) {
  19.                 $display_name = stripslashes($name_info['display_name']);
  20.             }
  21.         }
  22.     }
  23.  
  24.     if (isset($display_name)) {
  25.         $display_block .= "<p>Adding information for
  26.         <strong>$display_name</strong>:</p>";
  27.     } else {
  28.         $display_block .= "
  29.         <p><strong>First/Last Names:</strong><br/>
  30.         <input type=\"text\" name=\"f_name\" size=\"30\" maxlength=\"75\">
  31.         <input type=\"text\" name=\"l_name\" size=\"30\" maxlength=\"75\">";
  32.     }
  33.     $display_block .= "<p><strong>Address:</strong><br/>
  34.     <input type=\"text\" name=\"address1\" size=\"30\"></p>
  35.     <input type=\"text\" name=\"address2\" size=\"30\"></p>
  36.  
  37.     <p><strong>City/State/Zip:</strong><br/>
  38.     <input type=\"text\" name=\"city\" size=\"30\" maxlength=\"50\">
  39.     <input type=\"text\" name=\"county\" size=\"20\" maxlength=\"20\">
  40.     <input type=\"text\" name=\"post_code\" size=\"10\" maxlength=\"10\"></p>
  41.  
  42.     <p><strong>Address Type:</strong><br/>
  43.     <input type=\"radio\" name=\"add_type\" value=\"home\" checked> home
  44.     <input type=\"radio\" name=\"add_type\" value=\"work\"> work
  45.     <input type=\"radio\" name=\"add_type\" value=\"other\"> other</p>
  46.  
  47.     <p><strong>Telephone Number:</strong><br/>
  48.     <input type=\"text\" name=\"tel_number\" size=\"30\" maxlength=\"25\">
  49.     <input type=\"radio\" name=\"tel_type\" value=\"home\" checked> home
  50.     <input type=\"radio\" name=\"tel_type\" value=\"work\"> work
  51.     <input type=\"radio\" name=\"tel_type\" value=\"other\"> other</p>
  52.  
  53.     <p><strong>Fax Number:</strong><br/>
  54.     <input type=\"text\" name=\"fax_number\" size=\"30\" maxlength=\"25\">
  55.     <input type=\"radio\" name=\"fax_type\" value=\"home\" checked> home
  56.     <input type=\"radio\" name=\"fax_type\" value=\"work\"> work
  57.     <input type=\"radio\" name=\"fax_type\" value=\"other\"> other</p>
  58.  
  59.     <p><strong>Email Address:</strong><br/>
  60.     <input type=\"text\" name=\"email\" size=\"30\" maxlength=\"150\">
  61.     <input type=\"radio\" name=\"email_type\" value=\"home\" checked> home
  62.     <input type=\"radio\" name=\"email_type\" value=\"work\"> work
  63.     <input type=\"radio\" name=\"email_type\" value=\"other\"> other</p>
  64.  
  65.     <p><strong>Personal Note:</strong><br/>
  66.     <textarea name=\"note\" cols=\"35\" rows=\"3\" wrap=\"virtual\"></textarea></p>";
  67.  
  68.     if ($_GET) {
  69.         $display_block .= "<input type=\"hidden\" name=\"master_id\" value=\"".$_GET["master_id"]."\">";
  70.     }
  71.  
  72.     $display_block .= "<p><input type=\"submit\" name=\"submit\" value=\"Add Entry\"></p>
  73.     </form>";
  74.  
  75. } else if ($_POST) {
  76.     //time to add to tables, so check for required fields
  77.     if ((($_POST["f_name"] == "") || ($_POST["l_name"] == "")) &&
  78.     (!isset($_POST["master_id"]))) {
  79.         header("Location: addentry.php");
  80.         exit;
  81.     }
  82.  
  83.     //connect to database
  84.         $mysqli = mysqli_connect("localhost", "web88-farmer", "whitep8", "web88-farmer");
  85.  
  86.     if (!$_POST["master_id"]) {
  87.         //add to master_name table
  88.         $add_master_sql = "INSERT INTO master_name (date_added, date_modified, f_name, l_name)
  89.                            VALUES (now(), now(), '".$_POST["f_name"]."', '".$_POST["l_name"]."')";
  90.         $add_master_res = mysqli_query($mysqli, $add_master_sql) or die(mysqli_error($mysqli));
  91.  
  92.         //get master_id for use with other tables
  93.         $master_id = mysqli_insert_id($mysqli);
  94.     } else {
  95.          $master_id = $_POST["master_id"];
  96.     }
  97.  
  98.     if (($_POST["address1"]) || ($_POST["address2"]) ||($_POST["city"]) || ($_POST["county"]) || ($_POST["post_code"])) {
  99.         //something relevant, so add to address table
  100.         $add_address_sql = "INSERT INTO address (master_id, date_added, date_modified,
  101.                             address1, address2, city, county, post_code, type)  VALUES ('".$master_id."',
  102.                             now(), now(), '".$_POST["address1"]."', '".$_POST["address2"]."', '".$_POST["city"]."',
  103.                             '".$_POST["county"]."' , '".$_POST["post_code"]."' , '".$_POST["add_type"]."')";
  104.         $add_address_res = mysqli_query($mysqli, $add_address_sql) or die(mysqli_error($mysqli));
  105.     }
  106.  
  107.     if ($_POST["tel_number"]) {
  108.         //something relevant, so add to telephone table
  109.         $add_tel_sql = "INSERT INTO telephone (master_id, date_added, date_modified,
  110.                         tel_number, type)  VALUES ('".$master_id."', now(), now(),
  111.                         '".$_POST["tel_number"]."', '".$_POST["tel_type"]."')";
  112.         $add_tel_res = mysqli_query($mysqli, $add_tel_sql) or die(mysqli_error($mysqli));
  113.     }
  114.  
  115.     if ($_POST["fax_number"]) {
  116.         //something relevant, so add to fax table
  117.         $add_fax_sql = "INSERT INTO fax (master_id, date_added, date_modified,
  118.                         fax_number, type)  VALUES ('".$master_id."', now(), now(),
  119.                         '".$_POST["fax_number"]."', '".$_POST["fax_type"]."')";
  120.         $add_fax_res = mysqli_query($mysqli, $add_fax_sql) or die(mysqli_error($mysqli));
  121.     }
  122.  
  123.     if ($_POST["email"]) {
  124.         //something relevant, so add to email table
  125.         $add_email_sql = "INSERT INTO email (master_id, date_added, date_modified,
  126.                           email, type)  VALUES ('".$master_id."', now(), now(),
  127.                           '".$_POST["email"]."', '".$_POST["email_type"]."')";
  128.         $add_email_res = mysqli_query($mysqli, $add_email_sql) or die(mysqli_error($mysqli));
  129.     }
  130.  
  131.     if ($_POST["note"]) {
  132.         //something relevant, so add to notes table
  133.         $add_notes_sql = "UPDATE personal_notes set note = '".$_POST["note"]."' WHERE
  134.                          master_id = '".$master_id."'";
  135.         $add_notes_res = mysqli_query($mysqli, $add_notes_sql) or die(mysqli_error($mysqli));
  136.     }
  137.     mysqli_close($mysqli);
  138.     $display_block = "<p>Your entry has been added.  Would you like to <a href=\"addentry.php\">add another</a>?</p>";
  139. }
  140. ?>
  141. <html>
  142. <head>
  143. <title>Add an Entry</title>
  144. </head>
  145. <body>
  146. <h1>Add an Entry</h1>
  147. <?php echo $display_block; ?>
  148. </body>
  149. </html>
  150.  
Nov 15 '07 #1
2 4285
mwasif
802 Expert 512MB
You should use PHP CODE tags instead of CODE. This helps others to read the source code easily.

Turn On PHP Debugging Messages.

What are you trying to do in this line?
[PHP]if ((!$_POST) || (isset($_GET["master_id"] !=" ")) {[/PHP]

See how isset() works.
Nov 15 '07 #2
pbmods
5,821 Expert 4TB
Heya, Whitey.

500 errors are usually caused by permissions issues or an error in a .htaccess file.

Make sure all your scripts have execute permissions, and check the ownership. The files should be owned and/or in the same group as the web server (usually 'www' or 'apache').

If you are using .htaccess files, verify that there are no errors or typos.
Nov 17 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: | last post by:
I am accessing the same error-containing ASP page on an ISP server using w2k IE6 but with different effect. On the first computer I get several line of HTML outputed by ASP, shown correctly by...
5
by: Ben | last post by:
hi when I try to excecute an ASP (either JS or VB) script to say, access a database record, I get an Internal Server Error HTTP 500.100 Why? and HOW CAN I FIX THIS? Thanks
4
by: Patrick Masson | last post by:
Hello, Our configuration : Apache 2.0.53 PHP 5.0.4 PC Windows 2000 MATLAB 6.1 We work on a consulting project in France which involves MATLAB Web server,
8
by: Rod | last post by:
I have been working with ASP.NET 1.1 for quite a while now. For some reason, opening some ASP.NET applications we wrote is producing the following error message: "The Web server reported...
4
by: jf li | last post by:
I have a Asp.net web application and a Asp.net Web service application. The Web application is using HtmlInputFile to get a 50M size of file selected by end user, read the data of this file and...
11
by: Lieven | last post by:
Hey, I had a hard disc problem last week on my server. I replaced the disc and copied al the files to the new hard disc, everything works fine again except some php scripts that are using the...
23
by: ticfranca | last post by:
Hi, I'm getting this error in the code below: sub Pega_recorde { $database = 'bundinha'; $host = 'localhost'; $usuario = 'myhumoradm'; $senha = 'my8xr2d2'; ...
0
by: ticfranca | last post by:
i'm getting an error at the line : $sth->execute() or die $dbh->errstr; the error is : The server encountered an internal error or misconfiguration and was unable to complete your request. Please...
3
by: rooznamechi.h | last post by:
Hi, I use Url rewriting on my website and my website works normally , but I don't know why Google crawlers can not read my pages . For example look at address below :...
3
by: guillaume.braux | last post by:
Hello, I am running WS2008 + IIS7 + FASTCGI + ZendCore. I have not modified the default ZendCore php.ini configuration file. Actualy, any kind of PHP error, warning or notice gives me...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.