[PHP-DB] Multiple Sorts

2004-03-16 Thread Robert Sossomon
How can I write a sort to sort on 2 columns, one ascending, one
descending?

$get_list = select * from access_tracking where user = '$user_id' order
by time,date_accessed desc

But the ordering seems backwards sorted by date first, and then time.

TIA!!
Robert

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



RE: [PHP-DB] Multiple Sorts

2004-03-16 Thread Hutchins, Richard
Robert,

You should be able to just do:
SELECT * FROM access_tracking WHERE user = '$user_id' ORDER BY time
DESC,date_accessed ASC;

Just experiment with the ORDER BY columns and the ASC and DESC orders to get
the results you're looking for.

Hope this helps,
Rich

 -Original Message-
 From: Robert Sossomon [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, March 16, 2004 7:57 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Multiple Sorts
 
 
 How can I write a sort to sort on 2 columns, one ascending, one
 descending?
 
 $get_list = select * from access_tracking where user = 
 '$user_id' order
 by time,date_accessed desc
 
 But the ordering seems backwards sorted by date first, and then time.
 
 TIA!!
 Robert
 
 -- 
 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] Multiple Sorts

2004-03-16 Thread kc68
I asked this question several weeks ago; search for kc68 on this list 
archives and you should find the more complete response.  The coding with 
my fields is:
?sort_field=cbc asc, net_receiptssort_order=desc  Play with the order and 
asc and desc as another response suggested.  What's confusing is that the 
first field requires only the asc statement where the second requires the 
full sort_order=

Ken


On Tue, 16 Mar 2004 07:57:25 -0500, Robert Sossomon [EMAIL PROTECTED] 
wrote:

How can I write a sort to sort on 2 columns, one ascending, one
descending?
$get_list = select * from access_tracking where user = '$user_id' order
by time,date_accessed desc
But the ordering seems backwards sorted by date first, and then time.

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


[PHP-DB] mssql query

2004-03-16 Thread Adam Williams
I've used mysql a little, but now I'm working with a MS SQL SERVER 2000 
database.  We have a proprietary application/hardware setup where 
when a person enters the building, the time they enter the building 
is automatically put into the database in a field called eventtime, and 
their access card is entered in a field called cardnum.  The 
time entered is like the mysql NOW() function (i dunno what its called in 
mssql), the format is -MM-DD HH:MM:SS.000 anyway.  I need to write an 
SQL query that will get a unique count of cardnum based on how many times 
the person enters a building each day.  So I need to do some sort of 
UNIQUE (although in mssql I think its distinct) count on the -MM-DD 
and ignore the HH:MM:SS.000, but looking at the mssql reference book I 
have, it doesn't go into great detail on date functions, so I was 
wondering if anyone knows how to do a unique on the eventtime with 
the date and ignore the time.

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



Re: [PHP-DB] mssql query

2004-03-16 Thread Adam Voigt
SELECT count(id) FROM users WHERE DATEDIFF(eventtime,GETDATE(),d) == 1;

Or something along those lines, all the date functions are very well
documented in the digital books that come with Enterprise Manager.
Open up the reference, and search for datediff, and there should be a
link in there for the date functions as a whole.


On Tue, 2004-03-16 at 10:32, Adam Williams wrote:
 I've used mysql a little, but now I'm working with a MS SQL SERVER 2000 
 database.  We have a proprietary application/hardware setup where 
 when a person enters the building, the time they enter the building 
 is automatically put into the database in a field called eventtime, and 
 their access card is entered in a field called cardnum.  The 
 time entered is like the mysql NOW() function (i dunno what its called in 
 mssql), the format is -MM-DD HH:MM:SS.000 anyway.  I need to write an 
 SQL query that will get a unique count of cardnum based on how many times 
 the person enters a building each day.  So I need to do some sort of 
 UNIQUE (although in mssql I think its distinct) count on the -MM-DD 
 and ignore the HH:MM:SS.000, but looking at the mssql reference book I 
 have, it doesn't go into great detail on date functions, so I was 
 wondering if anyone knows how to do a unique on the eventtime with 
 the date and ignore the time.
-- 

Adam Voigt
[EMAIL PROTECTED]

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



[PHP-DB] Re: Inserting Data in Multiple Tables - MySQL

2004-03-16 Thread Justin Patrin
Craig Hoffman wrote:

Is it possible to write one INSERT statement to populate multiple tables?
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
Nope. One record, one insert.

Well, actually, some DBs support multiple inserts with one query (such 
as mysql 4) but not into multiple tables.

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


[PHP-DB] Re: Inserting Data in Multiple Tables.. again

2004-03-16 Thread Justin Patrin
Craig Hoffman wrote:

