Fw: [PHP-DB] RE: LIMIT and get_num_rows

2002-01-20 Thread DL Neil

Apologies to the original post-er, I see that I was getting ahead of myself...

http://www.mysql.com/doc/N/u/Nutshell_Other_features.html
1.5.4  Other Features Available From MySQL 4.0.0
... Functions like SQL_CALC_FOUND_ROWS and FOUND_ROWS() makes it possible to know how 
many rows a query would
have returned without a LIMIT clause.

FYI/Coming soon/watch this space!

Regards,
=dn



- Original Message -
From: DL Neil [EMAIL PROTECTED]
To: matt stewart [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: 14 January 2002 14:17
Subject: Re: [PHP-DB] RE: LIMIT and get_num_rows


 Have you (original post-er) tested performing a SELECT ... LIMIT 0, 20 and then 
calling mysql_num_rows()?
 Does it return 20 (the LIMIT) or the number of rows SELECT-ed before/without regard 
to the limit?

 =dn

 - Original Message -
 From: matt stewart [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: 14 January 2002 14:05
 Subject: RE: [PHP-DB] RE: LIMIT and get_num_rows


  you've assumed correctly - so it's definitely faster to do the two queries?
  okey dokey, then that's the method i shall use.
  thanks to everyone who's added their thoughts!
 
  -Original Message-
  From: Peter Westergaard [mailto:[EMAIL PROTECTED]]
  Sent: 14 January 2002 14:01
  To: [EMAIL PROTECTED]
  Subject: [PHP-DB] RE: LIMIT and get_num_rows
 
 
 
  but presumably if i'm doing a SELECT count(*) FROM Designs WHERE Keywords
  LIKE %sport%
  followed by a SELECT * FROM Designs WHERE Keywords LIKE %sport% LIMIT
  0,20
  
  it's still using nearly as much processing time as just returning all the
  designs and just using a get_num_rows and then only using the first 20?
 
  I absolutely think it will not.
 
  After all, the table record count should be able to reference the index,
  (you are running this query against an indexed 'Keywords' column yes?),
  while assembling the table of returned data will take quite a bit more
  memory, which is what you're really trying to cut down, I think.
 
  Cheers,
  -Peter
 
 
  --
  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]
 
  ---
  Incoming mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.313 / Virus Database: 174 - Release Date: 02/01/02
 
 
  ---
  Outgoing mail is certified Virus Free.
  Checked by AVG anti-virus system (http://www.grisoft.com).
  Version: 6.0.313 / Virus Database: 174 - Release Date: 02/01/02
 
 
  --
  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]




[PHP-DB] Mysql-class

2002-01-20 Thread Johannes Hiemer

Hi,
i coded a Mysql-Class, there are no compiling-errors when i run it.
But the problem is that it doesn´t do what i want it to do.
I added the sourcecode below and would be happy for any sugestions
how to make it better.

Cu Johannes Hiemer

Code:
?

class get_db {
var $database = forum;

var $islinked = 0;
var $iserror  = 0;

  var $reporterror = array();
var $islinux  = 0;


  var $server   = localhost;
var $user = root;
var $password = ;

function connect() {

   if ($islinux == 1)  {
 $use_pconnect = 1;
 global $use_pconnect;
 }
else {
 $use_pconnet = 0;
 global $use_pconnect;
 }

 if(0 == $this-islinked) {

 if($password == ) {

 if($use_pconnect == 0) {
 $this-link_id = mysql_pconnect($this-server,
$this-user);
 }
 else {
$this-link_id = mysql_connect($this-server, $this-user,
$this-password);
 }
 }
 else  {
 if($use_pconnect == 1) {
 $this-link_id = mysql_pconnect($this-server,
$this-user);
 }
 else {
 $this-link_id = mysql_connect($this-server,
$this-user, $this-password);
 }
 }
 }

 if(!$this-link_id) {

 $this-stopm(Couldn´t connect to: .$this-server.
  with .$this-user..mysql_error.reason);
 }

 if(!$this-database == ) {
 $this-db_query = mysql_db_query($this-database,
$this-link_id);
 $this-stopm(Couldn´t connect to.$this-database);
 }

}
function error() {
$this-error = mysql_error();
return $this-error;
}

function errno() {
$this-errno = mysql_errno();
return $this-errno;
}

function reporterrno() {


$this-errno = mysql_errno();
$this-file = db_logs.txt;

if(file_exists($this-file)) {
$this-openlogfile = fopen($this-file, a+);

 if(feof($this-openlogfile)) {
fputs($this-openlogfile, date(d.M.Y h:m:s,
time()).br.$REMOTE_ADDR.br\n.$this-errno);
fclose($this-openlogfile);
}
}
else {
$this-openlogfile = fopen($this-file,a+);

if(feof($this-openlogfile)) {
fputs($this-openlogfile, date(d.M.Y h:m:s,
time()).,.$REMOTE_ADDR.brn);
fclose($this-openlogfile);
}
@mail([EMAIL PROTECTED], 'Mysql_error: .$this-errno.',
date(d.M.Y h:m:s, time()).,.$REMOTE_ADDR.br\n.$this-errno.);

}
  }
function db_select($database) {

$this-database = $database;
$this-db_query = mysql_select_db($this-database, $this-link_id);
$this-stopm(Couldn´t connect
to.$this-database.reason.$this-error);

}

function db_query($string_query) {

$this-query = mysql_query($string_query, $this-link_id);

if(!$this-query) {
$this-stopm(Invalid Mysql_query: .$string_query);
}

return $this-query;

}

function fetch_array($string_query) {

if (isset($query_string)) {
if(!empty($string_query)) {
$this-stopm(Query was emtpy or wrong.$this-error);
}

   $this-fetch_data = mysql_fetch_array($this-query, $this-link_id);

if(!$this-fetch_data) {
$this-stopm(Query was emtpy or wrong.$this-error);
}
else {

return $this-fetch_data;
}
}
   }

function stopm($msg) {
$this-error=mysql_error();
$this-errno=mysql_errno();


if ($this-reporterror == 1) {
  $message=Database error in $this-appname: $msg\n;
  $message.=mysql error: $this-error\n;
  $message.=mysql error number: $this-errno\n;
  $message.=Date: .date(l dS of F Y h:i:s A).\n;
  $message.=Script: .getenv(REQUEST_URI).\n;
  $message.=Referer: .getenv(HTTP_REFERER).\n;

  @mail([EMAIL PROTECTED], 'Mysql_error: .$this-errno.',
date(d.M.Y h:m:s, time()).,.$REMOTE_ADDR.br\n.$this-errno.);

  echo \n!-- $message --\n;

  echo /td/tr/table\npEs sind Probleme mit der Datenbank
aufgetreten.\n;
  echo Versuchen sie es erneut in dem sie den Refresh Button des
Browser nutzen./p;
  echo Es wurde eine Email an unseren Techniker gesendeta
href=\mailto:$technicalemail\;Techniker/a, der mit diesem Link
kontaktiert werden kann, sofern der Fehler erneut auftritt./p;
  echo pWir bitten vielmals um Entschuldigung./p;
  die();
   }
}
  }

  $test = new get_db();
  $test - connect();
  $test - db_query(SELECT * FROM topics);
  $test - fetch_array(SELECT * FROM topics);
  echo $test;

?



-- 
PHP Database 

Re: [PHP-DB] Mysql-class

2002-01-20 Thread Jason Wong

On Monday 21 January 2002 21:52, Johannes Hiemer wrote:
 Hi,
 i coded a Mysql-Class, there are no compiling-errors when i run it.
 But the problem is that it doesn´t do what i want it to do.
 I added the sourcecode below and would be happy for any sugestions
 how to make it better.

[snip]

What did you want it to do? 

What is it doing now? 

What error does it give, if any?


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

/*
Always there remain portions of our heart into which no one is able to enter,
invite them as we may.
*/

-- 
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] HTTP authentication

