Jump to content

Help with error messaging


tarik321

Recommended Posts

Hi i was wondering if anyone could help me on this problem.

 

I am designing an helpdesk system and there are bascially 3 bits to it, i am designing in PHP, mySQL

 

1) Client fills in an online form after logging in and submits it (so save to the database) where it will be displayed on another page.

 

2) An technical user would then open this query up after he logs in, looks at the query and then add his/her comments to the problem, and this is then UPDATED in the database.

 

3) I have included error messaging, so if the technical analyst has not filled in an certain field then he/she would not be able to update the query as they would be prompted by an error message to do so first.

 

 

I hope this is okay so far.

 

Im having a problem showing these error messages, when i click the submit button, it will not show an error messages, it just goes to a blank white screen showing the following message -

 

Unable to perform query: select * from form where formID =

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

 

 

This is my error message code, i have all the basic aspects of this, but the program is not working.

 

if($prioritylevel == "Please Select") 
{

	$message1 = "Please select the issue topic";
	header("Location: analystformedit.php?message1=$message1");
	exit();
}

else if($status == "Please Select") 
{
	$message2 = "Please enter the system affected";
	header("Location: analystformedit.php?message2=$message2");
	exit();
}

else if($supportcomments == "") 
{
	$message3 = "Please enter details of the problem";
	header("Location: analystformedit.php?message3=$message3");
	exit();
}

 

 

Thanks

 

 

Link to comment
https://forums.phpfreaks.com/topic/95509-help-with-error-messaging/
Share on other sites

This is whole form checking code -

 

<?php
require "connect.php";
$formID = $_GET['formID'];
$issuetitle = $_GET['issuetitle'];
$datesubmitted = $_GET['datesubmitted'];
$timesubmitted = $_GET['timesubmitted'];
$systemaffected = $_GET['systemaffected'];
$prioritylevel = $_GET['prioritylevel'];
$issuedetails = $_GET['issuedetails'];
$supportcomments = $_GET['supportcomments'];
$clientFname = $_GET['clientFname'];
$clientSurname = $_GET['clientSurname'];
$teamname = $_GET['teamname'];
$clientID = $_GET['clientID'];
$status = $_GET['status'];
$dateactioned = $_GET['dateactioned'];
$timeactioned = $_GET['timeactioned'];
$analystFname = $_GET['analystFname'];
$analystSname = $_GET['analystSname'];

if($prioritylevel == "Please Select") 
{

	$message1 = "Please select the issue topic";
	header("Location: analystformedit.php?message1=$message1");
	exit();
}

else if($status == "Please Select") 
{
	$message2 = "Please enter the system affected";
	header("Location: analystformedit.php?message2=$message2");
	exit();
}

else if($supportcomments == "") 
{
	$message3 = "Please enter details of the problem";
	header("Location: analystformedit.php?message3=$message3");
	exit();
}
else
{		
	$query = "update form set issuetitle ='".$issuetitle."', datesubmitted ='".$datesubmitted."', timesubmitted ='".$timesubmitted."', systemaffected ='".		 												$systemaffected."', prioritylevel ='".$prioritylevel."', issuedetails ='".$issuedetails."', supportcomments ='".$supportcomments."', clientFname ='".$clientFname."', 	clientSurname ='".$clientSurname."', teamname ='".$teamname."', clientID ='".$clientID."', status ='".$status."', dateactioned = '".$dateactioned."', timeactioned = '".			$timeactioned."', analystFname = '".$analystFname."', analystSname = '".$analystSname."' where formID =".$formID;

   $result = mysql_query($query, $connection) or die ("Unable to perform query<br>$query");
header("Location: enquiryscreen.php?var=formID");
exit();
}
?>

 

And in the screen i place the error messages, would display the code by the following code -

 

<?php
if(isset($_GET['message1']))
{
	echo $_GET['message1'];
}
?>  

     

 

Is this enough ?

 

Thanks

   

 

Sorry, and in the form where i would display the details filled in by the client, i have this sql statement.

 

<?php
    require "connect.php";
$formID = $_GET['formID'];
$query = "select * from form where formID = ".$formID;
$result = mysql_query($query, $connection) or die ("Unable to perform query: $query<p>".mysql_error());
$row= mysql_fetch_array($result);
?>

Ok. Firstly you may want to change this line

 

$query = "select * from form where formID = ".$formID;

 

to this

 

$query = "select * from form where formID = '$formID'";

 

 

I take it you are also checking to see if $_GET['message2'] & $_GET['message3'] are set ?

 

:)

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.