468,457 Members | 1,486 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,457 developers. It's quick & easy.

PEAR MDB2 - Fatal error: Call to undefined function MDB2_Driver_mssql::getMessage()

Hi, I have the following code that gives me this odd error message at
a line of code inside the PEAR libraries:

"Fatal error: Call to undefined function:
MDB2_Driver_mssql::getMessage(). in C:\php\PEAR\lib\MDB2.php on line
1921"

My code is a simple submit processing form for a login page:

<?php
require_once('Database/MSSQL_Constants_TEST.php');
require_once('MDB2.php');

$dsn = array(
'phptype' ="mssql",
'hostspec' =$MY_DB_HOST,
'port' =$MY_DB_PORT,
'database' =$MY_DB_NAME,
'username' =$MY_DB_USER,
'password' =$MY_DB_PASS
);
$dbh = MDB2::connect($dsn);

if (PEAR::isError($dbh)) {
echo "An error occurred while trying to connect to the database
server.<br>\n";
echo "Error message: " . $dbh->getMessage() . "<br>\n";
echo "A more detailed error description: " . $dbh-
>getDebugInfo() . "<br>\n";
exit();
}

// Check username and password
$result = false;
if ( isset($_POST['username']) && isset($_POST['password']) ) {
$params = array($_POST['username'], $_POST['password']);
$result = $dbh->query($WEBAPP_LOGIN_SQL, $params);

if (PEAR::isError($result)) {
echo "An error occurred while trying execute the following
query:<br>\n";
echo "$WEBAPP_LOGIN_SQL<br>\n";
echo "Error message: " . $dbh->getMessage() . "<br>\n";
echo "A more detailed error description: " . $dbh-
>getDebugInfo() . "<br>\n";
exit();
}
}

// Forward to the resulting page
if (!$result) {
header( "Location: login.php?bad=1" );
} else {
header( "Location: portal.php" );
}

?>

I will apreciate the help!!!!

Feb 19 '07 #1
2 5787
sa********@gmail.com wrote:
Hi, I have the following code that gives me this odd error message at
a line of code inside the PEAR libraries:

"Fatal error: Call to undefined function:
MDB2_Driver_mssql::getMessage(). in C:\php\PEAR\lib\MDB2.php on line
1921"

My code is a simple submit processing form for a login page:

<?php
require_once('Database/MSSQL_Constants_TEST.php');
require_once('MDB2.php');

$dsn = array(
'phptype' ="mssql",
'hostspec' =$MY_DB_HOST,
'port' =$MY_DB_PORT,
'database' =$MY_DB_NAME,
'username' =$MY_DB_USER,
'password' =$MY_DB_PASS
);
$dbh = MDB2::connect($dsn);
Hi,

Shouldn't that be with a &?

$dbh =& MDB2::connect($dsn);

http://pear.php.net/package/MDB2/doc...#methodconnect

Regards,
Erwin Moller
>
if (PEAR::isError($dbh)) {
echo "An error occurred while trying to connect to the database
server.<br>\n";
echo "Error message: " . $dbh->getMessage() . "<br>\n";
echo "A more detailed error description: " . $dbh-
>>getDebugInfo() . "<br>\n";
exit();
}

// Check username and password
$result = false;
if ( isset($_POST['username']) && isset($_POST['password']) ) {
$params = array($_POST['username'], $_POST['password']);
$result = $dbh->query($WEBAPP_LOGIN_SQL, $params);

if (PEAR::isError($result)) {
echo "An error occurred while trying execute the following
query:<br>\n";
echo "$WEBAPP_LOGIN_SQL<br>\n";
echo "Error message: " . $dbh->getMessage() . "<br>\n";
echo "A more detailed error description: " . $dbh-
>>getDebugInfo() . "<br>\n";
exit();
}
}

// Forward to the resulting page
if (!$result) {
header( "Location: login.php?bad=1" );
} else {
header( "Location: portal.php" );
}

?>

I will apreciate the help!!!!
Feb 20 '07 #2
Hi, thanks Erwin.

That's correct I fixed that and I also corrected the way I was reading
the error message for the $result object. But now I have a different
error. I'm trying to use a prepared query with SQL Server Express and
is not working. I'm getting this output(in error):

username: lll
An error occurred while trying to execute the following query:
select UserKey from [User] where UserName = ?
Error message: MDB2 Error: syntax error
A more detailed error description: _doQuery: [Error message: Could not
execute statement] [Last executed query: select UserKey from [User]
where UserName = ?] [Native code: 102] [Native message: Incorrect
syntax near '?'.]
>From this piece of code:
// Check username and password
$result = false;
if ( isset($_POST['username']) && isset($_POST['password']) ) {
$username = $_POST['username'];
// $password = $_POST['password'];
echo "username: $username<br>\n";
//echo "password: $password<br>\n";

$result =& $dbh->query($WEBAPP_LOGIN_SQL, $username);

if (PEAR::isError($result)) {
echo "An error occurred while trying to execute the following
query:<br>\n";
echo "$WEBAPP_LOGIN_SQL<br>\n";
echo "Error message: " . $result->getMessage() . "<br>\n";
echo "A more detailed error description: " . $result-
>getDebugInfo() . "<br>\n";
exit();
}
}

And the query in the global variable $WEBAPP_LOGIN_SQL is:

$WEBAPP_LOGIN_SQL = "select UserKey from [User] where UserName = ?";

So I'm thinking in appending strings to form my query (in the usual
unsafe way) and think of some regular expressions to filter out
keywords for any possible inyection attack (i.e. delete|insert|update|
etc...).
Feb 20 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by freak | last post: by
3 posts views Thread by Sven Jacobs | last post: by
4 posts views Thread by VB User | last post: by
reply views Thread by mail | last post: by
reply views Thread by Samuel Zallocco | last post: by
3 posts views Thread by Rob Wilkerson | last post: by
1 post views Thread by subhajit12345 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.