It's unclear (to me anyway) what you mean. Do you want to move an id from one database table to another? Move a cell from one HTML table to another? And the comma separator is supposed to do what, exactly? Split the id's?
syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in
in.. the suspense is killing me.
One of those variables in the queries is probably not set properly. You should also not be using the deprecated mysql but one of the improved mysqli or PDOAPI's.
By using prepared statements you can prevent variables messing up your syntax. By allowing variables to be set directly into the query you're open to security risks.
edit: I see what you mean by using comma separator now
$list_id = implode('","', $m_id);
You're splitting on "," and not just ,. So do implode(',', $m_id) if there's only a comma or implode(', ', $m_id) if there's a comma and a space. And consider not storing it as a comma separated string in your database but in its own table.
your implode has '""' if you need the middle "" you should add addslashes()
to allow it to work plus you should refrain from using mysql like traevel said plus if you are staying with the mysql you should clean the post's
$name = filter_input(INPUT_POST, 'name', FILTER_SANITIZE_STRING);
$email = filter_input(INPUT_POST, 'email', FILTER_SANITIZE_EMAIL);
$phone = filter_input(INPUT_POST, 'phone', NUMBER_INT);
$a=mysql_query("select * from `tbl_interest` WHERE email = '".$email."' and phone = '".$phone."' ")or die(mysql_error());
if($count_a > 0)
$list_id = implode(',', $m_id);
mysql_query("update `tbl_products` set interest = '".$list_id."' where id=".$row_a['id']."")or die(mysql_error());
mysql_query("insert into `tbl_interest` (`name` ,`email`,`phone` )values('".$name."','".$email."','".$phone."')")or die(mysql_error());
Thank you, I you want to store an id from one database table to another.
Suppose, from the above, if 2 is already registerd , it should not store like 1,2,3,4,5,2. its wrong. it sholud save 1,2,3,4,5. 2 should not store again. from the above code what are the changes to be made?