Jump to content

Edit Text Why


laado

Recommended Posts

its a code of edit text. bt when i edit text with numbers it cannot display error and msg displyed that text edit successfully. but the text not edited. why?following is the code:

<title>Edit News</title><?php//LAST UPDATE// 27-09-2007include("config.php");$error = "";$error1 = "";$error2 = "";$error3 = "";$error4 = "";$error5 = "";   $newsid = $_GET['newsid'];   if(isset($_POST['submit']))  {	  $title = $_POST['title'];	  $text1 = $_POST['text1'];	  $text2 = $_POST['text2'];//check if (title) field is empty then print error message.			  if(!$title){  //this means If the title is really empty.					 $error = "Error: News title is a required field. Please fill it.";	   			   }// end of if			  elseif ((bool) preg_match('/[0-9]/', $title)) {				 $error3 = "Error: News title must not contain numbers. Please refill it, with all numbers removed.";				 			   }			  elseif(!$text1){  //this means If the title is really empty.					 $error1= "Error: News text1 is a required field. Please fill it.";							}			  elseif ((bool) preg_match('/[0-9]/', $text1)) {				 $error4 = "Error: News title must not contain numbers. Please refill it, with all numbers removed.";				 			   } 			  elseif(!$text2){  //this means If the title is really empty.					 $error2= "Error: News text2 is a required field. Please fill it.";			   			   }	  	 elseif ((bool) preg_match('/[0-9]/', $text2)) {				 $error5 = "Error: News title must not contain numbers. Please refill it, with all numbers removed.";				 			   }		 $result = mysql_query("UPDATE news SET title='$title', text1='$text1', text2='$text2' WHERE newsid='$newsid' ",$connect);		  echo "<b>Thank you! News UPDATED Successfully!<br>You'll be redirected to Home Page after (4) Seconds";		  echo "<meta http-equiv=Refresh content=4;url=index.php>";}elseif($newsid){		$result = mysql_query("SELECT * FROM news WHERE newsid='$newsid' ",$connect);		while($myrow = mysql_fetch_assoc($result))			 {				$title = $myrow["title"];				$text1 = $myrow["text1"];				$text2= $myrow["text2"];?><br><h3>::Edit News</h3><form method="post" action="<?php echo $PHP_SELF ?>"><input type="hidden" name="newsid" value="<? echo $myrow['newsid']?>">Title: <input name="title" size="40" maxlength="255" value="<? echo $title; ?>"><?php echo $error ?> <?php echo $error3 ?><br>Text1: <textarea name="text1"  rows="7" cols="30"><? echo $text1; ?></textarea><?php echo $error1 ?> <?php echo $error4 ?><br>Text2: <textarea name="text2" rows="7" cols="30"><? echo $text2; ?></textarea> <?php echo $error2 ?> <?php echo $error5 ?><br><input type="submit" name="submit" value="Update News"></form><?			  }//end of while loop  }//end else?>

please tell me where is the error why it should not displayed error?

Link to comment
Share on other sites

1 - you have it set so that no matter what, it will attempt to update the database when the button is pushed (it's not within a statement conditional upon whether there are errors or not)2 - where is $connect getting set? configure?3 - the answer to "why it should not displayed error?" is because you never tell it to... you never even attempt to... you should have it so that if there are any errors, that INSTEAD of attempting to update the database it displays the errors and shows the form again.

Link to comment
Share on other sites

plz point out exectly where i should change in the code?and wht change i make in the code?

1 - you have it set so that no matter what, it will attempt to update the database when the button is pushed (it's not within a statement conditional upon whether there are errors or not)2 - where is $connect getting set? configure?3 - the answer to "why it should not displayed error?" is because you never tell it to... you never even attempt to... you should have it so that if there are any errors, that INSTEAD of attempting to update the database it displays the errors and shows the form again.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...