Mneva skoko
Mneva skoko

Reputation: 71

Mysql stored procedure where clause

Ok let me try this again.

query("CALL getemployee('$eml')"); $result = $sql->fetch_array(); ?> This is my stored procedure:

Delimiter //
Create procedure getemployee(in eml varchar(50))
Begin
  Select * from employees where email = eml;
End//
Delimiter ;

The error i get from browser: "Fatal error: Call to a member function fetch_array() on a non-object ...".

I use phpmyadmin version 3.2.4 and the mysql client version: 5.1.41

Upvotes: 3

Views: 2064

Answers (3)

Nikhil
Nikhil

Reputation: 1

CREATE PROCEDURE get_customers(IN inCustomerIdList VARCHAR(100))
BEGIN

  SELECT first_name, last_name, email FROM tbl_customers  
  WHERE customer_id IN (inCustomerIdList);

END$$

Upvotes: 0

newtover
newtover

Reputation: 32094

The eml variable you use is not defined. Should not it be as following:

Create procedure getemployee (in eml varchar(50))

Upvotes: 1

Daniel Vassallo
Daniel Vassallo

Reputation: 344431

Your CREATE PROCEDURE statement appears to be invalid.

You need to give a name to your procedure, and to the parameter that you are passing. Therefore you may want to try something like the following example:

DELIMITER //
CREATE PROCEDURE procName (IN eml varchar(50))
BEGIN
   SELECT * FROM employees WHERE email = eml;
END//    
DELIMITER ;

Upvotes: 2

Related Questions