|
Posted by Schmidty on 01/24/07 06:21
So if I do a $_SERVER['PHP_SELF'] in a function within a class that
will end the execution of that class and restart the same script? Do I
need to do all processing in a script before I display a page that will
have a $_SERVER['PHP_SELF'] action? Thanks for the help...
Schmidty
On Jan 23, 4:54 pm, Jerry Stuckle <jstuck...@attglobal.net> wrote:
> Schmidty wrote:
> > If you do a page reload with $_SERVER['PHP_SELF'] will your program
> > lose a mysqli connection upon the reload of the page? Would this code
> > work? I need to know how to carry over a connection between methods as
> > I am new to OOP? Thanks...
>
> > Example; ========================================
> > <?php
> > // webpage
> > $newsignon = new newuser();
> > logon();
>
> > if (isset($_POST['submit'])){
> > $newsignon = query("SELECT name, password FROM
> > database");
> > }
> > ?>
> > <?php
> > // class newuser
>
> > class newuser {
> > public $name;
> > private $passwd;
> > private $mysqli;
>
> > function __construct(){
> > include('dbconn.php');
> > $mysqli = new mysqli($dbnet, $dbuser, $dbpass, $dbname);
> > if (mysqli_connect_errno()){ printf("Can't connect to MySQL
> > Server. Errorcode: %s\n", mysqli_connect_error());
> > exit;
> > }
> > $this->mysqli = $mysqli; // is this right?
> > } //end constructor
>
> > function query($query){
> > if ($result = $this->mysqli->real_query($query)){
> > $result = $this->mysqli->store_result();
> > if($this->mysqli->error) { echo "ERROR with mysqli stored procedure";}
> > } // end if
>
> > } // end function
>
> > function logon(){
> > echo "<form action='".$_POST['PHP_SELF']."' method='post' >";
> > // Would this work?
> > echo "<input type='text' name='user' /><br /><input
> > type='password' name='passwd' />";
> > echo "<input type='submit' value='submit' />";
>
> > } // end function
>
> > } //end classSchmidty,
>
> As I explained in comp.database.mysql, you can't. Once a page's
> processing is completed, all connections (and objects) are released.
>
> You can keep information like user ids, etc. in the $_SESSION variable,
> but not the connection. Even if you could keep the connection info in
> there, the connection itself will be closed.
>
> Each page is it's own little program. Any external resources opened by
> it are closed at the end of the page processing.
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstuck...@attglobal.net
> ==================
Navigation:
[Reply to this message]
|