2002-01-20 Thread news.php.net

Heya,

I'm trying to find out how http header authentication works. For some reason
my webserver won't do it on a directory basis. But the problem is that the
documentation that came along with the PHP package doesn't help me much.

Can you guys give me a working example on how to use and implement it?

I would really appreciate it,

Kevin



-- 
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] strange link problem to a database item

2002-01-20 Thread chip

On Saturday 19 January 2002 01:52 am, Jason Wong banged out on the keys:
 Interesting problem. It seems that your thumbnails are in an invalid
 format. Using Opera right-clicking on picture and selecting Image
 Properties reveals that the purported image dimensions are 0 x 0 pixels
 and Bits per pixel is also 0.

 Saving the thumbnail and loading into IrfanView gives an invalid header
 error.

 I think you'll have to look at re-doing your thumbnails.

 hth

That's it. I just found out on the imagemagick list that the thumbnails 
created by xv are in a format which is loosely derived from pbmplus image 
formats.
So, I have found an app in the ports called jpgtn, it creates thumbnails from 
a directory of jpg files, works quite well. I will use that to create the 
thumbs, and all is well.

-- 
Chip

Windows 95/NT - 32 bit extensions and a graphical shell for a 16 bit patch
to an 8 bit operating system originally coded for a 4 bit microprocessor,
written by a 2 bit company that can't stand 1 bit of competition.


