473,241 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,241 software developers and data experts.

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 6265
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: freak | last post by:
hi i have problems reading an oracle(9i) clob from a php-script with the MDB-class from pear. the table files has 3 fields: id integer document clob picture clob
3
by: Sven Jacobs | last post by:
Dear newsgroup, I've upgraded to PEAR::DB 1.6.5 recently. Unfortunately now the database connection doesn't work as expected anymore :( The problems seems to be the method disconnect(), which...
1
by: Mike | last post by:
Last weekend I decided to install Apache 2.0.53-win32-x86-no_ssl PHP 5.0.3 Smarty 2.6.7 MySQL essential-4.1.10-win32 I have Apache up (Port 80 blocked at the router and firewall!) and I have...
4
by: VB User | last post by:
While trying to code in VB.NET I get this error: Reference to a non-shared member requires an object reference. Any suggestions/ideas why this occurs? VBUser
0
by: mail | last post by:
Hallo, ich habe ein php script geschrieben, welches mir mit hilfe der pear klassen automatisiert mails versenden soll. Als Ausgabe bekomme ich leider folgende Fehlermeldung: Fatal error: Call...
0
by: Samuel Zallocco | last post by:
Hi all, I've a problem with PHP5 + PEAR::SOAP. I Have the following 2 script that implements a simple web service: The Server Code running on WinXP + PHP5 + Apache 2.x:...
4
by: Benny | last post by:
I am creating a thread via "new Thread(new ThreadStart(p.ThreadProc))", is it safe for ThreadProc to use GetMessage/TranslateMessage/DispatchMessage instead of DoEvents? What I would like to do...
2
by: salvadorvp | last post by:
Hi, I wonder If somebody has experience this or could point me in the right direction: I have the following script (commented out just to use the username): // Check username and password //...
3
by: Rob Wilkerson | last post by:
Hey all - I'm bumping into an issue with my installation of the MDB2 package that I'm hoping someone else has seen. I'm trying to execute a query, but get an "unknown error" exception that I...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.