kr3m3r Posted August 20, 2007 Share Posted August 20, 2007 Hi guys, I'm trying to follow the code in my book (PHP and MySQL Web Development) as it is listed. Unfortunately, something isn't working out, I keep getting this error: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/.titch/rwkremer/kr3m3r.com/results.php on line 27 I looked up the error on google, and it seemed to be associated with quotes being out of place, but I can't seem to find any evidence of that. The Entire Code for the php is: <html> <head> <title>Book-O-Rama Search Results</title> </head> <body> <h1>Book-O-Rama Search Results</h1> <?php //create short variable names $searchtype=$HTTP_POST_VARS['searchtype']; $searchterm=$HTTP_POST_VARS['searchterm']; $searchterm = trim($searchterm); if(!$searchtype && !$searchterm) { echo 'You have not entered search details. Please go back and try again.'; exit; } $searchtype = addslashes($searchtype); $searchterm = addslashes($searchterm); @ $db - mysql_pconnect('learning', 'bookorama', bookorama123'); if(!$db) { echo 'Error: Could not connect to database. Please try later.'; exit; } mysql_select_db('books'); $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>'; } ?> </body> </html> Any help on this issue would be greatly appreciated. Thanks for your time. -Robb Quote Link to comment https://forums.phpfreaks.com/topic/65873-solved-parse-error-please-help/ Share on other sites More sharing options...
chocopi Posted August 20, 2007 Share Posted August 20, 2007 @ $db - mysql_pconnect('learning', 'bookorama', bookorama123'); should be @ $db - mysql_pconnect('learning', 'bookorama', 'bookorama123'); Quote Link to comment https://forums.phpfreaks.com/topic/65873-solved-parse-error-please-help/#findComment-329243 Share on other sites More sharing options...
akitchin Posted August 20, 2007 Share Posted August 20, 2007 there're two problems on this line: @ $db - mysql_pconnect('learning', 'bookorama', bookorama123'); first, you're trying to subtract the mysql_pconnect() results from $db. i assume you need an equal sign? you are also missing an opening single quote on the password parameter. a simple check of syntax highlighting gives you a good idea of where things start to go wrong. EDIT: chocopi beat me to it, but the issue with the equal sign still stands. Quote Link to comment https://forums.phpfreaks.com/topic/65873-solved-parse-error-please-help/#findComment-329244 Share on other sites More sharing options...
kr3m3r Posted August 20, 2007 Author Share Posted August 20, 2007 OK, your fresh eyes solved what I could not, that was where the missing quote was. I've fixed that and now no longer have the problem with the PARSE error. . Now before we can put this puppy to bed, can you help me figure out how to correctly specify the host? the hostname is learning.mysite.com, at least that is what i specified when i created it. the db i'm working with is called books. Any more help would be incredibly appreciated. Thanks again! -Robb Quote Link to comment https://forums.phpfreaks.com/topic/65873-solved-parse-error-please-help/#findComment-329254 Share on other sites More sharing options...
kr3m3r Posted August 20, 2007 Author Share Posted August 20, 2007 OK, I'm not sure how you did the edit thing, but you nailed my other problem. So THANKS akitchin and chocopi! Quote Link to comment https://forums.phpfreaks.com/topic/65873-solved-parse-error-please-help/#findComment-329286 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.