私は1年前に行った古い請願サイトに気付きましたが、PHPサーバのアップグレード以降しばらくは働いていないので、修正しています。私はそのほとんどを修正しましたが、今すぐ電子メールを確認することに固執しました。古いMySQLコードをMySQLiに変換するには?
警告:mysqli_num_rows()は、パラメータ1がmysqli_resultされることを想定し、ライン上の/home/merlin/public_html/index.phpで与え アレイ64
警告:mysqli_query()は、少なくとも2つのパラメータを想定し、 mysqli_error()は正確に1パラメータ、0ライン75
に/home/merlin/public_html/index.phpで与え期待:線上 /home/merlin/public_html/index.php 75警告が与えられる1
CODE:(私は修正しようとしました)
<?php
if(isset($_GET['key']) ? $_GET['key'] : '') {
include('database.php');
$confirmId = (isset($_GET['key']) ? $_GET['key'] : null);
$errorMessage = "";
$validCount = 0;
$sql = "SELECT confirmed FROM email_list WHERE confirmationcode='$confirmId'";
$sqll = mysqli_query($mysqli,$sql);
$result = mysqli_fetch_array($sqll);
$validCount = mysqli_num_rows($result);
if($result['confirmed'] == 1) {
echo "<div class=\"notice error\">You have already confirmed this petition signup.</div>";
} else if($result['confirmed'] == 0){
$query = "UPDATE email_list SET confirmed = 1 WHERE confirmationcode='$confirmId'";
mysqli_query($query) OR die(mysqli_error());
echo '<div class=\"notice error\">Your petition has been accepted, Thank you and with your help we might just get Merlin back on our screens. Why not spread the word on Twitter and Facebook? Just quick the icons to the right.</div>';
}
}
?>
PREVIOUS CODE:(からの変換)
<?php
if(isset($_GET['key']) ? $_GET['key'] : '') {
include('database.php');
$confirmId = (isset($_GET['key']) ? $_GET['key'] : null);
$errorMessage = "";
$validCount = 0;
$query = "SELECT confirmed FROM email_list WHERE confirmationcode='$confirmId'";
$result = mysql_query($query);
$validCount = mysql_num_rows($result);
if($result['confirmed'] == 1) {
echo "<div class=\"notice error\">You have already confirmed this petition signup.</div>";
} else if($result['confirmed'] == 0){
$query = "UPDATE email_list SET confirmed = 1 WHERE confirmationcode='$confirmId'";
mysql_query($query) OR die(mysql_error());
echo '<div class=\"notice error\">Your petition has been accepted, Thank you and with your help we might just get Merlin back on our screens. Why not spread the word on Twitter and Facebook? Just quick the icons to the right.</div>';
}
}
?>
NEW database.phpで:
RTFM? http://php.net/manual/en/mysqli-stmt.num-rows.php関数はステートメントハンドルを期待しています。エラーが表示されている場合は、配列を渡しています。 –
エラーテキストには何が書かれているのか分かりませんか? –