--
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] RE: Recalculation ?

2002-01-20 Thread Adam Royle

You shouldn't need to unset session variables if you're going to use them
again, just write over them. And to check if a session variable has been
used or not, you can use:

if (session_is_registered($qty)){
calcluation in here
}

If the calculation part is the same in your 'if' statement, then you should
need to do the session_unset() and session_register() stuff. If $qty is
already registered as a session variable, you can safely run
session_register($qty) again and cause no harm to the already registered
variable, so this will register a session variable, but not change an
existing session variable.

Also, in logic (I haven't tested though), your condition for your 'if'
statement ($qty == $qty) will always evaluate to true.

Adam

-Original Message-
From: Dave Carrera [mailto:[EMAIL PROTECTED]]
Sent: Saturday, January 19, 2002 3:17 AM
To: php List
Subject: Recalculation ?


Hi All,

I have create a page to calculate qtys and show totals.
This works fine, except that I change a qty the change is not registered and
calculate from the old value.

I am using sessions and have try a loop of
if($qty == $qty){
than calc stuff here}
else{
session_unset($qty);
session_register($qty);
calc stuff here
}

And have tried other ways but to no avail.

Can someone throw any light on this.

As always any help is appreciated.

Dave C





-- 
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] HTTP authentication

2002-01-20 Thread Beau Lebens

not that this has anything to do with databases... ([php-db])

assuming;
1. you are using apache
2. you have command-line access to your server
3. your webhost has htaccess enabled and configured to use .htaccess as
the security file

you should be able to drop a file called (usally) .htaccess into the
directory you want to secure. you then go to the command line and do
something like

$ htpasswd -c /home/you/htbin/.htpasswd username

which creates (-c) the password file (/home/you/htbin/.htpasswd) and adds a
user called username to it. when you hit enter it will ask for a password
(twice).

now the .htaccess file which is in your to-be-secured directory needs to
look something like this;

 snip
AuthUserFile /path/to/htpasswd/file
AuthName Name to Appear in Box
AuthType Basic

Limit GET POST
require valid-user
/Limit
 snip

that example looks in /path/to/htpasswd/file and confirms that the
user/pass combintation is a valid-user (any valid combo from the file) and
if so, allows them access.

you can get more information on all of this in the apache docuemntation at
apache.org, search for htaccess and you might also be interested in the
groups ability of the system, so search for htgroup (i think)

hth

beau


// -Original Message-
// From: news.php.net [mailto:[EMAIL PROTECTED]]
// Sent: Monday, 21 January 2002 3:36 AM
// To: [EMAIL PROTECTED]
// Subject: [PHP-DB] HTTP authentication
// 
// 
// Heya,
// 
// I'm trying to find out how http header authentication works. 
// For some reason
// my webserver won't do it on a directory basis. But the 
// problem is that the
// documentation that came along with the PHP package doesn't 
// help me much.
// 
// Can you guys give me a working example on how to use and 
// implement it?
// 
// I would really appreciate it,
// 
// Kevin
// 
// 
// 
// -- 
// 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] HTTP authentication

