Page 2 of 2
Re: Help with adding to this code...
Posted: Sat Mar 12, 2011 7:28 pm
by Jonah Bron
tattooartist wrote:I figured it out that the syntax for that string query will not work with my version of php. I changed it to
mysql_escape_string() and it went through. Since this onemysql_escape_string() is a deprecated query I figured it was my version of php being older. This old string worked but it is now getting caught up with this....
Glad you figured it out. If you can, you really should upgrade your PHP installation.
tattooartist wrote:Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/pennstateind.com/httpdocs/php_test/library_search_test.php on line 711
That sounds like the query encountered an error. It returns false if an error occures. So, lets do this. Change this line:
To this:
Code: Select all
$result = mysql_query($query);
if (!$result) {
die(mysql_error());
}
tattooartist wrote:I am so grateful for your help with this! Thank you. If it gets to be too much of a pain now worries:)
No trouble, though I appreciate the sentiment

Re: Help with adding to this code...
Posted: Sat Mar 12, 2011 9:48 pm
by tattooartist
Thanks again. I got this error this time around.
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 'product_name LIKE='%SLIMLINE%'' at line 5

Re: Help with adding to this code...
Posted: Sat Mar 12, 2011 9:50 pm
by tattooartist
This is what it says in my phpMyadmin if this helps...
phpMyAdmin 2.6.0-pl3
MySQL 4.1.21
Re: Help with adding to this code...
Posted: Sun Mar 13, 2011 4:15 pm
by Jonah Bron
Oops, this should fix it.
Code: Select all
$query = 'SELECT *
FROM category c
INNER JOIN library l ON c.category_id = l.category_id
INNER JOIN files f ON l.file_id = f.file_id
WHERE product_name LIKE = "%' . $find . '%"';
Re: Help with adding to this code...
Posted: Sun Mar 13, 2011 6:38 pm
by tattooartist
It did not like the = for some reason. was getting another error. I removed it and walla! How can I repay you?
Re: Help with adding to this code...
Posted: Sun Mar 13, 2011 8:21 pm
by Jonah Bron
Oh yeah, of course. So everything works now? I visited the page and I get an error.
tattooartist wrote:I removed it and walla!
For future reference, "walla" is spelled "voilĂ "

Re: Help with adding to this code...
Posted: Mon Mar 14, 2011 6:32 am
by tattooartist
Yes everything is working great on the page. New location is
www.pennstateind.com/php_test/library2.php
Sorry about that
Re: Help with adding to this code...
Posted: Mon Mar 14, 2011 12:39 pm
by Jonah Bron
Great. But note, it won't work for separated multi-word searches. For example, if the user searches for "black enamel", "PK-PCLA2B: Slimline Black Enamel Pencil Kit" will come up (along with many others). But if he searches for "slimline pencil", no results will come up. Is this acceptable?
Re: Help with adding to this code...
Posted: Mon Mar 14, 2011 5:43 pm
by tattooartist
That will be fine. Thank you again!