SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    How to execute stored procedure in php mysql

    Hi i want to execute the stored procedure in mysql using php ? can any one give example for this

    i have code like this but it show error

    Fatal error: Call to undefined function mssql_init() in C:\wamp\www\workouts\storedprocedure.php on line 21

    PHP Code:

    $mysql_host 
    "localhost";
    $mysql_username "root";
    $mysql_password "";
    $mysql_database "test";

    $dbh=mysql_connect($mysql_host,$mysql_username,$mysql_password)or die(mysql_error());//connected to mysql
    echo "Connected to SQL";

    mysql_select_db($mysql_database,$dbh) or die (mysql_error());//connect to database
    echo "connect to db";

    $stmt mysql_init("test2",$conn); 

    $stmt $dbh->prepare("CALL test2");
    $stmt->bindParam(1$return_valuePDO::PARAM_STR4000); 

    // call the stored procedure
    $stmt->execute();

    print 
    "procedure returned $return_value\n"

  2. #2
    SitePoint Evangelist smftre's Avatar
    Join Date
    Dec 2008
    Location
    London
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You cannot use standard mysql to execute statements/stored procedures, you need to use mysqli.

    Run through something like this to get a better understanding: http://www.rvdavid.net/using-stored-...sqli-in-php-5/
    Statvoo.com The Website Traffic Monitor
    The best way to monitor traffic to your sites for free!


    Web Development London UK We make web 3.0 applications

  3. #3
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    using mysql we couldnt do stored procedures ?

  4. #4
    SitePoint Evangelist smftre's Avatar
    Join Date
    Dec 2008
    Location
    London
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sure I just answered that.... !?!?
    Statvoo.com The Website Traffic Monitor
    The best way to monitor traffic to your sites for free!


    Web Development London UK We make web 3.0 applications

  5. #5
    SitePoint Addict goldensona's Avatar
    Join Date
    Jun 2011
    Posts
    226
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your reply.

  6. #6
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by goldensona View Post
    Hi i want to execute the stored procedure in mysql using php ? can any one give example for this

    i have code like this but it show error

    Fatal error: Call to undefined function mssql_init() in C:\wamp\www\workouts\storedprocedure.php on line 21
    mSsql are you sure, not mYsql ?

  7. #7
    SitePoint Evangelist smftre's Avatar
    Join Date
    Dec 2008
    Location
    London
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol
    Statvoo.com The Website Traffic Monitor
    The best way to monitor traffic to your sites for free!


    Web Development London UK We make web 3.0 applications


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •