Re: RE: RE: [PHP-DB] Query construction

2001-09-19 Thread Russ Michell

> Learning is NEVER a waste of time...
No, of course not, but having been on these lists for sometime, I get the feeling some 
people (as I 
would, and do) get pi**ed off if someone doesn't at least try first before asking 
questions..

> p.s.  Your father is a psychiatrist???  Now, there, I could use some help...
No he isn't he just thinks he is ;-)

Many thanks.
Russ

On Wed, 19 Sep 2001 10:01:07 -0500 Rick Emery <[EMAIL PROTECTED]> wrote:

> It wasn't a waste of time.  Now, the next time you have a similar problem
> with a mySQL query, you'll follow this procedure.
> 
> Learning is NEVER a waste of time...
> 
> p.s.  Your father is a psychiatrist???  Now, there, I could use some help...
> 
> -Original Message-
> From: Russ Michell [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 19, 2001 9:56 AM
> To: Rick Emery
> Cc: [EMAIL PROTECTED]
> Subject: Re: RE: [PHP-DB] Query construction
> 
> 
> Ok ok ok!! Thank you both for the pointers, they did of course yield the
> problem - as bloody always 
> it's something completely different! As my old-dad always says: "Everything
> is about something 
> else" (although this was always meant in a psychiatrist-patient
> relationship..)
> 
> Thank you again both, and I apologise for seemingly wasting your time, but I
> do value people's 
> ideas and opinions, and hopefully others do of mine also.
> 
> Regards:
> Russ Michell (APU Webteam)
> 
> On Wed, 19 Sep 2001 09:41:47 -0500 Rick Emery <[EMAIL PROTECTED]> wrote:
> 
> > YES!!! Exactly
> > 
> > Russ...do what Steve syas...
> > 
> > -Original Message-----
> > From: Steve Cayford [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, September 19, 2001 9:32 AM
> > To: [EMAIL PROTECTED]
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: [PHP-DB] Query construction
> > 
> > 
> > Usually what I do when I'm having this type of problem is put the whole 
> > sql statement into a string variable then print the variable out just 
> > before running the query so you know exactly what's being sent to mysql. 
> > Then I log into mysql from the command line and enter the query manually 
> > to see what sort of response or error message I get.
> > 
> > -Steve
> > 
> > On Wednesday, September 19, 2001, at 09:01  AM, Russ Michell wrote:
> > 
> > > Hi there:
> > >
> > > Further to a previous submission (which can be ignored), I'd like the 
> > > following query to 'search' a
> > > table field of different team names (stored as a single string), but it 
> > > does't seem to work!
> > >
> > > "SELECT * FROM $table_users WHERE usrName='$username' AND 
> > > usrPswd=password('$password') AND affil_team RLIKE '$team+'";
> > > (I've also tried: RLIKE '$team?' )
> > >
> > > This should match the string found in the variable: '$team' with the 
> > > some of contents (string)
> > > found in 'affil_team'.
> > >
> > > For example my test has been, trying to find 'footballSat', so $team = 
> > > 'footballSat'. 'footballSat'
> > > exists as part of the string in the 'affil_team' field but the above 
> > > query refuses to find
> > > 'footballSat'!! (No error is received though)
> > >
> > > I'm using MySQL 3.22.32 + php4.0.3pl1
> > >
> > > Cheers
> > > Russ
> > >
> > > #---#
> > >   
> > >   "Believe nothing - consider everything" 
> > >
> > >   Russ Michell
> > >   Anglia Polytechnic University Webteam
> > >   Room 1C 'The Eastings' East Road, Cambridge
> > >
> > >   e: [EMAIL PROTECTED]
> > >   w: www.apu.ac.uk/webteam
> > >   t: +44 (0)1223 363271 x 2331
> > >
> > >   www.theruss.com
> > >   
> > > #---#
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >
> > 
> > -- 
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additiona

RE: RE: [PHP-DB] Query construction

2001-09-19 Thread Rick Emery

It wasn't a waste of time.  Now, the next time you have a similar problem
with a mySQL query, you'll follow this procedure.

Learning is NEVER a waste of time...

p.s.  Your father is a psychiatrist???  Now, there, I could use some help...

-Original Message-
From: Russ Michell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 19, 2001 9:56 AM
To: Rick Emery
Cc: [EMAIL PROTECTED]
Subject: Re: RE: [PHP-DB] Query construction


Ok ok ok!! Thank you both for the pointers, they did of course yield the
problem - as bloody always 
it's something completely different! As my old-dad always says: "Everything
is about something 
else" (although this was always meant in a psychiatrist-patient
relationship..)

Thank you again both, and I apologise for seemingly wasting your time, but I
do value people's 
ideas and opinions, and hopefully others do of mine also.

Regards:
Russ Michell (APU Webteam)

On Wed, 19 Sep 2001 09:41:47 -0500 Rick Emery <[EMAIL PROTECTED]> wrote:

> YES!!! Exactly
> 
> Russ...do what Steve syas...
> 
> -Original Message-
> From: Steve Cayford [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 19, 2001 9:32 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Query construction
> 
> 
> Usually what I do when I'm having this type of problem is put the whole 
> sql statement into a string variable then print the variable out just 
> before running the query so you know exactly what's being sent to mysql. 
> Then I log into mysql from the command line and enter the query manually 
> to see what sort of response or error message I get.
> 
> -Steve
> 
> On Wednesday, September 19, 2001, at 09:01  AM, Russ Michell wrote:
> 
> > Hi there:
> >
> > Further to a previous submission (which can be ignored), I'd like the 
> > following query to 'search' a
> > table field of different team names (stored as a single string), but it 
> > does't seem to work!
> >
> > "SELECT * FROM $table_users WHERE usrName='$username' AND 
> > usrPswd=password('$password') AND affil_team RLIKE '$team+'";
> > (I've also tried: RLIKE '$team?' )
> >
> > This should match the string found in the variable: '$team' with the 
> > some of contents (string)
> > found in 'affil_team'.
> >
> > For example my test has been, trying to find 'footballSat', so $team = 
> > 'footballSat'. 'footballSat'
> > exists as part of the string in the 'affil_team' field but the above 
> > query refuses to find
> > 'footballSat'!! (No error is received though)
> >
> > I'm using MySQL 3.22.32 + php4.0.3pl1
> >
> > Cheers
> > Russ
> >
> > #---#
> > 
> >   "Believe nothing - consider everything"   
> >
> >   Russ Michell
> >   Anglia Polytechnic University Webteam
> >   Room 1C 'The Eastings' East Road, Cambridge
> >
> >   e: [EMAIL PROTECTED]
> >   w: www.apu.ac.uk/webteam
> >   t: +44 (0)1223 363271 x 2331
> >
> >   www.theruss.com
> > 
> > #---#
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

#---#

  "Believe nothing - consider everything"   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  Room 1C 'The Eastings' East Road, Cambridge
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com

#---#

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: RE: [PHP-DB] Query construction

2001-09-19 Thread Russ Michell

Ok ok ok!! Thank you both for the pointers, they did of course yield the problem - as 
bloody always 
it's something completely different! As my old-dad always says: "Everything is about 
something 
else" (although this was always meant in a psychiatrist-patient relationship..)

Thank you again both, and I apologise for seemingly wasting your time, but I do value 
people's 
ideas and opinions, and hopefully others do of mine also.

Regards:
Russ Michell (APU Webteam)

On Wed, 19 Sep 2001 09:41:47 -0500 Rick Emery <[EMAIL PROTECTED]> wrote:

> YES!!! Exactly
> 
> Russ...do what Steve syas...
> 
> -Original Message-
> From: Steve Cayford [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 19, 2001 9:32 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Query construction
> 
> 
> Usually what I do when I'm having this type of problem is put the whole 
> sql statement into a string variable then print the variable out just 
> before running the query so you know exactly what's being sent to mysql. 
> Then I log into mysql from the command line and enter the query manually 
> to see what sort of response or error message I get.
> 
> -Steve
> 
> On Wednesday, September 19, 2001, at 09:01  AM, Russ Michell wrote:
> 
> > Hi there:
> >
> > Further to a previous submission (which can be ignored), I'd like the 
> > following query to 'search' a
> > table field of different team names (stored as a single string), but it 
> > does't seem to work!
> >
> > "SELECT * FROM $table_users WHERE usrName='$username' AND 
> > usrPswd=password('$password') AND affil_team RLIKE '$team+'";
> > (I've also tried: RLIKE '$team?' )
> >
> > This should match the string found in the variable: '$team' with the 
> > some of contents (string)
> > found in 'affil_team'.
> >
> > For example my test has been, trying to find 'footballSat', so $team = 
> > 'footballSat'. 'footballSat'
> > exists as part of the string in the 'affil_team' field but the above 
> > query refuses to find
> > 'footballSat'!! (No error is received though)
> >
> > I'm using MySQL 3.22.32 + php4.0.3pl1
> >
> > Cheers
> > Russ
> >
> > #---#
> > 
> >   "Believe nothing - consider everything"   
> >
> >   Russ Michell
> >   Anglia Polytechnic University Webteam
> >   Room 1C 'The Eastings' East Road, Cambridge
> >
> >   e: [EMAIL PROTECTED]
> >   w: www.apu.ac.uk/webteam
> >   t: +44 (0)1223 363271 x 2331
> >
> >   www.theruss.com
> > 
> > #---#
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]

#---#

  "Believe nothing - consider everything"   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  Room 1C 'The Eastings' East Road, Cambridge
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com

#---#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Query construction

2001-09-19 Thread Rick Emery

YES!!! Exactly

Russ...do what Steve syas...

-Original Message-
From: Steve Cayford [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 19, 2001 9:32 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Query construction


Usually what I do when I'm having this type of problem is put the whole 
sql statement into a string variable then print the variable out just 
before running the query so you know exactly what's being sent to mysql. 
Then I log into mysql from the command line and enter the query manually 
to see what sort of response or error message I get.

-Steve

On Wednesday, September 19, 2001, at 09:01  AM, Russ Michell wrote:

> Hi there:
>
> Further to a previous submission (which can be ignored), I'd like the 
> following query to 'search' a
> table field of different team names (stored as a single string), but it 
> does't seem to work!
>
> "SELECT * FROM $table_users WHERE usrName='$username' AND 
> usrPswd=password('$password') AND affil_team RLIKE '$team+'";
> (I've also tried: RLIKE '$team?' )
>
> This should match the string found in the variable: '$team' with the 
> some of contents (string)
> found in 'affil_team'.
>
> For example my test has been, trying to find 'footballSat', so $team = 
> 'footballSat'. 'footballSat'
> exists as part of the string in the 'affil_team' field but the above 
> query refuses to find
> 'footballSat'!! (No error is received though)
>
> I'm using MySQL 3.22.32 + php4.0.3pl1
>
> Cheers
> Russ
>
> #---#
>   
>   "Believe nothing - consider everything" 
>
>   Russ Michell
>   Anglia Polytechnic University Webteam
>   Room 1C 'The Eastings' East Road, Cambridge
>
>   e: [EMAIL PROTECTED]
>   w: www.apu.ac.uk/webteam
>   t: +44 (0)1223 363271 x 2331
>
>   www.theruss.com
>   
> #---#
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: RE: RE: [PHP-DB] Query construction

2001-09-19 Thread Rick Emery

You've created $sql.  Good.  Print it...display it...show its contents...

Does it contain the TEXT that you expect?  Copy and paste it to the "mysql>"
command line in mysql.


-Original Message-
From: Russ Michell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 19, 2001 9:33 AM
To: Rick Emery
Cc: [EMAIL PROTECTED]
Subject: Re: RE: RE: [PHP-DB] Query construction


I'm sorry but I must be missing something fundamental here. This is how my
code looks, and if the 
SQL query yields nothing and emits no error (as it currently is) it simply
reverts to error.php:

$sql = "SELECT * FROM $table_users WHERE usrName='$username' AND
usrPswd=password('$password') AND affil_team RLIKE '$team+'";
$result = mysql_query($sql, $connection) or die(mysql_error());
$num = mysql_num_rows($result);
//User hasn't been found in DB with current details:
if ($num == 0) {
header("Location: error.php?err=n_player);
exit;
}
else {
while($row = mysql_fetch_array($result)) {
etc etc


Cheers again:
Russ

On Wed, 19 Sep 2001 09:26:07 -0500 Rick Emery <[EMAIL PROTECTED]> wrote:

> $query = "SELECT * FROM $table_users WHERE usrName='$username' AND
> usrPswd=password('$password') AND affil_team RLIKE '$team+'"
> print $query
> 
> what were the contents of $query
> 
> -Original Message-
> From: Russ Michell [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 19, 2001 9:19 AM
> To: Rick Emery
> Cc: [EMAIL PROTECTED]
> Subject: Re: RE: [PHP-DB] Query construction
> 
> 
> If you mean did the pattern I'm trying to match: $team, contain what I
> though it should: 
> 'footballSat' then yes it did. I also receieve no error message from
> MySQl
> 
> The string in the table field I can view/alter in phpMyAdmin and I've
tried
> matching $team in the 
> query to the string as: footballSatfootballSun (etc etc) and also as:
> footballSat footballSun (etc 
> etc)..
> 
> Any ideas??
> Many thanks.
> 
> Russ
> 
> On Wed, 19 Sep 2001 09:12:36 -0500 Rick Emery <[EMAIL PROTECTED]> wrote:
> 
> > When you printed-out the string variable containing the SELECT
statement,
> > what did it look like?
> > 
> > -Original Message-
> > From: Russ Michell [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, September 19, 2001 9:01 AM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-DB] Query construction
> > 
> > 
> > Hi there:
> > 
> > Further to a previous submission (which can be ignored), I'd like the
> > following query to 'search' a 
> > table field of different team names (stored as a single string), but it
> > does't seem to work!
> > 
> > "SELECT * FROM $table_users WHERE usrName='$username' AND
> > usrPswd=password('$password') AND affil_team RLIKE '$team+'";
> > (I've also tried: RLIKE '$team?' )
> > 
> > This should match the string found in the variable: '$team' with the
some
> of
> > contents (string) 
> > found in 'affil_team'.
> > 
> > For example my test has been, trying to find 'footballSat', so $team =
> > 'footballSat'. 'footballSat' 
> > exists as part of the string in the 'affil_team' field but the above
query
> > refuses to find 
> > 'footballSat'!! (No error is received though)
> > 
> > I'm using MySQL 3.22.32 + php4.0.3pl1
> > 
> > Cheers
> > Russ
> > 
> > #---#
> > 
> >   "Believe nothing - consider everything"   
> >   
> >   Russ Michell
> >   Anglia Polytechnic University Webteam
> >   Room 1C 'The Eastings' East Road, Cambridge
> >   
> >   e: [EMAIL PROTECTED]
> >   w: www.apu.ac.uk/webteam
> >   t: +44 (0)1223 363271 x 2331
> > 
> >   www.theruss.com
> > 
> > #---#
> > 
> > 
> > -- 
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > 
> > -- 
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > 
> 
> #---

Re: RE: RE: [PHP-DB] Query construction

2001-09-19 Thread Russ Michell

I'm sorry but I must be missing something fundamental here. This is how my code looks, 
and if the 
SQL query yields nothing and emits no error (as it currently is) it simply reverts to 
error.php:

$sql = "SELECT * FROM $table_users WHERE usrName='$username' AND 
usrPswd=password('$password') AND affil_team RLIKE '$team+'";
$result = mysql_query($sql, $connection) or die(mysql_error());
$num = mysql_num_rows($result);
//User hasn't been found in DB with current details:
if ($num == 0) {
header("Location: error.php?err=n_player);
exit;
}
else {
while($row = mysql_fetch_array($result)) {
etc etc


Cheers again:
Russ

On Wed, 19 Sep 2001 09:26:07 -0500 Rick Emery <[EMAIL PROTECTED]> wrote:

> $query = "SELECT * FROM $table_users WHERE usrName='$username' AND
> usrPswd=password('$password') AND affil_team RLIKE '$team+'"
> print $query
> 
> what were the contents of $query
> 
> -Original Message-
> From: Russ Michell [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 19, 2001 9:19 AM
> To: Rick Emery
> Cc: [EMAIL PROTECTED]
> Subject: Re: RE: [PHP-DB] Query construction
> 
> 
> If you mean did the pattern I'm trying to match: $team, contain what I
> though it should: 
> 'footballSat' then yes it did. I also receieve no error message from
> MySQl
> 
> The string in the table field I can view/alter in phpMyAdmin and I've tried
> matching $team in the 
> query to the string as: footballSatfootballSun (etc etc) and also as:
> footballSat footballSun (etc 
> etc)..
> 
> Any ideas??
> Many thanks.
> 
> Russ
> 
> On Wed, 19 Sep 2001 09:12:36 -0500 Rick Emery <[EMAIL PROTECTED]> wrote:
> 
> > When you printed-out the string variable containing the SELECT statement,
> > what did it look like?
> > 
> > -Original Message-
> > From: Russ Michell [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, September 19, 2001 9:01 AM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-DB] Query construction
> > 
> > 
> > Hi there:
> > 
> > Further to a previous submission (which can be ignored), I'd like the
> > following query to 'search' a 
> > table field of different team names (stored as a single string), but it
> > does't seem to work!
> > 
> > "SELECT * FROM $table_users WHERE usrName='$username' AND
> > usrPswd=password('$password') AND affil_team RLIKE '$team+'";
> > (I've also tried: RLIKE '$team?' )
> > 
> > This should match the string found in the variable: '$team' with the some
> of
> > contents (string) 
> > found in 'affil_team'.
> > 
> > For example my test has been, trying to find 'footballSat', so $team =
> > 'footballSat'. 'footballSat' 
> > exists as part of the string in the 'affil_team' field but the above query
> > refuses to find 
> > 'footballSat'!! (No error is received though)
> > 
> > I'm using MySQL 3.22.32 + php4.0.3pl1
> > 
> > Cheers
> > Russ
> > 
> > #---#
> > 
> >   "Believe nothing - consider everything"   
> >   
> >   Russ Michell
> >   Anglia Polytechnic University Webteam
> >   Room 1C 'The Eastings' East Road, Cambridge
> >   
> >   e: [EMAIL PROTECTED]
> >   w: www.apu.ac.uk/webteam
> >   t: +44 (0)1223 363271 x 2331
> > 
> >   www.theruss.com
> > 
> > #---#
> > 
> > 
> > -- 
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > 
> > -- 
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > 
> 
> #---#
>   
>   "Believe nothing - consider everything" 
>   
>   Russ Michell
>   Anglia Polytechnic University Webteam
>   Room 1C 'The Eastings' East Road, Cambridge
>   
>   e: [EMAIL PROTECTED]
>   w: www.apu.ac.uk/webteam
>   t: +44 (0)1223 363271 x 2331
> 
>   www.theruss.com
&

Re: [PHP-DB] Query construction

2001-09-19 Thread Steve Cayford

Usually what I do when I'm having this type of problem is put the whole 
sql statement into a string variable then print the variable out just 
before running the query so you know exactly what's being sent to mysql. 
Then I log into mysql from the command line and enter the query manually 
to see what sort of response or error message I get.

-Steve

On Wednesday, September 19, 2001, at 09:01  AM, Russ Michell wrote:

> Hi there:
>
> Further to a previous submission (which can be ignored), I'd like the 
> following query to 'search' a
> table field of different team names (stored as a single string), but it 
> does't seem to work!
>
> "SELECT * FROM $table_users WHERE usrName='$username' AND 
> usrPswd=password('$password') AND affil_team RLIKE '$team+'";
> (I've also tried: RLIKE '$team?' )
>
> This should match the string found in the variable: '$team' with the 
> some of contents (string)
> found in 'affil_team'.
>
> For example my test has been, trying to find 'footballSat', so $team = 
> 'footballSat'. 'footballSat'
> exists as part of the string in the 'affil_team' field but the above 
> query refuses to find
> 'footballSat'!! (No error is received though)
>
> I'm using MySQL 3.22.32 + php4.0.3pl1
>
> Cheers
> Russ
>
> #---#
>   
>   "Believe nothing - consider everything" 
>
>   Russ Michell
>   Anglia Polytechnic University Webteam
>   Room 1C 'The Eastings' East Road, Cambridge
>
>   e: [EMAIL PROTECTED]
>   w: www.apu.ac.uk/webteam
>   t: +44 (0)1223 363271 x 2331
>
>   www.theruss.com
>   
> #---#
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: RE: [PHP-DB] Query construction

2001-09-19 Thread Rick Emery

$query = "SELECT * FROM $table_users WHERE usrName='$username' AND
usrPswd=password('$password') AND affil_team RLIKE '$team+'"
print $query

what were the contents of $query

-Original Message-
From: Russ Michell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 19, 2001 9:19 AM
To: Rick Emery
Cc: [EMAIL PROTECTED]
Subject: Re: RE: [PHP-DB] Query construction


If you mean did the pattern I'm trying to match: $team, contain what I
though it should: 
'footballSat' then yes it did. I also receieve no error message from
MySQl

The string in the table field I can view/alter in phpMyAdmin and I've tried
matching $team in the 
query to the string as: footballSatfootballSun (etc etc) and also as:
footballSat footballSun (etc 
etc)..

Any ideas??
Many thanks.

Russ

On Wed, 19 Sep 2001 09:12:36 -0500 Rick Emery <[EMAIL PROTECTED]> wrote:

> When you printed-out the string variable containing the SELECT statement,
> what did it look like?
> 
> -Original Message-
> From: Russ Michell [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 19, 2001 9:01 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Query construction
> 
> 
> Hi there:
> 
> Further to a previous submission (which can be ignored), I'd like the
> following query to 'search' a 
> table field of different team names (stored as a single string), but it
> does't seem to work!
> 
> "SELECT * FROM $table_users WHERE usrName='$username' AND
> usrPswd=password('$password') AND affil_team RLIKE '$team+'";
> (I've also tried: RLIKE '$team?' )
> 
> This should match the string found in the variable: '$team' with the some
of
> contents (string) 
> found in 'affil_team'.
> 
> For example my test has been, trying to find 'footballSat', so $team =
> 'footballSat'. 'footballSat' 
> exists as part of the string in the 'affil_team' field but the above query
> refuses to find 
> 'footballSat'!! (No error is received though)
> 
> I'm using MySQL 3.22.32 + php4.0.3pl1
> 
> Cheers
> Russ
> 
> #---#
>   
>   "Believe nothing - consider everything" 
>   
>   Russ Michell
>   Anglia Polytechnic University Webteam
>   Room 1C 'The Eastings' East Road, Cambridge
>   
>   e: [EMAIL PROTECTED]
>   w: www.apu.ac.uk/webteam
>   t: +44 (0)1223 363271 x 2331
> 
>   www.theruss.com
>   
> #---#
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

#---#

  "Believe nothing - consider everything"   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  Room 1C 'The Eastings' East Road, Cambridge
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com

#---#

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: RE: [PHP-DB] Query construction

2001-09-19 Thread Russ Michell

If you mean did the pattern I'm trying to match: $team, contain what I though it 
should: 
'footballSat' then yes it did. I also receieve no error message from MySQl

The string in the table field I can view/alter in phpMyAdmin and I've tried matching 
$team in the 
query to the string as: footballSatfootballSun (etc etc) and also as: footballSat 
footballSun (etc 
etc)..

Any ideas??
Many thanks.

Russ

On Wed, 19 Sep 2001 09:12:36 -0500 Rick Emery <[EMAIL PROTECTED]> wrote:

> When you printed-out the string variable containing the SELECT statement,
> what did it look like?
> 
> -Original Message-
> From: Russ Michell [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 19, 2001 9:01 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Query construction
> 
> 
> Hi there:
> 
> Further to a previous submission (which can be ignored), I'd like the
> following query to 'search' a 
> table field of different team names (stored as a single string), but it
> does't seem to work!
> 
> "SELECT * FROM $table_users WHERE usrName='$username' AND
> usrPswd=password('$password') AND affil_team RLIKE '$team+'";
> (I've also tried: RLIKE '$team?' )
> 
> This should match the string found in the variable: '$team' with the some of
> contents (string) 
> found in 'affil_team'.
> 
> For example my test has been, trying to find 'footballSat', so $team =
> 'footballSat'. 'footballSat' 
> exists as part of the string in the 'affil_team' field but the above query
> refuses to find 
> 'footballSat'!! (No error is received though)
> 
> I'm using MySQL 3.22.32 + php4.0.3pl1
> 
> Cheers
> Russ
> 
> #---#
>   
>   "Believe nothing - consider everything" 
>   
>   Russ Michell
>   Anglia Polytechnic University Webteam
>   Room 1C 'The Eastings' East Road, Cambridge
>   
>   e: [EMAIL PROTECTED]
>   w: www.apu.ac.uk/webteam
>   t: +44 (0)1223 363271 x 2331
> 
>   www.theruss.com
>   
> #---#
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

#---#

  "Believe nothing - consider everything"   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  Room 1C 'The Eastings' East Road, Cambridge
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com

#---#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Query construction

2001-09-19 Thread Rick Emery

When you printed-out the string variable containing the SELECT statement,
what did it look like?

-Original Message-
From: Russ Michell [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 19, 2001 9:01 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Query construction


Hi there:

Further to a previous submission (which can be ignored), I'd like the
following query to 'search' a 
table field of different team names (stored as a single string), but it
does't seem to work!

"SELECT * FROM $table_users WHERE usrName='$username' AND
usrPswd=password('$password') AND affil_team RLIKE '$team+'";
(I've also tried: RLIKE '$team?' )

This should match the string found in the variable: '$team' with the some of
contents (string) 
found in 'affil_team'.

For example my test has been, trying to find 'footballSat', so $team =
'footballSat'. 'footballSat' 
exists as part of the string in the 'affil_team' field but the above query
refuses to find 
'footballSat'!! (No error is received though)

I'm using MySQL 3.22.32 + php4.0.3pl1

Cheers
Russ

#---#

  "Believe nothing - consider everything"   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  Room 1C 'The Eastings' East Road, Cambridge
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com

#---#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Query construction

2001-09-19 Thread Russ Michell

Hi there:

Further to a previous submission (which can be ignored), I'd like the following query 
to 'search' a 
table field of different team names (stored as a single string), but it does't seem to 
work!

"SELECT * FROM $table_users WHERE usrName='$username' AND 
usrPswd=password('$password') AND affil_team RLIKE '$team+'";
(I've also tried: RLIKE '$team?' )

This should match the string found in the variable: '$team' with the some of contents 
(string) 
found in 'affil_team'.

For example my test has been, trying to find 'footballSat', so $team = 'footballSat'. 
'footballSat' 
exists as part of the string in the 'affil_team' field but the above query refuses to 
find 
'footballSat'!! (No error is received though)

I'm using MySQL 3.22.32 + php4.0.3pl1

Cheers
Russ

#---#

  "Believe nothing - consider everything"   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  Room 1C 'The Eastings' East Road, Cambridge
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com

#---#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: SV: [PHP-DB] Query construction (again)

2001-08-23 Thread Russ Michell

Thanks for that - but I just sorted it literally 10 seconds ago! I used:

$sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 8 DAY) > CURDATE()";

Something happens with using INTERVAL 7 DAY though, in that only 6 days worth of posts 
are 
displayed, so 8 will have to suffice!

Thanks very much!
Russ


On Thu, 23 Aug 2001 11:09:32 +0200 Torgil Zechel <[EMAIL PROTECTED]> wrote:

> This should work:
> 
> SELECT * FROM items WHERE TO_DAYS(NOW()) - TO_DAYS(submitDate) <= 7;
> 
> > -Ursprungligt meddelande-
> > Fran: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]For Russ Michell
> > Skickat: den 23 augusti 2001 11:46
> > Till: Gremlins Mailing List
> > Kopia: [EMAIL PROTECTED]
> > Amne: Re: [PHP-DB] Query construction (again)
> >
> >
> > (Apologies for cross-postings here but I lost a php-db list
> > members personal email address..)
> >
> > I need a query that in English would read something like:
> >
> > "Select all records from table: 'items' where each record is
> > displayed for 7days after it's
> > submission."
> >
> > It was suggested I may have to modify the output of now() to
> > match my MySQL DB 'submitDate' field
> > as in the query below:
> >
> > $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate,
> > INTERVAL 7 DAY) =
> > now()";
> >
> > So I tried the following:
> >
> > $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate,
> > INTERVAL 7 DAY) = DATE_FORMAT(NOW(),'Y-M-D')";
> >
> > MySQL didn't complain but nor did it print out all postings
> > submitted in the last seven days which
> > is what it is suppposed to be doing!
> >
> > The 'submitDate' field is a MySQL DATE field and I'm using
> > MySQL-3.22.32 if that's any use.
> > Why is the query not doing what it's told!!?
> >
> >
> > Cheers for your help thus far!
> > Russ
> >
> > Depending on how the date is stored (date + time, or just date)
> > On Wed, 22 Aug 2001 21:39:19 +0800 Gremlins Mailing List
> > <[EMAIL PROTECTED]> wrote:
> >
> > > - Original Message -
> > > From: Russ Michell <[EMAIL PROTECTED]>
> > > To: <[EMAIL PROTECTED]>
> > > Sent: Wednesday, August 22, 2001 10:16 PM
> > > Subject: [PHP-DB] Query construction (again)
> > >
> > >
> > > > Hey there folks - similar problem - different project!
> > > >
> > > > I want to select some records for a period of 7days after their insert
> > > [dateFrom] date.
> > > > Last time I asked you guys for help I was helped toward the following
> > > solution:
> > > >
> > > > $sql = "SELECT * FROM $Tpostings WHERE now()>=dateFrom AND
> > now() > > >
> > > > The problem in this new project is that the 'dateTo' field is
> > not included
> > > in the DB. It is 7-days
> > > > after 'dateFrom'. So why does the following query not work:
> > > >
> > > > $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 7
> > > DAY)";
> > > > No error is received though...
> > >
> > > There is no comparison in your WHERE clause. Try something like:
> > >
> > > $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate,
> > INTERVAL 7 DAY) =
> > > now()";
> > >
> > > Depending on how the date is stored (date + time, or just date)
> > you may have
> > > to modify the output of now() to match.
> > >
> > > hth
> > > --
> > > Jason Wong
> > > Gremlins Associates
> > > www.gremlins.com.hk
> > >
> > >
> > >
> > >
> > > --
> > > PHP Database Mailing List (http://www.php.net/)
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> > >
> >
> > #---#
> >
> >   "Believe nothing - consider everything"
> >
> >   Russ Michell
> >   Anglia Polytechnic University Webteam
> >
> >   e: [EMAIL PROTECTED]
> >   w: www.apu.ac.uk/webteam
> >   t: +44 (0)1223 363271 x 2331
> >
> >   www.theruss.com
> >
> > #---#
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

#---#

  "Believe nothing - consider everything"   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com

#---#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




SV: [PHP-DB] Query construction (again)

2001-08-23 Thread Torgil Zechel

This should work:

SELECT * FROM items WHERE TO_DAYS(NOW()) - TO_DAYS(submitDate) <= 7;

> -Ursprungligt meddelande-
> Fran: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]For Russ Michell
> Skickat: den 23 augusti 2001 11:46
> Till: Gremlins Mailing List
> Kopia: [EMAIL PROTECTED]
> Amne: Re: [PHP-DB] Query construction (again)
>
>
> (Apologies for cross-postings here but I lost a php-db list
> members personal email address..)
>
> I need a query that in English would read something like:
>
> "Select all records from table: 'items' where each record is
> displayed for 7days after it's
> submission."
>
> It was suggested I may have to modify the output of now() to
> match my MySQL DB 'submitDate' field
> as in the query below:
>
> $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate,
> INTERVAL 7 DAY) =
> now()";
>
> So I tried the following:
>
> $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate,
> INTERVAL 7 DAY) = DATE_FORMAT(NOW(),'Y-M-D')";
>
> MySQL didn't complain but nor did it print out all postings
> submitted in the last seven days which
> is what it is suppposed to be doing!
>
> The 'submitDate' field is a MySQL DATE field and I'm using
> MySQL-3.22.32 if that's any use.
> Why is the query not doing what it's told!!?
>
>
> Cheers for your help thus far!
> Russ
>
> Depending on how the date is stored (date + time, or just date)
> On Wed, 22 Aug 2001 21:39:19 +0800 Gremlins Mailing List
> <[EMAIL PROTECTED]> wrote:
>
> > - Original Message -
> > From: Russ Michell <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Wednesday, August 22, 2001 10:16 PM
> > Subject: [PHP-DB] Query construction (again)
> >
> >
> > > Hey there folks - similar problem - different project!
> > >
> > > I want to select some records for a period of 7days after their insert
> > [dateFrom] date.
> > > Last time I asked you guys for help I was helped toward the following
> > solution:
> > >
> > > $sql = "SELECT * FROM $Tpostings WHERE now()>=dateFrom AND
> now() > >
> > > The problem in this new project is that the 'dateTo' field is
> not included
> > in the DB. It is 7-days
> > > after 'dateFrom'. So why does the following query not work:
> > >
> > > $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 7
> > DAY)";
> > > No error is received though...
> >
> > There is no comparison in your WHERE clause. Try something like:
> >
> > $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate,
> INTERVAL 7 DAY) =
> > now()";
> >
> > Depending on how the date is stored (date + time, or just date)
> you may have
> > to modify the output of now() to match.
> >
> > hth
> > --
> > Jason Wong
> > Gremlins Associates
> > www.gremlins.com.hk
> >
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
>
> #---#
>
>   "Believe nothing - consider everything"
>
>   Russ Michell
>   Anglia Polytechnic University Webteam
>
>   e: [EMAIL PROTECTED]
>   w: www.apu.ac.uk/webteam
>   t: +44 (0)1223 363271 x 2331
>
>   www.theruss.com
>
> #---#
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Query construction (again)

2001-08-23 Thread Russ Michell

(Apologies for cross-postings here but I lost a php-db list members personal email 
address..)

I need a query that in English would read something like:

"Select all records from table: 'items' where each record is displayed for 7days after 
it's 
submission."

It was suggested I may have to modify the output of now() to match my MySQL DB 
'submitDate' field 
as in the query below:

$sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 7 DAY) =
now()";

So I tried the following:

$sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 7 DAY) = 
DATE_FORMAT(NOW(),'Y-M-D')";

MySQL didn't complain but nor did it print out all postings submitted in the last 
seven days which 
is what it is suppposed to be doing!

The 'submitDate' field is a MySQL DATE field and I'm using MySQL-3.22.32 if that's any 
use.
Why is the query not doing what it's told!!?


Cheers for your help thus far!
Russ

Depending on how the date is stored (date + time, or just date) 
On Wed, 22 Aug 2001 21:39:19 +0800 Gremlins Mailing List 
<[EMAIL PROTECTED]> wrote:

> - Original Message -
> From: Russ Michell <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, August 22, 2001 10:16 PM
> Subject: [PHP-DB] Query construction (again)
> 
> 
> > Hey there folks - similar problem - different project!
> >
> > I want to select some records for a period of 7days after their insert
> [dateFrom] date.
> > Last time I asked you guys for help I was helped toward the following
> solution:
> >
> > $sql = "SELECT * FROM $Tpostings WHERE now()>=dateFrom AND now() >
> > The problem in this new project is that the 'dateTo' field is not included
> in the DB. It is 7-days
> > after 'dateFrom'. So why does the following query not work:
> >
> > $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 7
> DAY)";
> > No error is received though...
> 
> There is no comparison in your WHERE clause. Try something like:
> 
> $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 7 DAY) =
> now()";
> 
> Depending on how the date is stored (date + time, or just date) you may have
> to modify the output of now() to match.
> 
> hth
> --
> Jason Wong
> Gremlins Associates
> www.gremlins.com.hk
> 
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

#---#

  "Believe nothing - consider everything"   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com

#---#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Query construction (again)

2001-08-22 Thread Jason Wong

- Original Message -
From: Russ Michell <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 22, 2001 10:16 PM
Subject: [PHP-DB] Query construction (again)


> Hey there folks - similar problem - different project!
>
> I want to select some records for a period of 7days after their insert
[dateFrom] date.
> Last time I asked you guys for help I was helped toward the following
solution:
>
> $sql = "SELECT * FROM $Tpostings WHERE now()>=dateFrom AND now()
> The problem in this new project is that the 'dateTo' field is not included
in the DB. It is 7-days
> after 'dateFrom'. So why does the following query not work:
>
> $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 7
DAY)";
> No error is received though...

There is no comparison in your WHERE clause. Try something like:

$sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 7 DAY) =
now()";

Depending on how the date is stored (date + time, or just date) you may have
to modify the output of now() to match.

hth
--
Jason Wong
Gremlins Associates
www.gremlins.com.hk





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Query construction (again)

2001-08-22 Thread Gremlins Mailing List

- Original Message -
From: Russ Michell <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 22, 2001 10:16 PM
Subject: [PHP-DB] Query construction (again)


> Hey there folks - similar problem - different project!
>
> I want to select some records for a period of 7days after their insert
[dateFrom] date.
> Last time I asked you guys for help I was helped toward the following
solution:
>
> $sql = "SELECT * FROM $Tpostings WHERE now()>=dateFrom AND now()
> The problem in this new project is that the 'dateTo' field is not included
in the DB. It is 7-days
> after 'dateFrom'. So why does the following query not work:
>
> $sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 7
DAY)";
> No error is received though...

There is no comparison in your WHERE clause. Try something like:

$sql = "SELECT * FROM $tabitem WHERE DATE_ADD(submitDate, INTERVAL 7 DAY) =
now()";

Depending on how the date is stored (date + time, or just date) you may have
to modify the output of now() to match.

hth
--
Jason Wong
Gremlins Associates
www.gremlins.com.hk




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] Query construction (again)

2001-08-22 Thread Russ Michell

Hey there folks - similar problem - different project!

I want to select some records for a period of 7days after their insert [dateFrom] date.
Last time I asked you guys for help I was helped toward the following solution:

$sql = "SELECT * FROM $Tpostings WHERE now()>=dateFrom AND now()http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP-DB] Query construction

2001-08-21 Thread Russ Michell

Okay I have it now!

while ($row = mysql_fetch_array($result)) {
$name = $row['name'];
$dc = $row['datecreated'];
$nameinurl = urlencode($name);

//Get total posts for each category

$totalsql = "SELECT COUNT(category) AS total FROM $Tpostings WHERE category='$name' 
GROUP BY 
category";
$totalresult = mysql_query($totalsql,$connect) or error("Sorry!");
$check2 = mysql_num_rows($totalresult);
if ($check2 == 0) {
$total = 0;
}
else {
while($totalrow = mysql_fetch_array($totalresult)) {
$total = $totalrow['total'];
}//end while
}//end else
}//end while

I used the WHERE clause on $name, which gives me the total postings for each category 
as a *name* 
as opposed simply to a *unique category*

Many thanks for all your efforts, it was those that led me to this solution!
Cheers.

Russ

On Tue, 21 Aug 2001 14:08:30 +0200 "Walter, Marcel" <[EMAIL PROTECTED]> wrote:

> What about this:
> select count(category), category from posts group by category
> 
> > -Original Message-
> > From:   Russ Michell [SMTP:[EMAIL PROTECTED]]
> > Sent:   Tuesday, August 21, 2001 14:44
> > To: Lunny Damian
> > Cc: [EMAIL PROTECTED]
> > Subject:Re: RE: RE: RE: [PHP-DB] Query construction
> > 
> > > I always love that feeling when you beat a problem that refuses to go
> > away.
> > So do I - but I aint beaten it yet! :-(
> > 
> > I'm still getting '2' as being the number of posts in each category when
> > '2' is actually only the 
> > number of posts in *one* of the categories...weird-huh?
> > 
> > Cheers.
> > 
> > Russ
> > 
> > On Tue, 21 Aug 2001 12:46:37 +0100 Lunny Damian <[EMAIL PROTECTED]>
> > wrote:
> > 
> > > I always love that feeling when you beat a problem that refuses to go
> > away.
> > > 
> > > Enjoy your lunch!
> > > 
> > > damian
> > > 
> > > > -Original Message-
> > > > From: Russ Michell [mailto:[EMAIL PROTECTED]]
> > > > Sent: 21 August 2001 13:23
> > > > To: Lunny Damian
> > > > Cc: [EMAIL PROTECTED]
> > > > Subject: Re: RE: RE: [PHP-DB] Query construction
> > > > 
> > > > 
> > > > Damn!!
> > > > 
> > > > That'll be it..
> > > > 
> > > > I'm running phpMyAdmin 2.1.0 , php.4.0.3pl1 and MySQL 3.22.32 
> > > > Then again I don't get an error message from your query..???
> > > > 
> > > > Perhaps it has to do with the query being embedded, that is 
> > > > *where* it's embedded:
> > > > 
> > > > $totalsql = "SELECT category,COUNT(*) FROM $Tpostings GROUP 
> > > > BY category";
> > > > $totalresult = mysql_query($totalsql,$connect) or 
> > > > error("Sorry! I was unable to process the 
> > > > required SQL transaction.");
> > > > while($totalrow = mysql_fetch_array($totalresult)) {
> > > > $total = $totalrow['category'];
> > > > }
> > > > 
> > > > //Results in:
> > > > 'some stuff' being echoed to the page..
> > > > 
> > > > So I tried:
> > > > $totalsql = "SELECT category,COUNT(*) AS total FROM 
> > > > $Tpostings GROUP BY category";
> > > > 
> > > > //Resulted in '2' being echoed to the page (2 is the number 
> > > > of posts in the 'some stuff' category) 
> > > > but 2 is displayed as being the number of posts in *all* the 
> > > > categories which isn't the case...
> > > > 
> > > > What do you think? (It's my luchtime too and I'm gonna go get some...)
> > > > Cheers once agin for trying.
> > > > 
> > > > Russ
> > > > 
> > > > On Tue, 21 Aug 2001 12:19:00 +0100 Lunny Damian 
> > > > <[EMAIL PROTECTED]> wrote:
> > > > 
> > > > > Russ,
> > > > > 
> > > > > I recreated your table/data (it's lunchtime and I thought 
> > > > I'd take a look at
> > > > > this) - my query returned the rows as below:
> > > > > 
> > > > > --
> > > > >  category count (*) 
> > > > > Edit Delete  russ category   3  
> > > > > Edit Delete  some stuff  1  
> > > &g

Re: RE: RE: RE: [PHP-DB] Query construction

2001-08-21 Thread Alnisa Allgood

At 1:44 PM +0100 8/21/01, Russ Michell wrote:
>  > I always love that feeling when you beat a problem that refuses to go away.
>So do I - but I aint beaten it yet! :-(
>
>I'm still getting '2' as being the number of posts in each category 
>when '2' is actually only the
>number of posts in *one* of the categories...weird-huh?
>

Try

SELECT category, COUNT(category) AS cat_count FROM postings GROUP BY 
category ORDER BY category

I find using the specific field you want count, instead of the count 
all fields changes the count results on occasion.

Alnisa
-- 
   .
Alnisa  Allgood
Executive Director
Nonprofit Tech
(ph) 415.337.7412  (fx) 415.337.7927
(url)  http://www.nonprofit-techworld.org
(url)  http://www.nonprofit-tech.org
(url)  http://www.tech-library.org
   .
Nonprofit Tech E-Update
mailto:[EMAIL PROTECTED]
   .
applying technology to transform
   .

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: RE: RE: RE: [PHP-DB] Query construction

2001-08-21 Thread Russ Michell

> I always love that feeling when you beat a problem that refuses to go away.
So do I - but I aint beaten it yet! :-(

I'm still getting '2' as being the number of posts in each category when '2' is 
actually only the 
number of posts in *one* of the categories...weird-huh?

Cheers.

Russ

On Tue, 21 Aug 2001 12:46:37 +0100 Lunny Damian <[EMAIL PROTECTED]> wrote:

> I always love that feeling when you beat a problem that refuses to go away.
> 
> Enjoy your lunch!
> 
> damian
> 
> > -Original Message-
> > From: Russ Michell [mailto:[EMAIL PROTECTED]]
> > Sent: 21 August 2001 13:23
> > To: Lunny Damian
> > Cc: [EMAIL PROTECTED]
> > Subject: Re: RE: RE: [PHP-DB] Query construction
> > 
> > 
> > Damn!!
> > 
> > That'll be it..
> > 
> > I'm running phpMyAdmin 2.1.0 , php.4.0.3pl1 and MySQL 3.22.32 
> > Then again I don't get an error message from your query..???
> > 
> > Perhaps it has to do with the query being embedded, that is 
> > *where* it's embedded:
> > 
> > $totalsql = "SELECT category,COUNT(*) FROM $Tpostings GROUP 
> > BY category";
> > $totalresult = mysql_query($totalsql,$connect) or 
> > error("Sorry! I was unable to process the 
> > required SQL transaction.");
> > while($totalrow = mysql_fetch_array($totalresult)) {
> > $total = $totalrow['category'];
> > }
> > 
> > //Results in:
> > 'some stuff' being echoed to the page..
> > 
> > So I tried:
> > $totalsql = "SELECT category,COUNT(*) AS total FROM 
> > $Tpostings GROUP BY category";
> > 
> > //Resulted in '2' being echoed to the page (2 is the number 
> > of posts in the 'some stuff' category) 
> > but 2 is displayed as being the number of posts in *all* the 
> > categories which isn't the case...
> > 
> > What do you think? (It's my luchtime too and I'm gonna go get some...)
> > Cheers once agin for trying.
> > 
> > Russ
> > 
> > On Tue, 21 Aug 2001 12:19:00 +0100 Lunny Damian 
> > <[EMAIL PROTECTED]> wrote:
> > 
> > > Russ,
> > > 
> > > I recreated your table/data (it's lunchtime and I thought 
> > I'd take a look at
> > > this) - my query returned the rows as below:
> > > 
> > > --
> > >  category count (*) 
> > > Edit Delete  russ category   3  
> > > Edit Delete  some stuff  1  
> > > --
> > > 
> > > I'm running with phpMyAdmin 2.2.0rc3 on PHP Version 
> > 4.0.4pl1 (MySQL is
> > > 3.23.36) - perhaps the problem lies with the versions?
> > > 
> > > damian
> > > 
> > > > -Original Message-
> > > > From: Russ Michell [mailto:[EMAIL PROTECTED]]
> > > > Sent: 21 August 2001 12:46
> > > > To: Lunny Damian
> > > > Subject: Re: RE: [PHP-DB] Query construction
> > > > 
> > > > 
> > > > Damian:
> > > > 
> > > > Thanks for that but it doesn't do what I wanted though. It 
> > > > actually returns the first item ('some 
> > > > stuff') from the table, where I wanted the total number of 
> > > > occurances of *each category* in the 

> > > > table, thus indicating the number of posts for each category 
> > > > in the 'posts' table.
> > > > 
> > > > !
> > > > 
> > > > Many thanks.
> > > > Russ
> > > > 
> > > > 
> > > > On Tue, 21 Aug 2001 11:23:35 +0100 Lunny Damian 
> > > > <[EMAIL PROTECTED]> wrote:
> > > > 
> > > > > Russ,
> > > > > 
> > > > > This should work for you:
> > > > > 
> > > > > -
> > > > > select category,count(*)
> > > > > from posts
> > > > > group by category;
> > > > > -
> > > > > 
> > > > > All the best,
> > > > > 
> > > > > damian
> > > > > 
> > > > > 
> > > > > > -Original Message-
> > > > > > From: Russ Michell [mailto:[EMAIL PROTECTED]]
> > > > > > Sent: 21 August 2001 12:10
> > > > > > To: [EMAIL PROTECTED]
> > > > > > Subject: [PHP-DB] Query construction
> > > > > > 
> &

Re: RE: RE: [PHP-DB] Query construction

2001-08-21 Thread Russ Michell

Damn!!

That'll be it..

I'm running phpMyAdmin 2.1.0 , php.4.0.3pl1 and MySQL 3.22.32 
Then again I don't get an error message from your query..???

Perhaps it has to do with the query being embedded, that is *where* it's embedded:

$totalsql = "SELECT category,COUNT(*) FROM $Tpostings GROUP BY category";
$totalresult = mysql_query($totalsql,$connect) or error("Sorry! I was unable to 
process the 
required SQL transaction.");
while($totalrow = mysql_fetch_array($totalresult)) {
$total = $totalrow['category'];
}

//Results in:
'some stuff' being echoed to the page..

So I tried:
$totalsql = "SELECT category,COUNT(*) AS total FROM $Tpostings GROUP BY category";

//Resulted in '2' being echoed to the page (2 is the number of posts in the 'some 
stuff' category) 
but 2 is displayed as being the number of posts in *all* the categories which isn't 
the case...

What do you think? (It's my luchtime too and I'm gonna go get some...)
Cheers once agin for trying.

Russ

On Tue, 21 Aug 2001 12:19:00 +0100 Lunny Damian <[EMAIL PROTECTED]> wrote:

> Russ,
> 
> I recreated your table/data (it's lunchtime and I thought I'd take a look at
> this) - my query returned the rows as below:
> 
> --
>  category count (*) 
> Edit Delete  russ category   3  
> Edit Delete  some stuff  1  
> --
> 
> I'm running with phpMyAdmin 2.2.0rc3 on PHP Version 4.0.4pl1 (MySQL is
> 3.23.36) - perhaps the problem lies with the versions?
> 
> damian
> 
> > -Original Message-
> > From: Russ Michell [mailto:[EMAIL PROTECTED]]
> > Sent: 21 August 2001 12:46
> > To: Lunny Damian
> > Subject: Re: RE: [PHP-DB] Query construction
> > 
> > 
> > Damian:
> > 
> > Thanks for that but it doesn't do what I wanted though. It 
> > actually returns the first item ('some 
> > stuff') from the table, where I wanted the total number of 
> > occurances of *each category* in the 
> > table, thus indicating the number of posts for each category 
> > in the 'posts' table.
> > 
> > !
> > 
> > Many thanks.
> > Russ
> > 
> > 
> > On Tue, 21 Aug 2001 11:23:35 +0100 Lunny Damian 
> > <[EMAIL PROTECTED]> wrote:
> > 
> > > Russ,
> > > 
> > > This should work for you:
> > > 
> > > -
> > > select category,count(*)
> > > from posts
> > > group by category;
> > > -
> > > 
> > > All the best,
> > > 
> > > damian
> > > 
> > > 
> > > > -Original Message-
> > > > From: Russ Michell [mailto:[EMAIL PROTECTED]]
> > > > Sent: 21 August 2001 12:10
> > > > To: [EMAIL PROTECTED]
> > > > Subject: [PHP-DB] Query construction
> > > > 
> > > > 
> > > > Hi there people:
> > > > 
> > > > I have a MySQL table consisting of category names among 
> > other things. 
> > > > I would like to be able to construct a query that tells me 
> > > > the number of times a unique category 
> > > > name occurs in the table:
> > > > 
> > > > //Table 'posts' from command-line
> > > > mysql> explain posts;
> > > > 
> > +--+-+--+-+++
> > > > | Field| Type| Null | Key | Default| 
> > Extra  |
> > > > 
> > +--+-+--+-+++
> > > > | id   | tinyint(3)  |  | PRI | 0  | 
> > auto_increment |
> > > > | category | varchar(25) |  | ||  
> >   |
> > > > | user | varchar(12) |  | ||  
> >   |
> > > > | dateFrom | date|  | | -00-00 |  
> >   |
> > > > | dateTo   | date|  | | -00-00 |  
> >   |
> > > > | title| varchar(25) |  | ||  
> >   |
> > > > | body | text|  | | NULL   |  
> >   |
> > > > 
> > +--+-+--+-+++
> > > > 7 rows in set (0.00 sec)
> > > > 
> > > > //Table 'posts' in phpMyAdmin tab
> > > > id category  userdateFromdateTo  title
> > > > body 

[PHP-DB] Query construction

2001-08-21 Thread Russ Michell

Hi there people:

I have a MySQL table consisting of category names among other things. 
I would like to be able to construct a query that tells me the number of times a 
unique category 
name occurs in the table:

//Table 'posts' from command-line
mysql> explain posts;
+--+-+--+-+++
| Field| Type| Null | Key | Default| Extra  |
+--+-+--+-+++
| id   | tinyint(3)  |  | PRI | 0  | auto_increment |
| category | varchar(25) |  | |||
| user | varchar(12) |  | |||
| dateFrom | date|  | | -00-00 ||
| dateTo   | date|  | | -00-00 ||
| title| varchar(25) |  | |||
| body | text|  | | NULL   ||
+--+-+--+-+++
7 rows in set (0.00 sec)

//Table 'posts' in phpMyAdmin tab
id category  userdateFromdateTo  titlebody 
3  some stuffmaurice 2001-09-23  2001-11-05  Maurcie's post   this is 
Maurice's test
4  russ category russmichell 2001-08-17  2001-08-27  Russ is theone   this is another 
test
9  russ category russmichell 2001-08-16  2001-08-19  Begon by Monday! This entry 
should dissapear
10 russ category russmichell 2001-08-16  2001-09-04  testing  This is another 
test!

For example I would like to know how many posts there are in the category 'russ 
category' (Should 
tell me there are 3 and only 1 for 'some stuff' ...

Can anyone help me toward a nice SQL query that would to this for me!?
Cheers all.

Russ

#---#

  "Believe nothing - consider everything"   
  
  Russ Michell
  Anglia Polytechnic University Webteam
  
  e: [EMAIL PROTECTED]
  w: www.apu.ac.uk/webteam
  t: +44 (0)1223 363271 x 2331

  www.theruss.com

#---#


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]