error in calling a stored procedure in php

This is a discussion on error in calling a stored procedure in php within the PHP General forums, part of the PHP Programming Forums category; i've a sql query as follows: SELECT tb1.col1,tb2.col1,tb3.col1 FROM tb1,tb2,tb3 where tb1....


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 10-31-2006
Gayatri
 
Posts: n/a
Default error in calling a stored procedure in php

i've a sql query as follows:

SELECT tb1.col1,tb2.col1,tb3.col1 FROM tb1,tb2,tb3 where
tb1.col1=tb2.col2 AND tb3.col3=tb2.col3 AND tb2.col4 BETWEEN 4 AND 5
AND tb2.col5 BETWEEN 6 AND 7;

if I run the above query thru php it works, but if i try to call a
procedure for above query as shown below it thrws error
ERROR 1064 (42000): the right syntax to use near 'tb1.col2
<?
$wherestr = "tb2.col4 BETWEEN 4 AND 5 AND tb2.col5 BETWEEN 6 AND 7";
CALL proc4($wherestr);

?>
Procedure#=>

DELIMITER $$

DROP PROCEDURE IF EXISTS `midas`.`sp_dm_domain_keyword_mapping`$$
CREATE DEFINER=`oteuser`@`%` PROCEDURE `sp_dm_domain_keyword_mapping`(
whereval varchar(500))
BEGIN

set @whereval = whereval;


set @sql1 = CONCAT('SELECT tb1.col1,tb2.col1,tb3.col1 FROM tb1,tb2,tb3
where tb1.col1=tb2.col2 AND tb3.col3=tb2.col3 AND ',@whereval);
PREPARE stmt FROM @sql1;

EXECUTE stmt using @whereval;
DEALLOCATE PREPARE stmt;


END$$

DELIMITER ;

what is the error in above code?

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:02 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0