Re: [PHP] counting records in db

2006-10-31 Thread Ivo F.A.C. Fokkema
On Mon, 30 Oct 2006 12:28:29 +0100, Robin Vickery wrote: On 30/10/06, Ivo F.A.C. Fokkema [EMAIL PROTECTED] wrote: On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: On Friday 27 October 2006 19:34, Richard Lynch wrote: And the

Re: [PHP] counting records in db

2006-10-31 Thread Roman Neuhauser
# [EMAIL PROTECTED] / 2006-10-27 20:14:58 +0200: And the header(Location: ...) requires a full URL. Why? HTTP protocol specification[1] says: 14.30 Location The Location response-header field is used to redirect the recipient to a location other than the Request-URI for completion of

Re: [PHP] counting records in db

2006-10-31 Thread Robin Vickery
On 30/10/06, Robert Cummings [EMAIL PROTECTED] wrote: On Mon, 2006-10-30 at 12:28 +0100, Robin Vickery wrote: On 30/10/06, Ivo F.A.C. Fokkema [EMAIL PROTECTED] wrote: On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: On

Re: [PHP] counting records in db

2006-10-31 Thread Richard Lynch
On Tue, October 31, 2006 4:58 am, Robin Vickery wrote: On 30/10/06, Robert Cummings [EMAIL PROTECTED] wrote: On Mon, 2006-10-30 at 12:28 +0100, Robin Vickery wrote: On 30/10/06, Ivo F.A.C. Fokkema [EMAIL PROTECTED] wrote: On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: On

Re: [PHP] counting records in db

2006-10-31 Thread Robert Cummings
On Tue, 2006-10-31 at 11:58 +0100, Robin Vickery wrote: On 30/10/06, Robert Cummings [EMAIL PROTECTED] wrote: On Mon, 2006-10-30 at 12:28 +0100, Robin Vickery wrote: On 30/10/06, Ivo F.A.C. Fokkema [EMAIL PROTECTED] wrote: On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote:

Re: [PHP] counting records in db

2006-10-30 Thread Ivo F.A.C. Fokkema
On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: On Friday 27 October 2006 19:34, Richard Lynch wrote: And the header(Location: ...) requires a full URL. No it doesn't. but he's missing an ' at first glance Yes, it does:

Re: [PHP] counting records in db

2006-10-30 Thread Robin Vickery
On 30/10/06, Ivo F.A.C. Fokkema [EMAIL PROTECTED] wrote: On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: On Friday 27 October 2006 19:34, Richard Lynch wrote: And the header(Location: ...) requires a full URL. No it doesn't. but

Re: [PHP] counting records in db

2006-10-30 Thread Robert Cummings
On Mon, 2006-10-30 at 12:28 +0100, Robin Vickery wrote: On 30/10/06, Ivo F.A.C. Fokkema [EMAIL PROTECTED] wrote: On Sun, 29 Oct 2006 23:40:47 -0600, Richard Lynch wrote: On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: On Friday 27 October 2006 19:34, Richard Lynch wrote: And the

Re: [PHP] counting records in db

2006-10-29 Thread Richard Lynch
On Fri, October 27, 2006 12:14 pm, [EMAIL PROTECTED] wrote: And the header(Location: ...) requires a full URL. Why? Because the docs say so? Because some user agents will not do what you want them to if you don't? -- Some people have a gift link here. Know what I want? I want you to buy a CD

Re: [PHP] counting records in db

2006-10-29 Thread Richard Lynch
On Fri, October 27, 2006 4:53 pm, Børge Holen wrote: On Friday 27 October 2006 19:34, Richard Lynch wrote: And the header(Location: ...) requires a full URL. No it doesn't. but he's missing an ' at first glance Yes, it does: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30

Re: [PHP] counting records in db

2006-10-27 Thread Satyam
- Original Message - From: Paul Novitski [EMAIL PROTECTED] While we're talking about optimization, I'd want to check to make sure COUNT(*) didn't ask MySQL to generate a throw-away recordset consisting of all fields. I wonder if it would be more machine-efficient to use

Re: [PHP] counting records in db

