Nicholas Posted March 11, 2010 Share Posted March 11, 2010 can someone help me please cant figure it out lol. staff_logs.php action function case 'mail_del': mail_del(); break; the function function mail_del() { global $db,$ir,$c,$userid,$h; if($ir['user_level'] > 2) { die("404"); } $q=$db->query("SELECT * FROM mail WHERE mail_id={$_GET['mail_id']}"); if(!$db->num_rows($q)) { print "Error, either this message does not exist, or it had already been deleted. [url='staff_logs.php?action=maillogs']Go Back[/url]"; $h->endpage(); exit; } $db->query("DELETE FROM mail WHERE mail_id={$_GET['ID']}"); print "Message deleted [url='staff_logs.php?action=maillogs']Go Back[/url]"; } the link [[url='staff_logs.php?action=mail_del&mail_id={$r[']Delete MSG[/url]] not quite sure if ive got the link correct or not, but the function is getting on my nerves lol, cant figure it out... i get this... Query was SELECT * FROM mail WHERE mail_id= meaning.... {$_GET['ID']} is wrong but idk what to change it too... ive tried... {$_GET['ID']} {$_GET['mail_id']} all i can think of... can someone help please? Quote Link to comment Share on other sites More sharing options...
Jordan Palmer Posted March 11, 2010 Share Posted March 11, 2010 Do you define the GET? Is the link correct? Quote Link to comment Share on other sites More sharing options...
Djkanna Posted March 11, 2010 Share Posted March 11, 2010 Try checking if "$r['mail_id']" that's right.. Quote Link to comment Share on other sites More sharing options...
Nicholas Posted March 11, 2010 Author Share Posted March 11, 2010 Try checking if "$r['mail_id']" that's right.. i think ive already tried $q=$db->query("SELECT * FROM mail WHERE mail_id={$r['mail_id']}"); i dont think it worked... Do you define the GET? Is the link correct? i did say im not sure if the links correct lol. Quote Link to comment Share on other sites More sharing options...
Analog Posted March 12, 2010 Share Posted March 12, 2010 add this to check if you set the get? if(!$_GET['mail_id']) { print "Error: No variable set"; exit; } If that stops your code, then the problem is that the link is not passing the variable on to the next function. So you would need to be looking at how the link is built in the view function. Quote Link to comment Share on other sites More sharing options...
Nicholas Posted March 12, 2010 Author Share Posted March 12, 2010 add this to check if you set the get? if(!$_GET['mail_id']) { print "Error: No variable set"; exit; } If that stops your code, then the problem is that the link is not passing the variable on to the next function. So you would need to be looking at how the link is built in the view function. omg how did i not think of that... how simple, it works now... thanks mate... Quote Link to comment Share on other sites More sharing options...
CrazyT Posted March 13, 2010 Share Posted March 13, 2010 ugh what can be so hard? $id = isset($_GET['id']) && is_string($_GET['id']) && preg_match("/^\d+$/ims", $_GET['id']) ? $_GET['id'] : null; if (is_null($id)) echo "<p class='error'>This is an invalid id.</p>"; else { $sql = $db->query("SELECT `blah`, `blah`, `blah` FROM `table` WHERE `id` = ". $id); ////so hard? # Do you script.. What can be so hard!? } Quote Link to comment Share on other sites More sharing options...
Djkanna Posted March 13, 2010 Share Posted March 13, 2010 Man that was hard to follow LazyT.. I've just realised the my post didn't come how I wanted it nor does it make sense -.- Quote Link to comment Share on other sites More sharing options...
Zero-Affect Posted March 15, 2010 Share Posted March 15, 2010 $id = isset($_GET['id']) && is_string($_GET['id']) && preg_match("/^\d+$/ims", $_GET['id']) ? $_GET['id'] : null; would it not be $id = ( isset($_GET['id']) AND ctype_digit($_GET['id']) ) ? $_GET['id'] : 0 ; and then maybe instead of is_null() use empty() I don't really see the point in the preg_match but if you care to explain... 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.