unistake Posted July 20, 2010 Share Posted July 20, 2010 Hi all, I have been trying to create a very simple php script to delete a users account however it doesnt appear to be that simple! The $_SESSION[logname] is correct as it echos when asked for. <?php session_start(); if (@$_SESSION['auth']!="yes") { header("Location:signin-redirect.php?page=my-account.php"); } else { include("../cxnconnection.php"); mysql_query("DROP FROM Members WHERE email='$_SESSION[logname]'") or die ("Cant delete Member where email is $_SESSION[logname]"); session_destroy(); unset($_SESSION); header("Location:../index.html"); } ?> Thanks for your help Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 20, 2010 Share Posted July 20, 2010 If you want to DELETE use DELETE. DROP is for removing the table entirely (data and structure) and, fortunately for you, has different syntax. Quote Link to comment Share on other sites More sharing options...
unistake Posted July 20, 2010 Author Share Posted July 20, 2010 Thanks for your reply Mchl, I have just changed the above script from mysql_query("DROP FROM Members WHERE email='$_SESSION[logname]'") to mysql_query("DELETE FROM Members WHERE email='$_SESSION[logname]'") I believe this is right but it is not working, do you know whats up with it? Quote Link to comment Share on other sites More sharing options...
Mchl Posted July 20, 2010 Share Posted July 20, 2010 Use mysql_error to display any errors mysql might have sent. Quote Link to comment Share on other sites More sharing options...
waynew Posted July 20, 2010 Share Posted July 20, 2010 mysql_query("DELETE FROM Members WHERE email='".$_SESSION['logname']."'"); ...will probably work. Quote Link to comment Share on other sites More sharing options...
unistake Posted July 21, 2010 Author Share Posted July 21, 2010 Still not working, my full code now is... <?php session_start(); if (@$_SESSION['auth']!="yes") { header("Location:signin-redirect.php?page=my-account.php"); } else { include("../cxnconnection.php"); mysql_query("DELETE FROM Members WHERE email='".$_SESSION['logname']."'") or die ("Cant delete Member where email is $_SESSION[logname]"); session_destroy(); unset($_SESSION); header("Location:../index.html"); } ?> Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 21, 2010 Share Posted July 21, 2010 Have you checked yourself if the value in $_SESSION['logname'] actually matches an email address in your table? Quote Link to comment Share on other sites More sharing options...
unistake Posted July 21, 2010 Author Share Posted July 21, 2010 yes it echoes here also or die ("Cant delete Member where email is $_SESSION[logname]"); I use the same logname to login and would not be allowed on to this php page otherwise. Thanks for the idea though! Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 21, 2010 Share Posted July 21, 2010 Mchl, suggested in his post in this thread to use mysql_error() to find out why the query is failing. Did you do that? Quote Link to comment Share on other sites More sharing options...
unistake Posted July 21, 2010 Author Share Posted July 21, 2010 it is just a blank screen. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted July 21, 2010 Share Posted July 21, 2010 You probably introduced a fatal parse error when you added the code incorrectly. Are you developing and debugging your code on a system with error_reporting set to E_ALL and display_errors set to ON in your master php.ini so that all the errors php detects will be reported and displayed? You will save a ton of time. Quote Link to comment Share on other sites More sharing options...
unistake Posted July 21, 2010 Author Share Posted July 21, 2010 Hi PFMaBiSmAd, I am trying to make a website on the go, I have made a few sites with php before but am struggling with this code. I wouldnt know how to check the above! Sounds like thats just what i need. how do i check my php.ini? 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.