Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6122409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:53:45+00:00 2026-05-23T15:53:45+00:00

i’m getting an error and i think is an access problem to the class,

  • 0

i’m getting an error and i think is an access problem to the class, but i’m not sure and don’t know how to solve.

I create a DSN:

require_once ('DB.php');
    $dsn = array(
'phptype'  => 'mysql',
'username' => 'cmsconex_cms',
'password' => 'y10ba01',
'hostspec' => 'localhost',
'database' => 'cmsconex_cms',
);

$db =& DB::connect($dsn, $options);
if (DB::isError($db)) {
    die($db->getMessage());
}
$db->Query("SET CHARACTER SET UTF8");
$db->Query("SET NAMES UTF8");

And in a custom class:

class user {

function get_userdata($field, $value) {
        global $db;

        $sql = printf ( "SELECT %s FROM usuarios WHERE %s = '%s'", $field, $field, $value );

        $resultado = & $db->getAll ( $sql, DB_FETCHMODE_ASSOC );

        $valor = $resultado[0][$field];

        if ($value == $valor) {
            return true;
        } else {
            return $valor;
        }
    }

}

The problem is when i execute a query, for example:

SELECT usuario FROM usuarios WHERE usuario = 'test'

I get the error:

SELECT usuario FROM usuarios WHERE usuario = 'test'
Fatal error: Cannot use object of type DB_Error as array in /home/cmsconex/public_html/includes/classes/user.php on line 269

Is strange, beacause if i call this other function i get no error and everyting runs great :

function logSession($usuario_id, $ip) {
        global $db;
        $ip = ip2long ( $ip );
        $sql = "INSERT INTO accesos (id, usuario_id, fecha, pagina, ip) VALUES (0, '$usuario_id', NOW(), '', '$ip')";
        $res = & $db->query ( $sql ); // Ejecutar la consulta
    }

So i think the problem is when calling a method of DB class with parameters like DB_FETCHMODE_ASSOC

Could anyone show me the light please?

Thnx so muchh.

The Complete error is:

1
DB_Error Object ( [error_message_prefix] => [mode] => 1 [level] => 1024 [code] => -2 [message] => DB Error: syntax error [userinfo] => 51 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’51’ at line 1] [backtrace] => Array ( [0] => Array ( [file] => /usr/local/lib/php/DB.php [line] => 966 [function] => PEAR_Error [class] => PEAR_Error [type] => -> [args] => Array ( [0] => DB Error: syntax error [1] => -2 [2] => 1 [3] => 1024 [4] => 51 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’51’ at line 1] ) ) [1] => Array ( [file] => /usr/lib/php/PEAR.php [line] => 531 [function] => DB_Error [class] => DB_Error [type] => -> [object] => DB_Error Object RECURSION [args] => Array ( [0] => -2 [1] => 1 [2] => 1024 [3] => 51 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’51’ at line 1] ) ) [2] => Array ( [file] => /usr/local/lib/php/DB/common.php [line] => 1903 [function] => raiseError [class] => PEAR [type] => -> [object] => DB_mysql Object ( [phptype] => mysql [dbsyntax] => mysql [features] => Array ( [limit] => alter [new_link] => 4.2.0 [numrows] => 1 [pconnect] => 1 [prepare] => [ssl] => [transactions] => 1 ) [errorcode_map] => Array ( [1004] => -15 [1005] => -15 [1006] => -15 [1007] => -5 [1008] => -17 [1022] => -5 [1044] => -26 [1046] => -14 [1048] => -3 [1049] => -27 [1050] => -5 [1051] => -18 [1054] => -19 [1061] => -5 [1062] => -5 [1064] => -2 [1091] => -4 [1100] => -21 [1136] => -22 [1142] => -26 [1146] => -18 [1216] => -3 [1217] => -3 [1356] => -13 [1451] => -3 [1452] => -3 ) [connection] => Resource id #10 [dsn] => Array ( [phptype] => mysql [dbsyntax] => mysql [username] => cmsconex_cms [password] => y10ba01 [protocol] => [hostspec] => localhost [port] => [socket] => [database] => cmsconex_cms ) [autocommit] => 1 [transaction_opcount] => 0 [_db] => cmsconex_cms [fetchmode] => 1 [fetchmode_object_class] => stdClass [was_connected] => [last_query] => 51 [options] => Array ( [result_buffering] => 500 [persistent] => 1 [ssl] => [debug] => 0 [seqname_format] => %s_seq [autofree] => [portability] => 0 [optimize] => performance ) [last_parameters] => Array ( ) [prepare_tokens] => Array ( ) [prepare_types] => Array ( ) [prepared_queries] => Array ( ) [_last_query_manip] => [_next_query_manip] => [_debug] => [_default_error_mode] => [_default_error_options] => [_default_error_handler] => [_error_class] => DB_Error [_expected_errors] => Array ( ) ) [args] => Array ( [0] => [1] => -2 [2] => [3] => [4] => 51 [nativecode=1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’51’ at line 1] [5] => DB_Error [6] => 1 ) ) [3] => Array ( [file] => /usr/local/lib/php/DB/mysql.php [line] => 898 [function] => raiseError [class] => DB_common [type] => -> [object] => DB_mysql Object ( [phptype] => mysql [dbsyntax] => mysql [features] => Array ( [limit] => alter [new_link] => 4.2.0 [numrows] => 1 [pconnect] => 1 [prepare] => [ssl] => [transactions] => 1 ) [errorcode_map] => Array ( [1004] => -15 [1005] => -15 [1006] => -15 [1007] => -5 [1008] => -17 [1022] => -5 [1044] => -26 [1046] => -14 [1048] => -3 [1049] => -27 [1050] => -5 [1051] => -18 [1054] => -19 [1061] => -5 [1062] => -5 [1064] => -2 [1091] => -4 [1100] => -21 [1136] => -22 [1142] => -26 [1146] => -18 [1216] => -3 [1217] => -3 [1356] => -13 [1451] => -3 [1452] => -3 ) [connection] => Resource id #10 [dsn] => Array ( [phptype] => mysql [dbsyntax] => mysql [username] => cmsconex_cms [password] => y10ba01 [protocol] => [hostspec] => localhost [port] => [socket] => [database] => cmsconex_cms ) [autocommit] => 1 [transaction_opcount] => 0 [_db] => cmsconex_cms [fetchmode] => 1 [fetchmode_object_class] => stdClass [was_connected] => [last_query] => 51 [options] => Array ( [result_buffering] => 500 [persistent] => 1 [ssl] => [debug] => 0 [seqname_format] => %s_seq [autofree] => [portability] => 0 [optimize] => performance ) [last_parameters] => Array ( ) [prepare_tokens] => Array ( ) [prepare_types] => Array ( ) [prepared_queries] => Array ( ) [_last_query_manip] => [_next_query_manip] => [_debug] => [_default_error_mode] => [_default_error_options] => [_default_error_handler] => [_error_class] => DB_Error [_expected_errors] => Array ( ) ) [args] => Array ( [0] => -2 [1] => [2] => [3] => [4] => 1064 ** You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ’51’ at line 1 ) ) [4] => Array ( [file] => /usr/local/lib/php/DB/mysql.php [line] => 327 [function] => mysqlRaiseError [class] => DB_mysql [type] => -> [object] => DB_mysql Object ( [phptype] => mysql [dbsyntax] => mysql [features] => Array ( [limit] => alter [new_link] => 4.2.0 [numrows] => 1 [pconnect] => 1 [prepare] => [ssl] => [transactions] => 1 ) [errorcode_map] => Array ( [1004] => -15 [1005] => -15 [1006] => -15 [1007] => -5 [1008] => -17 [1022] => -5 [1044] => -26 [1046] => -14 [1048] => -3 [1049] => -27 [1050] => -5 [1051] => -18 [1054] => -19 [1061] => -5 [1062] => -5 [1064] => -2 [1091] => -4 [1100] => -21 [1136] => -22 [1142] => -26 [1146] => -18 [1216] => -3 [1217] => -3 [1356] => -13 [1451] => -3 [1452] => -3 ) [connection] => Resource id #10 [dsn] => Array ( [phptype] => mysql [dbsyntax] => mysql [username] => cmsconex_cms [password] => y10ba01 [protocol] => [hostspec] => localhost [port] => [socket] => [database] => cmsconex_cms ) [autocommit] => 1 [transaction_opcount] => 0 [_db] => cmsconex_cms [fetchmode] => 1 [fetchmode_object_class] => stdClass [was_connected] => [last_query] => 51 [options] => Array ( [result_buffering] => 500 [persistent] => 1 [ssl] => [debug] => 0 [seqname_format] => %s_seq [autofree] => [portability] => 0 [optimize] => performance ) [last_parameters] => Array ( ) [prepare_tokens] => Array ( ) [prepare_types] => Array ( ) [prepared_queries] => Array ( ) [_last_query_manip] => [_next_query_manip] => [_debug] => [_default_error_mode] => [_default_error_options] => [_default_error_handler] => [_error_class] => DB_Error [_expected_errors] => Array ( ) ) [args] => Array ( ) ) [5] => Array ( [file] => /usr/local/lib/php/DB/common.php [line] => 1216 [function] => simpleQuery [class] => DB_mysql [type] => -> [object] => DB_mysql Object ( [phptype] => mysql [dbsyntax] => mysql [features] => Array ( [limit] => alter [new_link] => 4.2.0 [numrows] => 1 [pconnect] => 1 [prepare] => [ssl] => [transactions] => 1 ) [errorcode_map] => Array ( [1004] => -15 [1005] => -15 [1006] => -15 [1007] => -5 [1008] => -17 [1022] => -5 [1044] => -26 [1046] => -14 [1048] => -3 [1049] => -27 [1050] => -5 [1051] => -18 [1054] => -19 [1061] => -5 [1062] => -5 [1064] => -2 [1091] => -4 [1100] => -21 [1136] => -22 [1142] => -26 [1146] => -18 [1216] => -3 [1217] => -3 [1356] => -13 [1451] => -3 [1452] => -3 ) [connection] => Resource id #10 [dsn] => Array ( [phptype] => mysql [dbsyntax] => mysql [username] => cmsconex_cms [password] => y10ba01 [protocol] => [hostspec] => localhost [port] => [socket] => [database] => cmsconex_cms ) [autocommit] => 1 [transaction_opcount] => 0 [_db] => cmsconex_cms [fetchmode] => 1 [fetchmode_object_class] => stdClass [was_connected] => [last_query] => 51 [options] => Array ( [result_buffering] => 500 [persistent] => 1 [ssl] => [debug] => 0 [seqname_format] => %s_seq [autofree] => [portability] => 0 [optimize] => performance ) [last_parameters] => Array ( ) [prepare_tokens] => Array ( ) [prepare_types] => Array ( ) [prepared_queries] => Array ( ) [_last_query_manip] => [_next_query_manip] => [_debug] => [_default_error_mode] => [_default_error_options] => [_default_error_handler] => [_error_class] => DB_Error [_expected_errors] => Array ( ) ) [args] => Array ( [0] => 51 ) ) [6] => Array ( [file] => /usr/local/lib/php/DB/common.php [line] => 1663 [function] => query [class] => DB_common [type] => -> [object] => DB_mysql Object ( [phptype] => mysql [dbsyntax] => mysql [features] => Array ( [limit] => alter [new_link] => 4.2.0 [numrows] => 1 [pconnect] => 1 [prepare] => [ssl] => [transactions] => 1 ) [errorcode_map] => Array ( [1004] => -15 [1005] => -15 [1006] => -15 [1007] => -5 [1008] => -17 [1022] => -5 [1044] => -26 [1046] => -14 [1048] => -3 [1049] => -27 [1050] => -5 [1051] => -18 [1054] => -19 [1061] => -5 [1062] => -5 [1064] => -2 [1091] => -4 [1100] => -21 [1136] => -22 [1142] => -26 [1146] => -18 [1216] => -3 [1217] => -3 [1356] => -13 [1451] => -3 [1452] => -3 ) [connection] => Resource id #10 [dsn] => Array ( [phptype] => mysql [dbsyntax] => mysql [username] => cmsconex_cms [password] => y10ba01 [protocol] => [hostspec] => localhost [port] => [socket] => [database] => cmsconex_cms ) [autocommit] => 1 [transaction_opcount] => 0 [_db] => cmsconex_cms [fetchmode] => 1 [fetchmode_object_class] => stdClass [was_connected] => [last_query] => 51 [options] => Array ( [result_buffering] => 500 [persistent] => 1 [ssl] => [debug] => 0 [seqname_format] => %s_seq [autofree] => [portability] => 0 [optimize] => performance ) [last_parameters] => Array ( ) [prepare_tokens] => Array ( ) [prepare_types] => Array ( ) [prepared_queries] => Array ( ) [_last_query_manip] => [_next_query_manip] => [_debug] => [_default_error_mode] => [_default_error_options] => [_default_error_handler] => [_error_class] => DB_Error [_expected_errors] => Array ( ) ) [args] => Array ( [0] => 51 ) ) [7] => Array ( [file] => /home/cmsconex/public_html/includes/classes/user.php [line] => 266 [function] => getAll [class] => DB_common [type] => -> [object] => DB_mysql Object ( [phptype] => mysql [dbsyntax] => mysql [features] => Array ( [limit] => alter [new_link] => 4.2.0 [numrows] => 1 [pconnect] => 1 [prepare] => [ssl] => [transactions] => 1 ) [errorcode_map] => Array ( [1004] => -15 [1005] => -15 [1006] => -15 [1007] => -5 [1008] => -17 [1022] => -5 [1044] => -26 [1046] => -14 [1048] => -3 [1049] => -27 [1050] => -5 [1051] => -18 [1054] => -19 [1061] => -5 [1062] => -5 [1064] => -2 [1091] => -4 [1100] => -21 [1136] => -22 [1142] => -26 [1146] => -18 [1216] => -3 [1217] => -3 [1356] => -13 [1451] => -3 [1452] => -3 ) [connection] => Resource id #10 [dsn] => Array ( [phptype] => mysql [dbsyntax] => mysql [username] => cmsconex_cms [password] => y10ba01 [protocol] => [hostspec] => localhost [port] => [socket] => [database] => cmsconex_cms ) [autocommit] => 1 [transaction_opcount] => 0 [_db] => cmsconex_cms [fetchmode] => 1 [fetchmode_object_class] => stdClass [was_connected] => [last_query] => 51 [options] => Array ( [result_buffering] => 500 [persistent] => 1 [ssl] => [debug] => 0 [seqname_format] => %s_seq [autofree] => [portability] => 0 [optimize] => performance ) [last_parameters] => Array ( ) [prepare_tokens] => Array ( ) [prepare_types] => Array ( ) [prepared_queries] => Array ( ) [_last_query_manip] => [_next_query_manip] => [_debug] => [_default_error_mode] => [_default_error_options] => [_default_error_handler] => [_error_class] => DB_Error [_expected_errors] => Array ( ) ) [args] => Array ( [0] => 51 [1] => 2 ) ) [8] => Array ( [file] => /home/cmsconex/public_html/includes/classes/user.php [line] => 250 [function] => get_userdata [class] => user [type] => -> [object] => user Object ( ) [args] => Array ( [0] => usuario [1] => test ) ) [9] => Array ( [file] => /home/cmsconex/public_html/gestion/usuarios-nuevo.php [line] => 39 [function] => username_exists [class] => user [type] => -> [object] => user Object ( ) [args] => Array ( [0] => test ) ) ) [callback] => ) 1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:53:45+00:00Added an answer on May 23, 2026 at 3:53 pm

    getAll returns a DB_Error object when it fails.
    You have to print to see what the error is.

    According to the doc, to retrieve the error just do:

    if (PEAR::isError($resultado)) {
        die($resultado->getMessage());
    }
    

    getAll needs an array as second parameter like:

    $resultado = & $db->getAll ( $sql, array(), DB_FETCHMODE_ASSOC );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.