Jump to content

[SOLVED] class help


corillo181

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.