Jump to content

Syntax Help with mysql post


TechMistress

Recommended Posts

Ok, I'm putting in or leaving out a , or a ; or something... Can someone help?

 

Original code, gives me error about having an apostrophe in it:

$q1 = "insert into listings set 
				AgentID = '$_POST[AgentID]',
				CategoryID = '$CategoryID',
				SubcategoryID = '$SubcategoryID',
				address = '$_POST[address]',
				city = '$_POST[city]',
				state = '$_POST[state]',
				province = '$_POST[province]',
				zip_code = '$_POST[zip_code]',
				country = '$_POST[country]',
				SubdivisionName = '$_POST[subdivisionName]',
				FeaturedListing = '$_POST[FeaturedListing]',
				ShortDesc ='$_POST[shortDesc]',
				DetailedDesc = '$_POST[DetailedDesc]',
				Price = '$_POST[Price]',
				currencyID = '$_POST[currencyID]',
				neighbourhood = '$_POST[neighbourhood]',
				PropertyType = '$_POST[PropertyType]',
				rooms = '$_POST[rooms]',
				bathrooms = '$_POST[bathrooms]',
				fireplace = '$_POST[fireplace]',
				garage = '$_POST[garage]',
				SquareFeet = '$_POST[squareFeet]',
				LotSize = '$_POST[LotSize]',
				HomeAge = '$_POST[HomeAge]',
				NearSchool = '$_POST[NearSchool]',
				NearTransit = '$_POST[NearTransit]',
				NearPark = '$_POST[NearPark]',
				OceanView = '$_POST[OceanView]',
				LakeView = '$_POST[LakeView]',
				MountainView = '$_POST[MountainView]',
				OceanWaterfront = '$_POST[OceanWaterfront]',
				LakeWaterfront = '$_POST[LakeWaterfront]',
				RiverWaterfront = '$_POST[RiverWaterfront]',
				image = '$ImageStr',
				DateAdded = '$t' ";

mysql_query($q1) or die(mysql_error()); 

 

So, I added the mysql_real_escape_string on the two fields in question:

 

					AgentID = '$_POST[AgentID]',
				CategoryID = '$CategoryID',
				SubcategoryID = '$SubcategoryID',
				address = '$_POST[address]',
				city = '$_POST[city]',
				state = '$_POST[state]',
				province = '$_POST[province]',
				zip_code = '$_POST[zip_code]',
				country = '$_POST[country]',
				SubdivisionName = '$_POST[subdivisionName]',
				FeaturedListing = '$_POST[FeaturedListing]',
				ShortDesc = mysql_real_escape_string($_POST[shortDesc]),
				DetailedDesc = mysql_real_escape_string($_POST[DetailedDesc]),
				Price = '$_POST[Price]',
				currencyID = '$_POST[currencyID]',
				neighbourhood = '$_POST[neighbourhood]',
				PropertyType = '$_POST[PropertyType]',
				rooms = '$_POST[rooms]',
				bathrooms = '$_POST[bathrooms]',
				fireplace = '$_POST[fireplace]',
				garage = '$_POST[garage]',
				SquareFeet = '$_POST[squareFeet]',
				LotSize = '$_POST[LotSize]',
				HomeAge = '$_POST[HomeAge]',
				NearSchool = '$_POST[NearSchool]',
				NearTransit = '$_POST[NearTransit]',
				NearPark = '$_POST[NearPark]',
				OceanView = '$_POST[OceanView]',
				LakeView = '$_POST[LakeView]',
				MountainView = '$_POST[MountainView]',
				OceanWaterfront = '$_POST[OceanWaterfront]',
				LakeWaterfront = '$_POST[LakeWaterfront]',
				RiverWaterfront = '$_POST[RiverWaterfront]',
				image = '$ImageStr',
				DateAdded = '$t' ";

 

but, this is breaks the post also. I get this error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1235000', currencyID = '1', neighbourhood = '', PropertyType = 'W' at line 14

 

So now it's allowing the apostrophe, but it messed up the set.

 

How do I continue the set? which is each line in single quotes, followed by a comma.

 

I've tried so many ways, but it always breaks somewhere.

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/190415-syntax-help-with-mysql-post/
Share on other sites

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.