Error: Uncaught mysqli_sql_exception: Too many keys specified;最多允许 64 个键

问题描述 投票:0回答:0

我想在我的网站上制作搜索帐户系统

我搜索:savadeekab

我的数据库:


DisplayName    Email            Password    SecurityQuestion    SecurityAnswer  Rank
savadeekab     [email protected]   123456      yearMotherBorn      1978            admin
savadeekab     [email protected]  5555        yearGrandFatherBorn 1923            member
test           [email protected] test        yearFatherBorn      1977            member

搜索“savadeekab”后我想要的结果

DisplayName    Email            Password    SecurityQuestion    SecurityAnswer  Rank
savadeekab     [email protected]   123456      yearMotherBorn      1978            admin
savadeekab     [email protected]  5555        yearGrandFatherBorn 1923            member

但是当我搜索“savadeekab”时出现这个错误:

致命错误:Uncaught mysqli_sql_exception: Too many keys specified; D:\NewXAMPP\htdocs\Main\Account\Admin llUserSearch.php:22 中允许最多 64 个键
堆栈跟踪:
#0 D:\NewXAMPP\htdocs\Main\Account\Admin llUserSearch.php(22): mysqli_query(Object(mysqli), 'ALTER TABLE acc...')
#1 {main} 在第 22 行的 D:\NewXAMPP\htdocs\Main\Account\Admin llUserSearch.php 中抛出

我的PHP代码:

<link rel="stylesheet" href="allUser.css" type="text/css">
<?php
session_start();
$button = $_GET ['submit'];
$search = $_GET ['search'];

// connect to the database
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "website";

$con = mysqli_connect($servername, $username, $password, $dbname);

// check if connection was successful
if (!$con) {
    die("Connection failed: " . mysqli_connect_error());
}

// Add fulltext index to the search table
$alter_sql = "ALTER TABLE account ADD FULLTEXT (DisplayName, Email, Password, SecurityQuestion, SecurityAnswer, Rank)";
$alter_result = mysqli_query($con, $alter_sql);

// Check if the query executed successfully
if (!$alter_result) {
    die("Error: " . mysqli_error($con));
}

// Select the rows that match the search query
$select_sql = "SELECT * FROM account WHERE MATCH(DisplayName, Email, Password, SecurityQuestion, SecurityAnswer, Rank) AGAINST ('$search')";
$select_result = mysqli_query($con, $select_sql);

// Get the number of rows returned by the select query
$foundnum = mysqli_num_rows($select_result);

if($foundnum == 0){
    echo "Sorry we don't found any '<b>$search</b>'.";
}else{
    echo "<body style='background-color:#222327'>";
    echo '<h1 style="color:white; text-align:center; margin-top:20px;">' . $foundnum . ' Result found for "'.$search.'" </h1>';

    //get num of results stored in db
    $sql = "SELECT * FROM account WHERE MATCH(DisplayName, Email, Password, SecurityQuestion, SecurityAnswer, Rank) AGAINST ('$search')";
    $getquery = mysqli_query($con,$sql);

    echo '<table>
    <thead>
      <tr>
        <th>Display Name</th>
        <th>Email</th>
        <th>Password</th>
        <th>Security Question</th>
        <th>Security Question Answer</th>
        <th>Rank</th>
        <th>Action</th>
      </tr>
    </thead>
    ';

    while($runrows = mysqli_fetch_array($getquery)){
        $link = 'editUserData.php';
        $Name = $runrows["DisplayName"];
        $Email = $runrows["Email"];
        $Password = $runrows["Password"];
        $SecQ = $runrows["SecurityQuestion"];
        $SecA = $runrows["SecurityAnswer"];
        $Rank = $runrows["Rank"];
        // Output HTML anchor tag with link to another page
        // echo '<h5><a href="' . $link . '" style="color: white; font-size: 1rem; font-weight:200;">' . $Name . '  </a></h5>';
        echo '
        <tbody>
          <tr>
            <td>' . $Name . '</td>
            <td>' .$Email . '</td>
            <td>$Password</td>
            <td>$SecQ</td>
            <td>$SecA</td>
            <td>$Rank</td>
            <td>
              <button class="button_one">view</button>
            </td>
          </tr>';
    }
    
}

// close database connection
mysqli_close($con);
?>

我已经尝试在互联网上搜索它说我需要使用这个命令并编译它

./configure --prefix=/usr/local/mysql --with-max-indexes=255

但是我不知道在哪里编译它 PS:我的主机是本地主机(phpmyadmin)

我发现很多帖子都问过这个问题,但我没有得到任何适合我的答案。谢谢你回答我
问题!

php database phpmyadmin localhost fatal-error
© www.soinside.com 2019 - 2024. All rights reserved.