Jump to content

syntax error and i can't find it...ahhhh...please help me


agallo

Recommended Posts

I have a syntax error in the following code and have been looking for hours and I just feel I need a second set of eyes.

 

Thanks in advance for the help!  ;D

 

<?php
		  
		$section = $_POST['id'];
		$region = $_POST['region'];

		$query = mysql_select_db($database_localmap, $localmap);

			switch ($region) {

				case '_dallas':	$query_table = "SELECT * FROM `_dallas` WHERE id='$section'";
				break;
				case '_houston':	$query_table = "SELECT * FROM `_houston` WHERE id='$section'";
				break;
				case '_central':	$query_table = "SELECT * FROM `_central` WHERE id='$section'";
				break;
				case '_east':	$query_table = "SELECT * FROM `_east` WHERE id='$section'";
				break;
				case '_west':	$query_table = "SELECT * FROM `_west` WHERE id='$section'";
				break;
			}

		$table = mysql_query($query_table, $localmap) or die(mysql_error());
		$row_table = mysql_fetch_assoc($table);
		$totalRows_table = mysql_num_rows($table);  

		            
		$query = "UPDATE ".$table." SET qoteid=".$_POST['quoteid']." WHERE id=".$_POST['id'];
		mysql_query($query);		

		$query = "UPDATE ".$table." SET name=".$_POST['name']." WHERE id=".$_POST['id'];
		mysql_query($query);	

		$query = "UPDATE ".$table." SET brand=".$_POST['brand']." WHERE id=".$_POST['id'];
		mysql_query($query);	

		$query = "UPDATE ".$table." SET address= ".$_POST['address']." WHERE id= ".$_POST['id'];
		mysql_query($query);	

		$query = "UPDATE ".$table." SET city= ".$_POST['city']." WHERE id= ".$_POST['id'];
		mysql_query($query);	

		$query = "UPDATE ".$table." SET state= ".$_POST['state']." WHERE id= ".$_POST['id'];
		mysql_query($query);	

		$query = "UPDATE ".$table." SET zip= ".$_POST['zip']." WHERE id= ".$_POST['id'];
		mysql_query($query);	

		$query = "UPDATE ".$table." SET latitude= ".$_POST['lat']." WHERE id= ".$_POST['id'];
		mysql_query($query);	

		$query = "UPDATE ".$table." SET longitude= ".$_POST['lng']." WHERE id= ".$_POST['id'];
		mysql_query($query);	

		$query = "UPDATE ".$table." SET zoom= ".$_POST['zoom']." WHERE id= ".$_POST['id'];
		mysql_query($query);	

?>

Well, do you have a syntax error or not? If you have a syntax error, you'd be getting an error message, with a line that the error occurs on.

 

I assume the problems lie with the lack of quotes around your strings in your update queries. Also, you don't need to update each field in a separate query. Finally, whenever you have a problem with queries not working, add an or die statement to the query. Try:

 

<?php
$sql = "UPDATE $table SET quoteid='".$_POST['quoteid']."', name='".$_POST['name']."', brand='".$_POST['brand']."', address='".$_POST['address']."', city='".$_POST['city']."', state='".$_POST['state']."', zip='".$_POST['zip']."', latitude='".$_POST['latitude']."', longitude='".$_POST['longitude']."', zoom='".$_POST['zoom']."',"	
mysql_query($sql) or die(mysql_error().'Query:'.$sql);
?>

 

 

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.