Re: [PHP-DB] MySQL Conditional Trigger

2008-12-21 Thread Chris

Aleksandar Vojnovic wrote:

You could try with the  operator.
!=, Not equal operator


Same issue as using '=':

mysql select 2  null;
+---+
| 2  null |
+---+
|  NULL |
+---+
1 row in set (0.00 sec)

Comparing anything with null returns null. (I'm not asking for a 
solution, I'm stating it as fact).



Or you could try it this way - ISNULL(col_or_data_to_check).
Example:
mysql SELECT ISNULL(1+1);
+-+
| ISNULL(1+1) |
+-+
|   0 |
+-+
1 row in set (0.02 sec)


You can also use 'coalesce' to set default value for null columns.

http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#function_coalesce

http://dev.mysql.com/doc/refman/5.0/en/working-with-null.html

--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] ntwdblib.dll not found in any of the 5.2.8 zip files

2008-12-21 Thread Chris

Fred Silsbee wrote:



--- On Sat, 12/20/08, Fergus Gibson fgibso...@gmail.com wrote:


From: Fergus Gibson fgibso...@gmail.com
Subject: Re: [PHP-DB] ntwdblib.dll not found in any of the 5.2.8 zip files
To: fredsils...@yahoo.com
Date: Saturday, December 20, 2008, 6:06 PM
On Sat, Dec 20, 2008 at 7:59 AM, Fred Silsbee
fredsils...@yahoo.com wrote:

ntwdblib.dll proves to be necessary...otherwise

I'll get a mssql_connect not found

I used the ntwdblib.dll file from a 5.2.6 zip file

This resource might help:

http://www.userscape.com/helpdesk/index.php?pg=kb.pageid=13

According to the information there and on the forum thread
they link,
the problem you have is likely that the ntwdblib.dll is the
wrong
version.  They say you can find the correct DLL in the
system32
directory on the SQL Server.  If you copy that to your
extension dir,
you should be good.



YOU ARE THE MAIN MAN! THAT WORKED! THE CORRECT VERSION SHOULD BE

INCLUDED IN THE 5.2.8 ZIP FILE


So lodge a bug at http://bugs.php.net.

--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] SELECT query

2008-12-21 Thread Ron Piggott
I am working on a web based Bible searching query.  So far I am able to
generate:

SELECT * FROM `bible_verses` INNER JOIN `bible_books` ON
`bible_books`.`id` = `bible_verses`.`b` WHERE `t` IN ( 'Lord' ,
'Jesus' ) LIMIT 0 , 10

Is an IN the correct syntax to use?

I am trying to take what the user types in (variable is $keyword_search)
and allow a search where if the same 2 or 3 words are in the verse of
the Bible that verse would be a match, but not necessarily be beside
each other.

$keyword_search_string  = str_replace( , ' , ', $keyword_search);
$query .= IN ( ' . $keyword_search_string . ' ) ;

How do I do this correctly?

Ron


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] Re: SELECT query

2008-12-21 Thread Ron Piggott

One more thing ... Bible is stored by verses, t is the text of the verse

On Sun, 2008-12-21 at 19:52 -0500, Ron Piggott wrote:
 I am working on a web based Bible searching query.  So far I am able to
 generate:
 
 SELECT * FROM `bible_verses` INNER JOIN `bible_books` ON
 `bible_books`.`id` = `bible_verses`.`b` WHERE `t` IN ( 'Lord' ,
 'Jesus' ) LIMIT 0 , 10
 
 Is an IN the correct syntax to use?
 
 I am trying to take what the user types in (variable is $keyword_search)
 and allow a search where if the same 2 or 3 words are in the verse of
 the Bible that verse would be a match, but not necessarily be beside
 each other.
 
 $keyword_search_string  = str_replace( , ' , ', $keyword_search);
 $query .= IN ( ' . $keyword_search_string . ' ) ;
 
 How do I do this correctly?
 
 Ron
-- 

Acts Ministries Christian Evangelism
Where People Matter
12 Burton Street
Belleville, Ontario, Canada 
K8P 1E6

ron.pigg...@actsministries.org
www.actsministrieschristianevangelism.org

In Belleville Phone: (613) 967-0032
In North America Call Toll Free: (866) ACTS-MIN
Fax: (613) 967-9963


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: SELECT query

2008-12-21 Thread Bastien Koert
On Sun, Dec 21, 2008 at 7:56 PM, Ron Piggott ron.pigg...@actsministries.org
 wrote:


 One more thing ... Bible is stored by verses, t is the text of the verse

 On Sun, 2008-12-21 at 19:52 -0500, Ron Piggott wrote:
  I am working on a web based Bible searching query.  So far I am able to
  generate:
 
  SELECT * FROM `bible_verses` INNER JOIN `bible_books` ON
  `bible_books`.`id` = `bible_verses`.`b` WHERE `t` IN ( 'Lord' ,
  'Jesus' ) LIMIT 0 , 10
 
  Is an IN the correct syntax to use?
 
  I am trying to take what the user types in (variable is $keyword_search)
  and allow a search where if the same 2 or 3 words are in the verse of
  the Bible that verse would be a match, but not necessarily be beside
  each other.
 
  $keyword_search_string  = str_replace( , ' , ', $keyword_search);
  $query .= IN ( ' . $keyword_search_string . ' ) ;
 
  How do I do this correctly?
 
  Ron
 --

 Acts Ministries Christian Evangelism
 Where People Matter
 12 Burton Street
 Belleville, Ontario, Canada
 K8P 1E6

 ron.pigg...@actsministries.org
 www.actsministrieschristianevangelism.org

 In Belleville Phone: (613) 967-0032
 In North America Call Toll Free: (866) ACTS-MIN
 Fax: (613) 967-9963


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


query code looks correct. are you getting an error? have you tried echoing
out the sql and testing in phpmyadmin or some other gui tool?

-- 

Bastien

Cat, the other other white meat


Re: [PHP-DB] Re: SELECT query

2008-12-21 Thread Chris

Bastien Koert wrote:

On Sun, Dec 21, 2008 at 7:56 PM, Ron Piggott ron.pigg...@actsministries.org

wrote:



One more thing ... Bible is stored by verses, t is the text of the verse

On Sun, 2008-12-21 at 19:52 -0500, Ron Piggott wrote:

I am working on a web based Bible searching query.  So far I am able to
generate:

SELECT * FROM `bible_verses` INNER JOIN `bible_books` ON
`bible_books`.`id` = `bible_verses`.`b` WHERE `t` IN ( 'Lord' ,
'Jesus' ) LIMIT 0 , 10

Is an IN the correct syntax to use?


This will work fine. An IN clause is like multiple OR's:

... where t = 'Lord' OR t = 'Jesus' ...


I am trying to take what the user types in (variable is $keyword_search)
and allow a search where if the same 2 or 3 words are in the verse of
the Bible that verse would be a match, but not necessarily be beside
each other.

$keyword_search_string  = str_replace( , ' , ', $keyword_search);
$query .= IN ( ' . $keyword_search_string . ' ) ;


This will seem a little long winded but you need to check for sql 
injection. As it stands, you'll get an error when you search for a name 
with a quote (o'reilly). Might not be in the bible (I have no idea) but 
doesn't mean someone won't try it ;)



// look at the keywords one by one - they are space separated
$keywords = explode(' ', $keyword_search);

// now go through them all and escape them.
$keyword_searches = array();
foreach ($keywords as $keyword) {
  $keyword_searches[] = mysql_real_escape_string($keyword);
}

// then turn it all into an IN string.
$keyword_search_string = IN (' . implode(',', $keyword_searches) . ');


You may want to eventually look at full text searching, depending on how 
slow this is and how important search is to your site. The syntax is 
completely different.


http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

--
Postgresql  php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php