Wrox Programmer Forums
|
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2004, 12:55 AM
Authorized User
 
Join Date: Jun 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 12 “search” and “compose”

Hello,
I found the following errors (below) when testing Ch12 code. What are the ways to solve them?
Thank you,
**************************************************
1. On page Compose .php: When I type the text and then press button “save” it works fine, but when I copy and paste text from .doc file it gives me the error
“Could not update article; You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 't cause processing halting ', date_submitted='2004-06-18 22:

2. “Search” function at the beginning of each page doesn’t work. I tried for the title and/or one of the words in text body. No result:“No articles found that match the search terms”.
 
Old June 21st, 2004, 05:27 PM
Authorized User
 
Join Date: May 2004
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

1. How much text are you submitting? Is it short enough to paste here so we can look at it? My guess is that there might be a character in the text that SQL doesn't like. If I can look at the text, I might be able to figure it out (and test it on my server).

2. This is a little hard to troubleshoot without a little more information. To search for the problem, you should figure out what the SQL statement is that's generated by the search form by echoing it to the screen. Then, copy that SQL and paste it directly into MySQL using phpmyadmin, and see what results you get. If you are still stumped, then reply here, including the SQL statement.

Michael K. Glass
Author, Beginning PHP, Apache, MySQL Web Development
 
Old June 21st, 2004, 11:20 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 101
Thanks: 0
Thanked 0 Times in 0 Posts
Default

My experience has been that usually the problem is the quotation marks. Sometimes when you copy the code from the .pdf these really weird quote marks appear which give error.

Hope this helped.

Christian

 
Old June 23rd, 2004, 01:52 AM
Authorized User
 
Join Date: Jun 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,
I tried to
1.(for search in title) echo as sql : SELECT article_id FROM cms_articles WHERE MATCH (title,body) AGAINST ('qwe') ORDER BY MATCH (title,body) AGAINST ('qwe') DESC
Search Result: Resource id #5
2.( for search in body) echo sql : SELECT article_id FROM cms_articles WHERE MATCH (title,body) AGAINST ('Programs') ORDER BY MATCH (title,body) AGAINST ('Programs') DESC
Search Result: Resource id #5
in PHP My Admin both times give an error #1064
the SQL statemnet is from file search.php CH12 p.380

$sql = "SELECT article_id FROM cms_articles " .
     "WHERE MATCH (title,body) " .
     "AGAINST ('" . $_GET['keywords'] . "') " .
     "ORDER BY MATCH (title,body) " .
     "AGAINST ('" . $_GET['keywords'] . "') DESC";

Could you plese help to solve the problem?
Thank you,
 
Old June 28th, 2004, 05:30 PM
Authorized User
 
Join Date: May 2004
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK, I have tested those SQL statements on my server, and they work properly. The only thing I can think that would cause your server to return 1064 (parse error) is that it is an older version of MySQL. Can you tell me what version you are using?

I'm a little confused, though. In your first post, you said that you got the error when you attempt to do an insert, not when you do the search. You said that the search returns 0 rows... which indicates to me that the Search SQL statements DO work...

Let me know what the INSERT query looks like.

In the meantime, you should know that there is a caveat when doing full text searches. If a word is found in at least 50% of the database entries, then that word is basically ignored. Think about it... if you search for a word that occurs in 1000 of your 2000 entries, do you want your search to return all 1000 posts? Most likely, you have very few rows right now, so most searches will not return anything. I recommend creating a few more articles, then your searches will start returning relevant documents.

Michael K. Glass
Author, Beginning PHP, Apache, MySQL Web Development
 
Old June 30th, 2004, 04:54 PM
Authorized User
 
Join Date: Jun 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for reply,
I use MYSQL 4.0.18.
About insert and search confusion: there were two separate quiestions in my first post. The one related to "Insert" statement is solved. The problem about "Search" is still unsolved.
Actually I didn't know about fulltext search omission according to 50% rule you explained. If this is the case, then how to solve that -I need every article with the searched word to be returned. Do I need to change table structure and remove FULLTEXT KEY(title,body)? Do I need to change body from medium text to varchar? Will it solve the problem?
Thank you,
 
Old July 2nd, 2004, 04:58 PM
Authorized User
 
Join Date: May 2004
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It doesn't omit 50% of the articles it finds. The 50% rule means that if over 50% of the articles contain the search term you are looking for in full text searches only, then that term is ignored (since searching is supposed to narrow down the field).

If you want to bypass this requirement (and I don't recommend that you do), you have options. Take a look at this page:

http://dev.mysql.com/doc/mysql/en/Fu...ne-tuning.html

It should tell you all you need to know about how to fix the 50% "problem" you are having. However, once you have a large number of records in your database, I don't think you'll have a problem at all. The more records you have, the better full text indexing will work.

Michael K. Glass
Author, Beginning PHP, Apache, MySQL Web Development
 
Old December 24th, 2004, 03:57 PM
Registered User
 
Join Date: Dec 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

lanita,

I'm using MYSQL 4.0.13 and I am having the same problem about fulltext search. I am wondering if you got it resolved.








Similar Threads
Thread Thread Starter Forum Replies Last Post
Generics chapter 12 difficult chapter i found ...? Larryz C# 2005 1 July 4th, 2007 09:40 PM
Errors on Chapter 12 example(12.8) sonnie ASP.NET 2.0 Professional 2 June 7th, 2006 10:55 AM
Chapter 12 Koga VB.NET 2002/2003 Basics 0 November 2nd, 2004 11:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.