problem with stored prodedure :-(

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahlem
    New Member
    • May 2010
    • 1

    #1

    problem with stored prodedure :-(

    hi all , I had create a procedure stored in mysql 5.1 this is its code:
    Code:
    CREATE PROCEDURE `verif_numtel` (IN login varchar(10), IN numero INT,INOUT erreur INT) DETERMINISTIC
    BEGIN
    SET erreur= 0;
    
    IF(numero<0) THEN SET erreur= 1;
    
    ELSE INSERT INTO Membre_de_bureau (loginMB,num_telMB) VALUES (login, numero);
    
    END IF;
    
    END;//
    and i try to call him in php to use this code:

    Code:
    try
    {
    	$bdd = new PDO('mysql:host=localhost;dbname=club_investissement1', '****', '****');
    }
    catch (Exception $e)
    {
            die('Erreur : ' . $e->getMessage());
    }
    $log = 'prince';$numtel = 555; $err = 0;
    
    
    $req =$bdd->prepare("CALL verif_numtel(?,?,?)");
    $req->bindParam(1, $log, PDO::PARAM_STR, 10);
    $req->bindParam(2, $numtel, PDO::PARAM_INT);
    $req->bindParam(3, $err, PDO::PARAM_INT|PDO::PARAM_INPUT_OUTPUT);
    $req->execute();
     print "procedure returned $err \n";
    but the code would not work and i don't no what the probleme if can anywone can help me please?
    (ps sorry for my bad english i'm french women ....)
    Last edited by Dormilich; May 19 '10, 01:26 PM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I would have done the check ($numero < 0) on the PHP side, so that you don’t have to use a stored procedure …

    Did you try to execute the Stored Procedure directly? (e.g. in phpMyAdmin or any other DB interface)

    Comment

    Working...