Re: [PHP-DB] Re: mysql query

2013-08-23 Thread Lester Caine

Ethan Rosenberg wrote:

I'm probably wrong, but in some contexts; eg, sql query, $ signs are not used.
I tried and added the incorrect $ sign, and Netbeans did not complain.  If
anyone knows of an editor that will able to spot this kind of error, please
inform the list.


You do need to take a little more care when using variables IN strings and watch 
that they are highlighted. As you say, the parsing is not actually wrong as it 
is valid 'text' and adding SQL parsers for every database is not really 
practical and probably would not fix the problem anyway? Personally I use 
Firebird, and have always built the SQL using parameters, so that the SQL is 
pure text, and values are passed in an array. This is something MySQL was a lot 
later in catching onto, but many of the simple security problems are totally 
eliminated using that approach.


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP-DB] Re: mysql query

2013-08-23 Thread Karl DeSaulniers
If your on a PC I would just get Eclipse. But if you have netbeans, you can set 
the syntax highlighting for the different scripts you write in the preferences. 
PHP, java, javascript, etc...

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DB] Re: mysql query

2013-08-23 Thread Lester Caine

Karl DeSaulniers wrote:

If your on a PC I would just get Eclipse. But if you have netbeans, you can set 
the syntax highlighting for the different scripts you write in the preferences. 
PHP, java, javascript, etc...


But the problem tha5 has been identified will never be flagged by simple 
highlighting. Debugging complex SQL queries is possibly better done outside of 
the PHP pages. Not sure exactly what SQL plug-in I've got running on Eclipse at 
the moment, but as Ethan identified earlier, the SQL script ran from the command 
line. It was passing the variables into it which was wrong.


I'm with him on the statement that MySQL should have returned an error. 
Certainly Firebird would have done and so identifying the problem might have 
been easier.


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP-DB] Re: mysql query

2013-08-23 Thread Jim Giner

On 8/22/2013 8:08 PM, Ethan Rosenberg wrote:


Ethan Rosenberg, PhD
/Pres/CEO/
*Hygeia Biomedical Research, Inc*
2 Cameo Ridge Road
Monsey, NY 10952
T: 845 352-3908
F: 845 352-7566
erosenb...@hygeiabiomedical.com
On 08/22/2013 06:56 PM, Jim Giner wrote:

On 8/22/2013 4:14 PM, Ethan Rosenberg wrote:

On 08/22/2013 11:54 AM, Jim Giner wrote:

On 8/22/2013 9:52 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = insert into Inventory (UPC,
quant,
manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc',
$qnt,'$mnf','$itm',
odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt
$opf
$stkkbr /;
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan




Ethan - you are simply missing two dollar signs as pointed out. Once
you correct them, if there are any more errors you should then be
seeing
the message from mysqli_error.

And as for the advice to dump single quotes, I'd ignore it. The use of
double and single quotes is a very handy feature and makes for very
readable code.  Escaping double quotes is such a royal pia and
makes for
more trouble deciphering code later on.  The sample you provided
for us
is some of the best and most understandable code you've ever showed
us.


Also - Ethan - if you used an editor that was designed for php you
probably would have seen these missing $ signs since a good one would
highlight php syntax and the lack of the $ would have produced a
different color than you expected.


Jim -

I  used Netbeans.  All it said is variable unused is scope, which is
a  error that I often find does not mean anything.  I am as pressurized
as you are.  Any suggestions as to an editor?

Ethan



Did you mean to say unused IN scope?  That would be telling you that
it is not yet defined and that could be a problem if you expect to be
already defined.

Several other posts here have listed their favorites.  Notepad ++
seems to be a favorite.  I use HTML-kit Tools as my developing
environment. Handles highlighting for php, html and js, as well as
project organization.  Also includes an ftp engine to allow me to
modify, upload and then go test my code very quickly. (I don't run php
or apache locally.)

Jim -

Thanks.

unused IN scope - correct.

There are lots of editors mentioned in this email trail.  I thank all
for the suggestions.

Netbeans, Aptana Studio, etc will all highlight code and show the errors
the code would generate in a browse. The problem here was two missing $
signs.

I'm probably wrong, but in some contexts; eg, sql query, $ signs are not
used.  I tried and added the incorrect $ sign, and Netbeans did not
complain.  If anyone knows of an editor that will able to spot this kind
of error, please inform the list.

Ethan

Wrong in one sense - all php vars must have a $ sign.  When building a 
query statemtent, if the editor doesn't tell you something (by not 
colorizing it) Sql is going to tell you when you attempt to run it. 
That's why one should ALWAYS include an error check after any operation.


BTW - this line
echo '$sql2br /';

isn't going to give you what you want.

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



Re: [PHP-DB] Re: mysql query

2013-08-23 Thread Jim Giner

On 8/23/2013 4:32 AM, Lester Caine wrote:

Karl DeSaulniers wrote:

If your on a PC I would just get Eclipse. But if you have netbeans,
you can set the syntax highlighting for the different scripts you
write in the preferences. PHP, java, javascript, etc...


But the problem tha5 has been identified will never be flagged by simple
highlighting. Debugging complex SQL queries is possibly better done
outside of the PHP pages. Not sure exactly what SQL plug-in I've got
running on Eclipse at the moment, but as Ethan identified earlier, the
SQL script ran from the command line. It was passing the variables into
it which was wrong.

I'm with him on the statement that MySQL should have returned an error.
Certainly Firebird would have done and so identifying the problem might
have been easier.

I think the reason he didn't get the error was cause of his lack of a 
connection which never allowed it to run.


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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Vinay Kannan
Jim, I know this is a stupid question to be asking this far into PHP
Development, maybe was a bit lazy, or just got too used to Notepad++, which
editor for PHP are you using? The feature which you mentioned for a good
php editor, sounds exciting, offcourse i would be looking only at the free
ones :D


On Thu, Aug 22, 2013 at 9:24 PM, Jim Giner jim.gi...@albanyhandball.comwrote:

 On 8/22/2013 9:52 AM, Jim Giner wrote:

 On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

 Dear List -

 I can't figure this out

 mysql describe Inventory;
 +-+-+-**-+-+-+---+
 | Field   | Type| Null | Key | Default | Extra |
 +-+-+-**-+-+-+---+
 | UPC | varchar(14) | YES  | | NULL |   |
 | quant   | int(5)  | NO   | | NULL |   |
 | manuf   | varchar(20) | YES  | | NULL |   |
 | item| varchar(50) | YES  | | NULL |   |
 | orderpt | tinyint(4)  | NO   | | NULL |   |
 | ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
 | stock   | int(3)  | YES  | | NULL |   |
 +-+-+-**-+-+-+---+

 Here are code snippets -

$upc   = $_SESSION['UPC'];
$qnt   = $_POST['quant'];
$mnf   = $_POST['manuf'];
$itm   = $_POST['item'];
$odrpt = $_POST['oderpt'];
$opf   = $_POST['ordrpt_flag'];
$stk= $_POST['stock'];

$sql2 = insert into Inventory (UPC, quant,
 manuf, item, orderpt, ordrpt_flag, stock)
  .values ('$upc', $qnt,'$mnf','$itm',
 odrpt, 0, $stk);
$result2 = mysqli_query(cxn, $sql2);
echo '$sql2br /';
print_r($sql2);
echo br /$upc $qnt $mnf $itm $odrpt $opf
 $stkkbr /;
if (!$result2)
  die('Could not enter data: ' .
 mysqli_error());

 The mysql query fails.  I cannot figure out why.  It works from the
 command line.

 TIA

 Ethan



  Ethan - you are simply missing two dollar signs as pointed out.  Once
 you correct them, if there are any more errors you should then be seeing
 the message from mysqli_error.

 And as for the advice to dump single quotes, I'd ignore it.  The use of
 double and single quotes is a very handy feature and makes for very
 readable code.  Escaping double quotes is such a royal pia and makes for
 more trouble deciphering code later on.  The sample you provided for us
 is some of the best and most understandable code you've ever showed us.

  Also - Ethan - if you used an editor that was designed for php you
 probably would have seen these missing $ signs since a good one would
 highlight php syntax and the lack of the $ would have produced a different
 color than you expected.


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




Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Toby Hart Dyke


