Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. How to call procedure in MySQL to use in PHP?

How to call procedure in MySQL to use in PHP?

Scheduled Pinned Locked Moved Web Development
phpsharepointdatabasemysqlsales
12 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Hy Chanhan

    Hi all, i have a procedure below: //==============MySQL======================================= CREATE PROCEDURE `sp_select_customer`(custid int) begin select * from customer where customer_id=custid; end; //================PHP code===================================== $con=mysql_connect("localhost","root","root") or die("Connection is fail."); $db=mysql_select_db("mydatabase",$con); $result=mysql_query("CALL sp_select_customer(9)"); // it's not working when i use CALL PROCEDURE $row=mysql_fetch_array($result); echo $row['0']; //=============================== Please help me! Thanks,

    Hy Chan Han

    M Offline
    M Offline
    Michael Sync
    wrote on last edited by
    #2

    What error are you getting?

    Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

    H 1 Reply Last reply
    0
    • M Michael Sync

      What error are you getting?

      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

      H Offline
      H Offline
      Hy Chanhan
      wrote on last edited by
      #3

      Here is error: ============================= Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\itec\select.php on line 8 ============================= It's not working when procedure use select statement. I use insert statement it's working ok. Thanks,

      Hy ChanHan

      M 1 Reply Last reply
      0
      • H Hy Chanhan

        Here is error: ============================= Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\itec\select.php on line 8 ============================= It's not working when procedure use select statement. I use insert statement it's working ok. Thanks,

        Hy ChanHan

        M Offline
        M Offline
        Michael Sync
        wrote on last edited by
        #4

        Try to use multi_query instead of mysql_query.

        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

        H 1 Reply Last reply
        0
        • M Michael Sync

          Try to use multi_query instead of mysql_query.

          Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

          H Offline
          H Offline
          Hy Chanhan
          wrote on last edited by
          #5

          Error appeared: Fatal error: Call to undefined function multi_query() in C:\AppServ\www\itec\select.php on line 5

          Hy Chanhan

          M 1 Reply Last reply
          0
          • H Hy Chanhan

            Error appeared: Fatal error: Call to undefined function multi_query() in C:\AppServ\www\itec\select.php on line 5

            Hy Chanhan

            M Offline
            M Offline
            Michael Sync
            wrote on last edited by
            #6

            I have tested in my machine. (Note: I'm using the latest version of PHP and MySQL. )
            "; while($thisrow=mysql_fetch_row($result)) { $i=0; while ($i < mysql_num_fields($result)) { $field_name=mysql_fetch_field($result, $i); echo $thisrow[$i] . " "; //Display all the fields on one line $i++; } echo "
            "; //put a break after each database entry } ?> Hope it will work in your side too.. Let me know the result.. Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

            H 2 Replies Last reply
            0
            • M Michael Sync

              I have tested in my machine. (Note: I'm using the latest version of PHP and MySQL. )
              "; while($thisrow=mysql_fetch_row($result)) { $i=0; while ($i < mysql_num_fields($result)) { $field_name=mysql_fetch_field($result, $i); echo $thisrow[$i] . " "; //Display all the fields on one line $i++; } echo "
              "; //put a break after each database entry } ?> Hope it will work in your side too.. Let me know the result.. Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

              H Offline
              H Offline
              Hy Chanhan
              wrote on last edited by
              #7

              Hi, Thank you very much for your code, now it's working very well in my site. :rose:

              Hy ChanHan

              M 1 Reply Last reply
              0
              • M Michael Sync

                I have tested in my machine. (Note: I'm using the latest version of PHP and MySQL. )
                "; while($thisrow=mysql_fetch_row($result)) { $i=0; while ($i < mysql_num_fields($result)) { $field_name=mysql_fetch_field($result, $i); echo $thisrow[$i] . " "; //Display all the fields on one line $i++; } echo "
                "; //put a break after each database entry } ?> Hope it will work in your side too.. Let me know the result.. Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

                H Offline
                H Offline
                Hy Chanhan
                wrote on last edited by
                #8

                Hello again, When i refreshed 4 or 5 times i appeared this error message: why????? PROCEDURE bbg.sp_select_customer can't return a result set in the given context

                Hy ChanHan

                M 1 Reply Last reply
                0
                • H Hy Chanhan

                  Hello again, When i refreshed 4 or 5 times i appeared this error message: why????? PROCEDURE bbg.sp_select_customer can't return a result set in the given context

                  Hy ChanHan

                  M Offline
                  M Offline
                  Michael Sync
                  wrote on last edited by
                  #9

                  Hy Chanhan wrote:

                  PROCEDURE bbg.sp_select_customer can't return a result set in the given context

                  I will check again and will let you know..

                  Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

                  M 1 Reply Last reply
                  0
                  • H Hy Chanhan

                    Hi, Thank you very much for your code, now it's working very well in my site. :rose:

                    Hy ChanHan

                    M Offline
                    M Offline
                    Michael Sync
                    wrote on last edited by
                    #10

                    Hy Chanhan wrote:

                    Thank you very much for your code, now it's working very well in my site.

                    If my code is useful for you, please vote my message. thanks. :)

                    Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

                    1 Reply Last reply
                    0
                    • M Michael Sync

                      Hy Chanhan wrote:

                      PROCEDURE bbg.sp_select_customer can't return a result set in the given context

                      I will check again and will let you know..

                      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

                      M Offline
                      M Offline
                      Michael Sync
                      wrote on last edited by
                      #11

                      seem like i forget to close the connection.. try to add the code for closing connection..

                      Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

                      H 1 Reply Last reply
                      0
                      • M Michael Sync

                        seem like i forget to close the connection.. try to add the code for closing connection..

                        Thanks and Regards, Michael Sync ( Blog: http://michaelsync.net) If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you. :)

                        H Offline
                        H Offline
                        Hy Chanhan
                        wrote on last edited by
                        #12

                        It's still not working. Error is the same above. :(

                        Hy ChanHan

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups