Guest Drizzle Posted May 21, 2010 Posted May 21, 2010 For some reason, no matter what i do, if $_GET['cmd'] in the url = Delete, which is suppose to delete something, voids the function. However changing delete to delet,remove,del, etc. works fine. Anyone have any info on this? Quote
a_bertrand Posted May 21, 2010 Posted May 21, 2010 I think we would need more code to see what you are trying to do... Quote
Guest Drizzle Posted May 21, 2010 Posted May 21, 2010 switch($_GET['cmd']){ case 'Add': cmd_add(); break; case 'Edit': cmd_edit(); break; case 'Delete': cmd_delete(); break; } function cmd_add(){ //code } function cmd_edit(){ //code } function cmd_delete(){ //code } along the lines of that. I've done that format with the code and everything, and when the case = delete, it decides not to execute the delete switch. However, if its delet, del, remove, rm, etc. it works fine. I've checked for any problems that may have caused it. The code is fine, and it makes no sense that it isnt working. Also i do secure my code, but this is just a small example of what im trying to do, and i'm not going to worry about writing that down here. Quote
jon182 Posted May 21, 2010 Posted May 21, 2010 it could be that delete is a sort of "function" itself. I encountered the same problem but trying to use do im assuming it won't work for any words such as do, for, if, etc. Though im not positive as i don't know if delete is a "function" itself like do, or for. Quote
Danny696 Posted May 21, 2010 Posted May 21, 2010 Hm, how are you access the page, would it be like this; http://www.domain.com/page.php?cmd=delete Quote
Guest Drizzle Posted May 21, 2010 Posted May 21, 2010 Hm, how are you access the page, would it be like this; http://www.domain.com/page.php?cmd=delete Yes Quote
Zero-Affect Posted May 22, 2010 Posted May 22, 2010 if the function defined before hand? for example i can't use the function index in a sub file index.php?page=index&cmd=index (i might be wrong lol i just seem to remember having a issue with index). So if your using sub files like i do on CrimGame.com so index (in the page GET super global) is linked from like /modifications/files/index_page.php and the cmd=index is in there then that would be your issue. of if you define delete in some global file or header that could also be it. Considering delete() is shown as a function but actually isn't i wouldn't be worried about that. Quote
DigitalGerm Posted May 22, 2010 Posted May 22, 2010 I tested your code and it works fine. Try before switch statement a print_r($_GET); and a echo $_GET. I'm think the problem is not with the switch, try a lowercase exercise. Quote
Haunted Dawg Posted May 22, 2010 Posted May 22, 2010 http://www.php.net/manual/en/function.delete.php Try changing the case 'delete' to something else. Quote
DigitalGerm Posted May 22, 2010 Posted May 22, 2010 There's no function in php 5 that's called delete(); in php you can't call a function without "()" . javaScript can. Quote
Zero-Affect Posted May 22, 2010 Posted May 22, 2010 Considering delete() is shown as a function but actually isn't i wouldn't be worried about that.I kind of said it wasn't a function above Kyle. This is a dummy manual entry to satisfy those people who are looking for unlink() or unset() in the wrong place. (source: http://uk.php.net/manual/en/function.delete.php) Quote
Guest Drizzle Posted May 22, 2010 Posted May 22, 2010 if the function defined before hand? for example i can't use the function index in a sub file index.php?page=index&cmd=index (i might be wrong lol i just seem to remember having a issue with index). So if your using sub files like i do on CrimGame.com so index (in the page GET super global) is linked from like /modifications/files/index_page.php and the cmd=index is in there then that would be your issue. of if you define delete in some global file or header that could also be it. Considering delete() is shown as a function but actually isn't i wouldn't be worried about that. Nope it isnt using a sub. Just plain switch/case. and the function is defined Quote
Zero-Affect Posted May 22, 2010 Posted May 22, 2010 is it defined in another file like globals mainmenu smenu sglobals header global_func something like that? Quote
Spudinski Posted May 23, 2010 Posted May 23, 2010 Some technical data that may count.; Defining a string a literal 'string', may cause a problem with the case the word is defined as(CAPS or not). Try low-case names, it might just help. Quote
CrazyT Posted May 24, 2010 Posted May 24, 2010 There's other way's calling a function than switch you know? :) Quote
Spudinski Posted May 24, 2010 Posted May 24, 2010 If statements for the simplest. Another way, yet I don't want to admit that programmers use is also below; // if statement if ($foo == 'bar') fooFTW(); // "other" method $bar = array('blah', 'bleh', 'gah'); $getVar = (key_exists($foo, $bar)) ? $foo : null; $getVar(); // messy.. very Quote
CrazyT Posted May 24, 2010 Posted May 24, 2010 If statements for the simplest. Another way, yet I don't want to admit that programmers use is also below; // if statement if ($foo == 'bar') fooFTW(); // "other" method $bar = array('blah', 'bleh', 'gah'); $getVar = (key_exists($foo, $bar)) ? $foo : null; $getVar(); // messy.. very Yeah.. BTW key_exists() is no php function. :) - array_key_exists()/in_array(), use what ever. Quote
Jordan Palmer Posted May 24, 2010 Posted May 24, 2010 @Spud: Click Here  Then tell me you're script will work :) Quote
Jordan Palmer Posted May 24, 2010 Posted May 24, 2010 I'll be talking to Cb about you. **** Americans, Now I can see why there fat... Quote
sniko Posted May 24, 2010 Posted May 24, 2010 Fat americans is mainly a sterotype, not all americans are Quote
Zero-Affect Posted May 24, 2010 Posted May 24, 2010 What does that have to do with anything :-s Quote
Guest Posted May 24, 2010 Posted May 24, 2010 He has nothing to say now, aww! IDIOT, YOU LIKE MY SIGNATURE ON MY PROFILE? :D Quote
Guest Posted May 24, 2010 Posted May 24, 2010 LOL - Hes just being a idiot deleting every post, i can post faster than you deleting them. :D Quote
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.