I have 2-3 questions regarding my sql INSERT and how to go about combining multiple $_POST into one field.
- i’m having problems with my
INSERTstatement everything was working till I addedm_id=".intval($id)." - for field
m_ageI need to combine/insert the following three$_POST['month'] $_POST['day'] $_POST['year']into it. Should I create avar $age = $_POST['month'] + ...;then insert$ageintom_ageseparately? - same as 2. I want combine
$_POST['feet']and$_POST['inches']intom_height
code:
$fields = explode(" ", "m_id m_pos m_name m_age m_btype m_height");
$query = "INSERT INTO meminfo SET m_id=".intval($id).", ".dbSet($fields, "m_" + $_POST['add']);
this is not true.
While
m_id=".intval($id)."being correct statement,a
dbSet($fields, "m_" + $_POST['add']);one makes absolutely no sense.but you are right, the dbSet() function is intended to be used like that
and ‘m_id’ will be added to the set automatically. Same for the other artificial fields
However, adding an id (assuming autoincrement field) into insert query makes no sense.
Anyway, seeing your struggle with basic PHP syntax I am going to withdraw my proposal for using dbSet() function.
You have to write your inserts by hand, until you get familiar with them.
Otherwise no function will do no good for you.
The particular problem obviously coming from the
m_prefix you are using for all your fields. A strange whim making things unnecessary complicated. You’d better get rid of it.