我有php包含的問題,如果我包含文件,我看到錯誤Object not found
。我不知道該怎麼做..我試圖改變文件路徑,但它沒有幫助。我只看到錯誤...
的HtmlPhp包含問題
<div id="search" class="fleft">
<form action="lib/search.php" method="post">
<input type="text" name="searchText" placeholder="Search tweet!">
<input type="submit" name="search" value="Search"/>
</form>
</div>
<ul id="tweetDisplay">
<p>Tweets: </p>
<?php
include 'lib\search.php';
$searchQuery = $_SESSION['searchQuery'];
while($row = mysql_fetch_array($searchQuery)){
echo "----------------------------------------------";
echo "<li>Nickname: ".$row['nickname']."</li><li>".$row['text']."</li><li class='date'>".$row['pubdate']."</li>";
}
?>
</ul>
PHP腳本
<?php
include "connect.php";
session_start();
if ($_POST['searchText']){
$searchQuery = mysql_query("SELECT u.nickname, t.text, t.pubdate FROM 111212_tweets t INNER JOIN 111212_users AS u ON t.user_id = u.id WHERE t.text LIKE '%" . $_POST['searchText'] . "%' ORDER BY t.pubdate DESC");
$_SESSION['searchQuery'] = $searchQuery;
header('Location: ../main.php');
}else {
$searchQuery = mysql_query("SELECT u.nickname, t.text, t.pubdate FROM 111212_tweets t INNER JOIN 111212_users AS u ON t.user_id = u.id ORDER BY t.pubdate DESC");
$_SESSION['searchQuery'] = $searchQuery;
header('Location: ../main.php');
}
?>
如何將這兩個文件結合在一起? – Machavity
我使用'include'lib \ search.php'將php腳本包含到html中;''search.php是一個腳本文件名。我發現我寫了'lib \ search.php'',寫錯了斜槓,但是當我編輯它時,沒有任何變化 – vladja