2002-01-20 Thread news.php.net

Dear Beau,

Thanks for your answer, and indeed.. it doesn't have too much to do with
databases, although if an example of authentication using a database would
be great.

And I was a bit vague on which webserver (indeed Apache). And I do have
command line access. However in my initial message I said that directory
authentication (with .htaccess) doesn't work. And I've tried more than once
to get it to work.

So if you could still help me, or anyone else I would greatly appreciate it!

Yours,

Kevin
Beau Lebens [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 not that this has anything to do with databases... ([php-db])

 assuming;
 1. you are using apache
 2. you have command-line access to your server
 3. your webhost has htaccess enabled and configured to use .htaccess as
 the security file

 you should be able to drop a file called (usally) .htaccess into the
 directory you want to secure. you then go to the command line and do
 something like

 $ htpasswd -c /home/you/htbin/.htpasswd username

 which creates (-c) the password file (/home/you/htbin/.htpasswd) and adds
a
 user called username to it. when you hit enter it will ask for a
password
 (twice).

 now the .htaccess file which is in your to-be-secured directory needs to
 look something like this;

  snip
 AuthUserFile /path/to/htpasswd/file
 AuthName Name to Appear in Box
 AuthType Basic

 Limit GET POST
 require valid-user
 /Limit
  snip

 that example looks in /path/to/htpasswd/file and confirms that the
 user/pass combintation is a valid-user (any valid combo from the file)
and
 if so, allows them access.

 you can get more information on all of this in the apache docuemntation at
 apache.org, search for htaccess and you might also be interested in the
 groups ability of the system, so search for htgroup (i think)

 hth

 beau


 // -Original Message-
 // From: news.php.net [mailto:[EMAIL PROTECTED]]
 // Sent: Monday, 21 January 2002 3:36 AM
 // To: [EMAIL PROTECTED]
 // Subject: [PHP-DB] HTTP authentication
 //
 //
 // Heya,
 //
 // I'm trying to find out how http header authentication works.
 // For some reason
 // my webserver won't do it on a directory basis. But the
 // problem is that the
 // documentation that came along with the PHP package doesn't
 // help me much.
 //
 // Can you guys give me a working example on how to use and
 // implement it?
 //
 // I would really appreciate it,
 //
 // Kevin
 //
 //
 //
 // --
 // 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] Easy way to calculate difference between two dates

2002-01-20 Thread SpamSucks86

Is there an easy way to calculate the difference between the current
date and a date prior to January 1, 1970 (unix epoch). Just getting the
timestamp and then subtracting the other date from it won't work because
it will be a negative number. Any insight? I think this can be done very
easily in ASP (built in function? But I don't know ASP, it's just what I
heard). Thanks for your help =)



RE: [PHP-DB] HTTP authentication

2002-01-20 Thread Beau Lebens

in that case, check the php manual under the section titled

Features - HTTP Authentication With PHP

there is a nice example, which you should be able to modify to do things (i
have it working with pulling details from an XML file and then using them as
the required user/pass for authentication)

http://www.dentedreality.com.au/webpad/

if you download and install, then you need to use admin/admin as the
user/pass for the first time you modify the system settings. (it has zero
docuemntation so far :)

have fun

beau

