Re: [PHP-DB] Using CURDATE, DATE_SUB and DATE_ADD

2003-02-10 Thread Jason Wong
On Monday 10 February 2003 06:57, Barrie Matthews wrote:
 I am using the query below in attempting to control access to a web site.
 The idea is that today's date must be between 1 month before the start date
 and 1 month after the finish date.

 $query1 = SELECT VFT_name FROM `vft` WHERE CURDATE() 
 DATE_SUB(VFT_date_start, INTERVAL 1 month) AND CURDATE() 
 DATE_ADD(VFT_date_finish, INTERVAL 1 month) ;

 It seems that if a start date is say March 31, then any date in February
 (even Feb 01) is going to return true. I tried using days (28, 29, .. 35
 etc) instead of 1 month in the query but that doesn't seem to work.

 For a start-date of March 11 how can I deny access on Feb 10 but allow
 access starting on Feb 11?

There doesn't seem to be anything wrong with your DATE_SUB() and DATE_ADD():

mysql select date_sub('2003-03-11', interval 1 month);
+--+
| date_sub('2003-03-11', interval 1 month) |
+--+
| 2003-02-11   |
+--+
1 row in set (0.09 sec)

mysql select date_sub('2003-03-31', interval 1 month);
+--+
| date_sub('2003-03-31', interval 1 month) |
+--+
| 2003-02-28   |
+--+
1 row in set (0.00 sec)


You should check that VFT_date_start and VFT_date_finish actually contain what 
you expect them to contain. And also you could consider using BETWEEN instead 
of the less-than and greater-than comparisons.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Tell a man there are 300 billion stars in the universe and he'll believe you.
Tell him a bench has wet paint on it and he'll have to touch to be sure.
*/


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




[PHP-DB] sorting values

2003-02-10 Thread merlin
Hello everybody,

I am pulling out several values out of a mysqldb. Those come with different
tables and different criterias, thats why I cant sort them inside the sql
statement. I need to make 3 of those statements.
All the different results have an associated timestamp. How could I sort
them after pulling out the values into variables (sort after time desc)?

for esample:
new user pictures  time 10:00:00
new user articles   time 12:00:00
new whatever   time 11:00:00

thanx for any help,

merlin



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




[PHP-DB] Ordering...

2003-02-10 Thread nikos
Hi list!
How can I Order By in MySQL a column asceding and an other column desceding?



Qbit
  - Gatsis Nikos
Web developer
tel.: 2108256721 - 2108256722
fax: 2108256712
email: [EMAIL PROTECTED]
http://www.qbit.gr 



Re: [PHP-DB] Ordering...

2003-02-10 Thread Leif K-Brooks
order by col1 asc col2 desc

nikos wrote:


Hi list!
How can I Order By in MySQL a column asceding and an other column desceding?



Qbit
  - Gatsis Nikos
Web developer
tel.: 2108256721 - 2108256722
fax: 2108256712
email: [EMAIL PROTECTED]
http://www.qbit.gr 

 


--
The above message is encrypted with double rot13 encoding.  Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.




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




Re: [PHP-DB] sorting values

2003-02-10 Thread Doug Thompson
Merlin:

You might find it easiest to CREATE a temporary table.
You can use an INSERT .. SELECT query to extract the values from your
data tables and insert them in the temp table.
Then you can SELECT from the temporary table and use all of the SQL
functions for ordering, grouping, etc.

Doug

On Mon, 10 Feb 2003 15:14:55 +0100, merlin wrote:

Hello everybody,

I am pulling out several values out of a mysqldb. Those come with different
tables and different criterias, thats why I cant sort them inside the sql
statement. I need to make 3 of those statements.
All the different results have an associated timestamp. How could I sort
them after pulling out the values into variables (sort after time desc)?

for esample:
new user pictures  time 10:00:00
new user articles   time 12:00:00
new whatever   time 11:00:00

thanx for any help,

merlin



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




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




Re: [PHP-DB] Is my Hosting service full of it?

2003-02-10 Thread Jason Wong
On Monday 10 February 2003 01:23, Rich Hutchins wrote:
 Beyond inspecting the posted code, are there any quality FREE tools that
 can monitor MySQL resource usage? I searched Google using mysql resource
 tools and came up with a number of tools, but all required payment.

 I'm figuring that if you run a monitor while testing your code locally,
 you'll be able to pinpoint precisely what causes the recources to be chewed
 up.

