すべてのMySQLの第一は、PHPの最新バージョンでは削除されました
$name=$_GET['name']; //input type
$result = mysql_query("SELECT name FROM map");
while ($search = mysql_fetch_assoc($result)) {
$storeArray = $search['name'];
if($name!=$storeArray){
echo "<script>alert('Nothing match your voice search! ')</script>";
echo "<script>window.location.href=\"map_index.php? name='$storeArray'\" </script>";
}else{
$find=mysql_query("SELECT * FROM map WHERE name='$name'");
while($found=mysql_fetch_assoc($find)){
、その代わりにはmysqliのやPDOを使用しています。
<?php
$name = $_GET['name']; //input type
//Create Prepared Statement
if ($stmt = $mysqli->prepare("SELECT name FROM map WHERE name=?")) {
// bind parameters for markers the first parameter is the type, in this case it is a string, which is why we use 's'. If the parameter was an integer you would use 'i'.
//if this passes then the name that you are searching the database for exists
if ($stmt->bind_param("s", $name)) {
//success
}
else { ?>
<script>
alert('Nothing match your voice search!');
window.location.href="map_index.php?name=<?= $storeArray; ?>";
</script>
<?php }
} ?>
また、PHPからスクリプトタグとjavascriptをどのように分離したかにも注意してください。これは、あなたがそれを持っていた方法とまったく同じですが、はるかにクリーンで、ベストプラクティスと見なされます。
私のPHPは更新されていないので、私はmysqliを使用してそれを行うことはできません、mysqlのそのコードの代替はありますか?それは本当に大きな助けになるでしょう – Janaaan