PEAR Forum :: PHP Extension and Application Repository

PEAR Forum Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
MDB2 and User-Define MySQL Variables

 
Post new topic   Reply to topic    PEAR Forum Forum Index -> Database
View previous topic :: View next topic  
Author Message
soladon13



Joined: 08 Aug 2007
Posts: 4

PostPosted: Sun Jul 13, 2008 11:12 pm    Post subject: MDB2 and User-Define MySQL Variables Reply with quote

Hello,

I really need some help here.

I am running the following:

<?php
require_once('MDB2.php');

$dsn = 'mysqli://username:password@localhost/';

$db =& MDB2::singleton($dsn);

$prep =& $db->prepare('SELECT @x:=5');
$res = $prep->execute();

if (MDB2::isError($res)) {
echo "Error.\n";
echo $res->message . "\n";
echo $res->userinfo . "\n";
}

?>


but I am getting the following error:
"Error. MDB2 Error: not found [Error message: Unable to bind to missing placeholder: SELECT @x:=5] "

Is there another way to set a variable?
Any ideas for a fix?

Thank you
Back to top
View user's profile Send private message
mark



Joined: 07 Jan 2007
Posts: 1003

PostPosted: Mon Jul 14, 2008 7:31 am    Post subject: Reply with quote

The ":" conflicts with prepare, see here:
http://pear.php.net/manual/en/package.database.mdb2.intro-execute.php

If you use just query(), it should work:
http://pear.php.net/manual/en/package.database.mdb2.intro-query.php
Back to top
View user's profile Send private message
soladon13



Joined: 08 Aug 2007
Posts: 4

PostPosted: Tue Jul 15, 2008 1:00 am    Post subject: Reply with quote

mark wrote:
The ":" conflicts with prepare, see here:
http://pear.php.net/manual/en/package.database.mdb2.intro-execute.php

If you use just query(), it should work:
http://pear.php.net/manual/en/package.database.mdb2.intro-query.php



Thank you for your reply.
I used exec($sql) (since I wanted an insert ON DUPLICATE update) and it works fine.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    PEAR Forum Forum Index -> Database All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



PEAR Forum topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group

Provided by Ministry of Web developement

'Actiemonitor' online projectmanagement software