PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
The following (abbreviated) code used to work before register globals was turned off, now it doesn't. Actually the update part works, the delete part doesn't. I've gone through a ton of code and was able to fix everything but this.
The while loop justs pulls the links from the db and displays them. I pass the variable $task=delete_link in the querystring to invoke the top block of code. Simple stuff, but not working after upgrading to 4.2
With register globals off, you need to write query string vars like $task in this way: $_GET['task']
So replace:
if($task == 'delete_link')
with..
if($_GET['task'] == 'delete_link')
Also, where does $linkid come from? If it's in the global scope you can get it into a function scope with $GLOBALS['linkid']. I don't know the rest of your code though - that might not be necessary.
I read the sticky posts and it didn't help. There were a ton of things broken when I first upgraded and I've got them all addressed, its just this one thing. I don't know if I need to sleep on it or what, but It's not registering.
$sql = "DELETE FROM links WHERE linkid='".$_GET['linkid']."'";
I half-remember being advised always to enclose column vars in single quotes (even numerical input) for security reasons. Think it's something to do with query injection ie forcing mysql to treat the item as a string so that any ";" are neutralised.
I guess the (int) cast achieves much the same thing though - just thought I'd mention another option.