Go Back   Site Owners Forums - Webmaster Forums > Web Programming > Programming General > PHP / mySQL

Notices


Reply
 
Thread Tools Rate Thread Display Modes
Old 09-28-2016, 08:55 PM   #1
alexwaston
Registered User
 
Join Date: Aug 2016
Posts: 4
Mysqli call to mysql db routine not working

Hi, can someone help!

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

PHP Code:
DROP PROCEDURE `TestUserWeeklyAppts`;
CREATE DEFINER=`xxxx`@`%PROCEDURE `TestUserWeeklyAppts`(OUT `rowsINTNOT 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(IDINTO rows
FROM TblAppointments
WHERE StaffID 
StaffID AND ApptDate BETWEEN StartDate AND EndDate;
END 
THis just returns the number 22 everytine!
Here my PHP code

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(); 
So if anyone can explain where Im going wrong it woulbe be appreciated...

kind regards
Relax: the chainsmokers closer lyrics | rihanna work lyrics | cold water lyrics . Good fun!

Last edited by alexwaston; 12-27-2016 at 08:37 PM..
alexwaston is offline   Reply With Quote

Old 09-28-2016, 09:26 PM   #2
Xohopcom
Registered User
 
Join Date: Aug 2016
Posts: 67
I cant explain that, its too complicated
__________________
Create Your own Ecommerce Website for FREE here

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Xohopcom is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:13 PM.


Powered by vBulletin Copyright © 2020 vBulletin Solutions, Inc.