The problem is that the required file is not part of the class. You
have set $user,$pass,$db as global variables which are out of scope of
the class variables.

What I would do is create a new class with a constructor that connects
to the DB. Then include that class and make a new variable instance of
that class.


--- In flexcoders@yahoogroups.com, "timgerr" <tgallag...@...> wrote:
>
> Hello all, I have started using stored procedures for my MySql queries
> so to call the stored procedures I use mysqli.  The problem is that I
> have a class and one of my public methods calls private methods to do
> the work.  Here is what I mean.
> Class Tree{
>       var $mysqli;
>       var $finalArry;
>       var $collectArry;
>       var $dUName;
>       var $dPWord;
>       var $dHost;
>       var $dDB;
>       public function Tree()
>       {
>               $this->finalArry = array();
>               $this->collectArry = array();
>       }
> public function MasterCall(SB $obj)
>       {
>               switch($obj->call){
>                       case "BuildTreeStructure":
>                               $called = $this->BuildTreeStructure($obj);
>                               break;
>                       case "AddNewNode":
>                               $called = $this->AddNewNode($obj);
>                               break;  
>               }
>               return $called;
>       }
> 
> private function AddNewNode($obj)
>       {       
>               /* Calling the SQL stored procedure AddNodeSP                   
>                                                                         */
>               $mysqli = new mysqli('localhost', 'root', '', 'MeDatabase');
>           if (mysqli_connect_errno(  )) {
>                       printf("Connect failed: %s\n", mysqli_connect_error(  
> ));
>                       exit (  );
>           } else {
> //                    printf("Connect succeeded\n");
>           }
>               $sql = "CALL
> AddNodeSP('$obj->parentCBSid','$obj->rootCBSid','$obj->newNode')";
>               $mysqli->query($sql);
>               
>               if ($mysqli->errno) {
>               die("Execution failed: ".$mysqli->errno.": ".$mysqli->error);
>               }
>               $getTree = $this->BuildTreeStructure($obj);
>               return $getTree;
>       }
>       
> }
> Class SB {
>       var $parentCBSid;
>       var $rootCBSid;
>       var $newNode;
>       var $call;
>       var $user;
>       var $pass;
>       var $host;
>       var $db;
> }
> 
> so in my AddNewNode method I have a mysqli connection :
> $mysqli = new mysqli('localhost', 'root', '', 'MeDatabase');
> 
> I dont want to have to add this line everytime I do this because if I
> have to change my password.  SO I created a password file and did an
> include:
> In the AddNewNode method I do this
> require_once('PasswordFile.php');
> $mysqli = new mysqli('localhost',$user,$pass,$db);
> 
> 
> When I run this script from a webpage (remember I am using this as a
> service from Webord) It works fine.  When I run my flex app, I get an
> error in charles :
> <b>Warning</b>:  mysqli::mysqli() [<a
> href='function.mysqli-mysqli'>function.mysqli-mysqli</a>]:
> (28000/1045): Access denied for user 'ODBC'@'localhost' (using
> password: NO) in
> <b>C:\xampp\htdocs\weborb\Services\com\ArrayTree\Tree.php</b> on line
> <b>100</b><br />
> Connect failed: Access denied for user 'ODBC'@'localhost' (using
> password: NO)
> 
> Anyone know how I can use a password file with Weborb, mysqli, and Flex?
> 
> Thanks for the read,
> timgerr
>


Reply via email to