Jump to content

Recommended Posts

After overcoming this-> error "Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in  this->  $myconnection = mysql_connect($server, $user, $pass);" by changing mysql_query to mysqli_query($con, $query), I started getting this specific error on line 106= $result = mysqli_query($myconnection, $query) or $this->debugAndDie($query);

 

Warning: mysqli_query() expects parameter 1 to be mysqli, null given on line 106=="$result = mysqli_query($myconnection, $query) or $this->debugAndDie($query);"

 

This header wont go, I tried $myconnection = mysql_connect($query); and it says expecting 2 parameters.

Please I'm open to ideas to solve this,

 

<snip - code is posted in next post>

Edited by mac_gyver
removed code not in code tags as the op posted it later
<?php
/** A PHP class to access MySQL database with convenient methods
* in an object oriented way, and with a powerful debug system.\n
* Licence: LGPL \n
* Web site: http://slaout.linux62.org/
* @version 1.0
* @author Sébastien Laoût (slaout@linux62.org)
*/
class DB
{
/** Put this variable to true if you want ALL queries to be debugged by default:
*/
var $defaultDebug = false;

/** INTERNAL: The start time, in miliseconds.
*/
var $mtStart;
/** INTERNAL: The number of executed queries.
*/
var $nbQueries;
/** INTERNAL: The last result ressource of a query().
*/
var $lastResult;

/** Connect to a MySQL database to be able to use the methods below.
*/
function DB($base, $server, $user, $pass)
{
$this->mtStart = $this->getMicroTime();
$this->nbQueries = 0;
$this->lastResult = NULL;
$myconnection = mysqli_connect($server, $user, $pass);
$myconnection = mysqli_select_db($myconnection,$base) ;

if ($myconnection==FALSE) {
$data='Database Connection is Not valid Please Enter The valid database connection';
header("location:install.php?msg=$data");
exit;

}
}

/** Query the database.
* @param $query The query.
* @param $debug If true, it output the query and the resulting table.
* @return The result of the query, to use with fetchNextObject().
*/
function query($query, $debug = -1)
{
$this->nbQueries++;
$this->lastResult = mysql_query($query) or $this->debugAndDie($query);

$this->debug($debug, $query, $this->lastResult);

return $this->lastResult;
}
/** Do the same as query() but do not return nor store result.\n
* Should be used for INSERT, UPDATE, DELETE...
* @param $query The query.
* @param $debug If true, it output the query and the resulting table.
*/
function execute($query, $debug = -1)
{
$this->nbQueries++;
mysql_query($query) or $this->debugAndDie($query);

$this->debug($debug, $query);
}
/** Convenient method for mysql_fetch_object().
* @param $result The ressource returned by query(). If NULL, the last result returned by query() will be used.
* @return An object representing a data row.
*/
function fetchNextObject($result = NULL)
{
if ($result == NULL)
$result = $this->lastResult;

if ($result == NULL || mysql_num_rows($result) < 1)
return NULL;
else
return mysql_fetch_object($result);
}
/** Get the number of rows of a query.
* @param $result The ressource returned by query(). If NULL, the last result returned by query() will be used.
* @return The number of rows of the query (0 or more).
*/
function numRows($result = NULL)
{
if ($result == NULL)
return mysql_num_rows($this->lastResult);
else
return mysql_num_rows($result);
}
/** Get the result of the query as an object. The query should return a unique row.\n
* Note: no need to add "LIMIT 1" at the end of your query because
* the method will add that (for optimisation purpose).
* @param $query The query.
* @param $debug If true, it output the query and the resulting row.
* @return An object representing a data row (or NULL if result is empty).
*/
function queryUniqueObject($query, $debug = -1)
{
$query = "$query LIMIT 1";

$this->nbQueries++;
$result = mysqli_query($myconnection, $query) or $this->debugAndDie($query);

$this->debug($debug, $query, $result);

return mysql_fetch_object($result);
}
/** Get the result of the query as value. The query should return a unique cell.\n
* Note: no need to add "LIMIT 1" at the end of your query because
* the method will add that (for optimisation purpose).
* @param $query The query.
* @param $debug If true, it output the query and the resulting value.
* @return A value representing a data cell (or NULL if result is empty).
*/
function queryUniqueValue($query, $debug = -1)
{
$query = "$query LIMIT 1";

$this->nbQueries++;
$result = mysql_query($query) or $this->debugAndDie($query);
$line = mysql_fetch_row($result);

$this->debug($debug, $query, $result);

return $line[0];
}
/** Get the maximum value of a column in a table, with a condition.
* @param $column The column where to compute the maximum.
* @param $table The table where to compute the maximum.
* @param $where The condition before to compute the maximum.
* @return The maximum value (or NULL if result is empty).
*/
function maxOf($column, $table, $where)
{
return $this->queryUniqueValue("SELECT MAX(`$column`) FROM `$table` WHERE $where");
}
/** Get the maximum value of a column in a table.
* @param $column The column where to compute the maximum.
* @param $table The table where to compute the maximum.
* @return The maximum value (or NULL if result is empty).
*/
function maxOfAll($column, $table)
{
return $this->queryUniqueValue("SELECT MAX(`$column`) FROM `$table`");
}
/** Get the count of rows in a table, with a condition.
* @param $table The table where to compute the number of rows.
* @param $where The condition before to compute the number or rows.
* @return The number of rows (0 or more).
*/
function countOf($table, $where)
{
return $this->queryUniqueValue("SELECT COUNT(*) FROM `$table` WHERE $where");
}
/** Get the count of rows in a table.
* @param $table The table where to compute the number of rows.
* @return The number of rows (0 or more).
*/
function countOfAll($table)
{
return $this->queryUniqueValue("SELECT COUNT(*) FROM `$table`");
}
/** Internal function to debug when MySQL encountered an error,
* even if debug is set to Off.
* @param $query The SQL query to echo before diying.
*/
function debugAndDie($query)
{
$this->debugQuery($query, "Error");
die("<p style=\"margin: 2px;\">".mysql_error()."</p></div>");
}
/** Internal function to debug a MySQL query.\n
* Show the query and output the resulting table if not NULL.
* @param $debug The parameter passed to query() functions. Can be boolean or -1 (default).
* @param $query The SQL query to debug.
* @param $result The resulting table of the query, if available.
*/
function debug($debug, $query, $result = NULL)
{
if ($debug === -1 && $this->defaultDebug === false)
return;
if ($debug === false)
return;

$reason = ($debug === -1 ? "Default Debug" : "Debug");
$this->debugQuery($query, $reason);
if ($result == NULL)
echo "<p style=\"margin: 2px;\">Number of affected rows: ".mysql_affected_rows()."</p></div>";
else
$this->debugResult($result);
}
/** Internal function to output a query for debug purpose.\n
* Should be followed by a call to debugResult() or an echo of "</div>".
* @param $query The SQL query to debug.
* @param $reason The reason why this function is called: "Default Debug", "Debug" or "Error".
*/
function debugQuery($query, $reason = "Debug")
{
$color = ($reason == "Error" ? "red" : "orange");
echo "<div style=\"border: solid $color 1px; margin: 2px;\">".
"<p style=\"margin: 0 0 2px 0; padding: 0; background-color: #DDF;\">".
"<strong style=\"padding: 0 3px; background-color: $color; color: white;\">$reason:</strong> ".
"<span style=\"font-family: monospace;\">".htmlentities($query)."</span></p>";
}
/** Internal function to output a table representing the result of a query, for debug purpose.\n
* Should be preceded by a call to debugQuery().
* @param $result The resulting table of the query.
*/
function debugResult($result)
{
echo "<table border=\"1\" style=\"margin: 2px;\">".
"<thead style=\"font-size: 80%\">";
$numFields = mysql_num_fields($result);
// BEGIN HEADER
$tables = array();
$nbTables = -1;
$lastTable = "";
$fields = array();
$nbFields = -1;
while ($column = mysql_fetch_field($result)) {
if ($column->table != $lastTable) {
$nbTables++;
$tables[$nbTables] = array("name" => $column->table, "count" => 1);
} else
$tables[$nbTables]["count"]++;
$lastTable = $column->table;
$nbFields++;
$fields[$nbFields] = $column->name;
}
for ($i = 0; $i <= $nbTables; $i++)
echo "<th colspan=".$tables[$i]["count"].">".$tables[$i]["name"]."</th>";
echo "</thead>";
echo "<thead style=\"font-size: 80%\">";
for ($i = 0; $i <= $nbFields; $i++)
echo "<th>".$fields[$i]."</th>";
echo "</thead>";
// END HEADER
while ($row = mysql_fetch_array($result)) {
echo "<tr>";
for ($i = 0; $i < $numFields; $i++)
echo "<td>".htmlentities($row[$i])."</td>";
echo "</tr>";
}
echo "</table></div>";
$this->resetFetch($result);
}
/** Get how many time the script took from the begin of this object.
* @return The script execution time in seconds since the
* creation of this object.
*/
function getExecTime()
{
return round(($this->getMicroTime() - $this->mtStart) * 1000) / 1000;
}
/** Get the number of queries executed from the begin of this object.
* @return The number of queries executed on the database server since the
* creation of this object.
*/
function getQueriesCount()
{
return $this->nbQueries;
}
/** Go back to the first element of the result line.
* @param $result The resssource returned by a query() function.
*/
function resetFetch($result)
{
if (mysql_num_rows($result) > 0)
mysql_data_seek($result, 0);
}
/** Get the id of the very last inserted row.
* @return The id of the very last inserted row (in any table).
*/
function lastInsertedId()
{
return mysql_insert_id();
}
/** Close the connexion with the database server.\n
* It's usually unneeded since PHP do it automatically at script end.
*/
function close()
{
mysql_close();
}

/** Internal method to get the current time.
* @return The current time in seconds with microseconds (in float format).
*/
function getMicroTime()
{
list($msec, $sec) = explode(' ', microtime());
return floor($sec / 1000) + $msec;
}
} // class DB
?>

