Am 04.05.2012 16:09, schrieb Ethan Rosenberg:
function handle_data()
{
global $cxn;

What does this function? It neither takes any parameters nor returns any value. And it does not write back anything to its global $cxn. So it is quite useless and can be deleted.

$query = "select * from Intake3 where 1";



if(isset($_Request['Sex'])&& trim($_POST['Sex']) != '' )

there is no variable $_Request, it is $_REQUEST.
Why do you test on $_REQUEST and compare it with trimmed $_POST?

{
if ($_REQUEST['Sex'] === "0")
{
$sex = 'Male';
}
else
{
$sex = 'Female';
}

Why do you set a variable that is never used?

$allowed_fields = array
( 'Site' =>$_POST['Site'], 'MedRec' => $_POST['MedRec'], 'Fname' =>
$_POST['Fname'], 'Lname' => $_POST['Lname'] ,
'Phone' => $_POST['Phone'] , 'Sex' => $_POST['Sex'] , 'Height' =>
$_POST['Height'] );
if(empty($allowed_fields))
{
echo "ouch";
}
$query = "select * from Intake3 where 1 ";
foreach ( $allowed_fields as $key => $val )
{
if ( (($val != '')) )
{
$query .= " AND ($key = '$val') ";

Why the hell do you put unverified data into an sql query?

DISPLAY THE INPUT3 DATA:

 >>> THIS SEEMS TO BE THE ROUTINE THAT IS FAILING <<<

What fails?
I do not have access to your database, so I can not run your code to see what fails.

<?php

while ($row1 = mysqli_fetch_array($result1, MYSQLI_BOTH))
{
print_r($_POST);
global $MDRcheck;
$n1++;
echo "<br />n1 <br />";echo $n1;
{
if (($n1 > 2) && ($MDRcheck == $row1[1]))

What is $MDRcheck and what does this comparision mean?

SELECT AND DISPLAY DATA FROM VISIT3 DATABASE

<?php
$query2 = "select * from Visit3 where 1 AND (Site = 'AA') AND (MedRec =
$_GLOBALS[mdr])";

Quotes around mdr missing

$result2 = mysqli_query($cxn, $query2);
$num = mysqli_num_rows($result2);


global $finished;
$finished = 0;


while($row2 = mysqli_fetch_array($result2, MYSQLI_BOTH))
{
global $finished;

No need to global that twice.
And why ndo you use global and $_GLOBALS? STick to one or better skip it anyways. Globals are not to be used!

switch ( @$_POST[next_step] )

Remove all @ from your code or you won't see any errors on this.
Do proper checking and do NOT suppress errors or warnings.

echo "<form method=\"post\" action=\"\">";
echo "<input type=\"hidden\" name=\"next_step\" value=\"step4\" />";
echo "<enter><br />";
echo "Medical Record: &nbsp<input type=\"text\" name=\"MedRec\" value=\"
$_GLOBALS[mdr]\" />";

Quotes.

$Weight = $_POST['Weight'];
$Notes = $_POST['Notes'];
$sql2 = "INSERT INTO Visit3(Indx, Site, MedRec, Notes, Weight, BMI,
Date) VALUES(null, '$Site', '$MDRold', '$Notes',

Do NOT NEVER put data that is user input unchecked into a query.

?>

?>

Double closing tag?

echo "<td> $_GLOBALS[mdr] </td>\n";

Quotes.

$flag = 1;

What's this?

You really really should seperate your code from HTML.
Please truncate your apache and php error log.
Add

error_reporting(E_ALL);
ini_set('display_errors', 'On');

at the top of every php file right after <?php onto a new line.
Remove all @ from your lines and execute your script another time and see what errors are appear into your browser and your logfiles. Post them and the codelines for these errors on the list.

--
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: ma...@behnke.biz

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz

Attachment: smime.p7s
Description: S/MIME Kryptografische Unterschrift

Reply via email to