lokie538 Posted December 31, 2008 Share Posted December 31, 2008 Hi, Ive never deleted a row out of a table before and it is not working for me hehe. Ive got too different codes with ive tried, the top one works in phpmyadmin but when inserted into the code it always dies. Does the 3rd query below need picid to be the index or primary key? If there a way too see what the actually error is? <?php include ("checkio.php"); $picid = "3"; /*$_GET['picid'];*/ $query = "SELECT * FROM images WHERE picid = '" . $picid . "'"; $result = mysqli_query($cxn,$query) or die ("Couldnt execute queryLOL1111132."); $row = mysqli_fetch_assoc($result); $query2 = "INSERT INTO `1300facepainting`.`deletedpic` (`picid`, `creatorid`, `title`, `sumo`, `sumiototal`, `type`) VALUES ('" . $row['picid'] . "', '" . $row['creatorid'] . "', '" . $row['title'] . "', '" . $row['sumo'] . "', '" . $row['sumiototal'] . "0', '" . $row['type'] . "')"; $result2 = mysqli_query($cxn,$query2) or die ("Couldnt execute queryLOL222."); //This is the code that phpmyadmin made and works when entered into the sql section in phpmyadmin $query4 = "DELETE FROM images WHERE picid = '" . $picid . "'"; $result4 = mysqli_query($cxn,$query4) or die ("Couldnt execute deleting fails ."); // Tried this aswell but no luck $query3 = "DELETE FROM '1300facepainting'.'images' WHERE 'images'.'picid' = '" . $row['picid'] . "' AND 'images'.'creatorid' = '" . $row['creatorid'] . "' AND 'images'.'title' = '" . $row['title'] . "' AND 'images'.'sumo' = '" . $row['sumo'] . "' AND 'images'.'sumiototal' = '" . $row['sumiototal'] . "' AND 'images'.'type' = '" . $row['type'] . "' LIMIT 1"; $result3 = mysqli_query($cxn,$query3) or die ("Couldnt execute deleting fails ."); echo "good"; ?> Thanks in advance Quote Link to comment Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 $query3 = "DELETE FROM `images` WHERE `picid` = '" . $row['picid'] . "' AND `creatorid` = '" . $row['creatorid'] . "' AND `title` = '" . $row['title'] . "' AND `sumo` = '" . $row['sumo'] . "' AND `sumiototal` = '" . $row['sumiototal'] . "' AND `type` = '" . $row['type'] . "' LIMIT 1"; That is alot of conditions for a delete, but to each there own. Your main problem was using ' instead of ` around table/column names. The above should work with less confusion. Quote Link to comment Share on other sites More sharing options...
lokie538 Posted December 31, 2008 Author Share Posted December 31, 2008 Ok ill give that code a go now I am basicly trying to move a row from one table to another....... is there an easier way? lol the structure on both the tables is exactly the same! Quote Link to comment Share on other sites More sharing options...
bluesoul Posted December 31, 2008 Share Posted December 31, 2008 Nixed the old comment about OOP, you can use or die(mysqli_error($link)); Quote Link to comment Share on other sites More sharing options...
lokie538 Posted December 31, 2008 Author Share Posted December 31, 2008 Nixed the old comment about OOP, you can use or die(mysqli_error($link)); Thanks, im getting "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''images' WHERE 'picid' = '3' AND 'creatorid' = 'JUDSPE' AND 'title' = 'MMosqito'' at line 1" as an error? Quote Link to comment Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 Yes, read above you are using ' (single quotes) to surround the column names. You need to use ` (back ticks) to surround column names, single quotes is for data only. Quote Link to comment Share on other sites More sharing options...
lokie538 Posted December 31, 2008 Author Share Posted December 31, 2008 Lol i knew it would be something simple but how do i type a back tick? hehe Happy new year btw Quote Link to comment Share on other sites More sharing options...
premiso Posted December 31, 2008 Share Posted December 31, 2008 Lol i knew it would be something simple but how do i type a back tick? hehe Happy new year btw The key to the left of the (1) that has ` and ~ on it. Quote Link to comment Share on other sites More sharing options...
bluesoul Posted December 31, 2008 Share Posted December 31, 2008 Alternately, you can copy and paste this one. ` Quote Link to comment Share on other sites More sharing options...
lokie538 Posted December 31, 2008 Author Share Posted December 31, 2008 found it!! Thanks for all your help guys!! Quote Link to comment Share on other sites More sharing options...
lokie538 Posted December 31, 2008 Author Share Posted December 31, 2008 Apreciate it!! Its working 100% now!! Quote Link to comment Share on other sites More sharing options...
bluesoul Posted December 31, 2008 Share Posted December 31, 2008 Apreciate it!! Its working 100% now!! Be sure and click solved in the bottom left corner. Quote Link to comment 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.