[PHP-DB] Re: www-data file

2014-08-26 Thread Jim Giner

On 8/26/2014 12:20 AM, Ethan Rosenberg wrote:

Dear list -

When I use  fopen, the  file owner and group are both www-data.

How can I ensure that the owner and group will be ethan?

TIA

Ethan


Why should ownership be a concern when you are simply opening a file? 
AFAIK permissions are set at the time the file is placed there and will 
affect the access to them from then on.  If you are able to fopen the 
file, why do the permissions matter?  If you can't then you have an 
entirely different problem to discuss.


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



Re: [PHP-DB] Re: www-data file

2014-08-26 Thread Matt Pelmear

On 08/26/2014 06:21 AM, Jim Giner wrote:

On 8/26/2014 12:20 AM, Ethan Rosenberg wrote:

Dear list -

When I use  fopen, the  file owner and group are both www-data.

How can I ensure that the owner and group will be ethan?

TIA

Ethan


Why should ownership be a concern when you are simply opening a file? 
AFAIK permissions are set at the time the file is placed there and 
will affect the access to them from then on.  If you are able to fopen 
the file, why do the permissions matter?  If you can't then you have 
an entirely different problem to discuss.




fopen() can create files if they don't exist.
So if you open a file for writing, it will by default receive the 
user/group of the web server. If you then need to access the file as 
some other user, you run into this situation.

(I assume this is what Ethan is referring to here.)

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



Re: [PHP-DB] Re: www-data file

2014-08-26 Thread Jim Giner

On 8/26/2014 11:26 AM, Matt Pelmear wrote:


fopen() can create files if they don't exist.

I should have read the manual b4 replying.  :(

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



RE: [PHP-DB] Re: No data?

2012-07-27 Thread Brad
Not on my system.   :(






-Original Message-
From: Tamara Temple [mailto:tamo...@gmail.com] 
Sent: Friday, July 27, 2012 10:46 AM
To: Brad
Cc: 'tamouse mailing lists'; php-db@lists.php.net
Subject: Re: [PHP-DB] Re: No data?

Brad nyctelec...@gmail.com wrote:

 Wow, this is unbeileivable. Your test script fails with the attached csv
where column `a` in blank too!

No, with your attached file, it works:

array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 1
}
array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 2
}
array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 3
}
array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 4
}
array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 5
}
array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 6
}


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



RE: [PHP-DB] Re: No data?

2012-07-27 Thread Brad
Even though my permissions are 777 in my /tmp I am trying to send the file
to a tmp directory in my webroot and if I can even get it to create the file
it has the wrong name of 'Array', and then it still does not update my
database.




?php
var_dump($_FILES);
//db connection
require 'dbConnect.php';
//session file
require_once('../auth.php');
function uploadList(){
$target_path = /home/nyctelecomm.com/www/mail/upload/;
//$_FILE function, grab files
$inFile = $_FILES[file];
//Get file name
$filename = $inFile[name];
//strip the file extension
$filename = preg_replace('/\.[^.]+$/','',$filename);
var_dump($_FILES);
//grab sessionID which is memberID
$memberID = $_SESSION[SESS_MEMBER_ID];
//identify cvs, tested with MS excel in csv format
if ($inFile[type] == application/octet-stream)
{
if ($inFile[error]  0)
{
echo Return Code:  . $inFile['error'] . br /;
}
else
{
dbConnect();
//move_uploaded_file($_FILES[file],$target_path);
move_uploaded_file($inFile[file][tmp_name],
$target_path .'/'.$inFile);
//chmod ($filename['file'], 0777);
mysql_select_db('mailList') or die(mysql_error());
//assign temporary name to variable
//for insert since tmp_file is the real file
//$tmp_name =  $inFile[file];
$presql = CREATE TABLE IF NOT EXISTS `{$memberID}`
(id MEDIUMINT AUTO_INCREMENT PRIMARY KEY UNIQUE);
$midsql = ALTER TABLE `{$memberID}` ADD
`{$filename}` VARCHAR(60);
$sql = EOF
LOAD DATA LOCAL INFILE '{$inFile}'
INTO TABLE `{$memberID}`
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY
'\\''
LINES TERMINATED BY \\r\\n
IGNORE 1 LINES ($filename)
EOF;
var_dump($sql);
echo '$sql';
mysql_query($presql) or die(mysql_error());
mysql_query($midsql) or die(mysql_error());
mysql_query($sql) or die(mysql_error());
var_dump($sql);
echo '$sql';
if(mysql_error())
{
echo(mysql_error());
}
else
{
print('Import of campaign emails sucessfull
into mysql table.');
}
}
}
else
{
print('Invalid file type. Please make sure it is a text
file.');
}
}

//var_dump($_FILES);
uploadList();
?



*



array(1) { [file]= array(5) { [name]= string(13) testBook1.csv
[type]= string(24) application/octet-stream [tmp_name]= string(14)
/tmp/phpZVJWhW [error]= int(0) [size]= int(102) } } array(1) {
[file]= array(5) { [name]= string(13) testBook1.csv [type]=
string(24) application/octet-stream [tmp_name]= string(14)
/tmp/phpZVJWhW [error]= int(0) [size]= int(102) } } 
Notice: Undefined index: file in /home/nyctelecomm.com/www/mail/import.php
on line 29
string(169) LOAD DATA LOCAL INFILE 'Array' INTO TABLE `3` FIELDS
TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY \r\n
IGNORE 1 LINES (testBook1) $sqlFile 'Array' not found (Errcode: 2)



-Original Message-
From: Tamara Temple [mailto:tamo...@gmail.com] 
Sent: Friday, July 27, 2012 10:46 AM
To: Brad
Cc: 'tamouse mailing lists'; php-db@lists.php.net
Subject: Re: [PHP-DB] Re: No data?

Brad nyctelec...@gmail.com wrote:

 Wow, this is unbeileivable. Your test script fails with the attached csv
where column `a` in blank too!

No, with your attached file, it works:

array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 1
}
array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 2
}
array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 3
}
array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 4
}
array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 5
}
array(2) {
  [0]=
  string(15) br...@yahoo.com
  [1]=
  string(1) 6
}


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



Re: [PHP-DB] Re: No data?

2012-07-27 Thread Jim Giner

On 7/27/2012 11:03 AM, Brad wrote:

Even though my permissions are 777 in my /tmp I am trying to send the file
to a tmp directory in my webroot and if I can even get it to create the file
it has the wrong name of 'Array', and then it still does not update my
database.




?php
var_dump($_FILES);
//db connection
require 'dbConnect.php';
//session file
require_once('../auth.php');
function uploadList(){
 $target_path = /home/nyctelecomm.com/www/mail/upload/;
 //$_FILE function, grab files
 $inFile = $_FILES[file];
 //Get file name
 $filename = $inFile[name];
 //strip the file extension
 $filename = preg_replace('/\.[^.]+$/','',$filename);
 var_dump($_FILES);
 //grab sessionID which is memberID
 $memberID = $_SESSION[SESS_MEMBER_ID];
 //identify cvs, tested with MS excel in csv format
 if ($inFile[type] == application/octet-stream)
 {
 if ($inFile[error]  0)
 {
 echo Return Code:  . $inFile['error'] . br /;
 }
 else
 {
 dbConnect();
 //move_uploaded_file($_FILES[file],$target_path);
 move_uploaded_file($inFile[file][tmp_name],
$target_path .'/'.$inFile);
 //chmod ($filename['file'], 0777);
 mysql_select_db('mailList') or die(mysql_error());
 //assign temporary name to variable
 //for insert since tmp_file is the real file
 //$tmp_name =  $inFile[file];
 $presql = CREATE TABLE IF NOT EXISTS `{$memberID}`
(id MEDIUMINT AUTO_INCREMENT PRIMARY KEY UNIQUE);
 $midsql = ALTER TABLE `{$memberID}` ADD
`{$filename}` VARCHAR(60);
 $sql = EOF
 LOAD DATA LOCAL INFILE '{$inFile}'
 INTO TABLE `{$memberID}`
 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY
'\\''
 LINES TERMINATED BY \\r\\n
 IGNORE 1 LINES ($filename)
EOF;
 var_dump($sql);
 echo '$sql';
 mysql_query($presql) or die(mysql_error());
 mysql_query($midsql) or die(mysql_error());
 mysql_query($sql) or die(mysql_error());
 var_dump($sql);
 echo '$sql';
 if(mysql_error())
 {
 echo(mysql_error());
 }
 else
 {
 print('Import of campaign emails sucessfull
into mysql table.');
 }
 }
 }
 else
 {
 print('Invalid file type. Please make sure it is a text
file.');
 }
}

//var_dump($_FILES);
uploadList();
?



*



array(1) { [file]= array(5) { [name]= string(13) testBook1.csv
[type]= string(24) application/octet-stream [tmp_name]= string(14)
/tmp/phpZVJWhW [error]= int(0) [size]= int(102) } } array(1) {
[file]= array(5) { [name]= string(13) testBook1.csv [type]=
string(24) application/octet-stream [tmp_name]= string(14)
/tmp/phpZVJWhW [error]= int(0) [size]= int(102) } }
Notice: Undefined index: file in /home/nyctelecomm.com/www/mail/import.php
on line 29
string(169)LOAD DATA LOCAL INFILE 'Array' INTO TABLE `3` FIELDS
TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY \r\n
IGNORE 1 LINES (testBook1) $sqlFile 'Array' not found (Errcode: 2)



-Original Message-
From: Tamara Temple [mailto:tamo...@gmail.com]
Sent: Friday, July 27, 2012 10:46 AM
To: Brad
Cc: 'tamouse mailing lists'; php-db@lists.php.net
Subject: Re: [PHP-DB] Re: No data?

Brad nyctelec...@gmail.com wrote:


Wow, this is unbeileivable. Your test script fails with the attached csv

where column `a` in blank too!

No, with your attached file, it works:

array(2) {
   [0]=
   string(15) br...@yahoo.com
   [1]=
   string(1) 1
}
array(2) {
   [0]=
   string(15) br...@yahoo.com
   [1]=
   string(1) 2
}
array(2) {
   [0]=
   string(15) br...@yahoo.com
   [1]=
   string(1) 3
}
array(2) {
   [0]=
   string(15) br...@yahoo.com
   [1]=
   string(1) 4
}
array(2) {
   [0]=
   string(15) br...@yahoo.com
   [1]=
   string(1) 5
}
array(2) {
   [0]=
   string(15) br...@yahoo.com
   [1]=
   string(1) 6
}

You seem to be very stubborn in your attempts to handle this problem. 
All the suggestions we have provided you seem to be ignoring.  Dont' 
understand your mentality and I surely hope you are not exhausting your 
employer's resources on this effort.


Once again

RE: [PHP-DB] Re: No data?

2012-07-27 Thread Brad
@ Jim - Excuse me?
If you were following the thread you would see that even an outside third
party script failed, there is something else going on here.
As far as the use of $_FILES, no kidding, but when what you suggested failed
I started trying other things.
Not listening? Try to respond clear and not ambiguous, if someone isn't
following, you're not gonna squeeze blood from a turnip.

What is up with your hostility. I am so proud of you that you do this
every day, I don't. And the intent of the list is to support people working
through the kinks till they get to the point that they can bitch and gripe
at those just starting out as you do. If you're not happy with it,
unsubscribe!

Good day



-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com] 
Sent: Friday, July 27, 2012 11:32 AM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] Re: No data?

