I'm new to creating PHP and MySQL queries. I have a processor for a large form. Some fields are required, most field users are optional in my case, HTML IDs and MySQL column names are the same. I convert $ _POST to INSERT for fields and values. I've found a tutorial about using the array, but I can not work them - after several hours I have come back to using simple INSERT arrays and variables. I'm stuck, but I'm still stumped. Works in the following line and INSERTs 5 items in the database with more than 100 columns. The first 4 items are string, 5th item, monthly rcent is an integer. When I create an array for the fields and use it, it is as follows: I get a MySQL error - to use 'array' near values, check the manual related to your MySQL server version for correct syntax) '' US ', 'New York' 'Fairport, Monroe County, New York', '(43.09)' on line 1. I get this error if the array does not have objects inside or in the same quotes. I have read a lot and have tried many combinations and I can not get it. I want to see the correct syntax on a small scale before going back to forwarding expression to process $ _POST and both fields and values Are there. And yes, I know that I should use mysql_real_escape_string, but this is an easy step in the last time, in the end, some clues about syntax for an array of values would be helpful, especially if it differs from field array Ho. I know that I need to add a tap as the first array object to trigger MySQL autoincrement id. what else? I am very new, so please be specific. $ Colsx is an array, so the product that you are about to end is actually Before you do this, the array must be pre-processed in a string, for example For
$ colsx = array ('country', 'State,', 'city 3,', 'city 3gcod,', 'magazine'); Include $ Query = "$ table` ('$ colsx') values ('$ country', 'provide $ state', '$ city3', '$ city3Geocode', '$ monthlyRental')";
$ query = "$ 'table` (' $ colsx ') etc. ...
$ query = "INSERT IN 'sometable` ^^^^^ --- Yes, it literally says" array "
$ colsx = array (...); $ Col_string = implode (',', $ colsx); Include $ query = "$ table_ ($ col_string) etc ...";
Comments
Post a Comment