[SOLVED] error message help!!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

[SOLVED] error message help!!!

Post 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
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

<font="red">
:roll:
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

thanks feyd

i already changed that line, still, the problem is there...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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?
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post 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?
User avatar
pleigh
Forum Contributor
Posts: 445
Joined: Wed Jan 19, 2005 4:26 am

Post by pleigh »

problem fixed....thanks.... :wink:
Post Reply