php cannot execute mysql embedded procedure

Discussion in 'PHP' started by ralvez, Jul 4, 2008.

  1. #1
    Hello fellow PHP coders. I'm new to this forum so a little intro may be in order.
    I'm a software developer with a solid python and mod_pytho experience but I'm new to PHP. I have done over the years some PHP coding but nothing I would call serious.

    I'm now working on a "serious" PHP application with a database back-end and I'm having a strange problem that I cannot figure out after 3 days poking at it.

    In my database I have this stored procedure:

    CREATE DEFINER=`ralvez`@`localhost` PROCEDURE `newdate`(stgDate date, stgProgram varchar(10), stgLocation varchar(20))
    BEGIN
    select @pid:= programs_id from programs where programs.`Program` = stgProgram;
    select @lid:= locations_id from locations where locations.`Location` = stgLocation;
    insert into schedules (`Date`,`programs_fk`,`locations_fk`) values (stgDate,@pid,@lid);
    commit;
    END$$

    and given the appropriate values it works from the mysql prompt.

    But when I use this PHP code to make it do the same work it just gives me a blank page, no errors (not even in /var/log/httpd/error_log) whatsoever and the database does not get updated.
    Here is the relevant PHP code:

    $PDate = $_POST['pdate'];
    $Prog = $_POST['prog'];
    $PLoc = $_POST['ploc'];

    require_once('/home/ralvez/.dbconn/connect.php');

    $mysqli = new mysqli($mysql['host'], $mysql['username'], $mysql['password'], $mysql['database']);

    if (mysqli_connect_errno()){
    printf ("<p>Connection Error: %s</p>", mysqli_connect_error());
    exit();
    } else {
    $sql = "call new_date (\"$PDate\",\"$Prog\",\"$PLoc\")";

    if ($mysqli->errno <> 0){
    die ($mysqli->errno. " " .$mysqli->error);
    }

    }

    mysqli_close($mysqli);

    ?>

    Am I doing something stupid or plain wrong? :confused:

    I'll appreciate any help.


    R.
     
    ralvez, Jul 4, 2008 IP