PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old November 3rd, 2006, 02:51 AM
supergrover1981 supergrover1981 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 supergrover1981 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PEAR/PHP Newbie: DB_Error problem

Gidday Gang,

I've been trying to teach myself PHP/MySQL this past week using my beloved "Dive in & see what works" method. Everything had been going well until last night, when I ran into a bit of a brick wall. I keep getting the following error message:

Fatal error: Call to undefined method DB_Error::query() in Crogram FilesApache Software FoundationApache2.2htdocsmodify_post.php on line 50

The offending code is this:

php Code:
Original - php Code
  1.  
  2. if ($_GET[post_id] AND !$stop) {
  3. $query = "SELECT * FROM users NATURAL JOIN posts NATURAL JOIN categories where post_id = $_GET[post_id]";
  4. $result = $connection->query($query);
  5.  
  6. if (DB::isError($result))
  7. {
  8. die ("Could not query the database: <br>". $query. " ".
  9. DB::errorMessage($result));
  10. };
  11. ...


A few notes about the problem:

- I've tried running $query via MySQL at the command line, and it executes without problems
- I've added an echo call to $_GET[post_id] and it returns the correct value
- Line 50 is the "$result = $connection->query($query);" line

The only thing I can think of is that I lifted this snippet of code from a php file written in php4, whereas I'm running PHP 5.1.6. Is it possible that the DB_Error procedure has been superceded? (If so, anybody know what superceded it?)

Any help with this would be truly, sincerely appreciated.

With thanks in advance,
- JB :-)

Reply With Quote
  #2  
Old November 4th, 2006, 01:47 AM
Matt Matt is offline
Contributing User
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 12 m 16 sec
Reputation Power: 7
RE: PEAR/PHP Newbie: DB_Error problem

You're sure that is line 50 of modify_post.php?

Reply With Quote
  #3  
Old November 4th, 2006, 02:47 AM
supergrover1981 supergrover1981 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 supergrover1981 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: PEAR/PHP Newbie: DB_Error problem

*nods*

Unfortunately, yes.

- If I delete that row, that error message disappears.
- If I delete the if (DB::isError) line below it, no change

Reply With Quote
  #4  
Old November 4th, 2006, 02:59 AM
Matt Matt is offline
Contributing User
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 12 m 16 sec
Reputation Power: 7
RE: PEAR/PHP Newbie: DB_Error problem

$connection is failing to happen correctly. Just before that line do a:

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

Reply With Quote
  #5  
Old November 4th, 2006, 04:18 AM
supergrover1981 supergrover1981 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 supergrover1981 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: PEAR/PHP Newbie: DB_Error problem

Hmmm....interesting.
Your suggestion sprouts up a: "DB Error: Connect Failed" message.

The bizarre thing is that I have the following code at line 26, which passes through just fine.

php Code:
Original - php Code
  1. $connection = DB::connect( "mysql://$db_username:$db_password@$db_
  2. host/$db_database" );
  3. if (!$connection)
  4. {
  5. die ("Could not connect to the database: <br>". DB::errorMessage());
  6. };


I also have code very similar to that posted at the top of this thread for $_GET="Delete" - it presents the same error message (on line 37 instead of 50)

php Code:
Original - php Code
  1.  
  2. if ($_GET['action']=="delete" and !$stop)
  3. {
  4. $post_id=$_GET[post_id];
  5. $query = "delete from posts where post_id='".$post_id."' and
  6. user_id='".$user_id."'";
  7. $result = $connection->query($query);
  8. ..
  9. }


Many many thanks for the assistance here Matt - it's an enormous help. If you ever need a spare limb or kidney or anything, just gimme a call. :-)

Reply With Quote
  #6  
Old November 4th, 2006, 04:40 PM
Matt Matt is offline
Contributing User
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 12 m 16 sec
Reputation Power: 7
RE: PEAR/PHP Newbie: DB_Error problem

Yeah it's that your check:

if (!$connection)

isn't the right way to do it with PEAR. $connection ends up being true because it is assigned a DB_Error object. You have to check to see if it is an error like I posted in my last post...

Reply With Quote
  #7  
Old November 4th, 2006, 05:00 PM
supergrover1981 supergrover1981 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 supergrover1981 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: PEAR/PHP Newbie: DB_Error problem

*pout* Darn, you're right. Same "DB Error: connect failed" message as on line 50. Maybe I'll try connecting without PEAR and seeing if I have any more luck...

Reply With Quote
  #8  
Old November 6th, 2006, 12:41 PM
supergrover1981 supergrover1981 is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 10 supergrover1981 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: PEAR/PHP Newbie: DB_Error problem

*guilty, sheepish grin*

Oh dear. Oh dear oh dear oh dear.

There was a line break halfway through my DB::Connect statement (disguised by wordwrap, but nonetheless there)

*cowers in shame*

Apologies for the stupid mistake - many many thanks for the help anyway Matt. :-)

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > PEAR/PHP Newbie: DB_Error problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek