Problem with my PHP code

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!

Moderator: General Moderators

Locked
vram
Forum Newbie
Posts: 9
Joined: Tue Apr 08, 2003 3:58 am

Problem with my PHP code

Post by vram »

Hi friends
I created a webpage thru which i executed Db2 commands using
System function available in PHP.I created an instance which i set it to the
environment variable .Now when i try to create a sample Database i get the
error "SYSTEM" does not have the authority to perform the requested
command".I am able to do all these functions thru normal DB2CLP but unable
to achieve these tasks thru webpage.Can anyone help me to solve this
problem at the earliest?I have attached the code below which could be helpful for u to find
a solution.Thanx in advance.bye
Thanks and regards
Sriram

<?php //Start of PHP
session_start(); //Staring a SESSION
$_SESSION['instance']=$_POST[instance];
$_SESSION['Login']=$_POST[Login];
$_SESSION['pwd']=$_POST[pwd];
$instance=$_SESSION['instance'];
$Login=$_SESSION['Login'];
$pwd=$_SESSION['pwd'];

$instance contains the instance name obtained from the previous page in a
form
//ly $login and $pwd contains the domain username and password

system('db2stop'); //Stopping the current instance if any

$ins="db2icrt ".$instance; Eg Instance name is:::"newinst"
system($ins); //Executing $ins

echo "<BR>Instance ($instance) created succseefully";
prints::Instance (newinst) created succseefully

putenv("db2instance=$instance"); Setting the current instance to env
variable

system('db2cmd /c /w /i db2 get instance');
Prints ::The current database manager instance is: NEWINST

$att="db2cmd /c /w /i db2 attach to ".$instance." USER ".$Login." USING
".$pwd; //Attach the instance
system($att);

system('db2start');
Prints::
SQL5043N Support for one or more communications protocols failed to start
successfully. However, core database manager functionality started
successfully.

system('db2sampl');
Prints::
SQL1092N "SYSTEM" does not have the authority to perform the requested
command

//I need to create sample db only .My prj works around this databse

session_write_close();


?> //End of PHP
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

please see also:
viewtopic.php?p=36207
viewtopic.php?p=36029

Opening new threads on exactly the same topic does more harm than good.
The worst is you might receive the same (not working) tips because someone didn't read the previous ones.
Locked