Specifically, line 106 here.. Edited by mac_gyver
enable code line numbers

 

function queryUniqueObject($query, $debug = -1)
{
    $query = "$query LIMIT 1";

    $this->nbQueries++;
    $result = mysqli_query($myconnection, $query) or $this->debugAndDie($query);

    $this->debug($debug, $query, $result);

    return mysql_fetch_object($result);
}

 

The mysqli_query() function is executed within a function/method. The variable $myconnection is not defined inside that function - thus the failure. You can resolve the issue by making 'myconnection' a property of the class: $this->myconnection

 

Use that were you define the value and where you use it. Plus, declare it in the top of the class.

Your is so much coding for such a simple process.....

 

Anyway the problem is your class is not well thought out. In your query function where you try to execute a query, where is $myconnection defined? Hint: Not in that function.

@sycho, thanks for your effort, Im looking closely at your suggestion. To be more specific, the trouble spot is here:

function queryUniqueObject($query, $debug = -1)
    {
      $query = "$query LIMIT 1";

      $this->nbQueries++;
      $result = mysqli_query($myconnection, $query) or $this->debugAndDie($query);

      $this->debug($debug, $query, $result);

      return mysql_fetch_object($result);
    }

As ably described above, line 106 refers to "$result = mysqli_query($myconnection, $query) or $this->debugAndDie($query);". There's a possibility that $myconnection is not visible to the method. Well thought out Psycho.

 

