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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.