Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why is it echoing the variable name 1

Status
Not open for further replies.

snowboardr

Programmer
Feb 22, 2002
1,401
PH
new to php its echoing the variable name rather than the list i created...


Code:
		$cid = @$_POST["cid"];
			$cfirst = @$_POST["cfirst"];  	 	 	 	 	 
			$clast = @$_POST["clast"];
			$caddress  = @$_POST["caddress"]; 		 
			$ccity = @$_POST["ccity"]; 	 	 	 	 
			$cstate = @$_POST["cstate"];  	 	 	 	 	 	 	 
			$czip = @$_POST["czip"];  	 	 	 	 	 	 
			$cphone	 = @$_POST["cphone"]; 	  	 	 	 	 	 	  	 	 	 	 	 	 
			$cemail  = @$_POST["cemail"]; 
			 
				if (empty($cfirst)) {
					$errorlist = 'first name';
				}
				
				if (empty($clast)) {
					$errorlist .= ' last name';
				}
				
				if (empty($caddress)) {
					$errorlist .= ' address';
				}	
				
				if (empty($ccity)) {
					$errorlist .= ' city';
				}	
				 
				if (empty($czip)) {
					$errorlist .= ' zip';
				}	 
				
				if (empty($cphone)) {
					$errorlist .= ' phone';
				}	
				
				if (empty($cemail)) {
					$errorlist .= ' email';
				}	
				
				if (!(empty($errorlist))) {
					$errortmp = trim(errorlist);
					$strspace = ' ';
					$strReplaceSpace = ', ';
					
					$errortmp = str_ireplace ($strspace,$strReplaceSpace,$errortmp);
					$error = 'Error : Fields required : '.$errortmp;	
					
					echo $error;
					// 
					
				}

Jason

[red]Army[/red] : [white]Combat Engineer[/white] : [blue]21B[/blue]

 
You should have gotten a notice for this, but apparently your PHP is not set to display notices.

But in this line I'm assuming you want that to be the variable $errorlist, not just the string/CONSTANT errorlist.

So:

Code:
$errortmp = trim([red]$[/red]errorlist);

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top