Jump to content

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


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);
?>

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.