call MySQL stored procedure from php

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Urmi Biswas

    call MySQL stored procedure from php

    Hi All,

    Has anyone tried calling MySQL stored procedure from php scripts?
    I use PEAR DB module to access MySQL database.
    Not sure if php 4.4.0 (that we use) support calling stored procedures.

    Regards,
    Urmi


  • Jerry Stuckle

    #2
    Re: call MySQL stored procedure from php

    Urmi Biswas wrote:
    Hi All,
    >
    Has anyone tried calling MySQL stored procedure from php scripts?
    I use PEAR DB module to access MySQL database.
    Not sure if php 4.4.0 (that we use) support calling stored procedures.
    >
    Regards,
    Urmi
    >
    >
    I know of no reason why php 4.x (it's now backlevel and no longer
    supported - you should update ASAP) shouldn't support it, but php 5.x
    supports it fine.

    Did you try it?

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Urmi Biswas

      #3
      Re: call MySQL stored procedure from php

      Thanks Jerry for replying.

      I tried the following:

      $sth=$db->prepare("cal l validateFBT(?,? )");
      $bindvars=array ("1" =$SelectedFBT," 2" =$frequency);
      $res=$db->execute($sth,$ bindvars);

      if (DB::iserror($r es)) {
      die($res ->getMessage( ));
      }

      I get 'DB Error: unknown error'.

      Regards,
      Urmi






      "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
      news:gg1th3$5dc $2@news.motzare lla.org...
      Urmi Biswas wrote:
      >Hi All,
      >>
      >Has anyone tried calling MySQL stored procedure from php scripts?
      >I use PEAR DB module to access MySQL database.
      >Not sure if php 4.4.0 (that we use) support calling stored procedures.
      >>
      >Regards,
      >Urmi
      >>
      >>
      >
      I know of no reason why php 4.x (it's now backlevel and no longer
      supported - you should update ASAP) shouldn't support it, but php 5.x
      supports it fine.
      >
      Did you try it?
      >
      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstucklex@attgl obal.net
      =============== ===

      Comment

      • Jerry Stuckle

        #4
        Re: call MySQL stored procedure from php

        Urmi Biswas wrote:
        "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
        news:gg1th3$5dc $2@news.motzare lla.org...
        >Urmi Biswas wrote:
        >>Hi All,
        >>>
        >>Has anyone tried calling MySQL stored procedure from php scripts?
        >>I use PEAR DB module to access MySQL database.
        >>Not sure if php 4.4.0 (that we use) support calling stored procedures.
        >>>
        >>Regards,
        >>Urmi
        >>>
        >>>
        >I know of no reason why php 4.x (it's now backlevel and no longer
        >supported - you should update ASAP) shouldn't support it, but php 5.x
        >supports it fine.
        >>
        >Did you try it?
        >>
        Thanks Jerry for replying.
        >
        I tried the following:
        >
        $sth=$db->prepare("cal l validateFBT(?,? )");
        $bindvars=array ("1" =$SelectedFBT," 2" =$frequency);
        $res=$db->execute($sth,$ bindvars);
        >
        if (DB::iserror($r es)) {
        die($res ->getMessage( ));
        }
        >
        I get 'DB Error: unknown error'.
        >
        Regards,
        Urmi
        >
        (Top posting fixed)

        That may be because you're trying to use prepared statements. Not sure
        though. Do other operations work OK? Can you call your SP via
        mysql_query()?

        P.S. Please don't top post. Thanks.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Jerry Stuckle

          #5
          Re: call MySQL stored procedure from php

          Álvaro G. Vicario wrote:
          Urmi Biswas escribió:
          >$sth=$db->prepare("cal l validateFBT(?,? )");
          >$bindvars=arra y("1" =$SelectedFBT," 2" =$frequency);
          >$res=$db->execute($sth,$ bindvars);
          >>
          > if (DB::iserror($r es)) {
          > die($res ->getMessage( ));
          > }
          >>
          >I get 'DB Error: unknown error'.
          >
          According to the example in docs execute() seems to expect a numeric
          zero-based array:
          >

          >
          Check whether you get the same error if you don't specify array indexes
          (which are not needed anyway).
          >
          Good catch, Álvaro. That one went right by me.


          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • Urmi Biswas

            #6
            Re: call MySQL stored procedure from php

            "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
            news:gg3mmp$ke$ 3@news.motzarel la.org...
            Álvaro G. Vicario wrote:
            >Urmi Biswas escribió:
            >>$sth=$db->prepare("cal l validateFBT(?,? )");
            >>$bindvars=arr ay("1" =$SelectedFBT," 2" =$frequency);
            >>$res=$db->execute($sth,$ bindvars);
            >>>
            >> if (DB::iserror($r es)) {
            >> die($res ->getMessage( ));
            >> }
            >>>
            >>I get 'DB Error: unknown error'.
            >>
            >According to the example in docs execute() seems to expect a numeric
            >zero-based array:
            >>
            >http://pear.php.net/manual/en/packag...on.execute.php
            >>
            >Check whether you get the same error if you don't specify array indexes
            >(which are not needed anyway).
            >>
            >
            Good catch, Álvaro. That one went right by me.
            >
            >
            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstucklex@attgl obal.net
            =============== ===

            Tried without array index.... doesn't work. Same error.
            mysqli comes with php 5.

            Tried using mysql_query, it works!!!

            Thanks to all, for your inputs.

            Regards,
            Urmi


            Comment

            Working...