Jump to content
Larry Ullman's Book Forums

"No Element Found" Error In My Php File..


Recommended Posts

Dear all,

 

I'm getting "no element found error" in my one of php file shown below.

 

I have noted the following points.

 

1. When I preview my php file, the XML output is correct and does not give any error for me.

 

<response>
	 <field_error>appo_appointmentsubject</field_error>
	 <field_error>appo_appointmentvenue</field_error>
	 <field_error>appo_appointmentdate</field_error>
	 <field_error>appo_appointmentfromtime</field_error>
	 <field_error>appo_appointmenttotime</field_error>
	 <field_error>appo_professionalparticipants</field_error>
	 <system_error>Please correct problems with the highlighted field(s) below.</system_error>
</response>

 

2. I do not get the error message when the "error" variable is true in the code.

3. When the error variable is false, I do not get the error message up to the line called "This is the point"(It's a comment in the code). That means I have commented the rest of the code.

4. But when I uncomment the lines within the comment called "Error occurs after the following query.", I get this error.

 

I cannot figure out the issue here!

 

Can you find any issue in my code?

 

 

<?php # submit.php
header("Content-Type: text/xml");
echo '<?xml version="1.0" encoding="utf-8" standalone="yes" ?><response>';

$error = false;
$professional_participants_save_error = false;
$customer_participants_save_error = false;
$rights_save_error = false;

if (!empty($_POST['appo_appointmentsubject']))
{
$subject = $_POST['appo_appointmentsubject'];
}
else
{
$error = true;
echo '<field_error>appo_appointmentsubject</field_error>';
}

if (!empty($_POST['appo_appointmentdescription']))
{
$description = $_POST['appo_appointmentdescription'];
}
else
{
$description = null;
}

if (!empty($_POST['appo_appointmentvenue']))
{
$venue = $_POST['appo_appointmentvenue'];
}
else
{
$error = true;
echo '<field_error>appo_appointmentvenue</field_error>';
}

if (!empty($_POST['appo_appointmentdate']))
{
$date = date_create($_POST['appo_appointmentdate']);
}
else
{
$error = true;
echo '<field_error>appo_appointmentdate</field_error>';
}

if (!empty($_POST['appo_appointmentfromtime']))
{
$fromTime = $_POST['appo_appointmentfromtime'];
}
else
{
$error = true;
echo '<field_error>appo_appointmentfromtime</field_error>';
}

if (!empty($_POST['appo_appointmenttotime']))
{
$toTime = $_POST['appo_appointmenttotime'];
}
else
{
$error = true;
echo '<field_error>appo_appointmenttotime</field_error>';
}
if (!empty($_POST['appo_appointmentduration']))
{
$duration = $_POST['appo_appointmentduration'];
}
else
{
$duration = 0;
}

if (empty($_POST['appo_professionalparticipants']))
{
$error = true;
echo '<field_error>appo_professionalparticipants</field_error>';
}

if (!$error)
{
echo '<system_error>Test this code......</system_error>';
//Open the database connection.
require_once (dirname(__FILE__).'/../../functions/dbconnect.php');

session_start();
$username = $_SESSION['username'];

//Retrive the owner professional ID from the professional table. Owner professional is the current user logged in.
$q = "SELECT professionalID FROM Professional_Table WHERE userName LIKE '$username'";
$r = mysql_query($q, $dbc);
if (mysql_num_rows($r)==1)
{
// Retrieve the results:
$row = mysql_fetch_row($r);
//Prepare the owner professional ID.
$ownerProfessionalID = $row[0];
}


//"This is the point"


/*
//Error occurs after the following query.


//Insert the new appointment information into Appointment_Table.
$q1 = "INSERT INTO appointment_table
 (ownerProfessionalID, subject, description, venue, date, fromTime, toTime, duration)
 VALUES ($ownerProfessionalID, '$subject', '$description', '$venue', $date, $fromTime, $toTime, $duration)";
$r1 = mysql_query($q1, $dbc);


//End of Error occurs after the following query.


if (mysql_affected_rows($dbc) == 1)
{
//Start saving the professional and customer participants.

$appointmentID = mysql_insert_id($dbc);

//Check whether the change rights or view rights are set.
if(isset($_POST['appo_professionalparticipants']))
{
//Extract the professional names from change rights list seperately.
$line_data1 = explode("\n", $_POST['appo_professionalparticipants']);
//For each extracted professional name start saving the rights.
foreach($line_data1 as $key => $value1)
{
 //Retrive the allowed professional ID from the professional table.
 $q2 = "SELECT professionalID FROM Professional_Table WHERE name = '$value1'";
 $r2 = mysql_query($q2, $dbc);
 if (mysql_num_rows($r2)>0)
 {
 // Retrieve the results:
 $row2 = mysql_fetch_row($r2);
 //Prepare the professional ID.
 $professionalID = $row2[0];
 //Professional has both change and view rights.
 $q3 = "INSERT INTO Appointment_Professional_Table (appointmentID, professionalID) VALUE($appointmentID, $professionalID)";
 $r3 = mysql_query($q3, $dbc);
 if (mysql_affected_rows($dbc) == 0)
 {
 $professional_participants_save_error = true;
 }
 }
}
}

if(isset($_POST['appo_customerparticipants']))
{
//Extract the professional names from view rights list seperately.
$line_data2 = explode("\n", $_POST['appo_customerparticipants']);
//For each extracted professional name start saving the rights.
foreach($line_data2 as $key => $value2)
{
 $q4 = "SELECT customerID FROM Customer_Table WHERE name = '$value2'";
 $r4 = mysql_query($q4, $dbc);
 if (mysql_num_rows($r4)>0)
 {
 // Retrieve the results:
 $row4 = mysql_fetch_row($r4);
 //Prepare the professional ID.
 $customerID = $row4[0];
 //Professional has only view right.
 $q6 = "INSERT INTO Appointment_Customer_Table (appointmentID, customerID) VALUE($appointmentID, $customerID)";
 $r6 = mysql_query($q6, $dbc);
 if (mysql_affected_rows($dbc) == 0)
 {
 $customer_participants_save_error = true;
 }
 }
}
}
if($professional_participants_save_error)
{
echo '<system_error>Error occured while saving professional participants!' . mysql_error() . '</system_error>';
}
else if($customer_participants_save_error)
{
echo '<system_error>Error occured while saving customer participants!' . mysql_error() . '</system_error>';
}
else if($rights_save_error)
{
echo '<system_error>Error occured while saving user rights!' . mysql_error() . '</system_error>';
}
else
{
echo '<result>The appointment has been successfully saved.' . mysql_error() . '</result>';
}
}
else
{
// Query failure.

if(mysql_errno()>0)
{
echo '<system_error>Error occured while saving the appointment details.' . mysql_error() . '</system_error>';
}
}*/


//Lines are commented up to here.


mysql_close($dbc);
}
else
{ // Errors!
echo '<system_error>Please correct problems with the highlighted field(s) below.</system_error>';
}
echo '</response>';
exit();
?>

 

 

For your reference, I have included my dbconnect.php file also.

 

$dbc = @mysql_connect ('localhost', 'test', 'test');

// Confirm the connection and select the database:
if (!$dbc OR !mysql_select_db ('ams_db'))
{
// Handle the error, if desired.

// Print a message to the user, complete the page, and kill the script.
echo '<system_error>The site is currently experiencing technical difficulties. We apologize for any inconvenience.</system_error>';
echo '</response>';
exit();
}

 

Your support is highly appriciated!

 

Thanks in advance,

 

Sampath.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...