Page 1 of 1

[SOLVED] error message help!!!

Posted: Sun Feb 27, 2005 9:56 pm
by pleigh
hi there

i have this code:

Code: Select all

<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td valign="top">
		  <form action="<? $_SERVER&#1111;'PHP_SELF']; ?>" method="post">
		  <table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <!--spacer-->
		  <tr>
		  	<td width="20%">&nbsp;</td>
			<td width="1%">&nbsp;</td>
			<td width="79%">
			<?
			$id = $_SESSION&#1111;'userID'];
			
			//submit conditionals
			if (isset($_POST&#1111;'submit']))
			&#123;
				$errormessage = NULL;
				
				//verify title
				if (empty($_POST&#1111;'topic']))
				&#123;
					$t = FALSE;
					$errormessage .= 'Enter the title of your report!<br>';
				&#125;
				else
				&#123;
					$t = addslashes($_POST&#1111;'topic']);
				&#125;
				
				//verify accomplishment
				if (empty($_POST&#1111;'message']))
				&#123;
					$m = FALSE;
					$errormessage .= 'Enter your accomplishment report!<br>';
				&#125;
				else
				&#123;
					$m = addslashes($_POST&#1111;'message']);
				&#125;
				
				
				
				if ($t && $m)
				&#123;
					$query = "INSERT INTO forum(userID, topic, message, date)
					VALUES('$id','$t','$m', NOW())";
					$result = @mysql_query($query);
					
					if ($result)
					&#123;
						echo '<b>Your report has been recorded</b>';
						echo '<meta http-equiv="refresh" content="3;url=http://localhost/mysample/forum.php">';
						exit();
					&#125;
					else
					&#123;
						$errormessage .= 'Your report cannot be recorded due to system error<br>'.mysql_error();
					&#125;
					mysql_close();
				&#125;
				else
				&#123;
					$errormessage = 'Please try again<br>';
				&#125;
			&#125;
			
			if (isset($errormessage))
			&#123;
				echo '<font="red">', $errormessage, '</font>';
			&#125;
			?>
			</td>
		  </tr>
		  <!--title-->
		  <tr>
		  	<td width="20%" align="right"><b>TOPIC</b></td>
			<td width="1%"><b>:</b></td>
			<td width="79%"><input type="text" name="topic" value="<? if (isset($_POST&#1111;'topic'])) echo $_POST&#1111;'topic']; ?>"></td>
		  </tr>
		  <!--accomplishments-->
		  <tr valign="top">
		  	<td width="20%" align="right"><b>MESSAGE</b></td>
			<td width="1%"><b>:</b></td>
			<td width="79%"><textarea name="message" cols="40" rows="6"></textarea></td>
		  </tr>
		  
		  <tr valign="top">
		  	<td width="20%"></td>
			<td width="1%"></td>
			<td width="79%"><input type="submit" name="submit" value="submit report"></td>
		  </tr>
		  </table>
		  </form>
		  </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
the problem is, when i try not to input anything in the textfield and textarea, the error messages does not appear and the only error message is the 'TRY AGAIN' message, and instead of that message appearing in red, it appears to be black.what could be the problem with my code?

i cant seethe problem within this code, and i tried to read each line, compared it my other code, it seems to be good, but i spent so much time looking for the problem....hope u guys can help me...

thanks.

pleigh

Posted: Sun Feb 27, 2005 10:02 pm
by feyd

Code: Select all

<font="red">
:roll:

Posted: Sun Feb 27, 2005 10:06 pm
by pleigh
thanks feyd

i already changed that line, still, the problem is there...

Posted: Sun Feb 27, 2005 10:08 pm
by feyd
care to tell us what the new code for that is?

Does your code have a DTD set? If so, what is it?

Posted: Sun Feb 27, 2005 10:17 pm
by pleigh
the code is for posting a new thread/message/report in a reporting system, the problem is, when the user missed to input a text in the textfield and text area, the error message 'try again' appears, not appearing the right message 'Enter the title of your report!' and 'Enter your accomplishment report!'. i think the error is within

Code: Select all

if ($t && $m)
				&#123;
					$query = "INSERT INTO forum(userID, topic, message, date)
					VALUES('$id','$t','$m', NOW())";
					$result = @mysql_query($query);
					
					if ($result)
					&#123;
						echo '<b>Your report has been recorded</b>';
						echo '<meta http-equiv="refresh" content="3;url=http://localhost/mysample/forum.php">';
						exit();
					&#125;
					else
					&#123;
						$errormessage .= 'Your report cannot be recorded due to system error<br>'.mysql_error();
					&#125;
					mysql_close();
				&#125;
				else
				&#123;
					$errormessage = 'Please try again<br>';
				&#125;
because this code

Code: Select all

else
				&#123;
					$errormessage = 'Please try again<br>';
				&#125;
is the only error message that appears and it appears in black font, instead of red, but really not very sure...

and about this
Does your code have a DTD set? If so, what is it?
what is DTD set?sorry for the questions...

Posted: Sun Feb 27, 2005 10:25 pm
by feyd
you may want to use "$errormessage .=" on that try again line..

what did you change the <font> tag to now?

A DTD often looks like:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
it appears at the beginning of the html normally.

Posted: Sun Feb 27, 2005 10:38 pm
by pleigh
thanks feyd

i tried the

Code: Select all

else
&#123;
$errormessage .= 'please try again'
&#125;
and it worked ok now.

now, the problem is the font is still color black, ive changed the font color tag
to

Code: Select all

<font color=red>
but it is still black.

also did

Code: Select all

echo "<font color"red">".$message."</font>";
and lastly, i have no DTD set in my heading....what could be the implication is i did not include DTD set?

Posted: Sun Feb 27, 2005 11:00 pm
by pleigh
problem fixed....thanks.... :wink: