Mysqli call to mysql db routine not working
I'm new to php and mysql and making good progress. But I am stumped with a call to a mysql stored proc/routine.
It runs prefectly well in mysql reutrning just the number of rows in a table.
But I cannot get it to work in PHP. I have even stripped out all the IN to avoid any confusion. Here my routine SQL Code
DROP PROCEDURE `TestUserWeeklyAppts`;
CREATE DEFINER=`xxxx`@`%` PROCEDURE `TestUserWeeklyAppts`(OUT `rows` INT) NOT DETERMINISTIC NO SQL SQL SECURITY DEFINER BEGIN
DECLARE StartDate DATE;
DECLARE EndDate DATE;
DECLARE StaffID INT;
SET StaffID = 4;
SET StartDate = '2016-09-11';
SET EndDate = DATE_ADD(StartDate ,INTERVAL 7 DAY);
SELECT COUNT(ID) INTO rows
FROM TblAppointments
WHERE StaffID = StaffID AND ApptDate BETWEEN StartDate AND EndDate;
END
Here my PHP code
$mysqli = new mysqli($servername, $dbusername, $dbpassword);
mysqli_select_db($mysqli, $database);
if ($mysqli->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$stmt = $mysqli->prepare('CALL TestUserWeeklyAppts(@rows)');
$stmt->execute();
$select = $mysqli->query('SELECT @rows');
$result = $select->fetch_array();
print_r($result['Rows']);
if (!select) {
echo "false";
}
else {
echo "True"."<br>";
// output data of each row
while($row = mysql_fetch_array($result)){
print_r($row);
}
echo "Number of Select rows: ". $select->num_rows ."<br>";
echo "Number of Result Rows: ". $result->num_rows ."<br>";
}
$stmt->close();
Relax: watch latest fantasy movies | watch latest romance movies | watch bad moms movies. Good fun!
-
oompaloompa -
Thanks
{{ DiscussionBoard.errors[10867024].message }} -
-
sunsetcoder -
Thanks
{{ DiscussionBoard.errors[10867831].message }} -
-
David Beroff -
Thanks
SignaturePut MY voice on YOUR video: AwesomeAmericanAudio.com{{ DiscussionBoard.errors[10867882].message }} -