私のデータベースに挿入しようとしています。クエリをMySQL Workbenchに貼り付けてみましたが、動作しますが、ページを実行しても動作しません。クエリはデータベースに挿入されません
echo "<b>DISTRICT</b></br>";
echo "crime volume : " . $crimeVolume. "<br>";
echo "population : " . $population. "<br>";
echo "crime rate : " . $crimeRate=round(($crimeVolume/($population/100000)),2) . " <br>";
echo "crime efficiency/crime clearance efficiency : " . $efficiency=($SolvedCases/$crimeVolume) ." <br>";
echo "use of force : " . $useofForce . " incidents<br>";
echo "drug seizures : " . $numdrug . " (grams/seizures)<br>";
echo "firearm seizures : " . $firearmSeizures=round(($numfire/$stationFire),2) . " <br>";
echo "<br>";
require_once('../../mysqlConnector/mysql_connect.php');
$query2= "INSERT INTO computation (crimeVolume,crimeRate,crimeSolutionEfficiency,useofForce,drugSeizures,firearmsSeizures,stationID)
VALUES ('{$crimeVolume}','{$crimeRate}','{$efficiency}','{$useofForce}','{$numdrug}','{$firearmSeizures}','0');";
echo $query2;
$result=mysqli_query($dbc,$query2);
echo $result;
$ dbcはどこから来ますか?あなたは完全なコードを投稿できますか? –
あなたはSQLインジェクションのために広くオープンしています。 mysqliを使用しているので、[prepared statements](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php)と[bind_param](http://php.net/ manual/en/mysqli-stmt.bind-param.php)。 **これはあなたが持っているかもしれない厄介な引用問題を修正します**これは[mysqli_errors](http://php.net/manual/en/mysqli.error.php) – aynber
<? php $ dbc = mysqli_connect( 'localhost'、 'username'、 'password'、 'database'); if(!$ dbc){ die( '接続できませんでした:' .mysql_error()); } ?> これは$ dbcです! –