This is the procedure code.

DELIMITER # CREATE PROCEDURE select_from_users_by_user( IN p_user VARCHAR(32)) BEGIN SELECT * FROM users WHERE user=p_user; END # 

And this is the code in php

 $query = "CALL select_from_users_by_user('".$_SESSION['user']."')"; $result = mysql_query($query); if(!$result) die("error to connect date base: ".mysql_error()); $rows = mysql_fetch_array($result); 

But does not work, gives an error context. What can it be from?

    3 answers 3

    I do not know. INT values ​​through PHP right away I threw everything into normal. True with varchar did not try. For this purpose, especially even in the source code of my own where I encountered such code. Where are all the checks in the stored procedure. If $ _GET ['id_tt'] is not int, then exception will crash and try to call it.

      $db->query ("CALL AddVariant (".$_GET['id_tt'].")"); 
    • Well, the question is about a procedure that returns a descriptor with a table result ... - KiTE

    You do not correctly pass parameters to your procedure .. As a parameter, you must pass a variable and not a string ..

     mysql> SET @user = "vasea"; mysql> CALL select_from_users_by_user( @user ); 

    I hope the idea is clear ..

    • it doesn't work either :) - muerto

    This is a PHP problem ... Not treated ...