rahul
rahul

Reputation: 1

How to pass php variable as value in store procedure call in sql query?

I am not getting any results while passing the values intot the stores procuder I have the code below

<?php

     $a="26456";

     $result3=mysql_query('CALL getItemStock($a)');
     $row = mysql_fetch_array($result3);
?>

Upvotes: 0

Views: 256

Answers (1)

Akam
Akam

Reputation: 1052

Try this:

    $result3=mysql_query('CALL getItemStock('.$a.')');

or

    $result3=mysql_query("CALL getItemStock($a)");

UPDATE:

If the parameter defined as string then you need to enclose it with quotes as well. For example:

    $a = 'I am String';
    $result3=mysql_query("CALL getItemStock('$a')");

However, if the parameter defined as number, then no quotation required.

Upvotes: 2

Related Questions