Helpful Information
 
 
Category: Programming Articles
phpinclude tip (for running queries)

the main problem with phpinclude is running queries, it runs them on every page, even if they're not needed...

using the following you can make it so tey're only ran on certain files:

if ($PHP_SELF == "/full/files/path/and/file/name/and.extension") {
$DB_site->query("YOU\'RE QUERY HERE");
}


obviously you have to replace a few things (like the file path)

hope it helps some of you ;):D

You need to use == or that will return true every time. Also $PHP_SELF is depreicated. Finally this is easier:

if (strpos($_SERVER['PHP_SELF'], "filename.php") != false))
{
dowhatever();
}

Or use PAPI if you want to be really simple.

You need to use == or that will return true every time.
i always forget that for some reason...

Finally this is easier:

if (strpos($_SERVER['PHP_SELF'], "filename.php" ) != false))
{
dowhatever();
}

I find it easier to use the full path, seeing as for me it's quite short

Or use PAPI if you want to be really simple.
I don't like PAPI, one of my other admins would probably delete all of it, and i just think it's too long...










privacy (GDPR)