There is something called mysqltop.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-db
--
/*
Aim for the moon.  If you miss, you may hit a star.
-- W. Clement Stone
*/


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




[PHP-DB] question about access

2003-02-10 Thread Terry Romine
I'd like to get some opinions from the list.

We run php/mysql on our linux servers located behind a firewall. Many 
of our clients have scripts that access their databases via php running 
on the hosting server, and the general access is set up as:

	$hostname = localhost;
	$database  = clientsDB;
	$username = client;
	$password = ;

	etc..

One of our clients has a friend who wants to do some php/mysql and has 
asked for access to the database. We gave them the information above, 
and he complains that localhost is insufficient. We think that if he 
is requesting servername.domain.net:accessPort that that gives him 
access through the firewall. Instead, he should upload his scripts 
using ftp and use localhost, as all our other clients do.

What is the general consensus?

If giving an outsider this kind of access just asking for trouble?

Terry


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



Re: [PHP-DB] question about access

2003-02-10 Thread Doug Thompson
If your client's friend wants to do learning/development, let him load
PHPTriad, FoxServ, or one of the other trinity setups onto his
computer.

It is truly remarkable that you/your company would even consider such a
request for longer than it takes to say: Never in a million years.

Also, if I were running security at your site, I would closely monitor
that client's activities on the system assuming that's how you are set
up.  That is a loose cannon out there.

Doug

On Mon, 10 Feb 2003 10:29:18 -0600, Terry Romine wrote:

I'd like to get some opinions from the list.

We run php/mysql on our linux servers located behind a firewall. Many 
of our clients have scripts that access their databases via php running 
on the hosting server, and the general access is set up as:

   $hostname = localhost;
   $database  = clientsDB;
   $username = client;
   $password = ;

   etc..

One of our clients has a friend who wants to do some php/mysql and has 
asked for access to the database. We gave them the information above, 
and he complains that localhost is insufficient. We think that if he 
is requesting servername.domain.net:accessPort that that gives him 
access through the firewall. Instead, he should upload his scripts 
using ftp and use localhost, as all our other clients do.

What is the general consensus?

If giving an outsider this kind of access just asking for trouble?

Terry



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




RE: [PHP-DB] Getting array values into a query

2003-02-10 Thread Gary . Every
Try this:
I use it so that I can add variable names to a db table, then access them
throughout the script.

## Get the report_conf variables
   $sql = SELECT *
   FROM report_conf;
$prefs = get_rowset($conn_id,$sql);
  foreach($prefs as $pref){
$foo = $pref['name'];
$$foo = $pref['name_value'];
  }

The array you'd be interested in is $prefs, and it looks like this:
$key[0] = 'var1';
$value[0] = 'blue';
$key[1] = 'var2';
$value[1] = 'green';

After running the above, then
$var1 = 'blue';
$var2 = 'green';

I'm sure you'll need to tweak it a little, but the secret its the $$foo
(with two $ signs)
If $foo = 'aname'
then $$foo = $aname

The get_rowset is a function I've written to symplify my code, it returns
rows in an array from the DB


Gary Every
Sr. UNIX Administrator
Ingram Entertainment
(615) 287-4876
Pay It Forward
mailto:[EMAIL PROTECTED]
http://accessingram.com


-Original Message-
From: Michael Conway [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 07, 2003 4:47 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Getting array values into a query


I've been attempting to take the values from an array pulled from a
session to supply the variable in a WHERE clause. list() provides only
the first value as expected. implode() the last.  Any suggestions or
should I just load the values I want in the session through a query on
the previous script and call it directly to the function I want to use?

 

Michael Conway

[EMAIL PROTECTED]

(703) 968-8875

 




[PHP-DB] for xml auto from MS Sql Server

2003-02-10 Thread Daniel Cher
Folks,

I'd like to use Microsoft SQL Server 2000 XML capabilities for generating
query results in XML. It is very easy, just say for xml auto at the end of
your query.

The problem is that I cannot seem to retrieve the results back into PHP.
Anyone ever accomplish this?

Daniel



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