On 7/27/2012 11:03 AM, Brad wrote:
 Even though my permissions are 777 in my /tmp I am trying to send the 
 file to a tmp directory in my webroot and if I can even get it to 
 create the file it has the wrong name of 'Array', and then it still 
 does not update my database.




 ?php
 var_dump($_FILES);
 //db connection
 require 'dbConnect.php';
 //session file
 require_once('../auth.php');
 function uploadList(){
  $target_path = /home/nyctelecomm.com/www/mail/upload/;
  //$_FILE function, grab files
  $inFile = $_FILES[file];
  //Get file name
  $filename = $inFile[name];
  //strip the file extension
  $filename = preg_replace('/\.[^.]+$/','',$filename);
  var_dump($_FILES);
  //grab sessionID which is memberID
  $memberID = $_SESSION[SESS_MEMBER_ID];
  //identify cvs, tested with MS excel in csv format
  if ($inFile[type] == application/octet-stream)
  {
  if ($inFile[error]  0)
  {
  echo Return Code:  . $inFile['error'] . br
/;
  }
  else
  {
  dbConnect();

//move_uploaded_file($_FILES[file],$target_path);
  
 move_uploaded_file($inFile[file][tmp_name],
 $target_path .'/'.$inFile);
  //chmod ($filename['file'], 0777);
  mysql_select_db('mailList') or
die(mysql_error());
  //assign temporary name to variable
  //for insert since tmp_file is the real file
  //$tmp_name =  $inFile[file];
  $presql = CREATE TABLE IF NOT EXISTS 
 `{$memberID}` (id MEDIUMINT AUTO_INCREMENT PRIMARY KEY UNIQUE);
  $midsql = ALTER TABLE `{$memberID}` ADD 
 `{$filename}` VARCHAR(60);
  $sql = EOF
  LOAD DATA LOCAL INFILE '{$inFile}'
  INTO TABLE `{$memberID}`
  FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED 
 BY '\\''
  LINES TERMINATED BY \\r\\n
  IGNORE 1 LINES ($filename)
 EOF;
  var_dump($sql);
  echo '$sql';
  mysql_query($presql) or die(mysql_error());
  mysql_query($midsql) or die(mysql_error());
  mysql_query($sql) or die(mysql_error());
  var_dump($sql);
  echo '$sql';
  if(mysql_error())
  {
  echo(mysql_error());
  }
  else
  {
  print('Import of campaign emails 
 sucessfull into mysql table.');
  }
  }
  }
  else
  {
  print('Invalid file type. Please make sure it is a 
 text file.');
  }
 }

 //var_dump($_FILES);
 uploadList();
 ?


 **
 **
 *



 array(1) { [file]= array(5) { [name]= string(13) testBook1.csv
 [type]= string(24) application/octet-stream [tmp_name]= 
 string(14) /tmp/phpZVJWhW [error]= int(0) [size]= int(102) } } 
 array(1) { [file]= array(5) { [name]= string(13) testBook1.csv 
 [type]=
 string(24) application/octet-stream [tmp_name]= string(14) 
 /tmp/phpZVJWhW [error]= int(0) [size]= int(102) } }
 Notice: Undefined index: file in 
 /home/nyctelecomm.com/www/mail/import.php
 on line 29
 string(169)   LOAD DATA LOCAL INFILE 'Array' INTO TABLE `3` FIELDS
 TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY 
 \r\n IGNORE 1 LINES (testBook1) $sqlFile 'Array' not found 
 (Errcode: 2)



 -Original Message-
 From: Tamara Temple [mailto:tamo...@gmail.com]
 Sent: Friday, July 27, 2012 10:46 AM
 To: Brad
 Cc

RE: [PHP-DB] Re: No data?

2012-07-27 Thread Brad
Tamara, THANK YOU!
Switching the id field to last worked. But why?
I'm good to go now, but just curious.

Sincerely,
Brad



?php
var_dump($_FILES);
//db connection
require 'dbConnect.php';
//session file
require_once('../auth.php');
function uploadList(){
$target_path = /home/nyctelecomm.com/www/mail/upload/;
//$_FILE function, grab files
$inFile = $_FILES[file];
//Get file name
$filename = $inFile[name];
//strip the file extension
$filename = preg_replace('/\.[^.]+$/','',$filename);
var_dump($_FILES);
//grab sessionID which is memberID
$memberID = $_SESSION[SESS_MEMBER_ID];
//identify cvs, tested with MS excel in csv format
if ($inFile[type] == application/octet-stream)
{
if ($inFile[error]  0)
{
echo Return Code:  . $inFile['error'] . br /;
}
else
{
dbConnect();
//move_uploaded_file($_FILES[file],$target_path);
//chmod ($filename['file'], 0777);
mysql_select_db('mailList') or die(mysql_error());
//assign temporary name to variable
//for insert since tmp_file is the real file
$tmp_name =  $inFile[tmp_name];
$presql = CREATE TABLE IF NOT EXISTS `{$memberID}`
(id MEDIUMINT AUTO_INCREMENT PRIMARY KEY UNIQUE);
$midsql = ALTER TABLE `{$memberID}` ADD
`{$filename}` VARCHAR(60) FIRST;
$sql = EOF
LOAD DATA LOCAL INFILE '{$tmp_name}'
INTO TABLE `{$memberID}`
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY
'\\''
LINES TERMINATED BY \\r\\n
IGNORE 1 LINES ($filename)
EOF;
var_dump($sql);
echo '$sql';
mysql_query($presql) or die(mysql_error());
mysql_query($midsql) or die(mysql_error());
mysql_query($sql) or die(mysql_error());
var_dump($sql);
echo '$sql';
if(mysql_error())
{
echo(mysql_error());
}
else
{
print('Import of campaign emails sucessfull
into mysql table.');
}
}
}
else
{
print('Invalid file type. Please make sure it is a text
file.');
}
}

//var_dump($_FILES);
uploadList();
?

*output*
**
array(1) { [file]= array(5) { [name]= string(13) testBook1.csv
[type]= string(24) application/octet-stream [tmp_name]= string(14)
/tmp/phpZllgLU [error]= int(0) [size]= int(102) } } array(1) {
[file]= array(5) { [name]= string(13) testBook1.csv [type]=
string(24) application/octet-stream [tmp_name]= string(14)
/tmp/phpZllgLU [error]= int(0) [size]= int(102) } } string(178) 
LOAD DATA LOCAL INFILE '/tmp/phpZllgLU' INTO TABLE `3` FIELDS TERMINATED BY
',' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY \r\n IGNORE 1 LINES
(testBook1) $sqlstring(178)   LOAD DATA LOCAL INFILE '/tmp/phpZllgLU'
INTO TABLE `3` FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'' LINES
TERMINATED BY \r\n IGNORE 1 LINES (testBook1) $sqlImport of campaign
emails sucessfull into mysql table.

***database

mysql show tables;
++
| Tables_in_mailList |
++
| 3  |
++
1 row in set (0.00 sec)

mysql select * from `3`;
+--++
| testBook1| id |
+--++
| br...@yahoo.com
br...@yahoo.com
br...@yahoo.com
brads@yah |  1 |
+--++
1 row in set (0.00 sec)









-Original Message-
From: Tamara Temple [mailto:tamo...@gmail.com] 
Sent: Friday, July 27, 2012 12:50 PM
To: Brad
Subject: Re: [PHP-DB] Re: No data?

try this:

http://23.20.205.51/loadtablefromcsv/

See the source at http://23.20.205.51/loadtablefromcsv/index.phps

-- 
Tamara Temple
 aka tamouse__

Email: tamo...@gmail.com
Web: http://www.tamaratemple.com/

May you never see a stranger's face in the mirror


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



[PHP-DB] Re: No data?

2012-07-26 Thread Jim Giner
Are you any closer to getting your solution to work yet?  If not, could 
I ask for the general concept again?  From what I can remember, You want 
to allow a user to upload a csv file which you will then put into a sql 
table.  Additionally your code seems to be creating a new table for each 
file uploaded.  Are these csv files each unique, ie, do they have 
different data contents as in different fields of information?  Or do 
they all supply the same information in the same format.  ( Hope you get 
what I mean.)  If each file is different and each table is going to have 
different column names, how are these tables then going to be processed? 
You'll need different handlers for each table, no?  And if each file is 
the same then why not put the data into separate records of the same table?


As I mentioned before - it sure seems like you are trying to do too many 
things at once.  Concentrate on getting the client file onto the server 
with a unique name and THEN work on the next problem of putting it into 
a table if you must.


And if I am just entirely off-base, tell me to buzz off and I will leave 
this thread alone.  I just hate to see someone struggling for so many 
days on something that seems so simple to me.


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



RE: [PHP-DB] Re: No data?

2012-07-26 Thread Brad
1 User uploads file
2 program reads array
3 program creates a table called $memberID.$filename  if not exist
($filename is column)
4 program uploads data into table/column

I am messed up at #2 for some reason so #4 fails.
All 'key's appear to be in their correct place so I don't know. 

https://gist.github.com/3184155   - code

array(1) { [file]= array(5) { [name]= string(14) emailsTest.txt
[type]= string(10) text/plain [tmp_name]= string(14)
/tmp/php7wxmEI [error]= int(0) [size]= int(61) } } array(1) {
[file]= array(5) { [name]= string(14) emailsTest.txt [type]=
string(10) text/plain [tmp_name]= string(14) /tmp/php7wxmEI
[error]= int(0) [size]= int(61) } } string(165)   LOAD DATA LOCAL
INFILE '/tmp/php7wxmEI' INTO TABLE `3` FIELDS TERMINATED BY ',' OPTIONALLY
ENCLOSED BY '\'' LINES TERMINATED BY \r\n IGNORE 1 LINES $sqlDuplicate
column name 'emailsTest.txt'


mysql SHOW CREATE TABLE `3`;
+---+---


-+
| Table | Create Table
|
+---+---


-+
| 3 | CREATE TABLE `3` (
  `id` mediumint(9) NOT NULL AUTO_INCREMENT,
  `Array` varchar(60) DEFAULT NULL,
  `emailsTest.txt` varchar(60) DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `id` (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=utf8 |
+---+---


-+
1 row in set (0.00 sec)





mysql SELECT * FROM `3`;
Empty set (0.00 sec)





Brad Sumrall
NYCTelecomm.com
212 444-2996


-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com] 
Sent: Thursday, July 26, 2012 10:55 AM
To: php-db@lists.php.net
Subject: [PHP-DB] Re: No data?

Are you any closer to getting your solution to work yet?  If not, could I
ask for the general concept again?  From what I can remember, You want to
allow a user to upload a csv file which you will then put into a sql table.
Additionally your code seems to be creating a new table for each file
uploaded.  Are these csv files each unique, ie, do they have different data
contents as in different fields of information?  Or do they all supply the
same information in the same format.  ( Hope you get what I mean.)  If each
file is different and each table is going to have different column names,
how are these tables then going to be processed? 
You'll need different handlers for each table, no?  And if each file is the
same then why not put the data into separate records of the same table?

As I mentioned before - it sure seems like you are trying to do too many
things at once.  Concentrate on getting the client file onto the server with
a unique name and THEN work on the next problem of putting it into a table
if you must.

And if I am just entirely off-base, tell me to buzz off and I will leave
this thread alone.  I just hate to see someone struggling for so many days
on something that seems so simple to me.

--
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] Re: No data?

2012-07-26 Thread Jim Giner
Not sure what you mean - Program reads array.  What program is doing 
is utilizing the FILES element to get the info about the uploaded file 
and proceeds to finish the upload by moving it to a temporary folder of 
your creation.  Once that is done you HAVE the file under whatever name 
you want to call it in whatever folder you want it in.


Why don't you just do that part and then use some tool to look at your 
server structure to verify that you have the file.


NOW you can proceed with the rest, if you must.  You're going to create 
a table with a column/field name matching the filename and then you'll 
put the contents of that file into that single column in one record of 
this table.  So now you have a one record table with one column holding 
the contents of a file.  How is this different from just having the file?


1 User uploads file
2 program reads array
3 program creates a table called $memberID.$filename  if not exist
($filename is column)
4 program uploads data into table/column

I am messed up at #2 for some reason so #4 fails.



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



RE: [PHP-DB] Re: No data?

2012-07-26 Thread Brad
I don't 'have' a file. It creates a temporary file and then deletes it just
as fast in /tmp/.
Plus, how would I $_GET it? $_FILES is supposed to handle 'ALL' of this for
me? If not, what the heck does it do?


Brad Sumrall
NYCTelecomm.com
212 444-2996


-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com] 
Sent: Thursday, July 26, 2012 5:02 PM
To: Brad
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Re: No data?

Not sure what you mean - Program reads array.  What program is doing is
utilizing the FILES element to get the info about the uploaded file and
proceeds to finish the upload by moving it to a temporary folder of your
creation.  Once that is done you HAVE the file under whatever name you want
to call it in whatever folder you want it in.

Why don't you just do that part and then use some tool to look at your
server structure to verify that you have the file.

NOW you can proceed with the rest, if you must.  You're going to create a
table with a column/field name matching the filename and then you'll put the
contents of that file into that single column in one record of this table.
So now you have a one record table with one column holding the contents of a
file.  How is this different from just having the file?

1 User uploads file
2 program reads array
3 program creates a table called $memberID.$filename  if not exist
($filename is column)
4 program uploads data into table/column

I am messed up at #2 for some reason so #4 fails.



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



[PHP-DB] PHP-DB] Re: No data?

2012-07-26 Thread Brad
I apologize, I may have been mistaken about the role of $_FILES but this -
http://dev.mysql.com/doc/refman/5.0/en/load-data.html  confuses me. The use
of $_FILES with LOAD DATA is littered over the internet and manuals as a 1
shot deal. No hand off to another directory for storage till the next
function gets to it.
Straight from remote drive to database in 1 single quick shot.

Yours may be a work around but I honestly want it to work correctly. I'll
delete the server prior to a left field hack to accommodate a failing
function.  :(



-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
Sent: Thursday, July 26, 2012 5:17 PM
To: Brad
Subject: Re: [PHP-DB] Re: No data?

you need to read up on how html uploads files and how php handles them.

You cannot just use the temp file (I may be wrong here, but in general one
doesn't use it.).  You need to use the $_FILES info in order to get the
uploaded temporary file and save it permanently somewhere on your server.
THEN you can use it and when through with it, you can choose to delete it.
That's how it works.  The code that I gave you days ago accomplishes exactly
that and it gets used regularly on my site, so I know that it works.

Please try it and then use an ftp client to connect to your server and see
that the newly uploaded file is there.  Then you can do what you wish with
it.
On 7/26/2012 5:10 PM, Brad wrote:
 I don't 'have' a file. It creates a temporary file and then deletes it 
 just as fast in /tmp/.
 Plus, how would I $_GET it? $_FILES is supposed to handle 'ALL' of 
 this for me? If not, what the heck does it do?


 Brad Sumrall
 NYCTelecomm.com
 212 444-2996


 -Original Message-
 From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
 Sent: Thursday, July 26, 2012 5:02 PM
 To: Brad
 Cc: php-db@lists.php.net
 Subject: Re: [PHP-DB] Re: No data?

 Not sure what you mean - Program reads array.  What program is doing 
 is utilizing the FILES element to get the info about the uploaded file 
 and proceeds to finish the upload by moving it to a temporary folder 
 of your creation.  Once that is done you HAVE the file under whatever 
 name you want to call it in whatever folder you want it in.

 Why don't you just do that part and then use some tool to look at your 
 server structure to verify that you have the file.

 NOW you can proceed with the rest, if you must.  You're going to 
 create a table with a column/field name matching the filename and then 
 you'll put the contents of that file into that single column in one record
of this table.
 So now you have a one record table with one column holding the 
 contents of a file.  How is this different from just having the file?

 1 User uploads file
 2 program reads array
 3 program creates a table called $memberID.$filename  if not exist 
 ($filename is column)
 4 program uploads data into table/column

 I am messed up at #2 for some reason so #4 fails.






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



Re: [PHP-DB] PHP-DB] Re: No data?

2012-07-26 Thread Karl DeSaulniers

Jim I believe your correct.

Upload the file to temp
move the file to your dir on your server
and rename file
you can also set the permissions of the file while moving it.
put url to file (not temp file) in database (not the file contents)
done

Best,
Karl

On Jul 26, 2012, at 4:50 PM, Brad wrote:

I apologize, I may have been mistaken about the role of $_FILES but  
this -
http://dev.mysql.com/doc/refman/5.0/en/load-data.html  confuses me.  
The use
of $_FILES with LOAD DATA is littered over the internet and manuals  
as a 1

shot deal. No hand off to another directory for storage till the next
function gets to it.
Straight from remote drive to database in 1 single quick shot.

Yours may be a work around but I honestly want it to work correctly.  
I'll

delete the server prior to a left field hack to accommodate a failing
function.  :(



-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
Sent: Thursday, July 26, 2012 5:17 PM
To: Brad
Subject: Re: [PHP-DB] Re: No data?

you need to read up on how html uploads files and how php handles  
them.


You cannot just use the temp file (I may be wrong here, but in  
general one
doesn't use it.).  You need to use the $_FILES info in order to get  
the
uploaded temporary file and save it permanently somewhere on your  
server.
THEN you can use it and when through with it, you can choose to  
delete it.
That's how it works.  The code that I gave you days ago accomplishes  
exactly

that and it gets used regularly on my site, so I know that it works.

Please try it and then use an ftp client to connect to your server  
and see
that the newly uploaded file is there.  Then you can do what you  
wish with

it.
On 7/26/2012 5:10 PM, Brad wrote:
I don't 'have' a file. It creates a temporary file and then deletes  
it

just as fast in /tmp/.
Plus, how would I $_GET it? $_FILES is supposed to handle 'ALL' of
this for me? If not, what the heck does it do?


Brad Sumrall
NYCTelecomm.com
212 444-2996


-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
Sent: Thursday, July 26, 2012 5:02 PM
To: Brad
Cc: php-db@lists.php.net
Subject: Re: [PHP-DB] Re: No data?

Not sure what you mean - Program reads array.  What program is  
doing
is utilizing the FILES element to get the info about the uploaded  
file

and proceeds to finish the upload by moving it to a temporary folder
of your creation.  Once that is done you HAVE the file under whatever
name you want to call it in whatever folder you want it in.

Why don't you just do that part and then use some tool to look at  
your

server structure to verify that you have the file.

NOW you can proceed with the rest, if you must.  You're going to
create a table with a column/field name matching the filename and  
then
you'll put the contents of that file into that single column in one  
record

of this table.

So now you have a one record table with one column holding the
contents of a file.  How is this different from just having the file?

1 User uploads file
2 program reads array
3 program creates a table called $memberID.$filename  if not exist
($filename is column)
4 program uploads data into table/column

I am messed up at #2 for some reason so #4 fails.







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



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: No data?

2012-07-26 Thread Brad
Your method would work. H
Contemplating.

Brad



-Original Message-
From: Jim Giner [mailto:jim.gi...@albanyhandball.com] 
Sent: Thursday, July 26, 2012 6:02 PM
To: Brad
Subject: Re: [PHP-DB] Re: No data?

actually, I never heard of LOAD DATA myself.  But dont' think of my approach
as a work-around.  It's just another path to the very same result.  And
easier to debug. And easier to understand to another person looking at your
code down the road.  And it's not slower either.  Maybe a msec or two.
It is certainly not to be thought of as incorrect.  
It's how files are uploaded every day.  You're just trying to consolidate
two specific operations that YOU have to accomplish into one.  And so far
it's taken you how many days?
On 7/26/2012 5:49 PM, Brad wrote:
 I apologize, I may have been mistaken about the role of $_FILES but 
 this - http://dev.mysql.com/doc/refman/5.0/en/load-data.html  
 confuses me. The use of $_FILES with LOAD DATA is littered over the 
 internet and manuals as a 1 shot deal. No hand off to another 
 directory for storage till the next function gets to it.
 Straight from remote drive to database in 1 single quick shot.

 Yours may be a work around but I honestly want it to work correctly. 
 I'll delete the server prior to a left field hack to accommodate a 
 failing function.  :(



 -Original Message-
 From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
 Sent: Thursday, July 26, 2012 5:17 PM
 To: Brad
 Subject: Re: [PHP-DB] Re: No data?

 you need to read up on how html uploads files and how php handles them.

 You cannot just use the temp file (I may be wrong here, but in general 
 one doesn't use it.).  You need to use the $_FILES info in order to 
 get the uploaded temporary file and save it permanently somewhere on
your server.
 THEN you can use it and when through with it, you can choose to delete it.
 That's how it works.  The code that I gave you days ago accomplishes 
 exactly that and it gets used regularly on my site, so I know that it
works.

 Please try it and then use an ftp client to connect to your server and 
 see that the newly uploaded file is there.  Then you can do what you 
 wish with it.
 On 7/26/2012 5:10 PM, Brad wrote:
 I don't 'have' a file. It creates a temporary file and then deletes 
 it just as fast in /tmp/.
 Plus, how would I $_GET it? $_FILES is supposed to handle 'ALL' of 
 this for me? If not, what the heck does it do?


 Brad Sumrall
 NYCTelecomm.com
 212 444-2996


 -Original Message-
 From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
 Sent: Thursday, July 26, 2012 5:02 PM
 To: Brad
 Cc: php-db@lists.php.net
 Subject: Re: [PHP-DB] Re: No data?

 Not sure what you mean - Program reads array.  What program is 
 doing is utilizing the FILES element to get the info about the 
 uploaded file and proceeds to finish the upload by moving it to a 
 temporary folder of your creation.  Once that is done you HAVE the 
 file under whatever name you want to call it in whatever folder you want
it in.

 Why don't you just do that part and then use some tool to look at 
 your server structure to verify that you have the file.

 NOW you can proceed with the rest, if you must.  You're going to 
 create a table with a column/field name matching the filename and 
 then you'll put the contents of that file into that single column in 
 one record
 of this table.
 So now you have a one record table with one column holding the 
 contents of a file.  How is this different from just having the file?

 1 User uploads file
 2 program reads array
 3 program creates a table called $memberID.$filename  if not exist 
 ($filename is column)
 4 program uploads data into table/column

 I am messed up at #2 for some reason so #4 fails.








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



RE: [PHP-DB] PHP-DB] Re: No data?

2012-07-26 Thread Brad
Drats, I think you are correct.
:)


-Original Message-
From: Karl DeSaulniers [mailto:k...@designdrumm.com] 
Sent: Thursday, July 26, 2012 5:59 PM
To: php-db@lists.php.net
Subject: Re: [PHP-DB] PHP-DB] Re: No data?

Jim I believe your correct.

Upload the file to temp
move the file to your dir on your server and rename file you can also set
the permissions of the file while moving it.
put url to file (not temp file) in database (not the file contents) done

Best,
Karl

On Jul 26, 2012, at 4:50 PM, Brad wrote:

 I apologize, I may have been mistaken about the role of $_FILES but 
 this - http://dev.mysql.com/doc/refman/5.0/en/load-data.html  
 confuses me.
 The use
 of $_FILES with LOAD DATA is littered over the internet and manuals as 
 a 1 shot deal. No hand off to another directory for storage till the 
 next function gets to it.
 Straight from remote drive to database in 1 single quick shot.

 Yours may be a work around but I honestly want it to work correctly.  
 I'll
 delete the server prior to a left field hack to accommodate a failing 
 function.  :(



 -Original Message-
 From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
 Sent: Thursday, July 26, 2012 5:17 PM
 To: Brad
 Subject: Re: [PHP-DB] Re: No data?

 you need to read up on how html uploads files and how php handles 
 them.

 You cannot just use the temp file (I may be wrong here, but in general 
 one doesn't use it.).  You need to use the $_FILES info in order to 
 get the uploaded temporary file and save it permanently somewhere on 
 your server.
 THEN you can use it and when through with it, you can choose to delete 
 it.
 That's how it works.  The code that I gave you days ago accomplishes 
 exactly that and it gets used regularly on my site, so I know that it 
 works.

 Please try it and then use an ftp client to connect to your server and 
 see that the newly uploaded file is there.  Then you can do what you 
 wish with it.
 On 7/26/2012 5:10 PM, Brad wrote:
 I don't 'have' a file. It creates a temporary file and then deletes
 it
 just as fast in /tmp/.
 Plus, how would I $_GET it? $_FILES is supposed to handle 'ALL' of
 this for me? If not, what the heck does it do?


 Brad Sumrall
 NYCTelecomm.com
 212 444-2996


 -Original Message-
 From: Jim Giner [mailto:jim.gi...@albanyhandball.com]
 Sent: Thursday, July 26, 2012 5:02 PM
 To: Brad
 Cc: php-db@lists.php.net
 Subject: Re: [PHP-DB] Re: No data?

 Not sure what you mean - Program reads array.  What program is  
 doing
 is utilizing the FILES element to get the info about the uploaded  
 file
 and proceeds to finish the upload by moving it to a temporary folder
 of your creation.  Once that is done you HAVE the file under whatever
 name you want to call it in whatever folder you want it in.

 Why don't you just do that part and then use some tool to look at  
 your
 server structure to verify that you have the file.

 NOW you can proceed with the rest, if you must.  You're going to
 create a table with a column/field name matching the filename and  
 then
 you'll put the contents of that file into that single column in one  
 record
 of this table.
 So now you have a one record table with one column holding the
 contents of a file.  How is this different from just having the file?

 1 User uploads file
 2 program reads array
 3 program creates a table called $memberID.$filename  if not exist
 ($filename is column)
 4 program uploads data into table/column

 I am messed up at #2 for some reason so #4 fails.






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


Karl DeSaulniers
Design Drumm
http://designdrumm.com


-- 
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] Re: No data?

2012-07-26 Thread tamouse mailing lists
Brad, do take a look at http://pastie.org/4340383
It does work.

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



Re: [PHP-DB] Re: No data?

2012-07-26 Thread tamouse mailing lists
With one change to the data file to make the indexing work correctly
and read all the fields: to accommodate the first id auto_increment
field, the first value in the csv line must be null:

null.a,b,c,d,e
null,f,g,h,i,j
null,k,l,m,n,o

And further, the field count should subsequently be one less in line
53 when creating the table:

for ($i=0; $i  (count($fields)-1); $i++) {

and that should do it.

On Thu, Jul 26, 2012 at 10:20 PM, tamouse mailing lists
tamouse.li...@gmail.com wrote:
 Brad, do take a look at http://pastie.org/4340383
 It does work.

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



Re: [PHP-DB] Re: No data?

2012-07-26 Thread tamouse mailing lists
argh
forget that.
simply put the id auto_increment field *last* in the create table
defn, leave everything else as it was.

On Thu, Jul 26, 2012 at 10:38 PM, tamouse mailing lists
tamouse.li...@gmail.com wrote:
 With one change to the data file to make the indexing work correctly
 and read all the fields: to accommodate the first id auto_increment
 field, the first value in the csv line must be null:

 null.a,b,c,d,e
 null,f,g,h,i,j
 null,k,l,m,n,o

 And further, the field count should subsequently be one less in line
 53 when creating the table:

 for ($i=0; $i  (count($fields)-1); $i++) {

 and that should do it.

 On Thu, Jul 26, 2012 at 10:20 PM, tamouse mailing lists
 tamouse.li...@gmail.com wrote:
 Brad, do take a look at http://pastie.org/4340383
 It does work.

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



RE: [PHP-DB] Re: No data?

2012-07-26 Thread Brad
No, it did not work.

mysql show tables;
++
| Tables_in_mailList |
++
| testBook1csv   |
++
1 row in set (0.00 sec)

mysql select * from `testBook1csv`;
+++
| id | field0 |
+++
|  1 | NULL   |
|  2 | NULL   |
|  3 | NULL   |
|  4 | NULL   |
|  5 | NULL   |
|  6 | NULL   |
+++
6 rows in set (0.00 sec)



file upload example

$_FILES

  array(1) {
  [userfile]=
  array(5) {
[name]=
string(13) testBook1.csv
[type]=
string(24) application/octet-stream
[tmp_name]=
string(14) /tmp/phpiaW23p
[error]=
int(0)
[size]=
int(102)
  }
}
ls -l /tmp/phpiaW23p

-rw--- 1 apache apache 102 Jul 27 00:02 /tmp/phpiaW23p
$sql for create table

string(110) create table if not exists `testBook1csv` (id integer not null 
auto_increment primary key, field0 varchar(50))
$sql for load data

string(142) load data local infile '/tmp/phpiaW23p' into table `testBook1csv` 
fields terminated by ',' optionally enclosed by '' lines terminated by '\n'
Verify data contents

Table testBook1csv

string(28) select * from `testBook1csv`
$sql=
data

array(2) {
  [0]=
  string(1) 1
  [1]=
  NULL
}
array(2) {
  [0]=
  string(1) 2
  [1]=
  NULL
}
array(2) {
  [0]=
  string(1) 3
  [1]=
  NULL
}
array(2) {
  [0]=
  string(1) 4
  [1]=
  NULL
}
array(2) {
  [0]=
  string(1) 5
  [1]=
  NULL
}
array(2) {
  [0]=
  string(1) 6
  [1]=
  NULL
}

-Original Message-
From: tamouse mailing lists [mailto:tamouse.li...@gmail.com] 
Sent: Thursday, July 26, 2012 11:20 PM
To: Brad
Cc: jim.gi...@albanyhandball.com; php-db@lists.php.net
Subject: Re: [PHP-DB] Re: No data?

Brad, do take a look at http://pastie.org/4340383 It does work.


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



RE: [PHP-DB] Re: No data?

2012-07-26 Thread Brad
Wow, this is unbeileivable. Your test script fails with the attached csv where 
column `a` in blank too!


Php.ini
http://pastie.org/4340845


mysql select * from `testBook1csv`;
+++
| id | field0 |
+++
|  1 | NULL   |
|  2 | NULL   |
|  3 | NULL   |
|  4 | NULL   |
|  5 | NULL   |
|  6 | NULL   |
+++
6 rows in set (0.00 sec)


*output from your script**

file upload example

$_FILES

  array(1) {
  [userfile]=
  array(5) {
[name]=
string(13) testBook1.csv
[type]=
string(24) application/octet-stream
[tmp_name]=
string(14) /tmp/phphf42G8
[error]=
int(0)
[size]=
int(102)
  }
}
ls -l /tmp/phphf42G8

-rw--- 1 apache apache 102 Jul 27 00:17 /tmp/phphf42G8
$sql for create table

string(110) create table if not exists `testBook1csv` (id integer not null 
auto_increment primary key, field0 varchar(50))
$sql for load data

string(142) load data local infile '/tmp/phphf42G8' into table `testBook1csv` 
fields terminated by ',' optionally enclosed by '' lines terminated by '\n'
Verify data contents

Table testBook1csv

string(28) select * from `testBook1csv`
$sql=
data

array(2) {
  [0]=
  string(1) 1
  [1]=
  NULL
}
array(2) {
  [0]=
  string(1) 2
  [1]=
  NULL
}
array(2) {
  [0]=
  string(1) 3
  [1]=
  NULL
}
array(2) {
  [0]=
  string(1) 4
  [1]=
  NULL
}
array(2) {
  [0]=
  string(1) 5
  [1]=
  NULL
}
array(2) {
  [0]=
  string(1) 6
  [1]=
  NULL
}

-Original Message-
From: tamouse mailing lists [mailto:tamouse.li...@gmail.com] 
Sent: Thursday, July 26, 2012 11:39 PM
To: Brad
Cc: jim.gi...@albanyhandball.com; php-db@lists.php.net
Subject: Re: [PHP-DB] Re: No data?

With one change to the data file to make the indexing work correctly and read 
all the fields: to accommodate the first id auto_increment field, the first 
value in the csv line must be null:

null.a,b,c,d,e
null,f,g,h,i,j
null,k,l,m,n,o

And further, the field count should subsequently be one less in line
53 when creating the table:

for ($i=0; $i  (count($fields)-1); $i++) {

and that should do it.

On Thu, Jul 26, 2012 at 10:20 PM, tamouse mailing lists 
tamouse.li...@gmail.com wrote:
 Brad, do take a look at http://pastie.org/4340383 It does work.


testBook1.csv
Description: MS-Excel spreadsheet
-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DB] Re: Extracting data from Arrays in ISAM table

2007-05-20 Thread itoctopus
Step #1: Select name_field FROM the_table;
Step #2:
$arr_all_names = array();
foreach single_result in your result_set{ //you have to translate this into 
php
$arr_name = explode(',', $single_result['name']); //assuming that you 
are joining names in the field using a comma
$arr_all_names = $arr_all_names + $arr_name;
}
//remove redundancy
$arr_all_names = array_unique($arr_all_names);
//now sort the array
sort($arr_all_names);
//now all you have to do is to loop through the array to display it on your 
site



-- 
itoctopus - http://www.itoctopus.com
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
I have a table with between 100k and 200k rows.  One field, `names`, is
 populated, in each row, with an imploded array of up to 4 names.

 I require to create a list of names, without repeats, of all the names
 in `names` field to use in an html form.

 Any advise would be appreciated.  I have no ideas on how to start.

 Louise



 

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



[PHP-DB] Re: Transfer data between tables in MySQL

2006-11-29 Thread benmoreassynt
Rosen wrote:

 Hi,
 I have to transfer all data between two tables ( with identical structure
 ) Is this possible with one query, or I must read from table1 and manually
 insert into table2?
 
 Thanks in advance,
 Rosen

INSERT INTO `dbase2`.`table1`
SELECT *
FROM `dbase1`.`table1` ;

That will copy from 1st database to second. If you use phpMyAdmin you can do
it via the operations tab.

BMA

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



[PHP-DB] Re: Highlighting data selected from one table that appear in another

2005-09-01 Thread Frank Flynn
I'm thinking that you need a LEFT JOIN (see the mysql  
documentation) to do this.  Basically LEFT JOIN (or RIGHT JOIN) allow  
you to select all the rows from the table on the left side even if  
they have no corresponding row on the right side (the values of the  
columns in the select that belong to the right hand table will be  
NULL where there is no row to join to).


But if you could be more specific - send the schema and precisely  
what you were looking to do I could give you an example of how to  
make it work.


Good Luck,
Frank


On Sep 1, 2005, at 5:00 AM, [EMAIL PROTECTED] wrote:


From: boclair [EMAIL PROTECTED]
Date: September 1, 2005 4:50:05 AM PDT
To: php-db@lists.php.net php-db@lists.php.net
Subject: Highlighting data selected from one table that appear in  
another



Content-Type: multipart/alternative;
boundary=070700030402040702060708
X-Authentication-Info: Submitted using SMTP AUTH PLAIN at  
omta05ps.mx.bigpond.com from [138.130.220.111] using ID boclair at  
Thu, 1 Sep 2005 11:49:59 +


This is a multi-part message in MIME format.
--070700030402040702060708
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

mysql 4.0.25
php 4.3.1

I seem to be unable to solve this problem without some help.

A webpage is to list all the clients in a  mysql  Client table.   
Each

client has an an allocated clid.

Those clients who are listed, identified by their allocated clid, in a
Transactions are to be highlighted in different ways according to
progress of the transaction, the progress being determined on whether
date values have been inserted into various fields.

Since mysql select joining the tables lists only the clients whose
appear in both tables.

I have been attempting to create a temporary table inserting the data
from Client and Transactions  and selecting from that but not
successfully yet. But is this the way to go about it.

The scale is an anticipated 1000 clients per month of which an
anticipated 800 will involve transactions

Louise






[PHP-DB] Re: Highlighting data selected from one table that appear in another

2005-09-01 Thread boclair



Frank Flynn wrote:




But if you could be more specific - send the schema and precisely what 
you were looking to do I could give you an example of how to make it work.



I am still having difficulties with my workup and more help would be 
appreciated . 


I have two tables


CREATE TABLE `clients` (
 `id` tinyint(4) NOT NULL auto_increment,
 `clid` varchar(5) NOT NULL default '',
 `clfname` varchar(50) NOT NULL default '',
 `cllname` varchar(30) NOT NULL default '',
 PRIMARY KEY  (`id`),
 UNIQUE KEY `clid` (`clid`)
) TYPE=MyISAM COMMENT='workup table for client data';

CREATE TABLE `transactions` (
 `id` tinyint(4) NOT NULL auto_increment,
 `fmid` varchar(5) NOT NULL default '',
 `clid` varchar(5) NOT NULL default '',
 `bdate` date NOT NULL default '-00-00',
 `instr` mediumtext,
 `ecom` decimal(5,2) default NULL,
 `efdate` date default '-00-00',
 `acom` decimal(5,2) default NULL,
 `afdate` date default '-00-00',
 `transid` varchar(10) NOT NULL default '',
 PRIMARY KEY  (`id`,`fmid`),
 UNIQUE KEY `transid` (`transid`),
 KEY `fmid` (`fmid`)
) TYPE=MyISAM;  COMMENT='workup table for transaction data';

What is needed is to display a list of all clients each denoted 
applicably as

1.. No entry in transaction table  (client's clid not in transaction table)
2.. Client not yet interviewed ( instr empty, efdate default value and 
afdate default value)
3.. Client interviewed  ( instr !empty, efdate=default value and 
afdate=default value)
4.. Client's transaction in progress ( instr !empty, efdate!=default 
value and afdate=default value)
5.. Clients transaction finalised ( instr !empty, efdate!=default value 
and afdate!=default value)



What I appear to be getting is
LEFT JOIN only selects those clients with a matching clid in both tables

LEFT OUTER JOIN selects all clients with the appropriate 
transaction.fmid (for example) except when the client.clid is not 
matched by a transaction.clid when a spurious fmid is given.
   SELECT * FROM clients LEFT OUTER JOIN transaction ON 
clients.clid = transactions.clid ORDER BY clients.cllname ASC


I am obviously handling the join incorrectly.

Louise

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



[PHP-DB] Re: load data infile -- problem

2005-08-18 Thread Dan Baker
select.now [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 So, in command line, all works fine, all records are correctly imported.
  command line code -
 mysql load data infile 'c:\\datastream\\import\import
 -into table iport
 - fields terminated by ';'
 - ignore 9 lines;
 - /command line code 
 -- php code ---
 $a = 'c:\\\datastream\\\import\\\import';
 $extra_arg = 'fields terminated by \';\' ignore 9 lines;';
 $query = 'load data infile \''.$a.'\' into table import '.$extra_arg.'';
 $result = mysql_query ($query) or die_mysql (brExecutia comenzii 
 i$query/i a esuat.br);
 -- /php code --
 I get this output-error:
 ===
  load data infile 'c:\\datastream\\import\\import' into table import 
 fields terminated by ';' ignore 9 lines;
 ===

It looks like your slashes are a wee-bit messed up.  Maybe try:
$a = 'c:\\datastream\\import\\import';

Note: a single '\' means to escape the next character, so two '\\' means to 
put in a single '\'.  You had three '\\\'.
DanB

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



[PHP-DB] Re: Moving data from one MySQL table to another

2005-05-20 Thread Frank Flynn
First off - is this a solution in search of a problem?   Databases  
are excellent at indexing and caching frequently used data.  Though  
your table has millions of rows and you are only really interested in  
a few hundred you might find that performance is not noticeably any  
different than if you only had a few hundred rows total.  And if  
there is a big difference look at the indexes - really, it seems  
unbelievable but in fact it is true.

But if there is a big difference you can move the data with these two  
statements (and the data does not ever leave the DB).

INSERT INTO newTable (column1, column2, ...)
  SELECT column1, column2, ...  FROM oldTable WHERE column3  some  
date /* or whatever */

DELETE FROM oldTable WHERE column3  some date /* or whatever */
Be sure the two where clauses match exactly.
Good Luck,
Frank
On May 19, 2005, at 3:28 PM, [EMAIL PROTECTED] wrote:
From: Jeffrey [EMAIL PROTECTED]
Date: May 19, 2005 6:19:48 AM PDT
To: php-db@lists.php.net
Subject: Moving data from one MySQL table to another
I'm working on a web application and one of the things I am doing  
is creating an archiving function that would move older data to  
archive tables in order to minimise the amount of data in the   
active tables. This so that the data that is being used more  
frequently can be accessed faster by the users.

My approach in building the archive function is:
1) SELECT query on the data
2) mysql_fetch_array to put the data into an array
3) INSERT subqueries to put the data into the archive tables.
My concern is that in some cases, hundreds of rows of data would  
need to be moved  - which could lead to awfully big arrays.  
However, the archiving function is likely to be used infrequently -  
not more than 1 or 2 times per week.

This leads to two questions:
1) Could such a big array cause performance problems or worse?
2) Is there a better way?
Many thanks,
Jeff




[PHP-DB] Re: MySQL Data Not Returned

2004-11-13 Thread Neil Smith [MVP, Digital media]
My guess (and it will be correct) is that you've got a not visible 
character on the end of your email address in the database. Such a 
character could be a space, newline, tab or other similar character.

Make sure you use trim($email_address) to create the field to insert into 
the database !

Check the actual string you get returned from the query on the DB with the 
query
SELECT * FROM mailinglist WHERE email like '$email%'

Use strlen($resul[email]); and you'll see that the length of the email 
address is not the same as the number of characters in the email address if 
you count them manually.

Cheers - Neil
At 11:54 13/11/2004 +, you wrote:
I search the list like so:
$email=[EMAIL PROTECTED];
$query=mysqli_query($cnn,SELECT * FROM mailinglist WHERE
email='$email');
When I do:
Echo mysqli_num_rows($query);
I get 0 back, The address I am searching is in the database, I have
triple checked it with phpmyadmin.
The only way I can get it to return the record I am looking for is to do
this.
$email=[EMAIL PROTECTED];
$query=mysqli_query($cnn,SELECT * FROM mailinglist WHERE email like
'$email%');
Then this finally returns 1. I have tried many different email
addresses; nothing comes back, not even from the SQL query window within
phpmyadmin v. 2.6.0-rc2
This has been puzzling me for hours on end. If anyone can provide any
help, that would be great
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Re: LOAD DATA LOCAL INFILE

2004-08-16 Thread James Hatridge
Hi Dani et al..

The guys at MySQL turned this off for security reasons. :( They and SuSE say 
that you can turn it back on, but I've never been able to get it to work. 

There are two ways to handle this, first you have to use LOAD DATA INFILE. 
The file then needs to be either in /tmp and readable by everyone (this is 
best). Or the way I do it is put in the same dir where the database is, 
ie /var/lib/mysql/databaseXXX. The problem with this is that you have to 
change the premissions. Which is not a good idea on an internet machine. 

Hope this helps,

JIM
 
On Monday 16 August 2004 14:40, Daniel Kradolfer wrote:
 Hello

 I'm new to this list. I diden't found anything in the archive and by
 googleing to solve my problem.

 We have updated our server to PHP 4.3.8 and MySQL 4.0.2. Some of our
 clients run a shop software that need 'LOAD DATA LOCAL INFILE' to store
 its data to MySQL. MySQL itself supports the command. I can run it from
 mysql-client. That works. I have read about the fix on php.net
 (http://www.php.net/ChangeLog-4.php / http://bugs.php.net/28632).
 Until now, i couldn't find a solution to get it work.

 Is there way to get it work?

 Regards
 Dani

-- 
Jim Hatridge
Linux User #88484
--
                 BayerWulf
   Linux System # 129656
         The Recycled Beowulf Project
  Looking for throw-away or obsolete computers and parts
   to recycle into a Linux super computer

WartHog Bulletin
Info about new German Stamps
   http://www.fuzzybunnymilitia.org/~hatridge/bulletin

Viel Feind -- Viel Ehr'
Anti-US Propaganda stamp collection
  http://www.fuzzybunnymilitia.org/~hatridge/collection

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



[PHP-DB] Re: LOAD DATA LOCAL INFILE

2004-08-16 Thread Michelle Konzack
Am 2004-08-16 19:11:50, schrieb James Hatridge:
 Hi Dani et al..
 
 The guys at MySQL turned this off for security reasons. :( They and SuSE say 
 that you can turn it back on, but I've never been able to get it to work. 
 
 There are two ways to handle this, first you have to use LOAD DATA INFILE. 
 The file then needs to be either in /tmp and readable by everyone (this is 
 best). Or the way I do it is put in the same dir where the database is, 
 ie /var/lib/mysql/databaseXXX. The problem with this is that you have to 
 change the premissions. Which is not a good idea on an internet machine. 
 
 Hope this helps,

What about:

http://www.ispirer.com/doc/sqlways36/troubleshooting/mysql_db.html


In MySQL 4.0.x LOCAL will only work if MySQL 
server was started with --local-infile=1.


 JIM


Hello, 


Greetings
Michelle

-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/ 
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSM LinuxMichi
0033/3/8845235667100 Strasbourg/France   IRC #Debian (irc.icq.com)


signature.pgp
Description: Digital signature


[PHP-DB] Re: Exporting Data From MySQL Using PHP

2004-08-09 Thread Guus der Kinderen
Hello Ron,
If I understand correctly, you're asking what query to execute (and how 
to put the result in a textfile) to get the results you want?

The first part is described thorougly in the mysql-manual (chapter 
14.1.7 for example, search for the SELECT syntax or examples. You'll 
find it at http://dev.mysql.com/doc/mysql/en/ ). You probably need a 
query that looks like this:

SELECT e_mail FROM your_table_name
WHERE discipleship_mailing_list_e_mail_subscription = on;
This will return all the requested e-mail adresses.
Having this information printed to a file could be reached by using the 
INTO OUTFILE form of SELECT. Again, check the mysql-manual. for the 
exact syntax, but you'll probably end up with somthing like:

SELECT e_mail INTO OUTFILE '/some/filename.text' FROM your_table_name
WHERE discipleship_mailing_list_e_mail_subscription = on;
There are a bunch of other options and solutions, though this seems the 
easiest one to me. Mind that if you try to do this in PHP (and trough a 
webserver), the webserver should have write-access to the file you 
specify with 'OUTFILE' - that might be a problem. Personally, I'd run 
this as some sort of batch script (using the mysql command line 
interface with the -e option, for example).

Hope this helps you along a bit.
Regards,
Guus der Kinderen
Ron Piggott wrote:
I have created a MySQL database.  The table I am creating is a subscriptions
database.  I want to be able to export all e-mail addresses stored in the
e_mail column into a plain text file on the web server (1 e-mail address
per row) where the discipleship_mailing_list_e_mail_subscription equals
on.  I am new at PHP and I am not sure how to do this yet.
My idea is that the user would click an UPDATE button and this action
would be performed.  Are any of you able to help me with this?
Thanks.  Ron
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] Re: Exporting Data From MySQL Using PHP

2004-08-09 Thread Ron Piggott

It is a problem having write access to the file.   This is what the online
mySQL manual says ...

The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected
rows to a file. The file is created on the server host, so you must have the
FILE privilege to use this syntax. The file cannot already exist, which
among other things prevents files such as `/etc/passwd' and database tables
from being destroyed. The SELECT ... INTO OUTFILE statement is intended
primarily to let you very quickly dump a table on the server machine. If you
want to create the resulting file on some client host other than the server
host, you can't use SELECT ... INTO OUTFILE. In that case, you should
instead use some command like mysql -e SELECT ...  file_name on the
client host to generate the file.

I need to go with another option.

Another person wrote me and suggested using the fopen(), fwrite() and
fclose() commands.  I haven't investigated this option yet.  You know when
you first learn to walk you do so by example ... I am still needing to know
which commands to look up and try to apply to my situation.  I have got some
PHP code to work ... I am far from done the project I am working on.

I was able to get the command:

SELECT e_mail
FROM subscriptionsdatabase
WHERE discipleship_mailing_list_e_mail_subscription
LIKE 'on'

to work in the mySQL command prompt but when I put it into a .PHP file I get
a parse error.  I get that parse error by simply coping and pasting the
command into the PHP file.

In more detail what I am trying to do and why I e-mailed out the question is
to wipe clean a mailing list data file and re-create the e-mail
subscriptions data file based on which people joined the list during the
week.

I am still learning mySQL ... The things you wrote helped me play ... I
didn't get too far in creating code, but I am learning at the same time.

Thanks for the advice.

Ron

- Original Message -
From: Guus der Kinderen [EMAIL PROTECTED]
Newsgroups: php.db
To: Ron Piggott [EMAIL PROTECTED]
Sent: Monday, August 09, 2004 7:22 PM
Subject: Re: Exporting Data From MySQL Using PHP


 Hello Ron,

 If I understand correctly, you're asking what query to execute (and how
 to put the result in a textfile) to get the results you want?

 The first part is described thorougly in the mysql-manual (chapter
 14.1.7 for example, search for the SELECT syntax or examples. You'll
 find it at http://dev.mysql.com/doc/mysql/en/ ). You probably need a
 query that looks like this:

 SELECT e_mail FROM your_table_name
 WHERE discipleship_mailing_list_e_mail_subscription = on;

 This will return all the requested e-mail adresses.

 Having this information printed to a file could be reached by using the
 INTO OUTFILE form of SELECT. Again, check the mysql-manual. for the
 exact syntax, but you'll probably end up with somthing like:

 SELECT e_mail INTO OUTFILE '/some/filename.text' FROM your_table_name
 WHERE discipleship_mailing_list_e_mail_subscription = on;

 There are a bunch of other options and solutions, though this seems the
 easiest one to me. Mind that if you try to do this in PHP (and trough a
 webserver), the webserver should have write-access to the file you
 specify with 'OUTFILE' - that might be a problem. Personally, I'd run
 this as some sort of batch script (using the mysql command line
 interface with the -e option, for example).

 Hope this helps you along a bit.

 Regards,

 Guus der Kinderen


 Ron Piggott wrote:

  I have created a MySQL database.  The table I am creating is a
subscriptions
  database.  I want to be able to export all e-mail addresses stored in
the
  e_mail column into a plain text file on the web server (1 e-mail
address
  per row) where the discipleship_mailing_list_e_mail_subscription
equals
  on.  I am new at PHP and I am not sure how to do this yet.
 
  My idea is that the user would click an UPDATE button and this action
  would be performed.  Are any of you able to help me with this?
 
  Thanks.  Ron



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



Re: [PHP-DB] Re: Exporting Data From MySQL Using PHP

2004-08-09 Thread Peter Ellis
It has been my experience that you sometimes need to do backquotes (`)
in MySQL queries when cutting/pasting into PHP -- it's the same key as
the tilde (~) on my keyboard.  Try:

$result = mysql_query(SELECT e_mail FROM subscriptionsdatabase WHERE
`discipleship_mailing_list_e_mail_subscription` LIKE 'on');

That should work.  I've always used the equal sign instead of LIKE, but
that seems to be a matter of preference.

Regarding the second part, with the fopen() and fwrite() commands,
that's certainly doable.  For example, you could do something like:

$handle = fopen(/home/blah/blah.txt, w);

$result = mysql_query(...);

if($result) {
  while($somevar = do mysql fetch from $result) {
fwrite($handle, $somevar);
  }

  ...
}

fclose($result);

Now, I realize that code is sort of a hack, but since I'm doing it
mostly on the fly, you'll forgive me my coding errors.  Take a look at
the Filesystem section of the PHP manual for information on the
fopen/fwrite() commands, and the MySQL section for more information on
MySQL commands in PHP.

Hope this helps a little more in solving the puzzle.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Mon, 2004-08-09 at 22:44 -0400, Ron Piggott wrote:
 It is a problem having write access to the file.   This is what the online
 mySQL manual says ...
 
 The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected
 rows to a file. The file is created on the server host, so you must have the
 FILE privilege to use this syntax. The file cannot already exist, which
 among other things prevents files such as `/etc/passwd' and database tables
 from being destroyed. The SELECT ... INTO OUTFILE statement is intended
 primarily to let you very quickly dump a table on the server machine. If you
 want to create the resulting file on some client host other than the server
 host, you can't use SELECT ... INTO OUTFILE. In that case, you should
 instead use some command like mysql -e SELECT ...  file_name on the
 client host to generate the file.
 
 I need to go with another option.
 
 Another person wrote me and suggested using the fopen(), fwrite() and
 fclose() commands.  I haven't investigated this option yet.  You know when
 you first learn to walk you do so by example ... I am still needing to know
 which commands to look up and try to apply to my situation.  I have got some
 PHP code to work ... I am far from done the project I am working on.
 
 I was able to get the command:
 
 SELECT e_mail
 FROM subscriptionsdatabase
 WHERE discipleship_mailing_list_e_mail_subscription
 LIKE 'on'
 
 to work in the mySQL command prompt but when I put it into a .PHP file I get
 a parse error.  I get that parse error by simply coping and pasting the
 command into the PHP file.
 
 In more detail what I am trying to do and why I e-mailed out the question is
 to wipe clean a mailing list data file and re-create the e-mail
 subscriptions data file based on which people joined the list during the
 week.
 
 I am still learning mySQL ... The things you wrote helped me play ... I
 didn't get too far in creating code, but I am learning at the same time.
 
 Thanks for the advice.
 
 Ron
 
 - Original Message -
 From: Guus der Kinderen [EMAIL PROTECTED]
 Newsgroups: php.db
 To: Ron Piggott [EMAIL PROTECTED]
 Sent: Monday, August 09, 2004 7:22 PM
 Subject: Re: Exporting Data From MySQL Using PHP
 
 
  Hello Ron,
 
  If I understand correctly, you're asking what query to execute (and how
  to put the result in a textfile) to get the results you want?
 
  The first part is described thorougly in the mysql-manual (chapter
  14.1.7 for example, search for the SELECT syntax or examples. You'll
  find it at http://dev.mysql.com/doc/mysql/en/ ). You probably need a
  query that looks like this:
 
  SELECT e_mail FROM your_table_name
  WHERE discipleship_mailing_list_e_mail_subscription = on;
 
  This will return all the requested e-mail adresses.
 
  Having this information printed to a file could be reached by using the
  INTO OUTFILE form of SELECT. Again, check the mysql-manual. for the
  exact syntax, but you'll probably end up with somthing like:
 
  SELECT e_mail INTO OUTFILE '/some/filename.text' FROM your_table_name
  WHERE discipleship_mailing_list_e_mail_subscription = on;
 
  There are a bunch of other options and solutions, though this seems the
  easiest one to me. Mind that if you try to do this in PHP (and trough a
  webserver), the webserver should have write-access to the file you
  specify with 'OUTFILE' - that might be a problem. Personally, I'd run
  this as some sort of batch script (using the mysql command line
  interface with the -e option, for example).
 
  Hope this helps you along a bit.
 
  Regards,
 
  Guus der Kinderen
 
 
  Ron Piggott wrote:
 
   I have created a MySQL database.  The table I am creating is a
 subscriptions
   database.  I want to be able to export all e-mail addresses stored 

Re: [PHP-DB] Re: Exporting Data From MySQL Using PHP

2004-08-09 Thread Peter Ellis
Whoops -- the fclose() statement refers to $result when it should refer
to $handle.  My bad for not at least spot checking the message before
hitting send!
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Mon, 2004-08-09 at 20:34 -0700, Peter Ellis wrote:
 It has been my experience that you sometimes need to do backquotes (`)
 in MySQL queries when cutting/pasting into PHP -- it's the same key as
 the tilde (~) on my keyboard.  Try:
 
 $result = mysql_query(SELECT e_mail FROM subscriptionsdatabase WHERE
 `discipleship_mailing_list_e_mail_subscription` LIKE 'on');
 
 That should work.  I've always used the equal sign instead of LIKE, but
 that seems to be a matter of preference.
 
 Regarding the second part, with the fopen() and fwrite() commands,
 that's certainly doable.  For example, you could do something like:
 
 $handle = fopen(/home/blah/blah.txt, w);
 
 $result = mysql_query(...);
 
 if($result) {
   while($somevar = do mysql fetch from $result) {
 fwrite($handle, $somevar);
   }
 
   ...
 }
 
 fclose($result);
 
 Now, I realize that code is sort of a hack, but since I'm doing it
 mostly on the fly, you'll forgive me my coding errors.  Take a look at
 the Filesystem section of the PHP manual for information on the
 fopen/fwrite() commands, and the MySQL section for more information on
 MySQL commands in PHP.
 
 Hope this helps a little more in solving the puzzle.
 -- 
 Peter Ellis - [EMAIL PROTECTED]
 Web Design and Development Consultant
 naturalaxis | http://www.naturalaxis.com/
 
 On Mon, 2004-08-09 at 22:44 -0400, Ron Piggott wrote:
  It is a problem having write access to the file.   This is what the online
  mySQL manual says ...
  
  The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected
  rows to a file. The file is created on the server host, so you must have the
  FILE privilege to use this syntax. The file cannot already exist, which
  among other things prevents files such as `/etc/passwd' and database tables
  from being destroyed. The SELECT ... INTO OUTFILE statement is intended
  primarily to let you very quickly dump a table on the server machine. If you
  want to create the resulting file on some client host other than the server
  host, you can't use SELECT ... INTO OUTFILE. In that case, you should
  instead use some command like mysql -e SELECT ...  file_name on the
  client host to generate the file.
  
  I need to go with another option.
  
  Another person wrote me and suggested using the fopen(), fwrite() and
  fclose() commands.  I haven't investigated this option yet.  You know when
  you first learn to walk you do so by example ... I am still needing to know
  which commands to look up and try to apply to my situation.  I have got some
  PHP code to work ... I am far from done the project I am working on.
  
  I was able to get the command:
  
  SELECT e_mail
  FROM subscriptionsdatabase
  WHERE discipleship_mailing_list_e_mail_subscription
  LIKE 'on'
  
  to work in the mySQL command prompt but when I put it into a .PHP file I get
  a parse error.  I get that parse error by simply coping and pasting the
  command into the PHP file.
  
  In more detail what I am trying to do and why I e-mailed out the question is
  to wipe clean a mailing list data file and re-create the e-mail
  subscriptions data file based on which people joined the list during the
  week.
  
  I am still learning mySQL ... The things you wrote helped me play ... I
  didn't get too far in creating code, but I am learning at the same time.
  
  Thanks for the advice.
  
  Ron

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



Re: [PHP-DB] Re: Exporting Data From MySQL Using PHP

2004-08-09 Thread Jason Wong
On Tuesday 10 August 2004 11:34, Peter Ellis wrote:

 It has been my experience that you sometimes need to do backquotes (`)
 in MySQL queries when cutting/pasting into PHP -- it's the same key as
 the tilde (~) on my keyboard.  Try:

 $result = mysql_query(SELECT e_mail FROM subscriptionsdatabase WHERE
 `discipleship_mailing_list_e_mail_subscription` LIKE 'on');

The backticks (`) are only needed if:

(a) your column names uses (MySQL) reserved words (eg names of the builtin 
functions etc)

(b) you have spaces in your column names

Both (a) and (b) are rather bad and shouldn't really be used. Just use 
'friendly' column names and backticks will not be necessary.

 That should work.  I've always used the equal sign instead of LIKE, but
 that seems to be a matter of preference.

It is not a matter of preference, = and LIKE have different purposes. Refer to 
manual and/or some SQL tutorial for details.

-- 
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
--
/*
Why won't you let me kiss you goodnight?  Is it something I said?
-- Tom Ryan
*/

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



[PHP-DB] Re: Exporting Data From MySQL Using PHP

2004-08-09 Thread Guus der Kinderen
Ron Piggott wrote:
 I was able to get the command:

 SELECT e_mail
 FROM subscriptionsdatabase
 WHERE discipleship_mailing_list_e_mail_subscription
 LIKE 'on'

 to work in the mySQL command prompt but when I put it into a .PHP 
file I get
 a parse error.  I get that parse error by simply coping and pasting the
 command into the PHP file.

The reason that this didn't work is that you have to tell PHP first to 
create a link with your database, then execute a query and get back the 
results by issuing a few specific commands. Robby's example shows you 
how, but it's more thorougly explained in the php documentation. Have a 
look at http://www.php.net/manual/en/ref.mysql.php and its subpages. It 
has examples and explanations you'll find very useful in setting up PHP 
to work with a MySQL database.

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


Re: [PHP-DB] Re: Exporting Data From MySQL Using PHP

2004-08-09 Thread Peter Ellis
It seems to me that, at least in terms of consistency, using backticks
isn't a bad idea.  After all, if you look at any current version of
phpMyAdmin that generates PHP selection code, it uses backticks
constantly.  I take your point, but it seems to me like it's a good
habit no matter what.  Perhaps that's more a matter of semantics than
PHP programming itself :)

As for the difference between = and LIKE, you are correct -- I just
don't typically use LIKE for any of my database work, so I forget
there's a difference every once in a while :)  Thank you for the
reminder.
-- 
Peter Ellis - [EMAIL PROTECTED]
Web Design and Development Consultant
naturalaxis | http://www.naturalaxis.com/

On Tue, 2004-08-10 at 12:33 +0800, Jason Wong wrote:
 On Tuesday 10 August 2004 11:34, Peter Ellis wrote:
 
  It has been my experience that you sometimes need to do backquotes (`)
  in MySQL queries when cutting/pasting into PHP -- it's the same key as
  the tilde (~) on my keyboard.  Try:
 
  $result = mysql_query(SELECT e_mail FROM subscriptionsdatabase WHERE
  `discipleship_mailing_list_e_mail_subscription` LIKE 'on');
 
 The backticks (`) are only needed if:
 
 (a) your column names uses (MySQL) reserved words (eg names of the builtin 
 functions etc)
 
 (b) you have spaces in your column names
 
 Both (a) and (b) are rather bad and shouldn't really be used. Just use 
 'friendly' column names and backticks will not be necessary.
 
  That should work.  I've always used the equal sign instead of LIKE, but
  that seems to be a matter of preference.
 
 It is not a matter of preference, = and LIKE have different purposes. Refer to 
 manual and/or some SQL tutorial for details.
 
 -- 
 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
 --
 /*
 Why won't you let me kiss you goodnight?  Is it something I said?
   -- Tom Ryan
 */

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



[PHP-DB] Re: Posting Data to MySQL

2004-06-24 Thread Torsten Roehr
Tom Chubb [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am trying to design a form that posts the data to a DB, but being new to
 PHP/MySQL, it takes me ages to hand write the code and I'm sure there must
 be an easier way to do it?
 My form has 100 fields using 20 rows and 5 columns and it's taking me ages
 to write the code for it.
 Can anyone advise how they code large forms like that and if you know of
any
 software to make it easier?
 I've searched Google for hours and checked loads of Database scripts on
 sites like Hotscripts, but can't find anything.

Hi Tom,

that's a lot of information to display on one page. Can you split it up into
several forms? Of course this would not mean fewer work but maybe make it a
bit mor concise.

Regards, Torsten Roehr

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



RE: [PHP-DB] Re: Posting Data to MySQL

2004-06-24 Thread Galbreath, Mark A
Doesn't matter how many fields are on a form; they are returned as an array
of strings in the request object.  Just iterate through the array and update
the corresponding database fields.

Mark

-Original Message-
From: Torsten Roehr [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 24, 2004 10:02 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Re: Posting Data to MySQL


Tom Chubb [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I am trying to design a form that posts the data to a DB, but being new to
 PHP/MySQL, it takes me ages to hand write the code and I'm sure there must
 be an easier way to do it?
 My form has 100 fields using 20 rows and 5 columns and it's taking me ages
 to write the code for it.
 Can anyone advise how they code large forms like that and if you know of
any
 software to make it easier?
 I've searched Google for hours and checked loads of Database scripts on
 sites like Hotscripts, but can't find anything.

Hi Tom,

that's a lot of information to display on one page. Can you split it up into
several forms? Of course this would not mean fewer work but maybe make it a
bit mor concise.

Regards, Torsten Roehr

-- 
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] Re: Posting Data to MySQL

2004-06-24 Thread Torsten Roehr
Mark A Galbreath [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Doesn't matter how many fields are on a form; they are returned as an
array
 of strings in the request object.  Just iterate through the array and
update
 the corresponding database fields.

Mark, what I was trying to say was that having 100 form elements on one page
is quite a lot of information to comprehend for the user. And if each form
element has a different name you cannot just handle the data as an array.
You have to address each value individually.

Regards, Torsten

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



[PHP-DB] Re: Retrieve data from a table, edit/add it and enter it in a new table

2004-06-13 Thread franciccio
I see one bug in your code , that is you never rewind the pointer of
mysql_fetch_array($result), so at the end of the first cycle ...while
($r=mysq...)... the pointer is at the end of the query resource. You should
use mysql_data_seek($result,0) to rewind before doing another while cycle.
Hope it can help

Bye

Francesco Basile (PHP_newbee)

Justin [EMAIL PROTECTED] ha scritto nel messaggio
news:[EMAIL PROTECTED]
Hi,

I am trying to do the following:

Retrieve some information from a table, edit it by appending some further
information to it (a few more fields) and then enter the new data record
into a new table, and delete the old data in the original table. Sounds
confusing I know.

The code is below (I apologise for its poor style etc as I am very new to
php), but when I click on the  'Enter Information' button, nothing happens.
The existing data is retrieved without any problems and I can select it
using the radio button. But when I try and add data to the new fields
('option_close_price' and 'notes'), nothing happens.

Any help appreciated.


form action=? echo $PHP_SELF ? method=post
?
mysql_pconnect(localhost,root,password);
mysql_select_db(options);
if(!$cmd)
{
$result = mysql_query(select * from open_trades);
while($r=mysql_fetch_array($result))
{
$open_date=$r[open_date];
$share=$r[share];
$code=$r[code];
$short_long_trade=$r[short_long_trade];
$id=$r[id];
$expiry=$r[expiry];
$exercise=$r[excercise];
$option_price=$r[option_price];
$no_purchased=$r[no_purchased];
$no_sold=$r[no_sold];
$income_in=$r[income_in];
$income_out=$r[income_out];

print table border=\1\ cellpadding=\3\ cellspacing=\0\\n;
print td/tdtdOpen Date/tdtdShare/tdtdCode/tdtdShort
orbr Long Trade/tdtdExpiry/tdtdExcercise/tdtdOption
Price/tdtdNumberbr Purchased/tdtdNumber Sold/tdtdIncome
In/tdtdIncome Out/tdtd
/tr;

while ($row = mysql_fetch_array($result))

{
print trtd;
print INPUT TYPE='RADIO' NAME='id' VALUE='echo $id';
print /tdtd;
print $row[open_date];
print /tdtd;
print $row[share];
print /tdtd;
print $row[code];
print /tdtd;
print $row[short_long_trade];
print /tdtd;
print $row[expiry];
print /tdtd;
print $row[excercise];
print /tdtd;
print $row[option_price];
print /tdtd;
print $row[no_purchased];
print /tdtd;
print $row[no_sold];
print /tdtd;
print $row[income_in];
print /tdtd;
print $row[income_out];
print /td/tr\n;
}
print /table\n;

?

? }?
input type=submit name=cmd value=Close/form

? }
 ?

?

if($cmd==Close)
{
if (!$submit)
{



$result = mysql_query(select * from open_trades);
while($myrow=mysql_fetch_array($result))
?


input type=hidden name=id value=?php echo $myrow[id] ?

Option Close PriceINPUT TYPE=TEXT NAME=option_close_price VALUE=?PHP
echo $myrow[option_close_price]? SIZE=7 br
Notes:INPUT TYPE=TEXT NAME=notes VALUE=?php echo $myrow[notes] ?
SIZE=60br
input type=hidden name=cmd value=edit
input type=Submit name=submit value=Enter information
/form
? } ?



?
if($submit)
{

$query = INSERT INTO closed_trades SET code='$code',
option_price='$option_price', option_close_price='$option_close_price',
no_sold='$no_sold', open_date='$open_date',
short_long_trade='$short_long_trade, share='$share', expiry='$expiry',
excercise='$excercise', no_purchased='$no_purchased',
income_in='$income_in', income_out='$income_out', notes='$notes', id=$id';
$result = mysql_query($ql);

  $query = DELETE FROM open_trades WHERE id=$id;
  $result = mysql_query($sql);


echo Thank you! Information updated.;

}
}
?
/td
   /table

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



[PHP-DB] Re: Getting data from mysql db for html form

2004-06-10 Thread Gawie Marais
works like a bomb !!!

thanx man !



Torsten Roehr [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Gamco - Gawie Marais [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Hi,
 
  Could someone help me out here...
 
  I have a mysql database with a table that conatains names. I am setting
up
 a
  html form and I would like to create a multi-listing with those names so
  that you can choose one and then submit the form.


 // open db connection...

 $result = mysql_query(SELECT name FROM table);

 echo 'select name=names';

 while ($row = mysql_fetch_assoc($result)) {

 echo 'option' . $row['name'] . '/option';
 }

 echo '/select';

 Haven't tested it. Change 'name' to the name of your table column.

 Regards,

 Torsten Roehr

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



[PHP-DB] Re: Getting data from mysql db for html form

2004-06-09 Thread Torsten Roehr
Gamco - Gawie Marais [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi,

 Could someone help me out here...

 I have a mysql database with a table that conatains names. I am setting up
a
 html form and I would like to create a multi-listing with those names so
 that you can choose one and then submit the form.


// open db connection...

$result = mysql_query(SELECT name FROM table);

echo 'select name=names';

while ($row = mysql_fetch_assoc($result)) {

echo 'option' . $row['name'] . '/option';
}

echo '/select';

Haven't tested it. Change 'name' to the name of your table column.

Regards,

Torsten Roehr

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



[PHP-DB] Re: Dynamic Data

2004-06-07 Thread Justin Patrin
Christopher J. Crane wrote:
What is the best way to produce a report listing the fieldname and then the
data in that field. It is a report containing only one row from a table, but
I don't want to hard code the fields since they change often.
I can get the field names dynamically like this:
$fields = mysql_list_fields(Network, Subnets);
$num_columns = mysql_num_fields($fields);
for($ i = 0; $i  $num_columns; $i++) { echo mysql_field_name($fields,
$i); }
now is where I get confusedwhat I would like to happen is do a query on
a single row and put the results into mysql_fetch_assoc and during the prior
loop put the column name into the loop of the data. Something like:
$fields = mysql_list_fields(Network, Subnets);
$num_columns = mysql_num_fields($fields);
$result  =  mysql_query(SELECT * FROM table1 WHERE ID = '$ID';
$field = mysql_fetch_assoc($result)
for($ i = 0; $i  $num_columns; $i++) {
echo b . mysql_field_name($fields, $i) . : /b .
$field[mysql_field_name($fields, $i)] . br\n;
All you really need here is:
$sth = mysql_query(SELECT * FROM table1 WHERE ID = '$ID');
$rec = mysql_fetch_assoc($sth);
foreach($rec as $field = $value) {
  echo 'b'.$field.': /b'.$value.'br/';
}
--
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 into database!

2004-05-14 Thread Torsten Roehr
Ronald Allen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Two questions?
 First why am I getting  undefined variable tmp , yet it works
 Second how would I insert data into this table?
 ?
 $db_table = 'log';
 $conn = mysql_connect($db_host,$db_user,$db_pass);

 if ($conn == true) {
   mysql_select_db($db_name,$conn);
   $result = mysql_query(SELECT * from $db_table,$conn);
 while($row = mysql_fetch_object($result)) {
 $tmp .= ID   : $row-ID   br\n;
 $tmp .= Base : $row-Base br\n;
 $tmp .= Date_and_Time  : $row-Date_and_Time   br\n;
 $tmp .= Event_Type : $row-Event_Type br\n;
 $tmp .= Description : $row-Description br\n;
 $tmp .= Initials : $row-Initials brhr\n;
 }
 } else {
 echo 'could not connect to database : '. mysql_error();
 }
 print $tmp;
 ?

You have to initialize $temp before using it with '.='
$temp = '';
$temp .= 'my string';

Or just set the first line with =
$tmp = ID   : $row-ID   br\n;
$tmp .= Base : $row-Base br\n;
$tmp .= Date_and_Time  : $row-Date_and

Your insert should look like this (if ID is an auto-increment field):
$insert = INSERT INTO $db_table SET ;
$insert .= Base = ' . $row-Base . ', ;
$insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
$insert .= Event_Type = ' . $row-Event_Type . ', ;
$insert .= Description = ' . $row-Description . ', ;
$insert .= Initials = ' . $row-Initials . ';

mysql_query($insert, $conn);

Hope this helps,

Regards, Torsten

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



[PHP-DB] Re: inserting data into database!

2004-05-14 Thread Ronald Allen
Here is my code now, but I am getting a parsing error

Parse error: parse error, unexpected $end

$db_table = 'log';

$conn = mysql_connect($db_host,$db_user,$db_pass);

if ($conn == true) {

$insert = INSERT INTO $db_table SET ;

$insert .= Base = ' . $row-Base . ', ;

$insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;

$insert .= Event_Type = ' . $row-Event_Type . ', ;

$insert .= Description = ' . $row-Description . ', ;

$insert .= Initials = ' . $row-Initials . ';

mysql_query($insert, $conn);

?

Torsten Roehr [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Ronald Allen [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Two questions?
  First why am I getting  undefined variable tmp , yet it works
  Second how would I insert data into this table?
  ?
  $db_table = 'log';
  $conn = mysql_connect($db_host,$db_user,$db_pass);
 
  if ($conn == true) {
mysql_select_db($db_name,$conn);
$result = mysql_query(SELECT * from $db_table,$conn);
  while($row = mysql_fetch_object($result)) {
  $tmp .= ID   : $row-ID   br\n;
  $tmp .= Base : $row-Base br\n;
  $tmp .= Date_and_Time  : $row-Date_and_Time   br\n;
  $tmp .= Event_Type : $row-Event_Type br\n;
  $tmp .= Description : $row-Description br\n;
  $tmp .= Initials : $row-Initials brhr\n;
  }
  } else {
  echo 'could not connect to database : '. mysql_error();
  }
  print $tmp;
  ?

 You have to initialize $temp before using it with '.='
 $temp = '';
 $temp .= 'my string';

 Or just set the first line with =
 $tmp = ID   : $row-ID   br\n;
 $tmp .= Base : $row-Base br\n;
 $tmp .= Date_and_Time  : $row-Date_and

 Your insert should look like this (if ID is an auto-increment field):
 $insert = INSERT INTO $db_table SET ;
 $insert .= Base = ' . $row-Base . ', ;
 $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
 $insert .= Event_Type = ' . $row-Event_Type . ', ;
 $insert .= Description = ' . $row-Description . ', ;
 $insert .= Initials = ' . $row-Initials . ';

 mysql_query($insert, $conn);

 Hope this helps,

 Regards, Torsten

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



Re: [PHP-DB] Re: inserting data into database!

2004-05-14 Thread dpgirago
 Here is my code now, but I am getting a parsing error

 Parse error: parse error, unexpected $end

 $db_table = 'log';

 $conn = mysql_connect($db_host,$db_user,$db_pass);

 if ($conn == true) {

 $insert = INSERT INTO $db_table SET ;

 $insert .= Base = ' . $row-Base . ', ;

 $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;

 $insert .= Event_Type = ' . $row-Event_Type . ', ;

 $insert .= Description = ' . $row-Description . ', ;

  $insert .= Initials = ' . $row-Initials . ';

 mysql_query($insert, $conn);

?

If this is the actual code, you are missing a closing brace at the end of 
the block.

dave


[PHP-DB] Re: inserting data into database!

2004-05-14 Thread Ronald Allen
Now that I closed the bracket
 it tells me that $row is not defined.
I have plagiarized from a couple of different places to come up with my code
so that is the reason that it may not work that well.  Here is my code right
now

$conn = mysql_connect($db_host,$db_user,$db_pass);
if ($conn == true) {
 $insert = INSERT INTO $db_table SET ;
$insert .= Base = ' . $row-Base . ', ;
$insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
$insert .= Event_Type = ' . $row-Event_Type . ', ;
$insert .= Description = ' . $row-Description . ', ;
$insert .= Initials = ' . $row-Initials . ';

mysql_query($insert, $conn);

}
?
Ronald Allen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Here is my code now, but I am getting a parsing error

 Parse error: parse error, unexpected $end

 $db_table = 'log';

 $conn = mysql_connect($db_host,$db_user,$db_pass);

 if ($conn == true) {

 $insert = INSERT INTO $db_table SET ;

 $insert .= Base = ' . $row-Base . ', ;

 $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;

 $insert .= Event_Type = ' . $row-Event_Type . ', ;

 $insert .= Description = ' . $row-Description . ', ;

 $insert .= Initials = ' . $row-Initials . ';

 mysql_query($insert, $conn);

 ?

 Torsten Roehr [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Ronald Allen [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   Two questions?
   First why am I getting  undefined variable tmp , yet it works
   Second how would I insert data into this table?
   ?
   $db_table = 'log';
   $conn = mysql_connect($db_host,$db_user,$db_pass);
  
   if ($conn == true) {
 mysql_select_db($db_name,$conn);
 $result = mysql_query(SELECT * from $db_table,$conn);
   while($row = mysql_fetch_object($result)) {
   $tmp .= ID   : $row-ID   br\n;
   $tmp .= Base : $row-Base br\n;
   $tmp .= Date_and_Time  : $row-Date_and_Time   br\n;
   $tmp .= Event_Type : $row-Event_Type br\n;
   $tmp .= Description : $row-Description br\n;
   $tmp .= Initials : $row-Initials brhr\n;
   }
   } else {
   echo 'could not connect to database : '. mysql_error();
   }
   print $tmp;
   ?
 
  You have to initialize $temp before using it with '.='
  $temp = '';
  $temp .= 'my string';
 
  Or just set the first line with =
  $tmp = ID   : $row-ID   br\n;
  $tmp .= Base : $row-Base br\n;
  $tmp .= Date_and_Time  : $row-Date_and
 
  Your insert should look like this (if ID is an auto-increment field):
  $insert = INSERT INTO $db_table SET ;
  $insert .= Base = ' . $row-Base . ', ;
  $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
  $insert .= Event_Type = ' . $row-Event_Type . ', ;
  $insert .= Description = ' . $row-Description . ', ;
  $insert .= Initials = ' . $row-Initials . ';
 
  mysql_query($insert, $conn);
 
  Hope this helps,
 
  Regards, Torsten

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



RE: [PHP-DB] Re: inserting data into database!

2004-05-14 Thread Hutchins, Richard
Have you declared a new instance of the db class anywhere on your page?



 -Original Message-
 From: Ronald Allen [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 14, 2004 4:13 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Re: inserting data into database!
 
 
 Now that I closed the bracket
  it tells me that $row is not defined.
 I have plagiarized from a couple of different places to come 
 up with my code
 so that is the reason that it may not work that well.  Here 
 is my code right
 now
 
 $conn = mysql_connect($db_host,$db_user,$db_pass);
 if ($conn == true) {
  $insert = INSERT INTO $db_table SET ;
 $insert .= Base = ' . $row-Base . ', ;
 $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
 $insert .= Event_Type = ' . $row-Event_Type . ', ;
 $insert .= Description = ' . $row-Description . ', ;
 $insert .= Initials = ' . $row-Initials . ';
 
 mysql_query($insert, $conn);
 
 }
 ?
 Ronald Allen [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Here is my code now, but I am getting a parsing error
 
  Parse error: parse error, unexpected $end
 
  $db_table = 'log';
 
  $conn = mysql_connect($db_host,$db_user,$db_pass);
 
  if ($conn == true) {
 
  $insert = INSERT INTO $db_table SET ;
 
  $insert .= Base = ' . $row-Base . ', ;
 
  $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
 
  $insert .= Event_Type = ' . $row-Event_Type . ', ;
 
  $insert .= Description = ' . $row-Description . ', ;
 
  $insert .= Initials = ' . $row-Initials . ';
 
  mysql_query($insert, $conn);
 
  ?
 
  Torsten Roehr [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   Ronald Allen [EMAIL PROTECTED] wrote in message
   news:[EMAIL PROTECTED]
Two questions?
First why am I getting  undefined variable tmp , yet it works
Second how would I insert data into this table?
?
$db_table = 'log';
$conn = mysql_connect($db_host,$db_user,$db_pass);
   
if ($conn == true) {
  mysql_select_db($db_name,$conn);
  $result = mysql_query(SELECT * from $db_table,$conn);
while($row = mysql_fetch_object($result)) {
$tmp .= ID   : $row-ID   br\n;
$tmp .= Base : $row-Base br\n;
$tmp .= Date_and_Time  : $row-Date_and_Time   br\n;
$tmp .= Event_Type : $row-Event_Type br\n;
$tmp .= Description : $row-Description br\n;
$tmp .= Initials : $row-Initials brhr\n;
}
} else {
echo 'could not connect to database : '. mysql_error();
}
print $tmp;
?
  
   You have to initialize $temp before using it with '.='
   $temp = '';
   $temp .= 'my string';
  
   Or just set the first line with =
   $tmp = ID   : $row-ID   br\n;
   $tmp .= Base : $row-Base br\n;
   $tmp .= Date_and_Time  : $row-Date_and
  
   Your insert should look like this (if ID is an 
 auto-increment field):
   $insert = INSERT INTO $db_table SET ;
   $insert .= Base = ' . $row-Base . ', ;
   $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
   $insert .= Event_Type = ' . $row-Event_Type . ', ;
   $insert .= Description = ' . $row-Description . ', ;
   $insert .= Initials = ' . $row-Initials . ';
  
   mysql_query($insert, $conn);
  
   Hope this helps,
  
   Regards, Torsten
 
 -- 
 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] Re: inserting data into database!

2004-05-14 Thread Hutchins, Richard
...or whatever class contains $row- functionality?




 -Original Message-
 From: Ronald Allen [mailto:[EMAIL PROTECTED]
 Sent: Friday, May 14, 2004 4:13 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP-DB] Re: inserting data into database!
 
 
 Now that I closed the bracket
  it tells me that $row is not defined.
 I have plagiarized from a couple of different places to come 
 up with my code
 so that is the reason that it may not work that well.  Here 
 is my code right
 now
 
 $conn = mysql_connect($db_host,$db_user,$db_pass);
 if ($conn == true) {
  $insert = INSERT INTO $db_table SET ;
 $insert .= Base = ' . $row-Base . ', ;
 $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
 $insert .= Event_Type = ' . $row-Event_Type . ', ;
 $insert .= Description = ' . $row-Description . ', ;
 $insert .= Initials = ' . $row-Initials . ';
 
 mysql_query($insert, $conn);
 
 }
 ?
 Ronald Allen [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Here is my code now, but I am getting a parsing error
 
  Parse error: parse error, unexpected $end
 
  $db_table = 'log';
 
  $conn = mysql_connect($db_host,$db_user,$db_pass);
 
  if ($conn == true) {
 
  $insert = INSERT INTO $db_table SET ;
 
  $insert .= Base = ' . $row-Base . ', ;
 
  $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
 
  $insert .= Event_Type = ' . $row-Event_Type . ', ;
 
  $insert .= Description = ' . $row-Description . ', ;
 
  $insert .= Initials = ' . $row-Initials . ';
 
  mysql_query($insert, $conn);
 
  ?
 
  Torsten Roehr [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   Ronald Allen [EMAIL PROTECTED] wrote in message
   news:[EMAIL PROTECTED]
Two questions?
First why am I getting  undefined variable tmp , yet it works
Second how would I insert data into this table?
?
$db_table = 'log';
$conn = mysql_connect($db_host,$db_user,$db_pass);
   
if ($conn == true) {
  mysql_select_db($db_name,$conn);
  $result = mysql_query(SELECT * from $db_table,$conn);
while($row = mysql_fetch_object($result)) {
$tmp .= ID   : $row-ID   br\n;
$tmp .= Base : $row-Base br\n;
$tmp .= Date_and_Time  : $row-Date_and_Time   br\n;
$tmp .= Event_Type : $row-Event_Type br\n;
$tmp .= Description : $row-Description br\n;
$tmp .= Initials : $row-Initials brhr\n;
}
} else {
echo 'could not connect to database : '. mysql_error();
}
print $tmp;
?
  
   You have to initialize $temp before using it with '.='
   $temp = '';
   $temp .= 'my string';
  
   Or just set the first line with =
   $tmp = ID   : $row-ID   br\n;
   $tmp .= Base : $row-Base br\n;
   $tmp .= Date_and_Time  : $row-Date_and
  
   Your insert should look like this (if ID is an 
 auto-increment field):
   $insert = INSERT INTO $db_table SET ;
   $insert .= Base = ' . $row-Base . ', ;
   $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
   $insert .= Event_Type = ' . $row-Event_Type . ', ;
   $insert .= Description = ' . $row-Description . ', ;
   $insert .= Initials = ' . $row-Initials . ';
  
   mysql_query($insert, $conn);
  
   Hope this helps,
  
   Regards, Torsten
 
 -- 
 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] Re: inserting data into database!

2004-05-14 Thread Chris Berlioz
Go to PHP.net, books @ bookstore.

Seems like you are trying to insert data from an array into a MySQL table, I
would visit http://dev.mysql.com/doc/mysql/en/index.html site too.

Good luck.

===


Ronald The Newbie Allen [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 I have no idea what a class is .  I really am a newbie.  After you guys
help
 me with this what is a good place to start with learning PHP?

 Richard Hutchins [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  ...or whatever class contains $row- functionality?
 
 
 
 
   -Original Message-
   From: Ronald Allen [mailto:[EMAIL PROTECTED]
   Sent: Friday, May 14, 2004 4:13 PM
   To: [EMAIL PROTECTED]
   Subject: [PHP-DB] Re: inserting data into database!
  
  
   Now that I closed the bracket
it tells me that $row is not defined.
   I have plagiarized from a couple of different places to come
   up with my code
   so that is the reason that it may not work that well.  Here
   is my code right
   now
  
   $conn = mysql_connect($db_host,$db_user,$db_pass);
   if ($conn == true) {
$insert = INSERT INTO $db_table SET ;
   $insert .= Base = ' . $row-Base . ', ;
   $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
   $insert .= Event_Type = ' . $row-Event_Type . ', ;
   $insert .= Description = ' . $row-Description . ', ;
   $insert .= Initials = ' . $row-Initials . ';
  
   mysql_query($insert, $conn);
  
   }
   ?
   Ronald Allen [EMAIL PROTECTED] wrote in message
   news:[EMAIL PROTECTED]
Here is my code now, but I am getting a parsing error
   
Parse error: parse error, unexpected $end
   
$db_table = 'log';
   
$conn = mysql_connect($db_host,$db_user,$db_pass);
   
if ($conn == true) {
   
$insert = INSERT INTO $db_table SET ;
   
$insert .= Base = ' . $row-Base . ', ;
   
$insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
   
$insert .= Event_Type = ' . $row-Event_Type . ', ;
   
$insert .= Description = ' . $row-Description . ', ;
   
$insert .= Initials = ' . $row-Initials . ';
   
mysql_query($insert, $conn);
   
?
   
Torsten Roehr [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Ronald Allen [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Two questions?
  First why am I getting  undefined variable tmp , yet it works
  Second how would I insert data into this table?
  ?
  $db_table = 'log';
  $conn = mysql_connect($db_host,$db_user,$db_pass);
 
  if ($conn == true) {
mysql_select_db($db_name,$conn);
$result = mysql_query(SELECT * from $db_table,$conn);
  while($row = mysql_fetch_object($result)) {
  $tmp .= ID   : $row-ID   br\n;
  $tmp .= Base : $row-Base br\n;
  $tmp .= Date_and_Time  : $row-Date_and_Time   br\n;
  $tmp .= Event_Type : $row-Event_Type br\n;
  $tmp .= Description : $row-Description br\n;
  $tmp .= Initials : $row-Initials brhr\n;
  }
  } else {
  echo 'could not connect to database : '. mysql_error();
  }
  print $tmp;
  ?

 You have to initialize $temp before using it with '.='
 $temp = '';
 $temp .= 'my string';

 Or just set the first line with =
 $tmp = ID   : $row-ID   br\n;
 $tmp .= Base : $row-Base br\n;
 $tmp .= Date_and_Time  : $row-Date_and

 Your insert should look like this (if ID is an
   auto-increment field):
 $insert = INSERT INTO $db_table SET ;
 $insert .= Base = ' . $row-Base . ', ;
 $insert .= Date_and_Time = ' . $row-Date_and_Time . ', ;
 $insert .= Event_Type = ' . $row-Event_Type . ', ;
 $insert .= Description = ' . $row-Description . ', ;
 $insert .= Initials = ' . $row-Initials . ';

 mysql_query($insert, $conn);

 Hope this helps,

 Regards, Torsten
  
   -- 
   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



[PHP-DB] Re: finding data

2004-04-15 Thread pete M
the way I would do this is with count()

$row = mysql_fetch_assoc(SELECT count(*) as c FROM bivalues WHERE 
myvalue = '$zchar')

if ($row['c']  0)
{
echo 'result 2 - found it'
}else{
echo 'NOT found'
}
hope it helps
Pete

Douglas D Hull wrote:

I am trying to find data, or if not found set a variable to Err.  myvalue being a variable in my database and $zchar being my value to find.

The following result is never 1 even if no values were found, so the result is always 
2.  If the finding value does exist in my database this does find the correct value:
if (!$result = mysql_query(SELECT * FROM bivalues WHERE myvalue = '$zchar'))
{
echo 'result 1 - not found';
$myresut = Err;
}
else
{
{echo 'result 2 - found it'
}
The following result is never 2 even if the value actually exist in my database, so 
the result is always 1:
if (!$result = mysql_query(SELECT * FROM bivalues WHERE myvalue = $zchar))
{
echo 'result 1 - not found';
$myresult = Err;
}
else
{
{echo 'result 2 - found it'
}
Thanks for any help,
Doug
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Re: finding data

2004-04-15 Thread Mikael Grön
The way I would do it:

$result = mysql_query(select * from bivalues WHERE myvalue - '$zchar');
if (mysql_num_rows($result) {
echo Result 2 - found it;
} else {
echo Not found;
}
This leaves you with the option to start processing the data as soon as 
error checking is over. Using Count, you'll have to re-retrieve the 
data from the database, which takes twice as long time as doing it only 
once.. (or thereabout).

The problem you had is that no matter if the query presents results or 
not, the result variable is only set to 0 (thus the !$result syntax 
gives results) when there's been an error in the mysql query. Simply an 
empty table will not return an error!

Mike

On Apr 15, 2004, at 16:54, pete M wrote:

the way I would do this is with count()

$row = mysql_fetch_assoc(SELECT count(*) as c FROM bivalues WHERE 
myvalue = '$zchar')

if ($row['c']  0)
{
echo 'result 2 - found it'
}else{
echo 'NOT found'
}
hope it helps
Pete

Douglas D Hull wrote:

I am trying to find data, or if not found set a variable to Err.  
myvalue being a variable in my database and $zchar being my value to 
find.
The following result is never 1 even if no values were found, so the 
result is always 2.  If the finding value does exist in my database 
this does find the correct value:
if (!$result = mysql_query(SELECT * FROM bivalues WHERE myvalue = 
'$zchar'))
{
echo 'result 1 - not found';
$myresut = Err;
}
else
{
{echo 'result 2 - found it'
}
The following result is never 2 even if the value actually exist in 
my database, so the result is always 1:
if (!$result = mysql_query(SELECT * FROM bivalues WHERE myvalue = 
$zchar))
{
echo 'result 1 - not found';
$myresult = Err;
}
else
{
{echo 'result 2 - found it'
}
Thanks for any help,
Doug
--
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


[PHP-DB] Re: insert data in mysql table

2004-04-11 Thread Andy Ladouceur
From what I can see, the order that you created the table with and the 
order of the fields in the query do not match up. Changing the query to:

$add_all = INSERT INTO $table 
values('','$name','$day','$question','$email','');

Should make things run just fine.

Cheers,
Andy
Charalambos Nicolaou wrote:

Hi everyone ,

I have created this Mysql table

CREATE TABLE questions (ID INT NOT NULL AUTO_INCREMENT, name 
VARCHAR(25), day DATE, question TEXT, email VARCHAR(30), PRIMARY KEY(ID));

And I am trying to insert data in it using the following

body

?
if(isset($_GET['commented']))
{
echo(Your comment has been posted.);

$host = ;
$user = **;
$pass = *;
$db = **;
$table = questions;
$name = $_GET['form_uname'];
$question = $_GET['form_quest'];
$day = $_GET['form_day'];
$email = $_GET['from_email'];
mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
$add_all = INSERT INTO $table 
values('$name','$question','$day','$email','');
mysql_query($add_all) or die(mysql_error());
}
else
{
?
form method=get action=? echo $PHP_SELF  ; ? 
Name : input type=text name=form_uname
pQuestion :textarea rows=3 name=form_quest cols=36/textarea/p
pbr
Date: input type=text name=form_day
/p
pEmail: input type=text name=form_emailbrbr
input type= hidden name= commented value= set 
input type=submit value=Submit
/p
/form
?php
}
?
/body
Finally has a result to get the correct data only for the DATE and the 
data from the Question FORM goes to the name field. I do not know where 
the problem is. Help me please because I am going crazy,

Thanks in advance

Charalambos Nicolaou

_
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP-DB] Re: exporting data to excel

2004-03-25 Thread Galbreath, Mark A
Good stuff to know!  Thx, Geir!

Mark

-Original Message-
From: Geir Pedersen - Activio AS [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 24, 2004 9:05 PM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Re: exporting data to excel



Matthew,

 I am looking for the easiest way to export data to an excel file. Is
 the eaiest way to use PHP's file handling functions?

I assume you want to delivery the execl file to a web user.
Then there is no need to write the data to disk, you can
generate the whole thing on the fly while you deliver it to the
user. Here is a basic description on how:

1) Create a PHP document to generate the execl file and make
   sure the script produces HTTP headers telling the user agent
   that it is receiving an excel document. Start the script
   with:

  header (Content-type: application/vnd.ms-excel);
  header (Content-Disposition: attachment );

   The content disposition header says that the execl file is
   to be stored on disk. 

2) Generate the spreadsheet data as a list of newline separated
   rows with tab separated fields:

   echo field1\tfield2\t...\n;

3) Set up a link to the new PHP document. When a user clicks on
   that link, he will be prompted by his user agent on where to
   save the excel file.


---

Geir Pedersen
http://www.activio.com/

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



[PHP-DB] Re: exporting data to excel

2004-03-25 Thread Mignon Hunter
Hello all
 
I am also needing to do this - I got the xcel ss to generate but it wont tab to the 
next cell in xcel...

Here's what I've tried so far:


?php
  while ($row = mysql_fetch_assoc($res)) {  
  echo $row[first]  . \t  . $row[last] . \n;
//  echo $row[first]  . ,  . $row[last] . \n;
//  echo $row[first],$row[last]\n;
//  echo $row[first]\t$row[last]\t\n;
//  echo $row[first] . , . $row[last];
  }
  ?

***

But I get all the fields in one cell on each of these tries... 

Thanks

 Geir Pedersen - Activio AS [EMAIL PROTECTED] 03/24/04 08:04PM 

Matthew,

 I am looking for the easiest way to export data to an excel file. Is
 the eaiest way to use PHP's file handling functions?

I assume you want to delivery the execl file to a web user.
Then there is no need to write the data to disk, you can
generate the whole thing on the fly while you deliver it to the
user. Here is a basic description on how:

1) Create a PHP document to generate the execl file and make
   sure the script produces HTTP headers telling the user agent
   that it is receiving an excel document. Start the script
   with:

  header (Content-type: application/vnd.ms-excel);
  header (Content-Disposition: attachment );

   The content disposition header says that the execl file is
   to be stored on disk. 

2) Generate the spreadsheet data as a list of newline separated
   rows with tab separated fields:

   echo field1\tfield2\t...\n;

3) Set up a link to the new PHP document. When a user clicks on
   that link, he will be prompted by his user agent on where to
   save the excel file.


---

Geir Pedersen
http://www.activio.com/ 

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



[PHP-DB] Re: exporting data to excel

2004-03-25 Thread Mignon Hunter
Here's what I ended up doing that works:



(do all the db connection stuff - get your result, etc..)

table width=100% border=1
  tr
td div align=centerstrongName/strong/div/td
td div align=centerstrongCompany /strong/div/td
td div align=centerstrongAddress /strong/div/td
td div align=centerstrongE-mail/strong/div/td
td div align=centerstrongTelephone/strong/div/td
/tr

?php
  while ($row = mysql_fetch_assoc($res)) {
  ?
tr
td?php echo $row[first] . $row[last]; ?/td
td?php echo $row[company] . $row[title]; ?/td 
td?php echo $row[address1] . , . $row[city] . , . $row[state] . , . 
$row[zip]; ?/td
td?php echo $row[email]; ?/td
td?php echo $row[phone]; ?/td
/tr
?php 
}
? 
/table

**

use the header() info in this post at the top of your page, create another page and 
link to this script. You can either view the excel or save to disk...

Thanks
Mignon




 Geir Pedersen - Activio AS [EMAIL PROTECTED] 03/24/04 08:04PM 

Matthew,

 I am looking for the easiest way to export data to an excel file. Is
 the eaiest way to use PHP's file handling functions?

I assume you want to delivery the execl file to a web user.
Then there is no need to write the data to disk, you can
generate the whole thing on the fly while you deliver it to the
user. Here is a basic description on how:

1) Create a PHP document to generate the execl file and make
   sure the script produces HTTP headers telling the user agent
   that it is receiving an excel document. Start the script
   with:

  header (Content-type: application/vnd.ms-excel);
  header (Content-Disposition: attachment );

   The content disposition header says that the execl file is
   to be stored on disk. 

2) Generate the spreadsheet data as a list of newline separated
   rows with tab separated fields:

   echo field1\tfield2\t...\n;

3) Set up a link to the new PHP document. When a user clicks on
   that link, he will be prompted by his user agent on where to
   save the excel file.


---

Geir Pedersen
http://www.activio.com/ 

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



[PHP-DB] Re: exporting data to excel

2004-03-24 Thread Geir Pedersen - Activio AS

Matthew,

 I am looking for the easiest way to export data to an excel file. Is
 the eaiest way to use PHP's file handling functions?

I assume you want to delivery the execl file to a web user.
Then there is no need to write the data to disk, you can
generate the whole thing on the fly while you deliver it to the
user. Here is a basic description on how:

1) Create a PHP document to generate the execl file and make
   sure the script produces HTTP headers telling the user agent
   that it is receiving an excel document. Start the script
   with:

  header (Content-type: application/vnd.ms-excel);
  header (Content-Disposition: attachment );

   The content disposition header says that the execl file is
   to be stored on disk. 

2) Generate the spreadsheet data as a list of newline separated
   rows with tab separated fields:

   echo field1\tfield2\t...\n;

3) Set up a link to the new PHP document. When a user clicks on
   that link, he will be prompted by his user agent on where to
   save the excel file.


---

Geir Pedersen
http://www.activio.com/

-- 
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: Storing data in a file

2004-02-24 Thread Justin Patrin
Todd Cary wrote:

I have a client that does not want to use a DBMS for storing the email 
addresses the surfers input.  Is there a class available that has a 
search function as well as an append?

I would like to have several fields separated by a tab or  : .

Todd
I have heard that SQLite is pretty nice in this regard. It implements a 
basic database system but without having to run a seperate database process.

(Honestly, running mysql isn't that hard, but...)

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


[PHP-DB] RE: show data from 2 tables

2003-10-28 Thread Jeremy Shovan
  Try rewriting your query. It looks to me that you probably have an
error in your SQL statement and it only seems fine because you appended
the @ to the beginning of the mysql_query() function.
  I would suggest using a join statement.

If(!$result = mysql_query(SELECT orders.orderid, orders.amount,
orders.date, customer.name FROM orders RIGHT JOIN customers on
orders.customerid = customers.customerid WHERE customers.name = 'Don
Hansen')) {
  echo(mysql_error());  //I would take this out after you are done
debuging
} else {
  while ($row = mysql_fetch_array($result)) {
$zorderid = $row['orders.orderid'];
$zamt = $row['orders.amount'];
echo(str_pad($zorderid,4,' ').str_pad($zamt,6, '  ').'br');
  }
}
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 28, 2003 9:20 AM
To: [EMAIL PROTECTED]
Subject: show data from 2 tables

I am attempting to pull data from 2 tables.  My SELECT statement seems
ok.  But the next line: while ... etc. is giving me an error of
Supplied argument is not a valid MySQL result resource..  But this is
the way I usually show my data and it works fine when only 1 table is
involved.  Is there a different way of showing your data when pulling
data from more than one table?

$result = @mysql_query('SELECT orders.orderid, orders.amount,
orders.date
from customers, orders WHERE customers.name = Don Hansen and
customers.customerid = orders.customerid');

while ( $row = mysql_fetch_array($result) )
{
$zorderid = $row['orders.orderid'];
$zamt = $row['orders.amount'];
echo (str_pad($zorderid,4,' ') .  str_pad($zamt,6, '  ') .
'br');
}

Thanks,
Doug

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



[PHP-DB] Re: copying data

2002-12-15 Thread David Eisenhart
If its a 'one off' kind of transfer then i'd recommend that you consider
doing what I did - export the data from Access to text file(s) and then
import from the text file(s) into MySQL (phpMyAdmin is v handy for this lind
of task) {Of course if you want a more automated solution then this is not
the way to go)

David Eisenhart


 If I have a microsoft access file .mdb on my server, can I use  a php page
 to move the data from the file to a mysql db?

 Thanks,
 Eddie




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




[PHP-DB] Re: copying data

2002-12-15 Thread David Eisenhart
If its a 'one off' kind of transfer then i'd recommend that you consider
doing what I did - export the data from Access to text file(s) and then
import from the text file(s) into MySQL (phpMyAdmin is v handy for this lind
of task) {Of course if you want a more automated solution then this is not
the way to go)

David Eisenhart


 If I have a microsoft access file .mdb on my server, can I use  a php page
 to move the data from the file to a mysql db?

 Thanks,
 Eddie




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




[PHP-DB] RE: copying data

2002-12-15 Thread Thomas G. Knight
There is a utility called MyAcess it is like MyODBC and I have used it to do
this exact thing. It works very well. I believe you can find it on
Freshmeat.

Thomas G. Knight
[EMAIL PROTECTED]
http://www.slaponline.com

-Original Message-
From: David Eisenhart [mailto:[EMAIL PROTECTED]]
Sent: Sunday, December 15, 2002 4:51 AM
To: [EMAIL PROTECTED]
Subject: Re: copying data


If its a 'one off' kind of transfer then i'd recommend that you consider
doing what I did - export the data from Access to text file(s) and then
import from the text file(s) into MySQL (phpMyAdmin is v handy for this lind
of task) {Of course if you want a more automated solution then this is not
the way to go)

David Eisenhart


 If I have a microsoft access file .mdb on my server, can I use  a php page
 to move the data from the file to a mysql db?

 Thanks,
 Eddie





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




[PHP-DB] Re: upload data to MySql

2002-11-14 Thread Seabird
Thanx, I found out I forgot to pass it to my db.

Jacco
--
http://seabird.jmtech.ca

Attitude is Everything!
But Remember, Attitudes are Contagious!
Is Yours worth Catching
David Robley [EMAIL PROTECTED] wrote in message
news:MPG.183f2f6ec46a84169897c8;news.php.net...
 In article [EMAIL PROTECTED], [EMAIL PROTECTED]
 says...
  Hi everyone,
 
  I don't get my upload to work properly. It's a tutorial of the web, but
it
  doesn't function (unless I made a mistake). Please help me...
  I have a form passing on 5 fields (text for testing), name: year, make,
  model, price, picture and submit to PHP_SELF
 
  ?php
  if ($submit) {
 
  $db = mysql_connect(localhost,myname,mypassword);
 
  mysql_select_db($test,$db);
  //DB Test for testing...
 
  $sql = INSERT INTO test (year,make,model,price,picture) VALUES
  ('$year,$make,$model,$price,$picture');

 This line looks like your first problem. Each value being inserted which
 is a text type should be separately surrounded by single quotes. So:

  ('$year','$make','$model','$price','$picture');

 As a debugging aid, use

 echo mysql_error()

 after you pass the query to mysql with mysql_query() I don't see where you
 actually do that in this code snippet??

  //I created these columns in the table test
 
 
  echo year: $yearbr\n;
  echo make: $makebr\n;
  echo model: $modelbr\n;
  echo price: $pricebr\n;
  echo picture: $picturebr\n;
  }
 
  ?
 
  I know I need globals on for this.
  Thanx for the help,

 --
 David Robley
 Temporary Kiwi!

 Quod subigo farinam



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




[PHP-DB] Re:[PHP-DB] Re: Print data

2002-10-28 Thread xde7ori
I'm interested in examples with codes
thanks in advance..
 
 From: Dan Koken [EMAIL PROTECTED]
 Date: 2002/10/25 Fri AM 06:12:55 GMT+03:00
 To: [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject: [PHP-DB] Re: Print data
 
 We faced this problem, and decided if we couldn't get a good solution to 
 eliminate the printer. Turns out the users liked it better, and we 
 eliminated a lot of paper.
 - First we wrote a report writer.
 - All reports go to the database.
 - We wrote a report file system.
 - The report output title shows up in the user report file system in the 
 IN BASKET.
 - The user can click the file and it displays the first 5 pages to the 
 screen. They can change the start page and number of pages.
 - The user can file it into other files like WEEKLY REPORTS.
 - They can send the report to others and it shows up in their IN BASKET.
 - If they delete the report it sits in the WASTE BASKET file for 10 
 days. This gives them the ability to file it back somewhere if it was 
 deleted by mistake.
 
 This is fast because the reports are run on the server. Only one copy of 
 the report is kept in the database, and the user report file system 
 points to it.
 
 Anyway this was our solution and the users love it since they no longer 
 have to file paper, but file reports electronically. They can carbon 
 copy anyone. They can look at any section of the report any time. They 
 can still print the report if they want by using the print button.
 HTH... Have a great day... Dan
 
 
 José Moreira wrote:
  hello, at my company we have several network printers and i was was
  wondering if it's possible to print directly to them using PHP, instead
  of showing on the screen or both ...
  to gain more control on what is printed, because of the nasty browsers
  header and footer ... whom i now how to remove ...
  
  i know that the printer IP is  192.192.1.100 and the port is 9005 ...
  
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

Free Email Account at www.flash.ro


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




[PHP-DB] Re: Print data

2002-10-25 Thread Dan Koken
We faced this problem, and decided if we couldn't get a good solution to 
eliminate the printer. Turns out the users liked it better, and we 
eliminated a lot of paper.
- First we wrote a report writer.
- All reports go to the database.
- We wrote a report file system.
- The report output title shows up in the user report file system in the 
IN BASKET.
- The user can click the file and it displays the first 5 pages to the 
screen. They can change the start page and number of pages.
- The user can file it into other files like WEEKLY REPORTS.
- They can send the report to others and it shows up in their IN BASKET.
- If they delete the report it sits in the WASTE BASKET file for 10 
days. This gives them the ability to file it back somewhere if it was 
deleted by mistake.

This is fast because the reports are run on the server. Only one copy of 
the report is kept in the database, and the user report file system 
points to it.

Anyway this was our solution and the users love it since they no longer 
have to file paper, but file reports electronically. They can carbon 
copy anyone. They can look at any section of the report any time. They 
can still print the report if they want by using the print button.
HTH... Have a great day... Dan


José Moreira wrote:
hello, at my company we have several network printers and i was was
wondering if it's possible to print directly to them using PHP, instead
of showing on the screen or both ...
to gain more control on what is printed, because of the nasty browsers
header and footer ... whom i now how to remove ...

i know that the printer IP is  192.192.1.100 and the port is 9005 ...




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




[PHP-DB] Re: Print data

2002-10-24 Thread Brian McGarvie
an alternative I'm looking into is simply writing/formatting the data into a
text file, then using the good old 'net print' dos command to print the
file...

José Moreira [EMAIL PROTECTED] wrote in message
news:1035381924.1052.8.camel;inf4.pt...
 hello, at my company we have several network printers and i was was
 wondering if it's possible to print directly to them using PHP, instead
 of showing on the screen or both ...
 to gain more control on what is printed, because of the nasty browsers
 header and footer ... whom i now how to remove ...

 i know that the printer IP is  192.192.1.100 and the port is 9005 ...




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




[PHP-DB] Re: Print data

2002-10-24 Thread J Wynia
José Moreira wrote:

hello, at my company we have several network printers and i was was
wondering if it's possible to print directly to them using PHP, instead
of showing on the screen or both ...
to gain more control on what is printed, because of the nasty browsers
header and footer ... whom i now how to remove ...

i know that the printer IP is  192.192.1.100 and the port is 9005 ...



If you're willing to do a bit of work, you can do a workable solution. 
I'm assuming that PHP is running on a Windows server.

You can use the Windows printer functions if the printer was connected 
directly. If not, you can still get it to work. The Windows Scripting 
Host resources give you a few ways. A kludgy way would be to configure 
IE on the printer machine (since it's almost surely installed) to not 
show the header and footers. You can use the WSH functions to open a 
non-visible IE instance and issue the print command from there. WSH also 
has functions in it's COM objects for mapping network printers, etc so 
you could customize your own server's IE config and print to a mapped 
printer. Lots of ways to skin this cat, but they're all messy.


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



[PHP-DB] Re: Accessing data from next row? (mysql)

2002-10-14 Thread Adam Royle

Create an array and go through the array as needed.

Here is some code from one of my db functions:

$DB_RESULT = mysql_query($sql) or die(Error executing query:  . 
mysql_error());

// create an empty array to fill with data
$arrData = array();

$rowCount = 0;
while ($r = mysql_fetch_array($DB_RESULT, MYSQL_ASSOC)){
foreach ($r as $key = $value){
$arrData[$rowCount][$key] = $value;
}
$rowCount++;
}

then simply instead of your code:
while($array = mysql_fetch_array($result)){

use this:
for ($i=0;$icount($arrData);$i++){
$arrThisRow = $arrData[$i];
$arrNextRow = $arrData[$i+1];
}

obviously, if you are trying to access a variable which index does not 
exist, you will need to implement some sort of error checking, etc

adam


 Using mysql, how do I access the data of the next row using code
 something like this:
 $result = mysql_query(select column from table where 
 whatever='whatever');
 while($array = mysql_fetch_array($result)){
 //Whatever
 }


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




[PHP-DB] Re: Accessing data from next row? (mysql)

2002-10-14 Thread Adam Royle

Also, if you're not sure how to get the values from $arrThisRow / 
$arrNextRow:

echo $arrThisRow['columnName'];

or $arrData[$i]['columnName'] if you want to access it manually without 
the other two arrays

adam

On Monday, October 14, 2002, at 06:05  PM, Adam Royle wrote:

 Create an array and go through the array as needed.

 Here is some code from one of my db functions:

   $DB_RESULT = mysql_query($sql) or die(Error executing query:  . 
 mysql_error());

   // create an empty array to fill with data
   $arrData = array();

   $rowCount = 0;
   while ($r = mysql_fetch_array($DB_RESULT, MYSQL_ASSOC)){
   foreach ($r as $key = $value){
   $arrData[$rowCount][$key] = $value;
   }
   $rowCount++;
   }

 then simply instead of your code:
 while($array = mysql_fetch_array($result)){

 use this:
 for ($i=0;$icount($arrData);$i++){
   $arrThisRow = $arrData[$i];
   $arrNextRow = $arrData[$i+1];
 }

 obviously, if you are trying to access a variable which index does not 
 exist, you will need to implement some sort of error checking, etc

 adam


 Using mysql, how do I access the data of the next row using code
 something like this:
 $result = mysql_query(select column from table where 
 whatever='whatever');
 while($array = mysql_fetch_array($result)){
 //Whatever
 }



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




[PHP-DB] Re: odbc data sort problem (i think) :)

2002-08-29 Thread Lukas Boldrino

i got the problem.
the odbc driver fills unuses spaces in a row with blanks.

goddamn *g*

cu
Lukas Boldrino [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 hey guys !

 I´m trying to use a if syntax to compare data and preselect radiobuttons.
 I tried it like that:

 if ($checked == Patch)
 $checked6 = bla;

 With numbers it works great but with char my $checked6 variable is empty !
 I know php is case sensitive and I´m sure that problem is not the case
 sensitive
 so please help, im using a MS SQL Server 2000 (enterprise edition) and the
 odbc driver!

 thanks guys!

 -
 [EMAIL PROTECTED]
 -





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




Re: [PHP-DB] Re: odbc data sort problem (i think) :)

2002-08-29 Thread Andrew Hill

Lukas,

Use varchar instead of char to avoid this issue - that is the behavior 
you should expect regardless of the driver or ODBC use.

Best regards,
Andrew Hill
OpenLink Software

On Thursday, August 29, 2002, at 05:07 AM, Lukas Boldrino wrote:

 i got the problem.
 the odbc driver fills unuses spaces in a row with blanks.

 goddamn *g*

 cu
 Lukas Boldrino [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 hey guys !

 I¥m trying to use a if syntax to compare data and preselect 
 radiobuttons.
 I tried it like that:

 if ($checked == Patch)
 $checked6 = bla;

 With numbers it works great but with char my $checked6 variable is 
 empty !
 I know php is case sensitive and I¥m sure that problem is not the 
 case
 sensitive
 so please help, im using a MS SQL Server 2000 (enterprise edition) 
 and the
 odbc driver!

 thanks guys!

 -
 [EMAIL PROTECTED]
 -





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




[PHP-DB] Re: change data before its sent to db?

2002-07-17 Thread Tomator

You will laugh. When you quote month, you don't sort date by month field.
You sort by month - text constant being always equal. In fact you son't
sort it at all!

 The sort code ---

 if ($orderby == 'month_num'):
 $sql = select * from releases order by 'month';
 elseif ($orderby == 'month_num2'):
 $sql = select * from releases order by 'month' desc;

Try this:

$sql = select * from releases order by month;



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




[PHP-DB] Re: extract data from database into an array

2002-07-15 Thread Marcel Schindler


Chip Wiegand [EMAIL PROTECTED] wrote
 I have a database, all the data is numbers. I want to make a query that
 will extract the data and then make it available in an array, so the
 array is populated 'real-time'. I could just enter the number into an
 array manually, but I want to automate the job. I don't know what to
 start looking for, the 3 books I have either don't talk about this or I
 just am missing it.
 Could someone point me in the right direction?

This class makes it possible to return an array in two ways very easy.

Just try this

$db = new Ms_db;
$db-connect(true);  // open a persistant connection
$vars1 = $db-query(SELECT * FROM table);
$vars2 = $db-query(SELECT * FROM table,off);

$vars1 is now build this way
$vars1[row][column] contains the required value...

$vars2[column][row] contains the required value...


Maybe this helps:
?php
/**
mySQL - Database Class
**/

// Database Configuration Variables (local) //
  define (DB_SERVER,localhost);
  define (DB_USER,root);
  define (DB_PASS,);
  define (DB_DB,testfaq);


class Ms_db
{
/**
* Attributes of this class
**/
var $db_result   = 0; // Stores the last result_id
var $db_id   = 0; // Stores the current Database Connection ID
var $db_datasets = array(); // Stores the last read database-Set as hash
[colum-name][row_number]

/**
* Connect
* @author Marcel Schindler
* @param bool $persistant
* @return void
**/
function connect($persistant =
FALSE,$server=DB_SERVER,$user=DB_USER,$pass=DB_PASS,$database=DB_DB)
{
if (($persistant == FALSE))
{
$this-db_id = @mysql_connect($server,$user,$pass)
   or $this-db_error(Failed to connect to
Database-Server,mysql_error());
}
else
{
$this-db_id = @mysql_pconnect($server,$user,$pass)
   or $this-db_error(Persistant connection
failed,mysql_error());
}
@mysql_select_db($database) or $this-db_error(Failed to select
Database,mysql_error());
}

/**
* Query
* @param SQL-Query
* @param flip boolean
* @return array $dataset
**/
function query($sql,$flipped=on)
{
$db = $this-db_id;
$wert = array();
$count= 0;
if (!$db) $this-db_error(Keine Verbindung zur Datenbank);
$res = @mysql_query($sql) or $this-db_error(Fehlerhaftes
SQL-Statement,$sql.br.mysql_error());
while ($data = mysql_fetch_assoc($res))
{
$wert[$count] = $data;
$count  ;
}
if ($flipped == on) $wert = $this-reorder_array($wert);
$this-db_datasets=$wert;
return $wert;
}



/**
* Close - closes the connection to the Database
**/
function close()
{
mysql_close();
}

/**
* Reorder_array
* @param: $array = array();
* @return: $array;
**/
function reorder_array($arr)
{
$wert = array();
// Array ist vom Typ $wert[Zeile][Spalte], soll aber als
$wert[Spalte][Zeile]
foreach ($arr as $sub)
{
while (list ($key1,$val1) = each ($sub))
{
$wert[$key1][] = $val1;
}
}
$this-db_datasets = $wert;
return $wert;
}

/**
* db_error - displays a well-formatted HTML-Page with the error-message
* @param string errormessage
* @param string mysql-error (optional)
**/
function db_error($message,$error='')
{
echo 'htmlheadtitle'.$message.'/title/headbody
bgcolor=#ee';
echo 'table align=center width=600 height=400
bgcolor=#ff';
echo 'trtdh1Error:/h1/td/trtrtd';
highlight_string($message);
if ($error!='')
{
echo 'brbrMySQL said:'.$error;
}
echo '/td/tr/table/body/html';
die();
}

/**
* NumRows
* Checks the Number of rows affected by the last query
* @return integer $number
**/
function numrows()
{
$number = @mysql_num_rows($this-db_result);
return $number;
}
/**
* DUMP - just dumps the current array (just for informal purposes
* @param VOID
**/
function dump()
{
$x = $this-numrows();
if ($x == 0 ) $this-db_error(There was no query placed
before,);
echo 'strongQuery DUMP/strongbrtable border=1
cellspacing=0 cellpadding=0 width=100%tr';
$wert = $this-db_datasets;
$spalten = array_keys($wert);
foreach ($spalten as $values)
{
$spaltenname[] = $values;
echo th bgcolor=\#00\font
color=\#ff\$values/font/th;
}
echo /tr;
for ($t = 0; $t = $x; $t  )
{
if ($t % 2 == 0) echo tr bgcolor=\#dd\;
else echo tr bgcolor=\#ee\;
foreach($spaltenname as $values)
{
echo td vAlign=\top\.$wert[$values][$t]./td;
}
 

[PHP-DB] Re: Session data not being deleted on browser close.

2002-07-09 Thread Yasuo Ohgaki

Don't cross post such question...

All you need to understand is how cookie is managed unless
you are passing session id via URL.

Read RFC2965 and RFC2964.
You probably want to read netscape cookie spec also.

--
Yasuo Ohgaki

Youngie wrote:
 Why would my session data not be deleted after my browser is closed?
 
 I can set some session variables, close my browser, reopen them and the old
 values are still present,
 I can verify this by seeing that the file still containts my session data
 and values.
 
 Thanks
 
 John.
 
 



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




[PHP-DB] Re: Retreiving data from a table

2002-03-01 Thread Matthew Crouch

i'm guessing you use mysql, so
you can use the mysql_insert_id to retrieve the most recent addition, then
select on it

$newid=mysql_insert_id();
$sql=select [the auto_increment field] from table1 where id='$newid';

Does that help?

Morten Nielsen wrote:

 Hi,
 I got the following insert statement in my PHP code:

  $qid = db_query(
  INSERT INTO table1 (
   Name
  ) VALUES (
'$frm[Name]'
  ));

 This is working like I want it to But in the table there is a column, which
 is AUTO_INCREMENT I would like to retreive this number right after I added
 the data
 Can anybody help me?

 Thanks,
 Morten


-- 
PHP Database Mailing List (http://wwwphpnet/)
To unsubscribe, visit: http://wwwphpnet/unsubphp




[PHP-DB] Re: Insert data selected from drop down list into mySQL table

2002-01-09 Thread Peter Westergaard

George, 


When you use:


pre
OPTION value=$prd$prd/OPTION 
/pre


Why not use the Product ID in the VALUE tag, and use the Product 
NAME between the OPTION /OPTION tags?
That way, the VALUE is what is selected, and you can then use an 
SQL INSERT or UPDATE command to push that into the destination table.



One less check against the database, right?

-Peter 



===
EASY and FREE access to your email anywhere: http://Mailreader.com/
===



-- 
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: Retrieving data woes

2001-12-10 Thread Hugh Bothwell


Andres Sulleiro [EMAIL PROTECTED] wrote in message
002001c18193$eacb4450$[EMAIL PROTECTED]">news:002001c18193$eacb4450$[EMAIL PROTECTED]...
 I have a db table that has these columns:
 id, date, time, title, body

 some of the rows can have the same date and want to output the data
 according to date. Like so:

 dateA
 timeA1, titleA1
 bodyA1

 timeA2, titleA2
 bodyA2

 dateB
 timeB1, titleB1
 BodyB1

In your SQL request, sort by date.  When printing the output,
keep track of the previous date - only print the date if it
changes.  Something like

$conn = mysql_pconnect($host, $usr, $pwd);
mysql_select_db(mydb);
$sql = SELECT id,date,time,title,body FROM mytable ORDER BY date DESC;
$res = mysql_query($sql);

$date = previous date;
while($row = mysql_fetch_array($res)) {
if ($date != $row[date]) {
$date = $row[date];
echo br$date;
}

echo p.$row[time]. .$row[title];
echo br.$row[body];
}



-- 
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: new data detect

2001-07-25 Thread Hugh Bothwell


Sommai Fongnamthip [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi,
 I decide to make real time application (like stock market or online
 news).  How could I know when new data arrive to table and retrieve them
to
 display or update in web page?

You can't, actually, short of using server-side push;

what you can do is periodically requery the server; either reload the page
every so often, or (better) use a flag file - set it when data is changed -
and check it in the background with JavaScript, then reload the page only
when it is set.



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