0

I have triggered the stored procedure from php. I have passed the input parameters also as shown.

$id = 1;
$nameDetail = 'raj';
$result = mysqli_query('CALL InsertDetails($id,$nameDetail)');

But getting below error.

mysqli_query() expects at least 2 parameters, 1 given ...

Please suggest a solution.

7
  • are you connect database and host? Commented Mar 7, 2017 at 12:58
  • yes i connected database . SP has two parametes, i have passed two parameters also. But the error shows 1 given Commented Mar 7, 2017 at 13:00
  • $mysqli = mysqli_connect('localhost','username','password','dbname'); $mysqli->query("call InsertDetails($id,'$nameDetails')") try this Commented Mar 7, 2017 at 13:03
  • Thanks for your reply. issue resolved. But the values not inserted in corresponding table. Commented Mar 7, 2017 at 13:13
  • show your store procedure Commented Mar 7, 2017 at 13:15

2 Answers 2

1

The issue is that you're not set the mysqli connection.please try this

$connection = mysqli_connect('localhost','username','password','db');
    $result = mysqli_query($connection,'CALL InsertDetails($id,$nameDetail)');
Sign up to request clarification or add additional context in comments.

12 Comments

Thanks for your reply. I have $id = 1; $nameDetail= 'test' ; $result = mysqli_query($connection,'CALL InsertDetails($id,$nameDetail)');. But the values not inserted in table.
Yes it working. SP triggered. But values not stored in table. this is my SP CREATE PROCEDURE InsertDetails (id int, name varchar(100)) BEGIN Declare newvalue varchar(50) insert into student(id,Name) values(id,name); set newvalue = 'success'; select newvalue; END $$
wait let me check
change this, insert into student (id, Name) values (sid, sname);
run your store procedure to check,
|
0

You need to pass in the connection as the first parameter:

// connect to DB
$connect = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");

// run procedure
$result = mysqli_query($connect, 'CALL InsertDetails($id,$nameDetail)');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.