Yea, @ginerjm, of cos its well thought out.Btw, $myconnection is defined @ the top of the class here:

 function DB($base, $server, $user, $pass)
    {
      $this->mtStart    = $this->getMicroTime();
      $this->nbQueries  = 0;
      $this->lastResult = NULL;
     $myconnection = mysqli_connect($server, $user, $pass);
     $myconnection =  mysqli_select_db($myconnection,$base)              ;
      
      if ($myconnection==FALSE) {
          $data='Database Connection is Not valid Please Enter The valid database connection';
   header("location:install.php?msg=$data");
    exit;
       
}
    }

@mac, sorry about the mix up, I stand corrected.

Your connection var is NOT defined at the top of your class, hence my comment. It is defined as a local var within your constructor and nowhere else, hence again why things aren't working.

 

Meanwhile, you still have a lot of code to correct to utilize the mysqlI_ extension instead of the old MySQL_ one. You can't mix the two you know.

ok now I think there's been a major improvement. The  error has cleared but one of the scripts is now giving out error saying

"$data="Database Configration is Not vaild";" between lines 120 and 122.

	<!-- MAIN CONTENT -->
	<div id="content">
	<?php
         if((isset($_POST['host']) and isset($_POST['username']) and $_POST['host']!="" and $_POST['username']!="") or (isset($_SESSION['host']) and isset($_SESSION['user'])))
        {
          
            if(isset($_SESSION['host'])){
            $host= $_SESSION['host'];
            $user=$_SESSION['user'];
            $pass=$_SESSION['pass'];
            }
               if(isset($_POST['host'])){
            $host=  trim($_POST['host']);
            $user= trim($_POST['username']);
            $pass= trim($_POST['password']);
             }
                        $link = mysqli_connect("$host","$user","$pass");
if (!$link) {
    $data="Database Configration is Not vaild";
      header("location:install.php?msg=$data");
      exit;
}

        ?>
		<form action="setup_page.php" method="POST" id="login-form" class="cmxform" autocomplete="off">
		
                    <fieldset  >
				<p> <?php 
				
				if(isset($_REQUEST['msg'])) {
					
					$msg=$_REQUEST['msg'];
					echo "<p style=color:red>$msg</p>";						
				}
				?>
				
				</p>
				<p>
                                    <?php 
                                    $con=mysqli_connect("$host","$user","$pass");
                            // Check connection
                                 $sql="CREATE DATABASE MY_p";
                                  if (mysqli_query($con,$sql)){
                                       $sql="DROP DATABASE MY_p";
                                 mysqli_query($con,$sql);
  
                                    ?>
                                    <input type="radio" value="1" name="select[]"  id="create" onClick="create_data()" >Create New DataBase
                                        <input type="text" id="name" class="round full-width-input" name="name" autofocus  />
				<?php 
                                  }else{
                                      ?>
                                          
                                        <input type="radio"  disabled="disabled"  >Create New DataBase
                                         <input type="text" disabled="disabled" class="round full-width-input" placeholder="No Permission To Create New Database" name="name" autofocus  /> 
                                          <?php
                                  }
                                  ?>
                                
                                
                                </p>
				<p>					
                                    <input type="radio" name="select[]" id="select" onClick="select_data()" >Select Created DataBase<br>
                                    <select name="select_box" class="round full-width-input" id="select_box" style="padding: 5px 10px 5px 10px; border: 1px solid #D9DBDD;">
                                    <?php 


$dbh = new PDO( "mysql:host=$host", $user, $pass );
$dbs = $dbh->query( 'SHOW DATABASES' );

while( ( $db = $dbs->fetchColumn( 0 ) ) !== false )
{
    echo "<option value=".$db." style=margin:10px 10px 10px 10px;><p >$db</p></option>";
}
                                       ?>
                                      </select> 
                                   
				</p>
                                <input type="hidden" name="host" value="<?php echo $host ?>">
				
                                <input type="hidden" name="username" value="<?php echo $user ?>">
                                <input type="hidden" name="password" value="<?php echo $pass ?>">
				
                                <br>
                                <input type="checkbox" name="dummy" value="1" >Add Demo Data
                              <br>
                              <br>
			
				
				<!--<a href="dashboard.php" class="button round blue image-right ic-right-arrow">LOG IN</a>-->
				<input type="submit" class="button round blue image-right ic-right-arrow" name="submit" value="INSTALL" />
			</fieldset>

		</form>
		
	</div> <!-- end content -->
	  <?php } ?>
	
	
	<!-- FOOTER -->
	<div id="footer">

