Click here to Skip to main content
11,714,776 members (81,363 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: PHP MySQL
Hi all,
I have a form with dropdownlist containing fieldnames like firstname, lastname
I have a textbox to type the keyword.
According to the fieldname selected in dropdown and the keyword typed in textbox , I have to filter the user details.
I have written a stored procedure with prepared statement. But its not working.
create procedure prcUsers
	PvchFieldName varchar(30),
	PvchFieldValue varchar(30)
	declare f,v varchar(30);
    set @fname=PvchFieldName;
	set @val=PvchFieldValue;
	set @q= concat('select * from tbmstuser where ',f,'=? like',v,'=?%');
	prepare stmt from @q;	
	execute stmt using @fname, @val;
	deallocate prepare stmt;

calling the procedure gives me the following error

Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1	0.000 sec
Have to call like this
call prcUsers('vchFirstName','a');
Posted 16-Jan-13 18:02pm
Edited 16-Jan-13 20:43pm
(no name)502.4K
Sandeep Mewara at 17-Jan-13 1:44am
How do you call this SP?
Member 9762654 at 17-Jan-13 2:03am
have given in my solution check with that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 550
1 Richard MacCutchan 275
2 Maciej Los 274
3 ManasKumarM 155
4 CHill60 135
0 Sergey Alexandrovich Kryukov 545
1 CHill60 375
2 Maciej Los 324
3 Richard MacCutchan 310
4 OriginalGriff 260

Advertise | Privacy | Mobile
Web04 | 2.8.150819.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100