Here is the problem I am experiencing:  I have a form that collects data 
and I would like it to send  it to three tables in a MySQL DB.  One 
table is called TRAININGLOG , other is called CORE and the third is 
USERS.   The USER table is the main table that contains the primary 
key.  My question is, what is the correct way for handling something 
like this?  Do I need to write three separate queries (INSERT) 
statements?   I am using MySQL 4.0.17  if that helps?

Thanks in advance,
Craig
__
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: [EMAIL PROTECTED]
w: www.eclimb.net
_
You need three seperate queries.

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


[PHP-DB] Re: need to select one cell from one row in one table...?

2004-03-16 Thread Justin Patrin
Aj Seelund wrote:

ok, this might be difficult to explain, but this is what im trying to do...

i have a table in my db call db_blog.  in it i have an auto_increment 
column called entryNum. i use that strictly for order when i view the 
blog.  i also have a column called comNum.  each row in the table is an 
entry in the blog, and has comments (comNum)  i have a variable called 
$comNum that is used to count how many comments are per entry in the 
blog.  example, entry number 1 has 3 comments, and entry number 5 has 0 
comments.  if there are no comments on the entry, and the user wants to 
make one, and if statement decides whether to display or input into the 
db.  that works fine.  now, when i input lies the problem.  i want to 
input data in a newly created table called $entryNum_comms (xx_comms) 
AND add to the number in the comNum column for THAT entry in dm_blog.

example:

i am making the first comment on entry number 74 in db_blog.

comNum in dm_blog should change form 0 to 1 and the data fromt he form 
should be inserted into 74_comms, a newly created table for that entry.

example 2:

i am making the 3rd comment on entyr number 94 in db_blog.

comNum in db_blog should change form 3 to 4 and the data from the form 
should be entered into the already created table 94_comms.

the only thing i am stuck on is entering the data into the two different 
tables.

here is the code im using:

if ($comms==true) {

//define a table name based on main Post number
$theTable = $entryNum . '_comms';

if ($newTab==true) {
//create a table
 $sql = 'CREATE TABLE ' . $theTable . ' ( `daUser` VARCHAR( 
255 ) NOT NULL ,'
. ' `entryNumb` INT NOT NULL ,'
. ' `priv` VARCHAR( 1 ) NOT NULL ,'
. ' `comm` BLOB NOT NULL ,'
. ' PRIMARY KEY ( `entryNumb` ) )';
   
$resulter = mysql_query($sql) or die(There has been an error 
creating table: $theTable br / newTab = $newTab);
   
//insert the values into the table for the comment
$commPost = INSERT INTO $theTable VALUES ('$daUser', 
'$entryNumb', '$priv', '$comm');
   
//output the comment or errors
$CommResult = mysql_query($commPost) or die((Error on line 70 
of inputBlog.php) br /br / tableName:$theTable br / 
entryNum:$entryNum br / entryNumb:$entryNumbbr / priv:$priv br 
/usr:$daUserbr / comm:$comm);

}else{
$select_comNum = 'SELECT `comNum` FROM dm_blog'
   
//insert the values into the table for the comment
$commPost = INSERT INTO `' . $theTable . '` VALUES 
('$daUser', '$entryNumb', '$priv', '$comm');
$post = INSERT INTO dm_blog VALUES ('$comNum');
//output the comment or errors
$CommResult = mysql_query($commPost) or die((Error on line 78 
of inputBlog.php) br /br / tableName:$theTable br / 
entryNum:$entryNum br / priv:$priv br /usr:$daUserbr / 
comm:$comm);
$result = mysql_query($post) or die((Error on line 85 of 
inputBlog.php) br / $post /td \n\r /tr \n\r /table 
/body/html);
}

while($myrow = mysql_fetch_array($result2)){
$p_entryNumb = $myrow[entryNumb];
$p_daUser = $myrow[daUser];

echo entryNumber: $p_entryNumb [user: $p_daUser] br /;
}

//echo posting a comment;
//if posting a new post do this:
}else{
$post = INSERT INTO dm_blog VALUES ('$date', '$chapter', '$mood', 
'$theuser', '$message', '$entryNum' 
,'$song','$t_level','$r_thought','comms');
$result = mysql_query($post) or die((Error on line 85 of 
inputBlog.php) br / $post /td \n\r /tr \n\r /table 
/body/html);

}


thanks in advance
-AJ Seelund
[EMAIL PROTECTED]
You say you want to make a new table and then put a record in it? I 
don't see how that has anything to do with your subject.

You just need to run a create table query first, then insert a record, 
then update the comNum in the other table. Three seperate queries.

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


[PHP-DB] File Upload

2004-03-16 Thread Bruno Santos
Hello all

Can someone tell me why PHP give all this erros, when it really opens 
the file and displays all it's contents ?



Uploading files...
File Type: text/plain
UP: /tmp/teste.txt
UP2: teste.txtFile uploaded successfully
*Warning*: fopen(teste.txt): failed to open stream: Permission denied in 
*/usr/local/apache2/htdocs/projecto/examples/upload.php* on line *87*

