karatekid36 Posted June 22, 2007 Share Posted June 22, 2007 Why are these two line producing an error. All of the variables are fine it is the actual structure of this code. foreach($attend as $key => $value2){ mysql_query("INSERT INTO attendance ('eid', 'mid','attend_status') VALUES ('$eventid','$key','$value2') or die(mysql_error()"); } Quote Link to comment https://forums.phpfreaks.com/topic/56633-really-simple-only-two-lines-of-code-that-need-help/ Share on other sites More sharing options...
trq Posted June 22, 2007 Share Posted June 22, 2007 A few reasons. You have both php syntax and mysql syntax errors. Try... <?php foreach($attend as $key => $value2){ mysql_query("INSERT INTO attendance (eid, `mid`, attend_status) VALUES ('$eventid','$key','$value2')") or die(mysql_error()); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/56633-really-simple-only-two-lines-of-code-that-need-help/#findComment-279665 Share on other sites More sharing options...
teng84 Posted June 22, 2007 Share Posted June 22, 2007 foreach($attend as $key => $value2){ mysql_query("INSERT INTO attendance ('eid', 'mid','attend_status') VALUES ('".$eventid."','".$key."','".$value2."')") or die((mysql_error()); } Quote Link to comment https://forums.phpfreaks.com/topic/56633-really-simple-only-two-lines-of-code-that-need-help/#findComment-279666 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.