Notepad++ will do syntax highlighting. Go to Language  P  PHP with a 
PHP file open, and see the colours change! It should be automatic - are 
you using something other than 'php' as a file extension?


  Toby

On 8/22/2013 5:27 PM, Vinay Kannan wrote:

Jim, I know this is a stupid question to be asking this far into PHP
Development, maybe was a bit lazy, or just got too used to Notepad++, which
editor for PHP are you using? The feature which you mentioned for a good
php editor, sounds exciting, offcourse i would be looking only at the free
ones :D


On Thu, Aug 22, 2013 at 9:24 PM, Jim Giner jim.gi...@albanyhandball.comwrote:





  Also - Ethan - if you used an editor that was designed for php you
probably would have seen these missing $ signs since a good one would
highlight php syntax and the lack of the $ would have produced a different
color than you expected.





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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Vinay Kannan
Thanks Toby, Using Notepad ++ with the language selected to PHP, the syntax
coloring is on


On Thu, Aug 22, 2013 at 11:00 PM, Toby Hart Dyke t...@hartdyke.com wrote:


 Notepad++ will do syntax highlighting. Go to Language  P  PHP with a PHP
 file open, and see the colours change! It should be automatic - are you
 using something other than 'php' as a file extension?

   Toby


 On 8/22/2013 5:27 PM, Vinay Kannan wrote:

 Jim, I know this is a stupid question to be asking this far into PHP
 Development, maybe was a bit lazy, or just got too used to Notepad++,
 which
 editor for PHP are you using? The feature which you mentioned for a good
 php editor, sounds exciting, offcourse i would be looking only at the free
 ones :D


 On Thu, Aug 22, 2013 at 9:24 PM, Jim Giner jim.gi...@albanyhandball.com
 **wrote:



   Also - Ethan - if you used an editor that was designed for php you
 probably would have seen these missing $ signs since a good one would
 highlight php syntax and the lack of the $ would have produced a
 different
 color than you expected.




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




Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Lester Caine

Vinay Kannan wrote:

Jim, I know this is a stupid question to be asking this far into PHP
Development, maybe was a bit lazy, or just got too used to Notepad++, which
editor for PHP are you using? The feature which you mentioned for a good
php editor, sounds exciting, offcourse i would be looking only at the free
ones


There are a number of options for highlighting and error checking just about 
every language. Running Linux most of them are free ;)
gedit and kwrite highlight automatically and help identify problems. In the past 
I've been running on both linux and windows so something cross platform was 
essential, and it's still nice when I do have to worry about windows sites. 
Eclipse provides that base, and while PDT is the official plugin for PHP, I'm 
back on the older PHPEclipse as it fits much better with the way I work. With 
properly commented libraries it provides pop-up crib sheets onthe parameters for 
a selected function, and of cause the auto complete can be configured to match 
your preferred way of working ... I'm still on tabs for indenting


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk

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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Ethan Rosenberg, PhD

On 08/22/2013 09:51 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt $opf
$stkkbr /;
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan



Ethan - you are simply missing two dollar signs as pointed out. Once 
you correct them, if there are any more errors you should then be 
seeing the message from mysqli_error.


And as for the advice to dump single quotes, I'd ignore it.  The use 
of double and single quotes is a very handy feature and makes for very 
readable code.  Escaping double quotes is such a royal pia and makes 
for more trouble deciphering code later on.  The sample you provided 
for us is some of the best and most understandable code you've ever 
showed us.

Jim -

Thanks for the complement.

Ethan


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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Ethan Rosenberg

On 08/22/2013 11:54 AM, Jim Giner wrote:

On 8/22/2013 9:52 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = insert into Inventory (UPC, quant,
manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc', $qnt,'$mnf','$itm',
odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt $opf
$stkkbr /;
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan




Ethan - you are simply missing two dollar signs as pointed out. Once
you correct them, if there are any more errors you should then be seeing
the message from mysqli_error.

And as for the advice to dump single quotes, I'd ignore it.  The use of
double and single quotes is a very handy feature and makes for very
readable code.  Escaping double quotes is such a royal pia and makes for
more trouble deciphering code later on.  The sample you provided for us
is some of the best and most understandable code you've ever showed us.

Also - Ethan - if you used an editor that was designed for php you 
probably would have seen these missing $ signs since a good one would 
highlight php syntax and the lack of the $ would have produced a 
different color than you expected.



Jim -

I  used Netbeans.  All it said is variable unused is scope, which is 
a  error that I often find does not mean anything.  I am as pressurized 
as you are.  Any suggestions as to an editor?


Ethan



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



Re: [PHP-DB] Re: mysql query

2013-08-22 Thread Ethan Rosenberg


Ethan Rosenberg, PhD
/Pres/CEO/
*Hygeia Biomedical Research, Inc*
2 Cameo Ridge Road
Monsey, NY 10952
T: 845 352-3908
F: 845 352-7566
erosenb...@hygeiabiomedical.com
On 08/22/2013 06:56 PM, Jim Giner wrote:

On 8/22/2013 4:14 PM, Ethan Rosenberg wrote:

On 08/22/2013 11:54 AM, Jim Giner wrote:

On 8/22/2013 9:52 AM, Jim Giner wrote:

On 8/21/2013 7:48 PM, Ethan Rosenberg wrote:

Dear List -

I can't figure this out

mysql describe Inventory;
+-+-+--+-+-+---+
| Field   | Type| Null | Key | Default | Extra |
+-+-+--+-+-+---+
| UPC | varchar(14) | YES  | | NULL |   |
| quant   | int(5)  | NO   | | NULL |   |
| manuf   | varchar(20) | YES  | | NULL |   |
| item| varchar(50) | YES  | | NULL |   |
| orderpt | tinyint(4)  | NO   | | NULL |   |
| ordrpt_flag | tinyint(3)  | YES  | | NULL |   |
| stock   | int(3)  | YES  | | NULL |   |
+-+-+--+-+-+---+

Here are code snippets -

   $upc   = $_SESSION['UPC'];
   $qnt   = $_POST['quant'];
   $mnf   = $_POST['manuf'];
   $itm   = $_POST['item'];
   $odrpt = $_POST['oderpt'];
   $opf   = $_POST['ordrpt_flag'];
   $stk= $_POST['stock'];

   $sql2 = insert into Inventory (UPC, 
quant,

manuf, item, orderpt, ordrpt_flag, stock)
 .values ('$upc', 
$qnt,'$mnf','$itm',

odrpt, 0, $stk);
   $result2 = mysqli_query(cxn, $sql2);
   echo '$sql2br /';
   print_r($sql2);
   echo br /$upc $qnt $mnf $itm $odrpt 
$opf

$stkkbr /;
   if (!$result2)
 die('Could not enter data: ' .
mysqli_error());

The mysql query fails.  I cannot figure out why.  It works from the
command line.

TIA

Ethan




Ethan - you are simply missing two dollar signs as pointed out. Once
you correct them, if there are any more errors you should then be 
seeing

the message from mysqli_error.

And as for the advice to dump single quotes, I'd ignore it. The use of
double and single quotes is a very handy feature and makes for very
readable code.  Escaping double quotes is such a royal pia and 
makes for
more trouble deciphering code later on.  The sample you provided 
for us
is some of the best and most understandable code you've ever showed 
us.



Also - Ethan - if you used an editor that was designed for php you
probably would have seen these missing $ signs since a good one would
highlight php syntax and the lack of the $ would have produced a
different color than you expected.


Jim -

I  used Netbeans.  All it said is variable unused is scope, which is
a  error that I often find does not mean anything.  I am as pressurized
as you are.  Any suggestions as to an editor?

Ethan


Did you mean to say unused IN scope?  That would be telling you that 
it is not yet defined and that could be a problem if you expect to be 
already defined.


Several other posts here have listed their favorites.  Notepad ++ 
seems to be a favorite.  I use HTML-kit Tools as my developing 
environment. Handles highlighting for php, html and js, as well as 
project organization.  Also includes an ftp engine to allow me to 
modify, upload and then go test my code very quickly. (I don't run php 
or apache locally.)

Jim -

Thanks.

unused IN scope - correct.

There are lots of editors mentioned in this email trail.  I thank all 
for the suggestions.


Netbeans, Aptana Studio, etc will all highlight code and show the errors 
the code would generate in a browse. The problem here was two missing $ 
signs.


I'm probably wrong, but in some contexts; eg, sql query, $ signs are not 
used.  I tried and added the incorrect $ sign, and Netbeans did not 
complain.  If anyone knows of an editor that will able to spot this kind 
of error, please inform the list.


Ethan


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



Re: [PHP-DB] Re: MySQL Query on the Fly

2007-05-13 Thread Steven Cruz
You can the entire thing in Java script with Style sheets. Depends on 
what he wants to do. iframes could be far simpler. :)



itoctopus wrote:

You have to use an iframe to do what you want. Once the user select
something, you referesh the iframe and you pass specific parameters to it
based on the user's choice.

  


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



Re: [PHP-DB] Re: MySQL query, using DISTINCT...

2004-07-06 Thread Tristan . Pretty
  I have a system that tracks downloads, capturing loadsa info, but of
  interest here, is email and filename.
  Simply put, I wanna show all results where file name AND email are 
unique.
  (so if email '[EMAIL PROTECTED]' has filename 'word.doc' 5 times in a 
table,
  I want to only see it once.)
 
  What am I doing wrong...?
 
  SELECT DISTINCT(file_name, email) FROM `completed_downloads` WHERE 
`bu`  =
   'reech' AND date BETWEEN '2004-06-01' AND '2004-06-30'
 
  Tris...
 
 Hi Tristan,
 
 I'm not an MySQL expert but DISTINCT removes duplicate *rows* from your
 result set. As you select email AND file_name you will always have a 
unique
 row (combination of email and file_name). Try without specifying 
file_name:
 
 SELECT DISTINCT email FROM `completed_downloads` WHERE `bu` = 'reech' 
AND
 date BETWEEN '2004-06-01' AND '2004-06-30'
 
 Regards, Torsten Roehr

Ah...
But if the user has downloaded 3 files, I need to know that.
distinct email alone, wouldn't pick that up...
Cheers for your help though, I'm getting there...!
Any other ideas?

*
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
***

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



Re: [PHP-DB] Re: MySQL query, using DISTINCT...

2004-07-06 Thread zareef ahmed
Hi,

 using group by can also be usefull.

zareef ahmed  

--- Torsten Roehr [EMAIL PROTECTED] wrote:
 Tristan Pretty [EMAIL PROTECTED]
 wrote in message

news:[EMAIL PROTECTED]
 com...
  I have a system that tracks downloads, capturing
 loadsa info, but of
  interest here, is email and filename.
  Simply put, I wanna show all results where file
 name AND email are unique.
  (so if email '[EMAIL PROTECTED]' has filename
 'word.doc' 5 times in a table,
  I want to only see it once.)
 
  What am I doing wrong...?
 
  SELECT DISTINCT(file_name, email) FROM
 `completed_downloads` WHERE `bu`  =
   'reech' AND date BETWEEN '2004-06-01' AND
 '2004-06-30'
 
  Tris...
 
 Hi Tristan,
 
 I'm not an MySQL expert but DISTINCT removes
 duplicate *rows* from your
 result set. As you select email AND file_name you
 will always have a unique
 row (combination of email and file_name). Try
 without specifying file_name:
 
 SELECT DISTINCT email FROM `completed_downloads`
 WHERE `bu` = 'reech' AND
 date BETWEEN '2004-06-01' AND '2004-06-30'
 
 Regards, Torsten Roehr
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 


=
Zareef Ahmed :: A PHP Developer in Delhi(India).
Homepage :: http://www.zasaifi.com



__
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

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