|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
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 C The offending code is this: php Code:
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 :-) |
|
#2
|
|||
|
|||
|
RE: PEAR/PHP Newbie: DB_Error problem
You're sure that is line 50 of modify_post.php?
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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()); } |
|
#5
|
||||||||
|
||||||||
|
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:
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:
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. :-) |
|
#6
|
|||
|
|||
|
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... |
|
#7
|
|||
|
|||
|
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...
|
|
#8
|
|||
|
|||
|
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. :-) |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PEAR Packages > PEAR/PHP Newbie: DB_Error problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|