|
Posted by Howard on 02/14/06 14:06
Hi,
I have been racking my brain trying to figure out what I am missing trying
to follow this book to get a php script to work. I would really appreciate
if someone could point out my errors. I've been up really late going over
all the config files. Why do they always scim installation for the
applications and put it in the Appendix when its the first thing that new
users need to do. Then we run into these problems because the author takes
so much for granted
Thanks
Howard
I'm using Apache 2.0.55 with PHP 5.1.2 and MySql AB 5.0.18. Windows XP SP2.
What I believe I'm missing is how do I tell PHP & Apache where the Databases
are??
Here is the pathing my my installs.
C:/mysql/bin, c:/mysql/data/books, c:/apached/apache2/htdocs for servering
up web pages, and c:/php.
Here is the error log in apache, and the script
[Tue Feb 14 03:31:27 2006] [error] [client 127.0.0.1] PHP Parse error:
syntax error, unexpected T_STRING in
C:\\Apache\\Apache2\\htdocs\\results.php on line 30, referer:
http://127.0.0.1/search.html
And here is the script. The line 30 is the $result = mysql_query if you
count starting with 1 or $query = select if the first line is 0.
<?php
include config.php;
include opendb.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;
}
mysql_select_db('books');
$searchtype = addslashes($searchtype);
$searchterm = addslashes($searchterm);
$query = select * from books where ".$searchtype." like '%".$searchterm."%'
" ;
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo '<p>Number of books found: '.$num_results.'</p>';
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
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>';
}
?>
Navigation:
[Reply to this message]
|