![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 16 Pomógł: 0 Dołączył: 20.11.2007 Ostrzeżenie: (0%) ![]() ![]() |
Witam, bardzo będę wdzięczny za pomoc, bo juz sam nie wiem w czym jest problem. Mam stronę search.html i stronę results.php, w ramach results pragnę sie połączyc do określonej bazy i nic, wszytsko pada przy połączeniu.
search.html <html><head> <title>Book-O-Rama Catalog Search</title> </head> <body> <h1>Book-O-Rama Catalog Search</h1> <form action="results.php" method="post"> Choose Search Type:<br /> <select name="searchtype"> <option value="author">Author</option> <option value="title">Title</option> <option value="isbn">ISBN</option> </select> <br /> Enter Search Term:<br /> <input name="searchterm" type="text"> <br /> <input type="submit" value="Search"> </form> </body> </html> Strona results.php <html> <head> <title>Book-O-Rama Search Results</title> </head> <body> <h1>Book-O-Rama Search Results</h1> <?php // create short variable names $searchtype=$_POST['searchtype']; $searchterm=$_POST['searchterm']; $searchterm= trim($searchterm); if (!$searchtype || !$searchterm) { echo 'You have not entered search details. Please go back and try again.'; exit; } if (!get_magic_quotes_gpc()) { $searchtype = addslashes($searchtype); $searchterm = addslashes($searchterm); } @ $db = new mysqli('localhost', 'bookorama', 'bookorama123', 'books'); //strona pada w tym miejscu if (mysqli_connect_errno()) { echo 'Error: Could not connect to database. Please try again later.'; exit; } $query = "select * from books where ".$searchtype." like '%".$searchterm."%'"; $result = $db->query($query); $num_results = $result->num_rows; echo '<p>Number of books found: '.$num_results.'</p>'; for ($i=0; $i <$num_results; $i++) { $row = $result->fetch_assoc(); echo '<p><strong>'.($i+1).'. Title: '; echo htmlspecialchars(stripslashes($row['title'])); echo '</strong><br />Author: '; echo stripslashes($row['author']); echo '<br />ISBN: '; echo stripslashes($row['isbn']); echo '<br />Price: '; echo stripslashes($row['price']); echo '</p>'; } $result->free(); $db->close(); ?> </body> </html> Próbowałem zmiennic na mysql_connect, usuwać @ i nic, jak baza przejdzie do się zacina na komendzie if, jak ją usunę to się zacina na dalszej części kodu. Dal wyjaśnienia uzywam krasnala - Apache, PHP5 = dodatek Mysql 4.1.11 - dla wersji MySQL 3+ też nic nie chodziło. |
|
|
![]() ![]() |
![]() |
Aktualny czas: 22.08.2025 - 23:17 |