agallo Posted August 8, 2007 Share Posted August 8, 2007 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! <?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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/63948-syntax-error-and-i-cant-find-itahhhhplease-help-me/ Share on other sites More sharing options...
akitchin Posted August 8, 2007 Share Posted August 8, 2007 it would be helpful if you could tell us what error you're receiving. Quote Link to comment https://forums.phpfreaks.com/topic/63948-syntax-error-and-i-cant-find-itahhhhplease-help-me/#findComment-318748 Share on other sites More sharing options...
agallo Posted August 8, 2007 Author Share Posted August 8, 2007 sorry. i was really frusterated and i took my smoke break after i posted... oops -My update statements are not populating my database. Quote Link to comment https://forums.phpfreaks.com/topic/63948-syntax-error-and-i-cant-find-itahhhhplease-help-me/#findComment-318786 Share on other sites More sharing options...
Orio Posted August 8, 2007 Share Posted August 8, 2007 Change each mysql_query($query); into: mysql_query($query) or die(mysql_error()); Orio. Quote Link to comment https://forums.phpfreaks.com/topic/63948-syntax-error-and-i-cant-find-itahhhhplease-help-me/#findComment-318791 Share on other sites More sharing options...
GingerRobot Posted August 8, 2007 Share Posted August 8, 2007 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); ?> Quote Link to comment https://forums.phpfreaks.com/topic/63948-syntax-error-and-i-cant-find-itahhhhplease-help-me/#findComment-318799 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.