2006-10-27 Thread Richard Lynch
Your idea to use 'COUNT(Username)' is just about the ONLY part of that script that you are doing correctly... :-) Start reading here: http://phpsec.org/ And the header(Location: ...) requires a full URL. And you should have better error-checking, probably. [Though maybe you have a custom error

Re: [PHP] counting records in db

2006-10-27 Thread afan
Your idea to use 'COUNT(Username)' is just about the ONLY part of that script that you are doing correctly... :-) :D And the header(Location: ...) requires a full URL. Why? And you should have better error-checking, probably. [Though maybe you have a custom error handler not apparent]

Re: [PHP] counting records in db

2006-10-27 Thread Børge Holen
On Friday 27 October 2006 19:34, Richard Lynch wrote: Your idea to use 'COUNT(Username)' is just about the ONLY part of that script that you are doing correctly... :-) Start reading here: http://phpsec.org/ And the header(Location: ...) requires a full URL. No it doesn't. but he's

Re: [PHP] counting records in db

2006-10-26 Thread Dave Goodchild
$query = mysql_query( SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name = 'Smith'); $result = mysql_result($query, 0);

Re: [PHP] counting records in db

2006-10-26 Thread afan
WOW! That was fast! :D Thanks Dave! -afan $query = mysql_query( SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name = 'Smith'); $result = mysql_result($query, 0); -- PHP General Mailing List (http://www.php.net/) To unsubscribe,

Re: [PHP] counting records in db

2006-10-26 Thread afan
Hm. There is a little problem - this doesn't work. Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /var/www/html/xxx/tests/count.php on line 28 ? $query = mysql_query( SELECT COUNT(*) as NoOfRecords FROM customers

Re: [PHP] counting records in db

2006-10-26 Thread Paul Novitski
At 10/26/2006 10:38 AM, [EMAIL PROTECTED] wrote: what would be better solution to count records in table (e.g., how many customers have last name 'Smith'): $query = mysql_query( SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name =

Re: [PHP] counting records in db

2006-10-26 Thread afan
Sorry, my bad! It works jsut fine. I did misstake. :) $query = mysql_query( SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name = 'Smith'); $result = mysql_result($query, 0); -- PHP General Mailing List (http://www.php.net/)

Re: [PHP] counting records in db

2006-10-26 Thread Richard Lynch
On Thu, October 26, 2006 12:57 pm, Paul Novitski wrote: $query = mysql_query( SELECT COUNT(*) as NoOfRecords FROM customers WHERE last_name = 'Smith'); $result = mysql_fetch_array($query); $NoOfRecords = $result['NoOfRecords']; This would be

Re: [PHP] counting records in db

2006-10-26 Thread afan
Would it be ok to use the same code to check if customer is loged in? $query = mysql_query( SELECT COUNT(Username) as NoOfRecords FROM customers WHERE Username = '$Username' AND Password = '$Password'); if (mysql_result($query, 0) == 0) { echo

Re: [PHP] counting records in db

2006-10-26 Thread Dave Goodchild
Why would you want to do that? Think about what you're trying to do. In the first case you want a COUNT of records in the database, in the second you just want to see if the user/password combination or whatever exist, so just use a normal SELECT query, no need to use the wrong tool for the

RE: [PHP] counting records in db

2006-10-26 Thread Brad Fuller
Would it be ok to use the same code to check if customer is loged in? $query = mysql_query( SELECT COUNT(Username) as NoOfRecords FROM customers WHERE Username = '$Username' AND Password = '$Password'); if (mysql_result($query, 0) == 0) {

Re: [PHP] counting records in db

2006-10-26 Thread Paul Novitski
At 10/26/2006 11:16 AM, [EMAIL PROTECTED] wrote: Would it be ok to use the same code to check if customer is loged in? $query = mysql_query( SELECT COUNT(Username) as NoOfRecords FROM customers WHERE Username = '$Username' AND Password =

Re: [PHP] counting records in db

2006-10-26 Thread afan
Would it be ok to use the same code to check if customer is loged in? $query = mysql_query( SELECT COUNT(Username) as NoOfRecords FROM customers WHERE Username = '$Username' AND Password = '$Password'); if (mysql_result($query, 0) == 0) I just