我有一个php脚本,它应该向远程数据库插入一个新行。有些东西不能正常工作,但是当我尝试使用mysqli_error
进行调试时,它不会返回任何内容。代码如下:
$connect = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname) or die("Unable to Connect to '$dbhost'");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$query = "INSERT INTO #DBname.TableName# (Section,Gender,WinningTeam,LosingTeam,FixtureD,FixtureT,Venue,Court,Texts,SetsWon,SetsLost,Winner_Score,Loser_Score) VALUES ($Section,$Gender,$WinningTeam,$LosingTeam,$FixtureD,$FixtureT,$Venue,$Court,$Texts,$SetsWon,$SetsLost,$Winner_Score,$Loser_Score)";
$result = mysqli_query($connect, $query) or die (mysqli_error());
错误消息显示mysqli_error
预计恰好1个参数,0表示。但是,当我用mysqli_error($connect)
替换它时,我得到错误404 - 在服务器上找不到php脚本。
很确定我错过了一些明显的东西,有人可以帮忙吗?
亲切的问候
答案 0 :(得分:0)
函数mysqli_error()根据php.net
需要一个参数所以在你的情况下:
$result = mysqli_query($connect, $query) or die (mysqli_error($connect));