<?php
include("db_con.php");
$szID = addslashes($_GET['id']);
$szPART = addslashes($_GET['part']);
$sum = 0;
$todayc = date("Y-m-d");
$sql = "select * from counter where id='$szID' and date='$todayc' and part=$szPART";
$result = mysqli_query($sql);
if(!$result)
{
echo json_encode('DB access denied : Try again');
exit;
}
$row = mysqli_fetch_array($result);
if(!$row)
{
$sql0 = "insert into counter(id,date,part,cnt) values('$szID','$todayc',$szPART,1)";
mysqli_query($sql0);
}
else
{
$sql1="update counter set cnt=cnt+1 where id='$szID' and date='$todayc' and part=$szPART";
mysqli_query($sql1);
}
$sql="select * from counter where id='$szID' and date='$todayc' and part=$szPART";
$result=mysqli_query($sql);
$row=mysql_fetch_array($result);
$cnt=$row[cnt];
$sqlt="select * from counter where id='$szID' and part=$szPART";
$resultt=mysqli_query($sqlt);
while($rowt=mysqli_fetch_array($resultt)){
$sum+=$rowt[cnt];
}
$datas[0] = $sum;
$datas[1] = $cnt;
//echo json_encode("TOTAL:" . $sum . " TODAY:" . $cnt);
echo json_encode($datas);
?>
これは私のコードです。私は自分のWebサーバーでクエリを使用したいが、それは動作しません。私はMysqliクエリを解決するために助けが必要です
エラーメッセージがあります:
を期待しますPHP警告:mysqli_query()は、少なくとも2つのパラメータ、ライン上/var/www/html/sstemp/counter.phpで与え1 11
私は何をすべきかわからない、誰かが私にヒントを与えることができますか?
それははっきりと言いますmysqli_query()の場合、 '1)接続 2)クエリ' 詳細については、[this](http://www.w3schools.com/php/func_mysqli_query.asp)を参照してください。少なくともgoogleを試してください –
あなたはまた、このコードでSQLインジェクションを開いています。クエリをパラメータ化します。 – chris85
人々はこのエラーを読み取ったことがありますか? –