未定义的索引:在第2行的E:\ xampp \ htdocs \ FA2 \ search.php中提交
<?php
$button = $_GET [ 'submit' ];
$search = $_GET [ 'search' ];
if( !$button )
echo "you didn't submit a keyword";
else {
if( strlen( $search ) <= 1 )
echo "Search term too short";
else {
echo "You searched for <b> $search </b> <hr size='1' > </ br > ";
mysql_connect( "localhost","root","") ;
mysql_select_db("fa");
$search_exploded = explode ( " ", $search );
$x = 0;
foreach( $search_exploded as $search_each ) {
$x++;
$construct = "";
if( $x == 1 )
$construct .="keywords LIKE '%$search_each%'";
else $construct .="AND keywords LIKE '%$search_each%'";
}
$construct = " SELECT * FROM schoolname WHERE $construct ";
$run = mysql_query( $construct ); $foundnum = mysql_num_rows($run);
if ($foundnum == 0)
echo "Sorry, there are no matching result for <b> $search </b>. </br> </br> 1. Try more general words. for example: If you want to search 'how to create a website' then use general keyword like 'create' 'website' </br> 2. Try different words with similar meaning </br> 3. Please check your spelling";
else {
echo "$foundnum results found !<p>";
while( $runrows = mysql_fetch_assoc( $run ) ) {
$title = $runrows ['title'];
$desc = $runrows ['description'];
$url = $runrows ['url'];
echo "<a href='$url'> <b> $title </b> </a> <br> $desc <br> <a href='$url'> $url </a> <p>";
}
}
}
}
?>
表格代码:
<form action="search.php" method="get" enctype="multipart/form-data">
<input class="wow fadeInRight" data-wow-delay="0.5s" type="text" name="search" placeholder="Seach School Here" required/>
<input class="wow fadeInLeft" data-wow-delay="0.5s" type="submit" value="GET STARTED" name="submit"/>
</form>
答案 0 :(得分:0)
当你执行get请求时,看起来似乎没有设置提交值,这使得为null并且你得到了那个错误。
答案 1 :(得分:0)
首先检查
isset
<?php
if(isset($_GET)){
$button = $_GET [ 'submit' ];
$search = $_GET [ 'search' ];
if( !$button )
......
....
.....
}
答案 2 :(得分:0)
正如@Sami Kuhmonen所说,错误是enctype="multipart/form-data"
......
这仅适用于POST
数据,因为您无法通过GET
所以表格应该是:
<form action="search.php" method="get">
<input class="wow fadeInRight" data-wow-delay="0.5s" type="text" name="search" placeholder="Seach School Here" required/>
<input class="wow fadeInLeft" data-wow-delay="0.5s" type="submit" value="GET STARTED" name="submit"/>
</form>
答案 3 :(得分:0)
首先删除那些空格
android:screenOrientation="user(by default is unspecified)"
至$_GET['submit']
而是使用
$_GET['submit']
它包含通过$_REQUEST['submit']
或GET
方法