Can anyone tell me if the following MySQL procedure along with a PHP script work?
I've set up mysql procedure here and I think it makes sense but the PHP script will print error. By that I'm guessing that there were 0 rows effected?
MySQL:
DELIMITER $$
CREATE procedure spPlayer (IN pName NVARCHAR(50), IN pMobileNumber NVARCHAR(50), IN pTime datetime, OUT pID INT)
begin
select count(*) into @cnt FROM tblnewusers;
IF @cnt < 12 THEN
insert into tblplayers (Name, MobileNumber, Time)
values
(pName, pMobileNumber, pTime);
SELECT pID = @@IDENTITY;
END IF;
END$$
DELIMITER ;
PHP:
<?php
$dt = new datetime();
$name = "Test";
$mobile = "1234567";
$time = $dt->format('Y-m-d H:i:s');
$dbhost = 'dbHost here';
$dbuser = 'dbUser here';
$dbpass = 'dbPass here';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn)
{
die('Could not connect: '. mysql_error());
}
mysql_select_db("SafeDropbox", $conn);
$result = mysql_query("CALL spPlayer();");
if($result) {
echo "Success";
}
else {
echo "Error";
}
?>
EDIT Here's the MySql table set up it it helps!