You are here: mysqli connections and oop « PHP Programming Language « IT news, forums, messages
mysqli connections and oop

Posted by Schmidty on 01/24/07 00:38

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 class

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация