RE: [PHP-DB] auto_increment problem???

2002-08-25 Thread Russ

Miles:

Thanks for your input.

I'm running MySQL 3.23.49-nt-log on php4.2.1. and the table in question
is of type: MyISAM.
I noticed that, upon returning to work Monday (today) I deleted * from
the table and the auto_increment column reverted back to starting from
one again.

However, today I'm deleting * from the same table and the auto_increment
numbers start where the last [now deleted] entry left off.

I assume then that this table type has some relation or other to a
database connection. By this I mean if the DB connection times out or
otherwise quits, the auto_increment column assumes to re-use keys and
start again from one??

So is there then a PHP-MySQL function that can be used right after a
Query that explicitly tells MySQL to close such a connection so that
columns of type: INT - auto_increment will *always* start from 1 if the
table contains no records (table is empty)??

Thanks a lot for your help. :-)

-Original Message-
From: Miles Thompson [mailto:[EMAIL PROTECTED]]
Sent: Saturday, August 24, 2002 12:12 AM
To: Russ; [EMAIL PROTECTED]
Cc: Ross Gerring
Subject: Re: [PHP-DB] auto_increment problem???


Russ,

Check your docs to confirm this, as you are probably running a later 
version than I'm familiar with. If the table is defined as type "MyISAM"

the autoincrement numbers do not get reused, they steadily increase. You

can rely on them. The default table type is ISAM, and the autoincrement 
numbers do get reused.

How did I discover this? Same way you did, disappearing keys and very 
strange results on selects. Fortunately I discovered the difference
before 
I had too much data, but it had me going for a while.

Cheers - Miles Thompson

At 05:29 PM 8/23/2002 +0800, Russ wrote:
>G'day folks:
>
>The way I have my MySQL table set up should work as follows:
>
>1). If table IS NOT empty, get MySQL to insert auto_increment value
into
>primary key column as normal, then get value of previous record's
>second, none primary ID column. (latter column used for lookup purposes
>elsewhere)
>
>(This is do-able as there is already an existing record from which to
>gather a second none-primary ID.)
>
>2). If table IS empty, insert auto_increment value as normal, into
>primary key column and *the same value* into the second, none-primary
ID
>column.
>
>The thing is, as I'm using auto_increment as my primary key definition,
>and occassionally this table is emptied (deleted from), how can I get
>the second none primary ID column to reflect the new primary key
>auto_increment value of a new record, if no previous record exists??
>
>I hope you understand what I mean! ;-)
>Cheers.
>
>Russ
>
>Mr Russ Michell
>Web Applications Developer
>
>Itomic.com
>Email: [EMAIL PROTECTED]
>Tel: +61 (0)8 9321 3844
>Fax: +61 (0)8 6210 1364
>Post: PO Box 228, Innaloo, WA 6918, Australia
>Street: Suite 24, 158 William St, Perth, WA 6000, Australia
>
>"No proof of existence is not proof of non-existence."
>(Physicist: Stanton T. Friedman on Debunking Ufology)
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php



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




Re: [PHP-DB] full text search and how to underline keyword in results

2002-08-25 Thread Adam Royle

The first argument passed to eregi_replace is

" ".$keywords[$i]." "

You are concatenating the string and a space on the end and front. This was
obviously used as a hack to make sure only full words were highlighted. A
fix for this? A simple hack would be to take out the spaces, so it is simply
$keywords[$i], although you could figure out a proper regex if you don't
want partial words higlighted.

Adam


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




Re: [PHP-DB] full text search and how to underline keyword in results

2002-08-25 Thread Stuart McDonald

Yeah I had the same problem - also with question marks, quotes etc - I
couldn't figure out a fix for it - if you do - please lemme know!

cheers

stuart
- Original Message -
From: "andy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 25, 2002 11:40 PM
Subject: Re: [PHP-DB] full text search and how to underline keyword in
results


> > for ($i=0; $i < count($keywords); $i++) {
> > $blurb = eregi_replace(" ".$keywords[$i]." ", "  > color=\"#FF\">".$keywords[$i]." ", $blurb);
> > }
>
> Hello Stuart,
>
> great, thats a first success and works fast.
>
> There are just 2 things which fail on this function:
> 1. Problems with full stops. A word with a full stop will be ignored (e.g
> singapore. will not be found if you search for singapore)
> 2. If you search for singapore and there is a hit Singapore (notice the
> capital!) will be replaced with singapore in the text.
>
> I tryed to fix that, but I fear that my php experiance lacks on this stage
> :-(
>
> Maybe someone else or you do have a idea for a fix?
>
> Cheers Andy
>
>
>
> "Stuart McDonald" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
> 001901c24c45$2a5e6940$0100a8c0@stuart">news:001901c24c45$2a5e6940$0100a8c0@stuart...
> > Hi Andy,
> >
> > In answer to part two - here's a snippet of code I use to highlight
> relevant
> > words in red - hope it helps to put you on the right track.
> >
> > for ($i=0; $i < count($keywords); $i++) {
> > $blurb = eregi_replace(" ".$keywords[$i]." ", "  > color=\"#FF\">".$keywords[$i]." ", $blurb);
> > }
> >
> > where $keywords is an array containing all the words searched for and
> $blurb
> > is the snippet that is returned with the search results At this stage in
> the
> > flow, I've already retrieved relevant records - this is in fact the last
> > step before I format and display the results..
> >
> > Hope this helps
> >
> > stuart
> >
> >
> > - Original Message -
> > From: "andy" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Sunday, August 25, 2002 9:32 PM
> > Subject: [PHP-DB] full text search and how to underline keyword in
results
> >
> >
> > > Hi there,
> > >
> > > I am trying to write a php script to perform a full text search on a
> mysql
> > > db. I do a match against... and it digs out some results out of the
db.
> > >
> > > There are 2 problems:
> > >
> > > 1. How can I restrict the results to e.g. 100 characters, but to make
> sure
> > > the keyword is within this 100 characters?
> > > 2. Is it possible with php to underline the keyword inside the search
> > > results. This might be more tricky.
> > >
> > > Thank you for any help on that,
> > >
> > > Andy
> > >
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> > >
> >
> >
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>



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




[PHP-DB] Re: New to PHP & mySQL

2002-08-25 Thread Dan Koken

Ray,
Why not just simply give them a list of available times that meet their 
number of days requested starting with the day they ask for.
Would look something like this.
HTH. Dan. Have a great day.
--
";

$sql = "
SELECT
DATE_ADD(prev_end.bookin_start, INTERVAL 1 DAY) as available_start,
DATE_SUB(next_beg.bookin_end,   INTERVAL 1 DAY) as available_end,
intervening_book.booking_start 
as intervening_date

FROM bookings as prev_end

LEFT JOIN bookings as next_beg
ON 
next_beg.villa_id = '$req_villa_id'
WHERE 
prev_end.villa_id = '$req_villa_id'
AND (TODAYS(prev_end.booking_end) - TODAYS(next_beg.booking_start) >= 
$num_days
OR pre_end.booking_end is null)

LEFT JOIN bookings as intervening_book
ON 
intervening_book.villa_id = '$req_villa_id'
AND (   intervening_book.booking_end > prev_end.booking_end
AND 
intervening_book.bookeng_start < next_start.booking_start)

WHERE 
prev_end.villa_id = '$req_villa_id'
AND 
intervening_date is null

ORDER BY availabel_start LIMIT $limit
";
?>
--




Ray Healy ) wrote:
> Hi all
> (details of database at then end of this message)
> 
> I hope someone can give me some advice. I am trying to create a database and
> access via PHP for a friend of mine that has a caravan park. What I want him
> to be able to do is to add bookings for the caravans via a PHP page and for
> clients to be able to search to see if a caravan is available for rent.
> 
> I have created 2 tables and have put data into it via command prompt and
> also retrieved the data from it and carried out a join linking the 2 tables
> together. Which all seems to work well.
> 
> The one thing I cannot get into my head is how can you tell the database
> that all the days between the "start" and "end" dates are booked. Also when
> people search for a caravan on a specific date and say they want it for 7
> day the database/PHP checks to see if the entire period is totally free for
> them and does not colide with another booking.
> 
> I am not sure whether I should be in list list of the PHP list so sorry if I
> have got it wrong.
> 
> Any advice or places to visit would be greatly appreciated.
> 
> Thanks for all your help
> 
> Ray
> 
> 
> Details of what i have done already:
> 
> mysql> use matrix
> Database changed
> 
> mysql>CREATE TABLE bookings (
> -> booking_id SMALLINT (6) NOT NULL AUTO_INCREMENT,
> -> booking_start DATE NOT NULL DEFAULT '-00-00',
> -> booking_end DATE NOT NULL DEFAULT '-00-00',
> -> villa_id SMALLINT (6) NOT NULL DEFAULT '0',
> -> PRIMARY KEY (booking_id)
> -> );
> 
> mysql>INSERT INTO bookings VALUES (1, '2002-04-01', '2002-04-15', 3);
> mysql>INSERT INTO bookings VALUES (2, '2002-03-23', '2002-04-04', 1);
> 
> mysql>CREATE TABLE villas (
> -> villa_id SMALLINT (6) NOT NULL AUTO_INCREMENT,
> -> vill_name VARCHAR (25) NOT NULL DEFAULT '',
> -> PRIMARY KEY (villa_id)
> -> );
> 
> mysql>INSERT INTO villas VALUES (1, 'Gandy');
> mysql>INSERT INTO villas VALUES (2, 'Hathaway');
> mysql>INSERT INTO villas VALUES (3, 'Healy');
> mysql>INSERT INTO villas VALUES (4, 'Mcleod');
> 
> mysql> SELECT * FROM bookings;
> ++---+-+-+
> | booking_id | booking_start | booking_end | villa_id  |
> ++---+-+-+
> |  1  | 2002-04-01  | 2002-04-15  |3   |
> |  2  | 2002-03-23  | 2002-04-04  |1   |
> ++---+-+-+
> 2 rows in set (0.17 sec)
> 
> mysql> SELECT * FROM villas;
> +--++
> | villa_id | villa_name |
> +--++
> |1| Gandy|
> |2| Hathaway  |
> |3| Healy |
> |4| Mcleod  |
> +--++
> 4 rows in set (0.00 sec)
> 
> mysql> SELECT villa_name, booking_start, booking_end FROM bookings LEFT JOIN
> villas ON bookings.villa_id = villas.villa_id;
> ++---++
> | villa_name | booking_start | booking_end  |
> ++---++
> | Healy   | 2002-04-01 | 2002-04-15  |
> | Gandy  | 2002-03-23 | 2002-04-04  |
> ++---++
> 2 rows in set (0.00 sec)
> 
> 
> 


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




Re: [PHP-DB] full text search and how to underline keyword in results

2002-08-25 Thread DL Neil

andy,

I find the PCRE regex option easier to work with. Herewith a solution which
takes care of case (without changing the original text), and without regard
to spaces or other characters (including the first and last characters of
the string - which you didn't mention/identify as potential problems
earlier!).

You will observe the 'manufactured' the text string and that the found
'needles' are post-processed only by surrounding them with ampersands
instead of your font tags - to prove that the regex works. Trust it suits.

$RegExIn = "Singapore singapore singapore. Singapore. singapore";
$RegExPattern = "|(singapore)|i";
echo "Replaced:" . preg_replace( $RegExPattern, "&$0&", $RegExIn ) .
"~";

Regards,
=dn


> > for ($i=0; $i < count($keywords); $i++) {
> > $blurb = eregi_replace(" ".$keywords[$i]." ", "  > color=\"#FF\">".$keywords[$i]." ", $blurb);
> > }
> great, thats a first success and works fast.
> There are just 2 things which fail on this function:
> 1. Problems with full stops. A word with a full stop will be ignored (e.g
> singapore. will not be found if you search for singapore)
> 2. If you search for singapore and there is a hit Singapore (notice the
> capital!) will be replaced with singapore in the text.




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




Re: [PHP-DB] full text search and how to underline keyword in results

2002-08-25 Thread andy

> for ($i=0; $i < count($keywords); $i++) {
> $blurb = eregi_replace(" ".$keywords[$i]." ", "  color=\"#FF\">".$keywords[$i]." ", $blurb);
> }

Hello Stuart,

great, thats a first success and works fast.

There are just 2 things which fail on this function:
1. Problems with full stops. A word with a full stop will be ignored (e.g
singapore. will not be found if you search for singapore)
2. If you search for singapore and there is a hit Singapore (notice the
capital!) will be replaced with singapore in the text.

I tryed to fix that, but I fear that my php experiance lacks on this stage
:-(

Maybe someone else or you do have a idea for a fix?

Cheers Andy



"Stuart McDonald" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
001901c24c45$2a5e6940$0100a8c0@stuart">news:001901c24c45$2a5e6940$0100a8c0@stuart...
> Hi Andy,
>
> In answer to part two - here's a snippet of code I use to highlight
relevant
> words in red - hope it helps to put you on the right track.
>
> for ($i=0; $i < count($keywords); $i++) {
> $blurb = eregi_replace(" ".$keywords[$i]." ", "  color=\"#FF\">".$keywords[$i]." ", $blurb);
> }
>
> where $keywords is an array containing all the words searched for and
$blurb
> is the snippet that is returned with the search results At this stage in
the
> flow, I've already retrieved relevant records - this is in fact the last
> step before I format and display the results..
>
> Hope this helps
>
> stuart
>
>
> - Original Message -
> From: "andy" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Sunday, August 25, 2002 9:32 PM
> Subject: [PHP-DB] full text search and how to underline keyword in results
>
>
> > Hi there,
> >
> > I am trying to write a php script to perform a full text search on a
mysql
> > db. I do a match against... and it digs out some results out of the db.
> >
> > There are 2 problems:
> >
> > 1. How can I restrict the results to e.g. 100 characters, but to make
sure
> > the keyword is within this 100 characters?
> > 2. Is it possible with php to underline the keyword inside the search
> > results. This might be more tricky.
> >
> > Thank you for any help on that,
> >
> > Andy
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
>
>



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




[PHP-DB] Fwd: OS X 10.2 and MySQL 3.23.51 Failures

2002-08-25 Thread Allens

Hello again,
   Persistance pays off. Remember I'm pretty new at this, so be patient 
and kind please. I uninstalled the  builds for MySQL, and PHP from 
Marc's versions. I reinstalled Marc's version from his website. 
Everything started working again. Marc's builds did work. Not sure 
about ServerLogics yet. Sure their's works as well. Have a feeling that 
I missed something. One thing I have noticed to help other 
inexperienced folks is that with OS X 10.2 you need to make positively 
sure of your paths now. If you are at /usr/local/mysql and type 
mysqladmin or mysql, you'll get the "command not found" error. Marc 
does show how to fix this using the setenv command. Still not sure what 
caused the errors below, but working. Will leave that to the pros. 
Probably just a flaw in how I installed before. :)

Begin forwarded message:

> From: Allens <[EMAIL PROTECTED]>
> Date: Sun Aug 25, 2002  11:19:06 AM US/Eastern
> To: [EMAIL PROTECTED]
> Subject: OS X 10.2 and MySQL 3.23.51 Failures
>
> Hello,
>   I did a clean install of OS X 10.2 and clean installs of PHP, MYSQL. 
> Tried both Marc Liynage and ServerLogics builds. When trying to launch 
> mysql, I get the following errors at the command line:
>
> dyld: mysql Undefined symbols:
> mysql undefined reference to _BC expected to be defined in 
> /usr/lib/libSystem.B.dylib
> mysql undefined reference to _PC expected to be defined in 
> /usr/lib/libSystem.B.dylib
> mysql undefined reference to _UP expected to be defined in 
> /usr/lib/libSystem.B.dylib
> Trace/BPT trap
>
> The mysql.crash.log shows the following:
>
> **
>
> Date/Time:  2002-08-25 10:45:53 -0400
> OS Version: 10.2 (Build 6C115)
> Host:   powl-stat-t06.citlink.net
>
> Command:mysql
> PID:497
>
> Exception:  EXC_BREAKPOINT (0x0006)
> Code[0]:0x0001Code[1]:0x8fe01280
>
> Thread 0 Crashed:
>  #0   0x8fe01280 in halt
>  #1   0x8fe106b4 in link_in_need_modules
>  #2   0x8fe014e4 in _dyld_init
>
> PPC Thread State:
>   srr0: 0x8fe01280 srr1: 0x0002d030vrsave: 0x
>xer: 0x2000   lr: 0x8fe09c38  ctr: 0x8fe29468   mq: 0x
> r0: 0x0004   r1: 0xbc70   r2: 0x8fe0b7f4   r3: 0x0139
> r4: 0x   r5: 0x0139   r6: 0x000a   r7: 0x2e64796c
> r8: 0x2f6c6962   r9: 0x  r10: 0x8fe4850c  r11: 0x001a
>r12: 0x8fe71b60  r13: 0x  r14: 0x  r15: 0x
>r16: 0x  r17: 0x  r18: 0x  r19: 0x
>r20: 0x  r21: 0x  r22: 0x  r23: 0x
>r24: 0x  r25: 0x  r26: 0xbddc  r27: 0xbde4
>r28: 0x8fe4841c  r29: 0x8fe484ec  r30: 0x8fe484ec  r31: 0x8fe099bc
>
> **
>
> Date/Time:  2002-08-25 11:07:28 -0400
> OS Version: 10.2 (Build 6C115)
> Host:   powl-stat-t06.citlink.net
>
> Command:mysql
> PID:467
>
> Exception:  EXC_BREAKPOINT (0x0006)
> Code[0]:0x0001Code[1]:0x8fe01280
>
> Thread 0 Crashed:
>  #0   0x8fe01280 in halt
>  #1   0x8fe106b4 in link_in_need_modules
>  #2   0x8fe014e4 in _dyld_init
>
> PPC Thread State:
>   srr0: 0x8fe01280 srr1: 0x0002d030vrsave: 0x
>xer: 0x2000   lr: 0x8fe09c38  ctr: 0x8fe29468   mq: 0x
> r0: 0x0004   r1: 0xbc70   r2: 0x8fe0b7f4   r3: 0x0139
> r4: 0x   r5: 0x0139   r6: 0x000a   r7: 0x2e64796c
> r8: 0x2f6c6962   r9: 0x  r10: 0x8fe4850c  r11: 0x001a
>r12: 0x8fe71b60  r13: 0x  r14: 0x  r15: 0x
>r16: 0x  r17: 0x  r18: 0x  r19: 0x
>r20: 0x  r21: 0x  r22: 0x  r23: 0x
>r24: 0x  r25: 0x  r26: 0xbddc  r27: 0xbde4
>r28: 0x8fe4841c  r29: 0x8fe484ec  r30: 0x8fe484ec  r31: 0x8fe099bc
>
> **
>
> Date/Time:  2002-08-25 11:08:40 -0400
> OS Version: 10.2 (Build 6C115)
> Host:   powl-stat-t06.citlink.net
>
> Command:mysql
> PID:473
>
> Exception:  EXC_BREAKPOINT (0x0006)
> Code[0]:0x0001Code[1]:0x8fe01280
>
> Thread 0 Crashed:
>  #0   0x8fe01280 in halt
>  #1   0x8fe106b4 in link_in_need_modules
>  #2   0x8fe014e4 in _dyld_init
>
> PPC Thread State:
>   srr0: 0x8fe01280 srr1: 0x0002d030vrsave: 0x
>xer: 0x2000   lr: 0x8fe09c38  ctr: 0x8fe29468   mq: 0x
> r0: 0x0004   r1: 0xbcb0   r2: 0x8fe0b7f4   r3: 0x0139
> r4: 0x   r5: 0x0139   r6: 0x000a   r7: 0x2e64796c
> r8: 0x2f6c6962   r9: 0x  r10: 0x8fe4850c  r11: 0x001a
>r12: 0x8fe71b60  r13: 0x  r14: 0x  r15: 0x
>r16: 0x  r17: 0x  r18: 0x  r19: 0x
>r20: 0x  r21: 0x  r22: 0x  r23: 0x
>r24: 0x  r25: 0x  r26: 0xbe1c  r27: 0xbe24
>r28: 0x8fe4841c  r29: 0x8fe484ec  r30: 0x8fe484ec  r31: 0x8fe099bc
>
> **
>
> Date/Time:  2002-08-

[PHP-DB] OS X 10.2 and MySQL 3.23.51 Failures

2002-08-25 Thread Allens

Hello,
   I did a clean install of OS X 10.2 and clean installs of PHP, MYSQL. 
Tried both Marc Liynage and ServerLogics builds. When trying to launch 
mysql, I get the following errors at the command line:

dyld: mysql Undefined symbols:
mysql undefined reference to _BC expected to be defined in 
/usr/lib/libSystem.B.dylib
mysql undefined reference to _PC expected to be defined in 
/usr/lib/libSystem.B.dylib
mysql undefined reference to _UP expected to be defined in 
/usr/lib/libSystem.B.dylib
Trace/BPT trap

The mysql.crash.log shows the following:

**

Date/Time:  2002-08-25 10:45:53 -0400
OS Version: 10.2 (Build 6C115)
Host:   powl-stat-t06.citlink.net

Command:mysql
PID:497

Exception:  EXC_BREAKPOINT (0x0006)
Code[0]:0x0001Code[1]:0x8fe01280

Thread 0 Crashed:
  #0   0x8fe01280 in halt
  #1   0x8fe106b4 in link_in_need_modules
  #2   0x8fe014e4 in _dyld_init

PPC Thread State:
   srr0: 0x8fe01280 srr1: 0x0002d030vrsave: 0x
xer: 0x2000   lr: 0x8fe09c38  ctr: 0x8fe29468   mq: 0x
 r0: 0x0004   r1: 0xbc70   r2: 0x8fe0b7f4   r3: 0x0139
 r4: 0x   r5: 0x0139   r6: 0x000a   r7: 0x2e64796c
 r8: 0x2f6c6962   r9: 0x  r10: 0x8fe4850c  r11: 0x001a
r12: 0x8fe71b60  r13: 0x  r14: 0x  r15: 0x
r16: 0x  r17: 0x  r18: 0x  r19: 0x
r20: 0x  r21: 0x  r22: 0x  r23: 0x
r24: 0x  r25: 0x  r26: 0xbddc  r27: 0xbde4
r28: 0x8fe4841c  r29: 0x8fe484ec  r30: 0x8fe484ec  r31: 0x8fe099bc

**

Date/Time:  2002-08-25 11:07:28 -0400
OS Version: 10.2 (Build 6C115)
Host:   powl-stat-t06.citlink.net

Command:mysql
PID:467

Exception:  EXC_BREAKPOINT (0x0006)
Code[0]:0x0001Code[1]:0x8fe01280

Thread 0 Crashed:
  #0   0x8fe01280 in halt
  #1   0x8fe106b4 in link_in_need_modules
  #2   0x8fe014e4 in _dyld_init

PPC Thread State:
   srr0: 0x8fe01280 srr1: 0x0002d030vrsave: 0x
xer: 0x2000   lr: 0x8fe09c38  ctr: 0x8fe29468   mq: 0x
 r0: 0x0004   r1: 0xbc70   r2: 0x8fe0b7f4   r3: 0x0139
 r4: 0x   r5: 0x0139   r6: 0x000a   r7: 0x2e64796c
 r8: 0x2f6c6962   r9: 0x  r10: 0x8fe4850c  r11: 0x001a
r12: 0x8fe71b60  r13: 0x  r14: 0x  r15: 0x
r16: 0x  r17: 0x  r18: 0x  r19: 0x
r20: 0x  r21: 0x  r22: 0x  r23: 0x
r24: 0x  r25: 0x  r26: 0xbddc  r27: 0xbde4
r28: 0x8fe4841c  r29: 0x8fe484ec  r30: 0x8fe484ec  r31: 0x8fe099bc

**

Date/Time:  2002-08-25 11:08:40 -0400
OS Version: 10.2 (Build 6C115)
Host:   powl-stat-t06.citlink.net

Command:mysql
PID:473

Exception:  EXC_BREAKPOINT (0x0006)
Code[0]:0x0001Code[1]:0x8fe01280

Thread 0 Crashed:
  #0   0x8fe01280 in halt
  #1   0x8fe106b4 in link_in_need_modules
  #2   0x8fe014e4 in _dyld_init

PPC Thread State:
   srr0: 0x8fe01280 srr1: 0x0002d030vrsave: 0x
xer: 0x2000   lr: 0x8fe09c38  ctr: 0x8fe29468   mq: 0x
 r0: 0x0004   r1: 0xbcb0   r2: 0x8fe0b7f4   r3: 0x0139
 r4: 0x   r5: 0x0139   r6: 0x000a   r7: 0x2e64796c
 r8: 0x2f6c6962   r9: 0x  r10: 0x8fe4850c  r11: 0x001a
r12: 0x8fe71b60  r13: 0x  r14: 0x  r15: 0x
r16: 0x  r17: 0x  r18: 0x  r19: 0x
r20: 0x  r21: 0x  r22: 0x  r23: 0x
r24: 0x  r25: 0x  r26: 0xbe1c  r27: 0xbe24
r28: 0x8fe4841c  r29: 0x8fe484ec  r30: 0x8fe484ec  r31: 0x8fe099bc

**

Date/Time:  2002-08-25 11:12:40 -0400
OS Version: 10.2 (Build 6C115)
Host:   powl-stat-t06.citlink.net

Command:mysql
PID:480

Exception:  EXC_BREAKPOINT (0x0006)
Code[0]:0x0001Code[1]:0x8fe01280

Thread 0 Crashed:
  #0   0x8fe01280 in halt
  #1   0x8fe106b4 in link_in_need_modules
  #2   0x8fe014e4 in _dyld_init

PPC Thread State:
   srr0: 0x8fe01280 srr1: 0x0002d030vrsave: 0x
xer: 0x2000   lr: 0x8fe09c38  ctr: 0x8fe29468   mq: 0x
 r0: 0x0004   r1: 0xbc90   r2: 0x8fe0b7f4   r3: 0x0121
 r4: 0x   r5: 0x0121   r6: 0x000a   r7: 0x2e64796c
 r8: 0x2f6c6962   r9: 0x  r10: 0x8fe4850c  r11: 0x001a
r12: 0x8fe71b48  r13: 0x  r14: 0x  r15: 0x
r16: 0x  r17: 0x  r18: 0x  r19: 0x
r20: 0x  r21: 0x  r22: 0x  r23: 0x
r24: 0x  r25: 0x  r26: 0xbe00  r27: 0xbe08
r28: 0x8fe4841c  r29: 0x8fe484ec  r30: 0x8fe484ec  r31: 0x8fe099bc

Has anyone figured this anomoly out yet? I'm very new to MySQL and 
clueless at to the setup of the 

RE: [PHP-DB] New to PHP & mySQL

2002-08-25 Thread Mark Middleton


> The one thing I cannot get into my head is how can you tell the database
> that all the days between the "start" and "end" dates are booked.
> Also when
> people search for a caravan on a specific date and say they want it for 7
> day the database/PHP checks to see if the entire period is
> totally free for
> them and does not colide with another booking.

Ray, it looks like you've done some great work so far.  This one point that
you are struggling with may not be as difficult as you are imagining as
well.

When a potential customer is searching for availability, they are going to
have to select a start date and an end date for the period they are looking
to book.

Then, you just take those two dates, and compare them against the previous
bookings for the same villa...  (if you do it in one step, you can tell them
"those dates are not available" - if you perform it in two steps, you can
give the customer more information about whether the start date, or the end
date (or both) were the source of the conflict. )  i.e. if they want to book
the Healy on 4/10 - 4/20, it could tell them that it is not available until
4-15... instead of telling them that the dates "just won't work" - does that
make sense?

So, using your example, the Healy is booked from 4/1 - 4/15...

When a customer runs a query to find availability, they will select a
start_date of 4/10 and an end date of 4/20

(hehe, I just said 420...)

[one step method]

(of course convert the requested $start_date and $end_date into -MM-DD
format)

 '$start_date')
OR
(booking_start < '$end_date'
AND
booking_end > '$end_date'))
AND
villa_id = '$requested_villa_id'";

$query = mysql_query($sql);
$is_it_booked = mysql_fetch_object($query);
print "number of reservations during this date =
".$is_it_booked->how_many_booked;

?>

This checks if the start date is between the booked dates OR the end date is
between the booked dates
If rows are returned, then the dates are not available.

Does this help?

-Mark





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




[PHP-DB] New to PHP & mySQL

2002-08-25 Thread Ray Healy \(Data Net Services\)

Hi all
(details of database at then end of this message)

I hope someone can give me some advice. I am trying to create a database and
access via PHP for a friend of mine that has a caravan park. What I want him
to be able to do is to add bookings for the caravans via a PHP page and for
clients to be able to search to see if a caravan is available for rent.

I have created 2 tables and have put data into it via command prompt and
also retrieved the data from it and carried out a join linking the 2 tables
together. Which all seems to work well.

The one thing I cannot get into my head is how can you tell the database
that all the days between the "start" and "end" dates are booked. Also when
people search for a caravan on a specific date and say they want it for 7
day the database/PHP checks to see if the entire period is totally free for
them and does not colide with another booking.

I am not sure whether I should be in list list of the PHP list so sorry if I
have got it wrong.

Any advice or places to visit would be greatly appreciated.

Thanks for all your help

Ray


Details of what i have done already:

mysql> use matrix
Database changed

mysql>CREATE TABLE bookings (
-> booking_id SMALLINT (6) NOT NULL AUTO_INCREMENT,
-> booking_start DATE NOT NULL DEFAULT '-00-00',
-> booking_end DATE NOT NULL DEFAULT '-00-00',
-> villa_id SMALLINT (6) NOT NULL DEFAULT '0',
-> PRIMARY KEY (booking_id)
-> );

mysql>INSERT INTO bookings VALUES (1, '2002-04-01', '2002-04-15', 3);
mysql>INSERT INTO bookings VALUES (2, '2002-03-23', '2002-04-04', 1);

mysql>CREATE TABLE villas (
-> villa_id SMALLINT (6) NOT NULL AUTO_INCREMENT,
-> vill_name VARCHAR (25) NOT NULL DEFAULT '',
-> PRIMARY KEY (villa_id)
-> );

mysql>INSERT INTO villas VALUES (1, 'Gandy');
mysql>INSERT INTO villas VALUES (2, 'Hathaway');
mysql>INSERT INTO villas VALUES (3, 'Healy');
mysql>INSERT INTO villas VALUES (4, 'Mcleod');

mysql> SELECT * FROM bookings;
++---+-+-+
| booking_id | booking_start | booking_end | villa_id  |
++---+-+-+
|  1  | 2002-04-01  | 2002-04-15  |3   |
|  2  | 2002-03-23  | 2002-04-04  |1   |
++---+-+-+
2 rows in set (0.17 sec)

mysql> SELECT * FROM villas;
+--++
| villa_id | villa_name |
+--++
|1| Gandy|
|2| Hathaway  |
|3| Healy |
|4| Mcleod  |
+--++
4 rows in set (0.00 sec)

mysql> SELECT villa_name, booking_start, booking_end FROM bookings LEFT JOIN
villas ON bookings.villa_id = villas.villa_id;
++---++
| villa_name | booking_start | booking_end  |
++---++
| Healy   | 2002-04-01 | 2002-04-15  |
| Gandy  | 2002-03-23 | 2002-04-04  |
++---++
2 rows in set (0.00 sec)




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




Re: [PHP-DB] full text search and how to underline keyword in results

2002-08-25 Thread Stuart McDonald

Hi Andy,

In answer to part two - here's a snippet of code I use to highlight relevant
words in red - hope it helps to put you on the right track.

for ($i=0; $i < count($keywords); $i++) {
$blurb = eregi_replace(" ".$keywords[$i]." ", " ".$keywords[$i]." ", $blurb);
}

where $keywords is an array containing all the words searched for and $blurb
is the snippet that is returned with the search results At this stage in the
flow, I've already retrieved relevant records - this is in fact the last
step before I format and display the results..

Hope this helps

stuart


- Original Message -
From: "andy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, August 25, 2002 9:32 PM
Subject: [PHP-DB] full text search and how to underline keyword in results


> Hi there,
>
> I am trying to write a php script to perform a full text search on a mysql
> db. I do a match against... and it digs out some results out of the db.
>
> There are 2 problems:
>
> 1. How can I restrict the results to e.g. 100 characters, but to make sure
> the keyword is within this 100 characters?
> 2. Is it possible with php to underline the keyword inside the search
> results. This might be more tricky.
>
> Thank you for any help on that,
>
> Andy
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>



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




[PHP-DB] full text search and how to underline keyword in results

2002-08-25 Thread andy

Hi there,

I am trying to write a php script to perform a full text search on a mysql
db. I do a match against... and it digs out some results out of the db.

There are 2 problems:

1. How can I restrict the results to e.g. 100 characters, but to make sure
the keyword is within this 100 characters?
2. Is it possible with php to underline the keyword inside the search
results. This might be more tricky.

Thank you for any help on that,

Andy



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




Re: [PHP-DB] db questions and newbie...

2002-08-25 Thread DL Neil

Matt,
I've put this back on the list because other people are smarter than me/can
reply more quickly! (and I hate people who pretend to have 'the answer' when
they're plainly out of their depth/range of experience - so...)

I don't think that I've managed to completely understand where you are
heading with this. Possibly because we have different (programming language)
backgrounds/application histories. I don't understand why if $varsused is
already a list with comma separators that you want to use the "|" instead,
when CSV is so widely used/understood/available. Explode/Implode work to
communicate between a string and an array. Perhaps string replacement
functions or regular expressions would meet your needs more appropriately?

The (annotated) online manual has a number of examples and all manner of
ideas in the user contributed comments. The manual's definition section also
suggests looking at other 'similar' commands, eg the explode page offers
"See also preg_split(), spliti(), split(), and implode()." I recommend that
you work your way through the string and filesystem function
chapters/appendices of the manual to see what catches your attention/strikes
a chord with your preferences/history/intentions. When working with a 'new'
language it is usually a mistake to try to make it work the way your 'old'
one did - also expect your ratio of reading references to writing code to
change markedly!

Regards,
=dn


> I looked through the documentation on implode and explode... it doesn't
> seem to give a good example.
>
> I want to assign the file name, vars and delimiter.
>
> I looked at this example:
> $pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
> $pieces = explode(" ", $pizza);
>
> $data = "foo:*:1023:1000::/home/foo:/bin/sh";
> list($user,$pass,$uid,$gid,$gecos,$home,$shell) = explode(":",$data);
>
>
> But got all confused.
>
> Isn't there a piece of code that I can write so it will look like this:
>
> $filename = "datafile.txt";
> $varsused = "var1,var2,var3";
> $delimiter = " |  ";
>
> then the opposite of that to import/implode the records as well as to
> apply the filter?
>
> I know I'm new but I've used other programming languages where it's
> easier and more intuitive to import/export records and put filter on
> them.  Thanks.
>
> -Matt
>
>
> Dl Neil wrote:
> > Matt,
> > Welcome to the PHP and MySQL communities!
> >
> >
> >>I have lots of questions and am new to the list... so alas I hope I'm
> >>posting to the correct area. In PHP and MySQL... can you import and
> >>export to flat files?
> >
> >
> > =yes, check out the online PHP manual, appendix XXX, Filesystem
Functions
> > (http://uk2.php.net/manual/en/ref.filesystem.php)
> >
> >
> >>I want to export a series of vars, IE:
> >>Name, Age, State
> >>Bill  25   NY
> >>So that in a file, it will appear like so:
> >>Bill|25|NY
> >
> >
> > =check out the online PHP manual by entering implode and/or explode into
the
> > (functions) search facility
> >
> >
> >>With one record per line, separated by a delimiter?  And then import
> >>those record by being able to set a filter to sort all people from NY or
> >>all people that are 25 years old.
> >
> >
> > =sounds like a job for an RDBMS rather than a flat file, but there you
go...
> >
> >
> > =check out the online PHP manual for string functions and/or regular
> > expressions
> >
> >
> >>Also, I've been trying to playing around with PHP and MySQL.  I haven't
> >>found a great tutorial. Anyone know of a good link?  I'm comfortable
> >>somewhat with the myphpadmin to manage the mysql db, but other than
> >>that, I haven't found anything simple that goes indepth including:
> >>Sorting records IE... alphabetizing certain fields or sorting them by
> >>descending etc.
> >
> >
> > =it sounds as if you need to learn SQL. There are a huge number of
tutorials
> > available on the web (...check out Google). Better yet - visit the MySQL
> > site and follow the links to a "Links" page. This will direct you to a
> > number of sites that offer helpful articles and tutorials. Similarly the
PHP
> > site will point you to many great resource sites.
> >
> > =Don't overlook the online MySQL manual's Chapter 3 which is a
step-by-step
> > tutorial. There are many books available which introduce MySQL or PHP or
> > both together, and are most useful because you can read up the theory
and
> > then work through examples step-by-step.
> >
> >
> >>AND I haven't found much reference on DB locking to prevent file
> >
> > corruption.
> >
> > =check out the online MySQL manual (it has a search facility too)
> >
> >
> >>Any help to these issues would be great!
> >
> >
> > =did you detect a theme? The manuals are really v.good!
> > Sorry if it seems unhelpful to answer in this way, but help-yourself is
the
> > first law of the OpenSource jungle!
> >
> > =Regards,
> > =dn
> >
> >
>
>
> --
> Matt Zur
> [EMAIL PROTECTED]
> http://www.zurnet.com
>
> Need a Web Site??? - Visit... www.zurnet.com
>
> 1997 - 2002 - 5th Anniversary!!!
>
>