Jessica Posted August 29, 2007 Share Posted August 29, 2007 To turn on error reporting: ini_set('display_errors', 1); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/66586-solved-problem-deleting/page/2/#findComment-336844 Share on other sites More sharing options...
amylou Posted August 29, 2007 Author Share Posted August 29, 2007 i did that and the error is that i have undefined variables last=$last and first=$first. how would I define the variables in the delete code thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/66586-solved-problem-deleting/page/2/#findComment-336849 Share on other sites More sharing options...
Jessica Posted August 29, 2007 Share Posted August 29, 2007 Where are they coming from? last=$last doesn't make any sense. Are you saying it says undefined variable, or undefined index? Post the ACTUAL error and the lines of code it refers to. Quote Link to comment https://forums.phpfreaks.com/topic/66586-solved-problem-deleting/page/2/#findComment-336855 Share on other sites More sharing options...
amylou Posted August 29, 2007 Author Share Posted August 29, 2007 that is the error i am getting Notice: Undefined variable: last in C:\apache2triad\htdocs\index.php on line 14 Notice: Undefined variable: first in C:\apache2triad\htdocs\index.php on line 14 this is the line of code $query ="DELETE FROM timeoff WHERE last = '$last' AND first = '$first' "; Quote Link to comment https://forums.phpfreaks.com/topic/66586-solved-problem-deleting/page/2/#findComment-336858 Share on other sites More sharing options...
Jessica Posted August 29, 2007 Share Posted August 29, 2007 So where is $last defined? You're obviously not setting it, so where is it supposed to come from? Is it in the URL (use $_GET['last']). Is it posted? Use $_POST. Session? use $_SESSION. Otherwise, it's made up and has no use Quote Link to comment https://forums.phpfreaks.com/topic/66586-solved-problem-deleting/page/2/#findComment-336859 Share on other sites More sharing options...
amylou Posted August 29, 2007 Author Share Posted August 29, 2007 the program lets a person go to a form input first and last name click submit and the results are shown with their name , date, adn a check box after the last checkbox there is a link for delteing not sure how i would validate them in this code. if($_GET['m'] == 'del' ) { $requestId = $_GET['id']; $query ="DELETE FROM timeoff WHERE last = '$last' AND first = '$first' "; $result= mysql_query($query) or die(mysql_error()); Quote Link to comment https://forums.phpfreaks.com/topic/66586-solved-problem-deleting/page/2/#findComment-336871 Share on other sites More sharing options...
Jessica Posted August 29, 2007 Share Posted August 29, 2007 So $last needs to be defined by: $last = $_POST['last']; Also, you need to validate it. If someone puts in "O'Hara" it could break your code. It's open to SQL injection and a bunch of other stuff. Quote Link to comment https://forums.phpfreaks.com/topic/66586-solved-problem-deleting/page/2/#findComment-336890 Share on other sites More sharing options...
amylou Posted August 29, 2007 Author Share Posted August 29, 2007 Notice: Undefined index: last in C:\apache2triad\htdocs\index.php on line 13 Notice: Undefined index: first in C:\apache2triad\htdocs\index.php on line 14 the line of code that it goes to is the $last=$_POST['last']; $first=$_POST['first'] maybe i did not put it in the right spot i put it before the if statement Quote Link to comment https://forums.phpfreaks.com/topic/66586-solved-problem-deleting/page/2/#findComment-336895 Share on other sites More sharing options...
Jessica Posted August 29, 2007 Share Posted August 29, 2007 It sounds like nothing is being posted for those fields. Quote Link to comment https://forums.phpfreaks.com/topic/66586-solved-problem-deleting/page/2/#findComment-336944 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.