LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-10-2006, 10:51 AM   #1
gabebster
Member
 
Registered: Jun 2003
Location: Oklahoma
Distribution: Gentoo
Posts: 117

Rep: Reputation: 15
PHP5/PEAR with MySQL getting error DB_Error::fetchRow()


The error that I am getting is; Fatal error: Call to undefined method DB_Error::fetchRow(). As far as I can tell the code looks correct.
Code:
function checkLogin($uname,$pwrd)
{
	$db = getConnection();

	$input = "SELECT COUNT(*) AS numrows FROM UserTable WHERE Username = \"$uname\" AND Password = \"$pwrd\""; 

	$result = $db->query($query);
	// check that result was ok
	if(DB::isError($db))
	{
		echo $db->getMessage();
		exit;
	}
	//get number of returned rows
	$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
	$num_results = $row['numrows'];
	$db->disconnect();
	if($num_results == 1)
	{
		return true;
	}
	else
	{
		return false;
	}
}
What is really confusing me is I have a $result->fetchRow(DB_FETCHMODE_ASSOC) in another script that works fine. I have all of the necessary includes, all of the other database functions that I call before fetchRow() work. I can't figure out why its not running in this script while it will run in my other script. Any help would be appreciated.

gabebster
 
Old 03-11-2006, 10:11 AM   #2
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Try

PHP Code:
if(DB::isError($result)) 
 
Old 03-11-2006, 03:37 PM   #3
gabebster
Member
 
Registered: Jun 2003
Location: Oklahoma
Distribution: Gentoo
Posts: 117

Original Poster
Rep: Reputation: 15
It catches an error with the above code but the message doesn't look too helpful. The error is "Error: unknown error".

thanks,

gabebster
 
Old 03-12-2006, 05:52 AM   #4
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
You may want to check you connection before trying the query. Maybe the problem is there.
 
Old 03-13-2006, 01:47 PM   #5
gabebster
Member
 
Registered: Jun 2003
Location: Oklahoma
Distribution: Gentoo
Posts: 117

Original Poster
Rep: Reputation: 15
This is what I have for the connection. It has never given me an error while making a connection.
Code:
$dsn = "mysqli://$user:$pass@$host/$db_name";
$db = &DB::connect($dsn);

if(DB::isError($db))
{
	echo $db->getMessage();
	exit;
}
 
Old 03-13-2006, 02:11 PM   #6
gabebster
Member
 
Registered: Jun 2003
Location: Oklahoma
Distribution: Gentoo
Posts: 117

Original Poster
Rep: Reputation: 15
I figured out what I was doing wrong. I had
Code:
$result = $db->query($query);
when it should have been
Code:
$result = $db->query($input);
I hate it when I have a really dumb mistake that takes me a few days to figure out.

Thanks for your help,

gabebster
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php5 ./configure error: Cannot find MySQL header files ldp Linux - Software 28 08-26-2011 01:25 PM
php5 and mysql eric_f Slackware 2 10-05-2006 09:19 AM
php5 and MySQL 4.1 under Fedora C2 cidrolin Linux - Software 1 12-26-2004 04:06 AM
Error compiling PHP5 with MySQL Boby Linux - Software 3 09-10-2004 10:17 PM
MySQL - PHP5 - phpMyAdmin 2.6.0 Fuel Linux - Software 2 07-25-2004 02:39 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:22 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration