View Single Post
Old 09-08-2021, 08:47 AM  
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,078
Quote:
Originally Posted by zijlstravideo View Post
Lol, it's always those small things that mess things up. I once wasted an entire day because I had a white space in the $dbpass = "pass ";

By the way, I think you can even shorten this:

$id=0;
if ( ! isset($_GET['id'] ) )
{
header('Location: index.php');
}
else
{
$id=intval($_GET['id']);
}
if($id==0)
{
die('bad id passed in');
}

Into:

$id=intval($_GET['id']);
if($id==0)
{
header( "Location: index.php" ); //or any other page like 404
exit;
}

As intval will also output 0 if $id is empty.
Yep, that would work.

I tend to, when trying to do code 101 stuff use old old school. First step intialize variable to default value then use it.

But yeah you are initializing it to whatever comes into the get if it is a valid int or zero if not so it does the same thing in a couple of less words.

.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote