I am a MySQL/PHP beginner and have gotten further than I expected. I am
developing a web based library catalog. After getting everything
configured, I have been working on various query formats. System is Mac
OS 10.3.8, PHP 5, MySQL 4.1.
I would like to use boolean queries as shown below, but I cqn't seem to
get the $_POST variable sytax correct. Any pointers would be enormously
helpful.
From the MySQL command line, this query works:
mysql> select * from record where match
(author,title,n otes,other_entr ies) against ('+beethoven +symphonies' in
boolean mode);
However, when trying to take form input and build the same query in a
PHP script, something in the following doesn't work:
$name = $_POST['name'];
$title = $_POST['title'];
$result = mysql_query ("select * from record where match
(author,title,n otes,other_entr ies) against ('+$name +$title' in boolean
mode)"), $connection);
For comparison purposes, the following works perfectly on my system:
$result = mysql_query ("select * from record where author regexp
'$name' and title regexp '$title'", $connection);
Thanks,
RHB
developing a web based library catalog. After getting everything
configured, I have been working on various query formats. System is Mac
OS 10.3.8, PHP 5, MySQL 4.1.
I would like to use boolean queries as shown below, but I cqn't seem to
get the $_POST variable sytax correct. Any pointers would be enormously
helpful.
From the MySQL command line, this query works:
mysql> select * from record where match
(author,title,n otes,other_entr ies) against ('+beethoven +symphonies' in
boolean mode);
However, when trying to take form input and build the same query in a
PHP script, something in the following doesn't work:
$name = $_POST['name'];
$title = $_POST['title'];
$result = mysql_query ("select * from record where match
(author,title,n otes,other_entr ies) against ('+$name +$title' in boolean
mode)"), $connection);
For comparison purposes, the following works perfectly on my system:
$result = mysql_query ("select * from record where author regexp
'$name' and title regexp '$title'", $connection);
Thanks,
RHB
Comment