mschrank Posted July 5, 2006 Share Posted July 5, 2006 $pear_dsn = [i]xxxxx (confidential)[/i]require_once 'DB.php';$options = array( 'debug' => 2, 'portability' => DB_PORTABILITY_ALL,);$db =& DB::connect($pear_dsn, $options);if (PEAR::isError($db)) { die($db->getMessage());}$db->setFetchMode(DB_FETCHMODE_ASSOC);$sql = "delete from child_basic where child_id = '". $_GET['child_id']. "'";# send the query$query = $db->query($sql);if (PEAR::isError($db)) { die($db->getMessage());}...This query has no effect whatsoever, but works when the SQL is echo'd and cut and pasted into the mysql client.Totally confused.-Matt Quote Link to comment https://forums.phpfreaks.com/topic/13770-pear-query-just-not-working/ Share on other sites More sharing options...
Buyocat Posted July 5, 2006 Share Posted July 5, 2006 I'm not sure what the problem is, are you sure the query is being executed by the script? Have you tried echoing out the something just before and just after you execute it? Quote Link to comment https://forums.phpfreaks.com/topic/13770-pear-query-just-not-working/#findComment-53524 Share on other sites More sharing options...
mschrank Posted July 5, 2006 Author Share Posted July 5, 2006 Thanks for your reply. Yes, I have tried "echo $sql;" and I get a statement which works when cut and pasted directly into my postgresql client. So there is no problem with the sql statement of the building of it.It seems to me that the query function of the DB class is not working. Yet I have no idea why and I get no error messages. Quote Link to comment https://forums.phpfreaks.com/topic/13770-pear-query-just-not-working/#findComment-53535 Share on other sites More sharing options...
Buyocat Posted July 5, 2006 Share Posted July 5, 2006 Well, there are only two things I can think of. First, did you try to print something after the $db->query($sql); If so did it print out or not? I wasn't sure if you printed out the sql before or after executing it. If the stuff doesn't print out afterwards then there is some sort of error there. Second, I know with MDB2, which is the successor to DB, you have to have the MySQL drive installed. I'm not sure where to find it, though PEAR is probably a good place to start looking. At any rate, I couldn't do any queries until I added the file to a directory...I haven't used DB in a while, but I think what you have is right, so try what I suggested above, and if that doesn't work you can always try MDB2 or just your own script (though that will mean giving up features).One last thing, try changing the MySQL keywords to all caps, DELETE, FROM and WHERE. I'm not sure if that will do anything, but I've found some wierd MySQL behaviour before based off of similar stuff. For instance, recently I had a case like this one where I would print out the sql and it would execute if entered directly, but fail to execute if done through PHP. The sql was using a COUNT(*), the cause of the problem was a space between COUNT and ()... For some reason it worked through PHPmyAdmin but not through my script! Quote Link to comment https://forums.phpfreaks.com/topic/13770-pear-query-just-not-working/#findComment-53550 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.