-2
私はテーブルから受け取ったIDごとに別のクエリを実行したい、解決するのを助けてください。例えばMySQLのPHP条件ベースのクエリ
$ == 5ファイル名を指定して実行クエリA idcat場合とそうでない$ == 4 idcat実行クエリBここで
//include connection file
include_once("connection.php");
$db = new dbObj();
$connString = $db->getConnstring();
$params = $_REQUEST;
$action = isset($params['action']) != '' ? $params['action'] : '';
$empCls = new FillEmpty($connString);
function insertFillEmpty($params) {
$data = array();
$catintid = "SELECT categoryinternalID FROM inhandemptystock";
$results = mysqli_query($this->conn, $catintid);
$raw = mysql_fetch_array($results);
$idcat = $raw["categoryinternalID"];
if ($idcat == "5") {
$sqll = "INSERT INTO `testing` (goog) VALUES('" . $params["enteredBy"] . "'); ";
echo $result = mysqli_query($this->conn, $sqll) or die("error to insert employee data");
} else {
echo '<script language="javascript">';
echo 'alert("Something is wrong")';
echo '</script>';
}
}
あなたのコードは[** SQLインジェクション**](https://en.wikipedia.org/wiki/SQL_injection)攻撃に対して脆弱です。 [** mysqli **](https://secure.php.net/manual/en/mysqli.prepare.php)または[** PDO **](https://secure.php.net/)を使用してください。 manual/en/pdo.prepared-statements.php)は、[** this post **](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql - インジェクション - イン - php)。 –
あなたはmysqlとmysqliを混在させています。 mysql_ *関数を使わないでください。それらはv5.5(2013年6月)から廃止され、v7.0(2015年12月)以降削除されました。代わりに[** mysqli _ ***](https://secure.php.net/manual/en/book.mysqli.php)または[** PDO **](https://secure.php.net/** ** prepared statements **](https://secure.php.net/manual/en/pdo.prepare.php)と[**バインドされたパラメータ** ](https://secure.php.net/manual/en/pdostatement.bindparam.php)。 –
あなたはあなたが何をしているのか正確に説明していませんか?ここで何が問題なの? – David