save-to-database函数不起作用

y0u0uwnf  于 2021-06-15  发布在  Mysql
关注(0)|答案(0)|浏览(203)

除了从load\u info函数调用save\u info函数保存到数据库外,其他都正常工作,我尝试在if语句中包含save\u info函数的整个代码块,但仍然不起作用

// This function will save information to an existing account
//==MAN8==
function save_info($dbh, $table, $pname, $pip, $pnp, $pop, $psp)
{
try
	{
		$stmt = $dbh->prepare("UPDATE $table SET p_ip=?, p_np=?,p_op=?,p_sp=? WHERE p_name=?");
		$stmt->execute(array($pip,$pnp,$pop,$psp,$pname));
		echo "1";
	}
	catch (PDOExecption $ex)
		{	
			echo "0";
		}
	$dbh = null;
}

// This function will pull account information
//==MAN9==
function load_info($dbh,$table,$pname)
{
	{
		$stmt = $dbh->query("SELECT * FROM $table WHERE p_name = '$pname'");
		$result = $stmt->fetchObject();

		if ($result->p_ip > $result->p_np)
		{
		echo 'yes';
		}
	    if ($result->p_ip = $result->p_np)
		{
		save_info($dbh, $table, $pname, $pip, $pnp, $pop, $psp);	
		}	
	}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题