1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to call MySql Stored Procedure to PHP Script

Discussion in 'PHP' started by bartolay13, Dec 4, 2007.

  1. #1
    Please Post some simple script to call on Stored Procedures.
    Thanks in advance....
     
    bartolay13, Dec 4, 2007 IP
  2. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    its a database call so do it using

    mysql_connect('CALL procedure_name()');
     
    tonybogs, Dec 5, 2007 IP
  3. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #3
    whoa thanks for the reply... ill try it then,, thanks..
     
    bartolay13, Dec 5, 2007 IP
  4. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #4
    theres an error:

    Warning: mysql_connect() [function.mysql-connect]: Unknown MySQL server host 'call insertion()' (11004) in C:\wamp\www\www.P002.com\includes\member_signup.php on line 3

    heres my line 3

    mysql_connect('call insertion()');

    the stored procedure runs in mysql browser...

    DELIMITER $$

    DROP PROCEDURE IF EXISTS `profilesasiapacific`.`insertion` $$
    CREATE PROCEDURE `profilesasiapacific`.`insertion` ()
    BEGIN
    SELECT COUNT(*) FROM member;
    END $$

    DELIMITER ;

    please need help badly
     
    bartolay13, Dec 5, 2007 IP
  5. amnezia

    amnezia Peon

    Messages:
    990
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #5
    
    $db->query('call StoredProcedure()');
    
    PHP:
    where $db is a php mysql connection
     
    amnezia, Dec 6, 2007 IP
  6. legend2

    legend2 Well-Known Member

    Messages:
    1,537
    Likes Received:
    74
    Best Answers:
    0
    Trophy Points:
    115
    #6
    mysql_query("CALL ...");
     
    legend2, Dec 6, 2007 IP
  7. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Whoops,

    I made a booboo higher up sorry

    Yeah that shouldnt be mysql_connect, it should be mysql_query

    Apologies :S
     
    tonybogs, Dec 6, 2007 IP
  8. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #8
    when i type

    
    $a = mysql_query('call StoredProc()');
    var_dump($a);
    
    PHP:
    output: bool(false);
    the dump doesn't recognize the syntax....
     
    bartolay13, Dec 6, 2007 IP
  9. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #9
    @amnezia

    can i request for your full code...
    tnx :)
     
    bartolay13, Dec 6, 2007 IP
  10. bartolay13

    bartolay13 Active Member

    Messages:
    735
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    98
    #10
    nid some script.. please
     
    bartolay13, Dec 7, 2007 IP
  11. nanna_vijayalaxmi

    nanna_vijayalaxmi Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    $mysqli=new mysqli("Hostname","username","password","database");
    $res_new=array();
    $Query1="";$Query="";$result1=0;
    $url="sciencedaily.com";
    $Query1="call GetExpert_last('$url')";
    echo $Query1;
    echo "<br/>";
    $res = $mysqli->query("$Query1");
    if(mysqli_num_rows($res)>0)
    {
    $row = mysqli_fetch_row($res);
    $res = $row[0];
    echo $res;
    }
     
    nanna_vijayalaxmi, Dec 7, 2007 IP
  12. nanna_vijayalaxmi

    nanna_vijayalaxmi Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    Hi ,
    this is sample stored procedure call

    $mysqli=new mysqli("Hostname","username","password","database");
    $res_new=array();
    $Query1="";$Query="";$result1=0;
    $url="sciencedaily.com";
    $Query1="call GetExpert_last('$url')";
    echo $Query1;
    echo "<br/>";
    $res = $mysqli->query("$Query1");
    if(mysqli_num_rows($res)>0)
    {
    $row = mysqli_fetch_row($res);
    $res = $row[0];
    echo $res;
    }
    Edit/Delete Message
     
    nanna_vijayalaxmi, Dec 7, 2007 IP