Jump to content

call store procedure with php


ky0shiro

Recommended Posts

Hi, wanna ask about store procedure & php to call it :-)

i have already created this store procedure, but i can't call it in my php code..

can someone help me please.. ?? the result won't appear in the browser..

 

here is my store procedure code :

 

CREATE PROCEDURE `select_users`(id int(11), username varchar(100))

select * from users where id='id';

 

and here is my php code to call the store procedure above :

<?

$conn = mysqli_connect('localhost','root','','store_procedure');

$id = 2;

 

if ($result = mysqli_query($conn, "call select_users('$id', '$username')")) {

while( $row = mysqli_fetch_array($result) ){

echo $row['id']." - ".$row['username'] . "<br>";

}

}

mysqli_free_result($result);

mysqli_close($conn);

?>

 

 

after i execute that php code in my browser, it wont appear the result with id=2

my database just have 2 tables, 'id' & 'username'

php code above is just to view the result with id=2

but it won't appear.. does anyone know where is my mistake?

Thx before.. :-)

Link to comment
https://forums.phpfreaks.com/topic/56349-call-store-procedure-with-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.