kernelgpf Posted January 23, 2007 Share Posted January 23, 2007 I'm trying to make it so people can remove friends from their friendlist, but the query won't work. Both variables are set, query works if I put it in the SQL box in phpmyadmin.. here's my code.[code]<?phpinclude "header.php"; //DB connectionif($_GET['action'] == "removefriend"){$pid=$_GET['playerid'];mysql_query("DELETE FROM `friendslist` WHERE `playerid`='$pid' AND `friendof`='$sid'");echo "$sql";print "<p>Successfully removed friend.<p>";}$query=mysql_query("select playerid,note,friendid from friendslist where friendof='$sid'");$num=mysql_num_rows($query);if($num == "0"){print "No friends? What a shame. Get out there a socialize!";include "footer.php";exit;}else{print "You have <b>$num</b> friends.<p>";}print "<table border=2><th width=100>Friend</th><th width=300>Note</th><th width=200>Remove?</th>";for($i=0;$i<$num;$i++){$row=mysql_fetch_array($query);$query2=mysql_query("select basicname from users where id='$row[playerid]'");$row2=mysql_fetch_array($query2);print "<tr><td class=tstyle3><a href='/userprofiles.php?id=$row[playerid]'>$row2[basicname]</a></td><td class=tstyle3>$row[note]</td><td class=tstyle3> <a href='friendlist.php?action=removefriend&playerid=$row[friendid]'>[x] remove</a></td></tr>";}include "footer.php";?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/ Share on other sites More sharing options...
trq Posted January 23, 2007 Share Posted January 23, 2007 What does....[code=php:0]mysql_query("DELETE FROM `friendslist` WHERE `playerid`='$pid' AND `friendof`='$sid'") or die(mysql_error());[/code]produce? Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167220 Share on other sites More sharing options...
HuggieBear Posted January 23, 2007 Share Posted January 23, 2007 You aren't defining $sid anywhere.You have $pid defined ok, but not $sid.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167227 Share on other sites More sharing options...
kernelgpf Posted January 23, 2007 Author Share Posted January 23, 2007 $sid is defined, it's a session variable set in header.php. And the mysql_error() doesn't put out anything.I've printed both $pid and $sid to make sure they work- they do. Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167242 Share on other sites More sharing options...
simcoweb Posted January 23, 2007 Share Posted January 23, 2007 Ok, where is the session variable being transferred to? There's no mention of a session_start(); in the posted. code. Is it in the header file? Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167248 Share on other sites More sharing options...
kernelgpf Posted January 23, 2007 Author Share Posted January 23, 2007 Yeah, in the header.php file. Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167251 Share on other sites More sharing options...
simcoweb Posted January 23, 2007 Share Posted January 23, 2007 Can we see it, pretty please? ;) Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167261 Share on other sites More sharing options...
trq Posted January 23, 2007 Share Posted January 23, 2007 Can we try this?[code=php:0]$sql = "DELETE FROM `friendslist` WHERE `playerid`='$pid' AND `friendof`='$sid'"// mysql_query($sql);die($sql);[/code]What does this produce? Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167264 Share on other sites More sharing options...
kernelgpf Posted January 23, 2007 Author Share Posted January 23, 2007 thorpe> "DELETE FROM `friendslist` WHERE `playerid`='29' AND `friendof`='7'" Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167272 Share on other sites More sharing options...
HuggieBear Posted January 23, 2007 Share Posted January 23, 2007 If your passing integers then there's no need for the single quotes.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167274 Share on other sites More sharing options...
kernelgpf Posted January 23, 2007 Author Share Posted January 23, 2007 ..okay, but I took them away and my query still isn't working. =/ Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167281 Share on other sites More sharing options...
kernelgpf Posted January 23, 2007 Author Share Posted January 23, 2007 I figured out the problem. Thanks guys. ^^ Quote Link to comment https://forums.phpfreaks.com/topic/35379-solved-delete-query-not-working-though/#findComment-167287 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.