英文原文
try this...
see if works...
try
{
$dsn = 'mysql:dbname=db_name;host=localhost';
$dbh = new PDO($dsn, 'usr_name', 'password');
}
catch (PDOException $e)
{
echo 'Connection failed: ' . $e->getMessage();
}
//$stmt = $dbh->prepare("CALL db.stprNewUser(:usrEmail,:newUserOK,:stprComment)");
//changed :newUserOK to @newUserOK
//changed :stprComment to @stprComment
$stmt = $dbh->prepare("CALL db.stprNewUser(:usrEmail,@newUserOK,@stprComment);");
//declare only input parameters.
//good pratice put string length. assuming varchar(100).
$stmt->bindParam(':usrEmail', $tmpEmail, PDO::PARAM_STR,100);
//dont need these
// $stmt->bindParam(':newUserOK', $newUserOK, PDO::PARAM_INT,1);
// $stmt->bindParam(':stprComment', $stprComment, PDO::PARAM_STR,100);
$stmt->execute();
$outputArray = $dbh->query("select @newUserOK, @stprComment;")->fetchAll();
foreach($outputArray as $row)
{
"NewUserOk:" . $row["@newUserOk"] . ", StprComment:" . $row["@stprComment"];
}
//$outputArray = $dbh->query("select @newUserOK, @stprComment")->fetch(PDO::FETCH_ASSOC);
//print "procedure returned [" . $outputArray['@newUserOK'] . $outputArray['@stprComment'] . "]\n";
中文翻译
试试这个......
看看是否有效...
尝试
{
$ dsn ='mysql:dbname = db_name; host = localhost';
$ dbh = new PDO($ dsn,'usr_name','password');
}
catch(PDOException $ e)
{
echo'连接失败:'。 $ E->的getMessage();
}
// $ stmt = $ dbh-> prepare(" CALL db.stprNewUser(:usrEmail,:newUserOK,:stprComment)" );
//已更改:newUserOK为@newUserOK
//已更改:stprComment为@stprComment
$ stmt = $ dbh-> prepare(" CALL db.stprNewUser(:usrEmail,@ newUserOK,@ stprComment);" );
//仅声明输入参数。
//好的实践把字符串长度。假设varchar(100)。
$ stmt-> bindParam(':usrEmail',$ tmpEmail,PDO :: PARAM_STR,100);
//不需要这些
// $ stmt-> bindParam(':newUserOK',$ newUserOK,PDO :: PARAM_INT,1);
// $ stmt-> bindParam(':stprComment',$ stprComment,PDO :: PARAM_STR,100);
$ stmt->执行();
$ outputArray = $ dbh-> query(" select @newUserOK,@ stprComment;" ) - > fetchAll();
foreach($ outputArray为$ row)
{
" NewUserOk:" 。 $ row [" @ newUserOk" ]。 " ,StprComment:" 。 $行[ " @ stprComment" ];
}
// $ outputArray = $ dbh-> query(" select @ newUserOK,@ stprComment" ) - > fetch(PDO :: FETCH_ASSOC);
// print" 程序返回[" 。 $ outputArray ['@ newUserOK']。 $ outputArray ['@ stprComment']。 " ] \ n" 个;
try this...
see if works...
try
{
$dsn = 'mysql:dbname=db_name;host=localhost';
$dbh = new PDO($dsn, 'usr_name', 'password');
}
catch (PDOException $e)
{
echo 'Connection failed: ' . $e->getMessage();
}
//$stmt = $dbh->prepare("CALL db.stprNewUser(:usrEmail,:newUserOK,:stprComment)");
//changed :newUserOK to @newUserOK
//changed :stprComment to @stprComment
$stmt = $dbh->prepare("CALL db.stprNewUser(:usrEmail,@newUserOK,@stprComment);");
//declare only input parameters.
//good pratice put string length. assuming varchar(100).
$stmt->bindParam(':usrEmail', $tmpEmail, PDO::PARAM_STR,100);
//dont need these
// $stmt->bindParam(':newUserOK', $newUserOK, PDO::PARAM_INT,1);
// $stmt->bindParam(':stprComment', $stprComment, PDO::PARAM_STR,100);
$stmt->execute();
$outputArray = $dbh->query("select @newUserOK, @stprComment;")->fetchAll();
foreach($outputArray as $row)
{
"NewUserOk:" . $row["@newUserOk"] . ", StprComment:" . $row["@stprComment"];
}
//$outputArray = $dbh->query("select @newUserOK, @stprComment")->fetch(PDO::FETCH_ASSOC);
//print "procedure returned [" . $outputArray['@newUserOK'] . $outputArray['@stprComment'] . "]\n";
试试这个......
看看是否有效...
尝试
{
$ dsn ='mysql:dbname = db_name; host = localhost';
$ dbh = new PDO($ dsn,'usr_name','password');
}
catch(PDOException $ e)
{
echo'连接失败:'。 $ E->的getMessage();
}
// $ stmt = $ dbh-> prepare(" CALL db.stprNewUser(:usrEmail,:newUserOK,:stprComment)" );
//已更改:newUserOK为@newUserOK
//已更改:stprComment为@stprComment
$ stmt = $ dbh-> prepare(" CALL db.stprNewUser(:usrEmail,@ newUserOK,@ stprComment);" );
//仅声明输入参数。
//好的实践把字符串长度。假设varchar(100)。
$ stmt-> bindParam(':usrEmail',$ tmpEmail,PDO :: PARAM_STR,100);
//不需要这些
// $ stmt-> bindParam(':newUserOK',$ newUserOK,PDO :: PARAM_INT,1);
// $ stmt-> bindParam(':stprComment',$ stprComment,PDO :: PARAM_STR,100);
$ stmt->执行();
$ outputArray = $ dbh-> query(" select @newUserOK,@ stprComment;" ) - > fetchAll();
foreach($ outputArray为$ row)
{
" NewUserOk:" 。 $ row [" @ newUserOk" ]。 " ,StprComment:" 。 $行[ " @ stprComment" ];
}
// $ outputArray = $ dbh-> query(" select @ newUserOK,@ stprComment" ) - > fetch(PDO :: FETCH_ASSOC);
// print" 程序返回[" 。 $ outputArray ['@ newUserOK']。 $ outputArray ['@ stprComment']。 " ] \ n" 个;