// -Original Message-
// From: news.php.net [mailto:[EMAIL PROTECTED]]
// Sent: Monday, 21 January 2002 10:17 AM
// To: [EMAIL PROTECTED]
// Subject: Re: [PHP-DB] HTTP authentication
// 
// 
// Dear Beau,
// 
// Thanks for your answer, and indeed.. it doesn't have too 
// much to do with
// databases, although if an example of authentication using a 
// database would
// be great.
// 
// And I was a bit vague on which webserver (indeed Apache). 
// And I do have
// command line access. However in my initial message I said 
// that directory
// authentication (with .htaccess) doesn't work. And I've tried 
// more than once
// to get it to work.
// 
// So if you could still help me, or anyone else I would 
// greatly appreciate it!
// 
// Yours,
// 
// Kevin
// Beau Lebens [EMAIL PROTECTED] wrote in message
// news:[EMAIL PROTECTED].
// edu.au...
//  not that this has anything to do with databases... ([php-db])
// 
//  assuming;
//  1. you are using apache
//  2. you have command-line access to your server
//  3. your webhost has htaccess enabled and configured to use 
// .htaccess as
//  the security file
// 
//  you should be able to drop a file called (usally) 
// .htaccess into the
//  directory you want to secure. you then go to the command 
// line and do
//  something like
// 
//  $ htpasswd -c /home/you/htbin/.htpasswd username
// 
//  which creates (-c) the password file 
// (/home/you/htbin/.htpasswd) and adds
// a
//  user called username to it. when you hit enter it will ask for a
// password
//  (twice).
// 
//  now the .htaccess file which is in your to-be-secured 
// directory needs to
//  look something like this;
// 
//   snip
//  AuthUserFile /path/to/htpasswd/file
//  AuthName Name to Appear in Box
//  AuthType Basic
// 
//  Limit GET POST
//  require valid-user
//  /Limit
//   snip
// 
//  that example looks in /path/to/htpasswd/file and 
// confirms that the
//  user/pass combintation is a valid-user (any valid combo 
// from the file)
// and
//  if so, allows them access.
// 
//  you can get more information on all of this in the apache 
// docuemntation at
//  apache.org, search for htaccess and you might also be 
// interested in the
//  groups ability of the system, so search for htgroup (i think)
// 
//  hth
// 
//  beau
// 
// 
//  // -Original Message-
//  // From: news.php.net [mailto:[EMAIL PROTECTED]]
//  // Sent: Monday, 21 January 2002 3:36 AM
//  // To: [EMAIL PROTECTED]
//  // Subject: [PHP-DB] HTTP authentication
//  //
//  //
//  // Heya,
//  //
//  // I'm trying to find out how http header authentication works.
//  // For some reason
//  // my webserver won't do it on a directory basis. But the
//  // problem is that the
//  // documentation that came along with the PHP package doesn't
//  // help me much.
//  //
//  // Can you guys give me a working example on how to use and
//  // implement it?
//  //
//  // I would really appreciate it,
//  //
//  // Kevin
//  //
//  //
//  //
//  // --
//  // 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: [PHP-DB] Easy way to calculate difference between two dates

2002-01-20 Thread Beau Lebens

soo what happens with php if you do something like convert them both to 

Y-m-d H:i:s

and then subtract one from the other, i have a feeling (haven't tried) that
php will handle the rest for you...

// -Original Message-
// From: SpamSucks86 [mailto:[EMAIL PROTECTED]]
// Sent: Monday, 21 January 2002 10:19 AM
// To: [EMAIL PROTECTED]
// Subject: [PHP-DB] Easy way to calculate difference between two dates
// 
// 
// Is there an easy way to calculate the difference between the current
// date and a date prior to January 1, 1970 (unix epoch). Just 
// getting the
// timestamp and then subtracting the other date from it won't 
// work because
// it will be a negative number. Any insight? I think this can 
// be done very
// easily in ASP (built in function? But I don't know ASP, it's 
// just what I
// heard). Thanks for your help =)
// 

-- 
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] Easy way to calculate difference between two dates

2002-01-20 Thread Jason Wong

On Monday 21 January 2002 10:19, SpamSucks86 wrote:
 Is there an easy way to calculate the difference between the current
 date and a date prior to January 1, 1970 (unix epoch). Just getting the
 timestamp and then subtracting the other date from it won't work because
 it will be a negative number. Any insight? I think this can be done very
 easily in ASP (built in function? But I don't know ASP, it's just what I
 heard). Thanks for your help =)

Have a look at the chapter on calendar Functions. In particular

juliantojd() 
jdtojulian()

NB they only work for whole days (no H:M:S).

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

/*
His heart was yours from the first moment that you met.
*/

-- 
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]