473,788 Members | 2,735 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

500 internal server error

17 New Member
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 4298
mwasif
802 Recognized Expert Contributor
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 Recognized Expert Expert
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
10824
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 the browser, followed by a descriptive error message: Microsoft VBScript runtime error '800a000b' Division by zero followed by the number of the error-making line
5
8480
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
3727
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
10016
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 the following error when attempting to create or open the Web project located at the following URL: 'http://localhost/WebApplication1'. 'HTTP/1.1 500 Internal Server Error'."
4
6213
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 pass the data to the web service. I already modified both web.config files and changed maxRequestLength to 60000(kb). When I debug the upload process, it seems the Web application can get the 50M file and read the data without problem, but when the...
11
12316
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 mail() function. When executing these scripts I get this error: "500 Internal Server Error The server encountered an internal error or misconfiguration and was unable to complete your request.
23
24570
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'; $dbh=DBI->connect("DBI:mysql:database=$database;host=$host","$usuario","$senha") or die "Can't open DB: $!";
0
1220
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 contact the server administrator I already check permission of cgi-bin folder and the permission of this script file. Everything is OK. Somebody help me?Please.. Internal Server Error
3
2855
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 : http://www.labkhandha.com/Article/265/default.aspx As you can see you can see the page but here is Google's Web crawl error for this page and all rewrite pages : 500 (Internal server error) The server encountered an error and can't fulfill the request
3
5956
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 immediately a IIS 500 Error (Internal Server Error). It is a good thing in production environnement. For debuging purposes, I want temporary to be able to see PHP warnings and errors embedded on the html page.
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10177
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7519
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4074
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2897
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.