*Warning*: fwrite(): supplied argument is not a valid stream resource in 
*/usr/local/apache2/htdocs/projecto/examples/upload.php* on line *88*

*Warning*: fclose(): supplied argument is not a valid stream resource in 
*/usr/local/apache2/htdocs/projecto/examples/upload.php* on line *89*
Preview of uploaded file contents:

This is a test - File content



cheers all
Thx in advance
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] BLOB

2004-03-16 Thread Ng Hwee Hwee
hi,

i've read the blob document in MySQL manual and i know it is similar to a
text field and can store large amount of binary data..however, in phpMyAdmin
2.5.4,  i can't see the contents of my blob fields... how do you view it?

sorry for my ignorance..

hwee

- Original Message - 
From: JeRRy [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, March 16, 2004 1:27 PM
Subject: Re: [PHP-DB] BLOB

 Whoa, watch what your saying here because your well
 off the ball here.  For everyone else who is not aware
 BLOB is zilch security.  The details in a BLOB field
 is viewable easy enough.  Please read about BLOB on
 the mysql website that I listed to you, read it very
 carefully, obviously you did not even read a line of
 it.  Because the first few paragraphs tells you what
 it is, similar to a text field if you read it.  Please
 read links people send to you, otherwise why should we
 bother wasting our time replying if you can't take the
 courtesy to read what we type?

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



Re: [PHP-DB] BLOB

2004-03-16 Thread Micah Stevens


$data = mysql_query(select blob_column_name from table name);
while ($d = mysql_fetch_array($data)) {
echo $d['blob_column_name'].br;
}

.. or something like that. 

-Micah 

On Tuesday 16 March 2004 05:16 pm, Ng Hwee Hwee wrote:
 hi,

 i've read the blob document in MySQL manual and i know it is similar to a
 text field and can store large amount of binary data..however, in
 phpMyAdmin 2.5.4,  i can't see the contents of my blob fields... how do you
 view it?

 sorry for my ignorance..

 hwee

 - Original Message -
 From: JeRRy [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, March 16, 2004 1:27 PM
 Subject: Re: [PHP-DB] BLOB

  Whoa, watch what your saying here because your well
  off the ball here.  For everyone else who is not aware
  BLOB is zilch security.  The details in a BLOB field
  is viewable easy enough.  Please read about BLOB on
  the mysql website that I listed to you, read it very
  carefully, obviously you did not even read a line of
  it.  Because the first few paragraphs tells you what
  it is, similar to a text field if you read it.  Please
  read links people send to you, otherwise why should we
  bother wasting our time replying if you can't take the
  courtesy to read what we type?

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



[PHP-DB] Re: mssql query

2004-03-16 Thread Frank M Flynn
On Mar 16, 2004, at 5:17 PM, [EMAIL PROTECTED] wrote:

From: Adam Williams [EMAIL PROTECTED]
Date: March 16, 2004 7:32:57 AM PST
To: [EMAIL PROTECTED]
Subject: mssql query
I've used mysql a little, but now I'm working with a MS SQL SERVER 2000
database.  We have a proprietary application/hardware setup where
when a person enters the building, the time they enter the building
is automatically put into the database in a field called eventtime, and
their access card is entered in a field called cardnum.  The
time entered is like the mysql NOW() function (i dunno what its called 
in
mssql), the format is -MM-DD HH:MM:SS.000 anyway.  I need to write 
an
SQL query that will get a unique count of cardnum based on how many 
times
the person enters a building each day.  So I need to do some sort of
UNIQUE (although in mssql I think its distinct) count on the -MM-DD
and ignore the HH:MM:SS.000, but looking at the mssql reference book I
have, it doesn't go into great detail on date functions, so I was
wondering if anyone knows how to do a unique on the eventtime with
the date and ignore the time.


MS SQL has a rich set of date functions - they may be a little hard to 
figure out but you can do everything.

I'd try:

SELECT count(*), id,  convert(varchar, eventtime, 10)
FROM users
WHERE eventtime  '3/1/2004'  /* just so you  don't get the whole table 
*/
GROUP BY id,  convert(varchar, eventtime, 10)

The trick is convert(varchar, eventtime, 10) changes the datetime into 
a string and the last argument (10) is the format.  If you pick a 
format without the seconds you can use GROUP BY.

The function equivalent to NOW() is getdate() so try these:

select convert(varchar, getdate(), 9)
select convert(varchar, getdate(), 10)
select convert(varchar, getdate(), 11)
select convert(varchar, getdate(), 12)
select convert(varchar, getdate(), 110)  /* adding 100 is the same but 
with a 4 digit year */

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


[PHP-DB] PHP - MSSQL - LINUX

2004-03-16 Thread Santhosh Kumar
Hi All,

Where do I get mssql.so to connect mssql with my PHP4.0.6 and PHP4.3.3

Regards,
Santos Kumar.M