Tema: Php5 A Php4
Ver Mensaje Individual
  #1 (permalink)  
Antiguo 25/09/2006, 21:38
pincho
 
Fecha de Ingreso: mayo-2004
Ubicación: Argentina
Mensajes: 126
Antigüedad: 20 años
Puntos: 1
Exclamación Php5 A Php4

Hola foreros... me encontre esta clase pero no funciona en php4, podrían indicarme en que falla?
Se que es para php5 asi que les pregunto, hay alguna forma de acomodarlo para que funcione en PHP4, ya que mi servidor (y cerca del 80% de ellos) tiene PHP4 instalado.

Código PHP:

// defines database connection data
define('DB_HOST''localhost');
define('DB_USER''ajaxuser');
define('DB_PASSWORD''practical');
define('DB_DATABASE''ajax');


class 
Friendly
{
// stores the database connection
private $mMysqli;
// constructor opens database connection
function __construct()
{
$this->mMysqli = new mysqli(DB_HOSTDB_USERDB_PASSWORD,
DB_DATABASE);
}
// generate news message
public function getNews()
{
// this will store the news line
$news 'No news for today.';
// SQL that selects two random users from the database.
$query 'SELECT user_name FROM users ' .
'ORDER BY RAND() ' .
'LIMIT 2';
// execute the query
$result $this->mMysqli->query($query);
// retrieve the user rows
$row1 $result->fetch_array(MYSQLI_ASSOC);
$row2 $result->fetch_array(MYSQLI_ASSOC);
// close the input stream
$result->close();
// generate the news
if (!$row1 || !$row2)
{
$news 'Vacio!';
}
else
{
// create HTML-formatted news message
$name1 '<b>' $row1['user_name'] . '</b>';
$name2 '<b>' $row2['user_name'] . '</b>';
$randNum $this->getRandomNumber();
$news 'User ' $name1 ' works with user ' $name2 .
' at project #' $randNum '.';
}
// output the news line
return $news;
}
// returns a random number between 1 and 100
private function getRandomNumber()
{
// delays execution for quarter of a second
usleep(250000);
// holds the remote server address and parameters
$serverAddress 'http://www.random.org/cgi-bin/randnum';
$serverParams 'num=1&min=1&max=100';
// retrieve the random number from remote server
$randomNumber file_get_contents($serverAddress '?' .
$serverParams);
// output the random number
return trim($randomNumber);
}
// destructor closes database connection
function __destruct()
{
$this->mMysqli->close();
}

Sin más, saludos y gracias!