Here's the corrected db.class.php:

<?php
  /** A PHP class to access MySQL database with convenient methods
    * in an object oriented way, and with a powerful debug system.\n
    * Licence:  LGPL \n
    * Web site: http://slaout.linux62.org/
    * @version  1.0
    * @author   Sébastien Laoût (slaout@linux62.org)
    */
  class DB
  {
    /** Put this variable to true if you want ALL queries to be debugged by default:
      */
    var $defaultDebug = false;

    /** INTERNAL: The start time, in miliseconds.
      */
    var $mtStart;
    /** INTERNAL: The number of executed queries.
      */
    var $nbQueries;
    /** INTERNAL: The last result ressource of a query().
      */
    var $lastResult;

    /** Connect to a MySQL database to be able to use the methods below.
      */
	  
	  var $myconnection;
    function DB($base, $server, $user, $pass)
    {
      $this->mtStart    = $this->getMicroTime();
      $this->nbQueries  = 0;
      $this->lastResult = NULL;
     $this->myconnection = mysqli_connect($server, $user, $pass);
     $this->myconnection =  mysqli_select_db($this->myconnection,$base)              ;
      
      if ($myconnection==FALSE) {
          $data='Database Connection is Not valid Please Enter The valid database connection';
   header("location:install.php?msg=$data");
    exit;
       
}
    }

    /** Query the database.
      * @param $query The query.
      * @param $debug If true, it output the query and the resulting table.
      * @return The result of the query, to use with fetchNextObject().
      */
    function query($query, $debug = -1)
    {
      $this->nbQueries++;
      $this->lastResult = mysql_query($query) or $this->debugAndDie($query);

      $this->debug($debug, $query, $this->lastResult);

      return $this->lastResult;
    }
    /** Do the same as query() but do not return nor store result.\n
      * Should be used for INSERT, UPDATE, DELETE...
      * @param $query The query.
      * @param $debug If true, it output the query and the resulting table.
      */
    function execute($query, $debug = -1)
    {
      $this->nbQueries++;
      mysql_query($query) or $this->debugAndDie($query);

      $this->debug($debug, $query);
    }
    /** Convenient method for mysql_fetch_object().
      * @param $result The ressource returned by query(). If NULL, the last result returned by query() will be used.
      * @return An object representing a data row.
      */
    function fetchNextObject($result = NULL)
    {
      if ($result == NULL)
        $result = $this->lastResult;

      if ($result == NULL || mysql_num_rows($result) < 1)
        return NULL;
      else
        return mysql_fetch_object($result);
    }
    /** Get the number of rows of a query.
      * @param $result The ressource returned by query(). If NULL, the last result returned by query() will be used.
      * @return The number of rows of the query (0 or more).
      */
    function numRows($result = NULL)
    {
      if ($result == NULL)
        return mysql_num_rows($this->lastResult);
      else
        return mysql_num_rows($result);
    }
    /** Get the result of the query as an object. The query should return a unique row.\n
      * Note: no need to add "LIMIT 1" at the end of your query because
      * the method will add that (for optimisation purpose).
      * @param $query The query.
      * @param $debug If true, it output the query and the resulting row.
      * @return An object representing a data row (or NULL if result is empty).
      */
    function queryUniqueObject($query, $debug = -1)
    {
      $query = "$query LIMIT 1";

      $this->nbQueries++;
      $result = mysqli_query($this->myconnection, $query) or $this->debugAndDie($query);

      $this->debug($debug, $query, $result);

      return mysql_fetch_object($result);
    }
    /** Get the result of the query as value. The query should return a unique cell.\n
      * Note: no need to add "LIMIT 1" at the end of your query because
      * the method will add that (for optimisation purpose).
      * @param $query The query.
      * @param $debug If true, it output the query and the resulting value.
      * @return A value representing a data cell (or NULL if result is empty).
      */
    function queryUniqueValue($query, $debug = -1)
    {
      $query = "$query LIMIT 1";

      $this->nbQueries++;
      $result = mysql_query($query) or $this->debugAndDie($query);
      $line = mysql_fetch_row($result);

      $this->debug($debug, $query, $result);

      return $line[0];
    }
    /** Get the maximum value of a column in a table, with a condition.
      * @param $column The column where to compute the maximum.
      * @param $table The table where to compute the maximum.
      * @param $where The condition before to compute the maximum.
      * @return The maximum value (or NULL if result is empty).
      */
    function maxOf($column, $table, $where)
    {
      return $this->queryUniqueValue("SELECT MAX(`$column`) FROM `$table` WHERE $where");
    }
    /** Get the maximum value of a column in a table.
      * @param $column The column where to compute the maximum.
      * @param $table The table where to compute the maximum.
      * @return The maximum value (or NULL if result is empty).
      */
    function maxOfAll($column, $table)
    {
      return $this->queryUniqueValue("SELECT MAX(`$column`) FROM `$table`");
    }
    /** Get the count of rows in a table, with a condition.
      * @param $table The table where to compute the number of rows.
      * @param $where The condition before to compute the number or rows.
      * @return The number of rows (0 or more).
      */
    function countOf($table, $where)
    {
      return $this->queryUniqueValue("SELECT COUNT(*) FROM `$table` WHERE $where");
    }
    /** Get the count of rows in a table.
      * @param $table The table where to compute the number of rows.
      * @return The number of rows (0 or more).
      */
    function countOfAll($table)
    {
      return $this->queryUniqueValue("SELECT COUNT(*) FROM `$table`");
    }
    /** Internal function to debug when MySQL encountered an error,
      * even if debug is set to Off.
      * @param $query The SQL query to echo before diying.
      */
    function debugAndDie($query)
    {
      $this->debugQuery($query, "Error");
      die("<p style=\"margin: 2px;\">".mysql_error()."</p></div>");
    }
    /** Internal function to debug a MySQL query.\n
      * Show the query and output the resulting table if not NULL.
      * @param $debug The parameter passed to query() functions. Can be boolean or -1 (default).
      * @param $query The SQL query to debug.
      * @param $result The resulting table of the query, if available.
      */
    function debug($debug, $query, $result = NULL)
    {
      if ($debug === -1 && $this->defaultDebug === false)
        return;
      if ($debug === false)
        return;

      $reason = ($debug === -1 ? "Default Debug" : "Debug");
      $this->debugQuery($query, $reason);
      if ($result == NULL)
        echo "<p style=\"margin: 2px;\">Number of affected rows: ".mysql_affected_rows()."</p></div>";
      else
        $this->debugResult($result);
    }
    /** Internal function to output a query for debug purpose.\n
      * Should be followed by a call to debugResult() or an echo of "</div>".
      * @param $query The SQL query to debug.
      * @param $reason The reason why this function is called: "Default Debug", "Debug" or "Error".
      */
    function debugQuery($query, $reason = "Debug")
    {
      $color = ($reason == "Error" ? "red" : "orange");
      echo "<div style=\"border: solid $color 1px; margin: 2px;\">".
           "<p style=\"margin: 0 0 2px 0; padding: 0; background-color: #DDF;\">".
           "<strong style=\"padding: 0 3px; background-color: $color; color: white;\">$reason:</strong> ".
           "<span style=\"font-family: monospace;\">".htmlentities($query)."</span></p>";
    }
    /** Internal function to output a table representing the result of a query, for debug purpose.\n
      * Should be preceded by a call to debugQuery().
      * @param $result The resulting table of the query.
      */
    function debugResult($result)
    {
      echo "<table border=\"1\" style=\"margin: 2px;\">".
           "<thead style=\"font-size: 80%\">";
      $numFields = mysql_num_fields($result);
      // BEGIN HEADER
      $tables    = array();
      $nbTables  = -1;
      $lastTable = "";
      $fields    = array();
      $nbFields  = -1;
      while ($column = mysql_fetch_field($result)) {
        if ($column->table != $lastTable) {
          $nbTables++;
          $tables[$nbTables] = array("name" => $column->table, "count" => 1);
        } else
          $tables[$nbTables]["count"]++;
        $lastTable = $column->table;
        $nbFields++;
        $fields[$nbFields] = $column->name;
      }
      for ($i = 0; $i <= $nbTables; $i++)
        echo "<th colspan=".$tables[$i]["count"].">".$tables[$i]["name"]."</th>";
      echo "</thead>";
      echo "<thead style=\"font-size: 80%\">";
      for ($i = 0; $i <= $nbFields; $i++)
        echo "<th>".$fields[$i]."</th>";
      echo "</thead>";
      // END HEADER
      while ($row = mysql_fetch_array($result)) {
        echo "<tr>";
        for ($i = 0; $i < $numFields; $i++)
          echo "<td>".htmlentities($row[$i])."</td>";
        echo "</tr>";
      }
      echo "</table></div>";
      $this->resetFetch($result);
    }
    /** Get how many time the script took from the begin of this object.
      * @return The script execution time in seconds since the
      * creation of this object.
      */
    function getExecTime()
    {
      return round(($this->getMicroTime() - $this->mtStart) * 1000) / 1000;
    }
    /** Get the number of queries executed from the begin of this object.
      * @return The number of queries executed on the database server since the
      * creation of this object.
      */
    function getQueriesCount()
    {
      return $this->nbQueries;
    }
    /** Go back to the first element of the result line.
      * @param $result The resssource returned by a query() function.
      */
    function resetFetch($result)
    {
      if (mysql_num_rows($result) > 0)
        mysql_data_seek($result, 0);
    }
    /** Get the id of the very last inserted row.
      * @return The id of the very last inserted row (in any table).
      */
    function lastInsertedId()
    {
      return mysql_insert_id();
    }
    /** Close the connexion with the database server.\n
      * It's usually unneeded since PHP do it automatically at script end.
      */
    function close()
    {
      mysql_close();
    }

    /** Internal method to get the current time.
      * @return The current time in seconds with microseconds (in float format).
      */
    function getMicroTime()
    {
      list($msec, $sec) = explode(' ', microtime());
      return floor($sec / 1000) + $msec;
    }
  } // class DB
?>

Any better ideas?

You use a wild mixture of the old mysql_* functions and the new MySQLi extension. This is not possible. They're two entirely different extensions, and the functions are not interchangeable.

 

Why do you even do this? Did you try to update this old code and stopped in the middle of it? Then the first step you should do is finish the transition to MySQLi.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.