Undefined variable: QUERY_STRING & PHP_SELF in

Asked

Viewed 149 times

0

Gave this error in the script I’m trying to install:

Notice: Undefined variable: QUERY_STRING in /home/j38egopi/public_html/banner/ad_install.php on line 8

Notice: Undefined variable: PHP_SELF in /home/j38egopi/public_html/banner/ad_install.php on line 9

That are those lines:

$action=$QUERY_STRING;
$pagename=$PHP_SELF;

Code:

<?php
ini_set('display_errors',1);
ini_set('display_startup_erros',1);
error_reporting(E_ALL);

require "ad_inc.php";

$action=$QUERY_STRING;
$pagename=$PHP_SELF;

/* make connection to database */
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");
@mysql_select_db( "$dbName") or die( "Unable to select database");

head();
if($action == 'create_new'):
$create= "CREATE TABLE $table (id TINYINT not null AUTO_INCREMENT, zone VARCHAR (50) not null , image_url VARCHAR (200) not null , url VARCHAR (200) not null , displays_life VARCHAR (20) DEFAULT '0' not null , displays_day VARCHAR (20) DEFAULT '0' not null , clicks_life VARCHAR (20) DEFAULT '0' not null , clicks_day VARCHAR (20) DEFAULT '0' not null , dat_type VARCHAR (15) not null , html BLOB not null , PRIMARY KEY (id)) ";
$exec = MYSQL_QUERY($create);
 if($exec == 1):
 print "A tabela foi criada e deve estar funcionando corretamente no Mysql!. Vá em | ad_admin.php | agora para administrar o sistema";
 else:
 print "Algo deu errado! Talvez a tabela já exista. Ou Talvez o Username/Password esteja errado. Tente novamente";
 endif;

elseif($action == 'upgrade'):
$create= "ALTER TABLE $table ADD dat_type VARCHAR (15) not null , ADD html BLOB not null";
$exec = MYSQL_QUERY($create);
 if($exec == 1):
 print "Tabela criada, tudo deve estar funcionando corretamente!";
 else:
 print "Algo deu errado! Tente novamente";
 endif;
else:
print "<center>";
print "Escolha uma das opções abaixo:<br><br>";
print "<a href=\"$pagename?upgrade\">Upgrade para versão .7.*</a><br>";
print "<a href=\"$pagename?create_new\">Instalar agora</a><br><br>";
print "</center>";
endif;
foot();
MYSQL_CLOSE();
?>

1 answer

4

These variables are not declared in the script you posted, and by the error are also not in the ad_inc.php that is being included.

It seems that the script depends on the register_globals activated - which is highly contraindicated.

These variables are actually key in the superglobal $_SERVER. So a quick solution would be to replace these lines with:

$action = $_SERVER['QUERY_STRING'];
$pagename = $_SERVER['PHP_SELF'];

However, if there are more things that depend on the register_globals, the script can break at another point...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.