corillo181 Posted October 7, 2007 Share Posted October 7, 2007 i got a class that deletes song and photo everything work fine and both, but the record is not delete from my database. everything else deletes fine. <?php function allSong(){ $query = "SELECT * FROM tra_artist_song WHERE artist_id='{$this->id}'"; $result = $this->db->query($query); while($delSong = $this->db->fetch_array($result)){ if(unlink('../music/song/'.basename($delSong['song_path']))){ $this->display['allsong'] = 'song '.basename($delSong['song_path'])." deleted <br />"; }else{ $this->display['allsong'] = "There was a problem deleting the music files for this artist<br />"; } } /**************THIS PART IS NOT WORKING.*********************************************/ $query2 = "DELETE FROM tra_artist_song WHERE artist_id='{$this->id}''"; $this->db->query($query2); /********************************************************************************/ } function allPhoto(){ $query = "SELECT * FROM tra_artist_photo WHERE artist_id='{$this->id}'"; $result = $this->db->query($query); while($delSong = $this->db->fetch_array($result)){ if(unlink('../music/image/'.basename($delSong['image_path']))){ $this->display['allphoto'] = 'image '.basename($delSong['image_path'])." deleted <br />"; unlink('../music/image/'.basename($delSong['thumb_path'])); }else{ $this->display['allphoto'] = "There was a problem deleting the photo files for this artist<br />"; } } $query2 = "DELETE FROM tra_artist_photo WHERE artist_id='{$this->id}''"; $this->db->query($query2); } ?> Link to comment https://forums.phpfreaks.com/topic/72225-solved-class-help/ Share on other sites More sharing options...
teng84 Posted October 7, 2007 Share Posted October 7, 2007 hmm echo your query first to see if you have a value for id check your connection i dont know where here $this->db->query($query2); your connection lies tyr to vardump your connection to see wheter your connecting the right db or try to remove '' in your artist_id='{$this->id}' if your field is int not sure about this but i guess sometimes it affects your codes treating string as int or vise versa Link to comment https://forums.phpfreaks.com/topic/72225-solved-class-help/#findComment-364191 Share on other sites More sharing options...
corillo181 Posted October 7, 2007 Author Share Posted October 7, 2007 everything was right i just needed to remove a extra ' i had in the query. Link to comment https://forums.phpfreaks.com/topic/72225-solved-class-help/#findComment-364192 Share on other sites More sharing options...
teng84 Posted October 7, 2007 Share Posted October 7, 2007 Link to comment https://forums.phpfreaks.com/topic/72225-solved-class-help/#findComment-364193 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.