[HELP] array codeigniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: [HELP] array codeigniter (/showthread.php?tid=55481) |
[HELP] array codeigniter - El Forum - 10-28-2012 [eluser]Unknown[/eluser] i have tried to make sql code in CI, the problem is the ID_LABEL at t_publisher is filled with 0 where it should filled with number that taken from t_label.. $sql['query1'] = "INSERT into t_user (USER_NAME, USER_PASS, USER_STATUS, USER_TYPE) values ('$user', '$pass','1','publisher')"; $sql['query2'] = "INSERT INTO t_label (LABEL) values('$user')"; $id_label = "select id_label from t_label where label ='".$user."'"; $id = $this->db->query($id_label)->result(); $sql['query3'] = "INSERT INTO t_publisher (PUBLISHER, ARTIS, ID_LABEL) values('$user', 'Various Artist', '$id')"; $result = array(); foreach($sql as $key => $value){ $result[$key] = $this->db->query($value); } please help [HELP] array codeigniter - El Forum - 10-29-2012 [eluser]michalsn[/eluser] Code: $sql[‘query3’] = “INSERT INTO t_publisher (PUBLISHER, ARTIS, ID_LABEL) values(’$user’, ‘Various Artist’, ‘$id->id_label’)”; And escape your queries. Please read last two sections from user guide: http://ellislab.com/codeigniter/user-guide/database/queries.html |