douyou8266
douyou8266
2017-03-07 12:51

从php调用mysql存储过程时出错

已采纳

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.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答

  • dongqing4070 dongqing4070 4年前

    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)');
    
    点赞 评论 复制链接分享
  • doushichi3678 doushichi3678 4年前

    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)');
    
    点赞 评论 复制链接分享