Jump to content

how can i make the below code compatble with PHP 5 ?


phpvox

Recommended Posts

That code is riddled with bugs. php4 or 5. There is no such function as mysql_numrows, or mysql.

Actually, the mysql() function does it exist it's just not documented. Try it out and see.  It seems to be the same as mysql_db_query().

 

Also, phpvox, you must be doing something wrong because I made those changes to your code and ran it on my machine which has PHP5 and it works just fine.

 

No wonder the company went extinct :), that code is horribly written!

 

You are better off writing your own functions to interact with the database.  Just an FYI.

php.ini

 

mysql

 

Directive             Local Value Master Value

 

mysql.allow_persistent   On             On

mysql.connect_timeout 60           60

mysql.default_host   no value no value

mysql.default_password no value no value

mysql.default_port     no value no value

mysql.default_socket   no value no value

mysql.default_user   no value no value

mysql.max_links             Unlimited Unlimited

mysql.max_persistent Unlimited Unlimited

mysql.trace_mode Off Off

 

mysqli

MysqlI Support enabled

Client API version 4.1.20

MYSQLI_SOCKET /var/lib/mysql/mysql.sock

 

Directive Local Value Master Value

 

mysqli.default_host no value no value

mysqli.default_port 3306 3306

mysqli.default_pw no value no value

mysqli.default_socket no value no value

mysqli.default_user no value no value

mysqli.max_links Unlimited Unlimited

mysqli.reconnect Off Off

<?php
function c() {
global $db_host;
global $db_login;
global $db_pswd;
global $connected;
static $db;
if(!$connected){
	$db = @ mysql_connect($db_host, $db_login, $db_pswd);
	$connected = true;
}
return $db;
}

function q($q_str) {
global $db_name;
global $connected;
global $query_count;
global $show_debug_info;
global $queries_str;
$db = c();

$r = mysql_db_query($db_name, $q_str, $db);
echo mysql_error($db);
if ((ee() AND $show_debug_info)) {
	echo '' . ': ' . $q_str;
}

if (!$query_count) {
	$query_count = 0;
}

$queries_str .= '' . $q_str . '
';
++ $query_count;
return $r;
}

  function d ($db)
  {
    @mysql_close ($db);
  }

  function e ($r)
  {
    if (@mysql_numrows ($r))
    {
      return 0;
    }
    else
    {
      return 1;
    }

  }

  function ee ()
  {
    global $show_debug_info;
    $err = mysql_error ();
    if ($show_debug_info)
    {
      echo $err;
    }

    return ($err ? true : false);
  }

  function f ($r)
  {
    return @mysql_fetch_array ($r);
  }

  function fr ($r)
  {
    return @mysql_fetch_row ($r);
  }

  function nr ($r)
  {
    return @mysql_num_rows ($r);
  }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.