Branden Wagner Posted October 22, 2007 Share Posted October 22, 2007 include("task.class.php"); $task = new Task; if(isset($_POST['name'])) { $task->addTask($_POST['name']); } ... No matter what the addTask function will execute. The problem is it is putting it into a DB, so i endup with a bunch of blank entries with nothing but a timestamp everytime the page is visited. Quote Link to comment https://forums.phpfreaks.com/topic/74265-solved-whats-wrong-here-oop/ Share on other sites More sharing options...
teng84 Posted October 22, 2007 Share Posted October 22, 2007 BE SPECIFIC hmm if the prob is in that function( addTask )paste that here Quote Link to comment https://forums.phpfreaks.com/topic/74265-solved-whats-wrong-here-oop/#findComment-375206 Share on other sites More sharing options...
Branden Wagner Posted October 22, 2007 Author Share Posted October 22, 2007 the problem is the the function gets run no matter what. whether or not $_POST['name'] is set. the function works just fine.. but heres the code. mysql_connect(); mysql_query("insert into $todo values($_POST['name'])"); the problem isnt with the function itself.. its with the IF statement.. or something. because the function SHOULDNT get executed at. Quote Link to comment https://forums.phpfreaks.com/topic/74265-solved-whats-wrong-here-oop/#findComment-375208 Share on other sites More sharing options...
teng84 Posted October 22, 2007 Share Posted October 22, 2007 DEBUG ! try your condition if(isset($_POST['name'])) { echo $_POST['name'].'test'; $task->addTask($_POST['name']); } see if the function is executed even if the echo $_POST['name'].'test'; is not printed or paste here the value for that Quote Link to comment https://forums.phpfreaks.com/topic/74265-solved-whats-wrong-here-oop/#findComment-375209 Share on other sites More sharing options...
Branden Wagner Posted October 22, 2007 Author Share Posted October 22, 2007 ok i tried that and i just echoed the $_POST['name']."test" and that worked as it should! if name was set it print, if not i got just test but either way the addTask function still got executed. Quote Link to comment https://forums.phpfreaks.com/topic/74265-solved-whats-wrong-here-oop/#findComment-375210 Share on other sites More sharing options...
teng84 Posted October 22, 2007 Share Posted October 22, 2007 are you saying either way satisfy your condition ? Quote Link to comment https://forums.phpfreaks.com/topic/74265-solved-whats-wrong-here-oop/#findComment-375212 Share on other sites More sharing options...
Branden Wagner Posted October 22, 2007 Author Share Posted October 22, 2007 im saying that it doesnt matter if $_POST['name'] is set $task->addTask gets executed while everything else inside the condition works the way it should. Quote Link to comment https://forums.phpfreaks.com/topic/74265-solved-whats-wrong-here-oop/#findComment-375213 Share on other sites More sharing options...
Branden Wagner Posted October 22, 2007 Author Share Posted October 22, 2007 FIXED IT! .................. i reboot .............. Quote Link to comment https://forums.phpfreaks.com/topic/74265-solved-whats-wrong-here-oop/#findComment-375215 Share on other sites More sharing options...
teng84 Posted October 22, 2007 Share Posted October 22, 2007 nahh i have written long explanation Quote Link to comment https://forums.phpfreaks.com/topic/74265-solved-whats-wrong-here-oop/#findComment-375216 Share on other sites More sharing options...
Branden Wagner Posted October 22, 2007 Author Share Posted October 22, 2007 lol sorry, next time i wont reboot? Quote Link to comment https://forums.phpfreaks.com/topic/74265-solved-whats-wrong-here-oop/#findComment-375219 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.