sithembisophp 0 Newbie Poster

Hi everyone,

Can anyone tell my why this does not work?

I created a stored procedure that uses a variable / input value as table name, but it does not do what it's supposed to do.
Here is the code:

delimiter //
DROP PROCEDURE IF EXISTS userpages.respondtoconnectionrequest//
CREATE DEFINER = 'sithembiso'@'localhost' PROCEDURE userpages.respondtoconnectionrequest(IN tname VARCHAR(23),IN response INT,IN ouserid INT(14),IN fuserid INT(14),IN fftable VARCHAR(23))
BEGIN
	SET @u = CONCAT('UPDATE `userpages`.`',tname,'` SET `status`=',response,' WHERE `',tname,'`.`userID`=',fuserid);
	PREPARE stmtu FROM @u;
	EXECUTE stmtu;
	DEALLOCATE PREPARE stmtu;
	IF (response = 1) THEN
		SET @i = CONCAT('UPDATE `userpages`.`',fftable,'` SET `status`=',response,' WHERE `',fftable,'`.`userID`=',ouserid);
		PREPARE stmti FROM @i;
		EXECUTE stmti;
		DEALLOCATE PREPARE stmti;
	END IF;
END;
//
delimiter ;

If I call this using the following code, it does not update those fields and it does not return any error.

CALL userpages.respondtoconnectionrequest('91031707885__friends',1,'91031707885','43979905046','43979905046__friends');

Any light on this will be highly appreciated.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.