[PHP-DB] date problem in MySQL DB

2004-01-13 Thread Angelo Zanetti
Hi guys

This might be slightly off topic but hopefully someone can help.
I have a field that is a varchar and I stored dates in it. But now I want to
change the type of the column to date, but I have a problem that the formats
differ:

my format: mm/dd/
mySQL format: -mm-dd

So can I either:
a. change the format of the date format

or

b. do i have to write a function that changes my format to the mySQL before
changing the column type??

TIA

Angelo Zanetti


Disclaimer 
This e-mail transmission contains confidential information,
which is the property of the sender.
The information in this e-mail or attachments thereto is 
intended for the attention and use only of the addressee. 
Should you have received this e-mail in error, please delete 
and destroy it and any attachments thereto immediately. 
Under no circumstances will the Cape Technikon or the sender 
of this e-mail be liable to any party for any direct, indirect, 
special or other consequential damages for any use of this e-mail.
For the detailed e-mail disclaimer please refer to 
http://www.ctech.ac.za/polic or call +27 (0)21 460 3911

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



Re: [PHP-DB] date problem in MySQL DB

2004-01-13 Thread CPT John W. Holmes
From: Angelo Zanetti [EMAIL PROTECTED]

 This might be slightly off topic but hopefully someone can help.
 I have a field that is a varchar and I stored dates in it. But now I want
to
 change the type of the column to date, but I have a problem that the
formats
 differ:

 my format: mm/dd/
 mySQL format: -mm-dd

 So can I either:
 a. change the format of the date format

 or

 b. do i have to write a function that changes my format to the mySQL
before
 changing the column type??

You need to do option (b). Since this is a PHP list, I'd recommend
strtotime() and date() to do the formatting.

---John Holmes...

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



RE: [PHP-DB] date problem in MySQL DB

2004-01-13 Thread brett king


Hi Angelo

Yes you will have to reformat and he is something that may help you.
Hope it does

function dateCheckMysql ($date) {

list($dateDay, $dateMonth, $dateYear) = explode(/, $date);
if ((is_numeric($dateDay))  (is_numeric($dateMonth)) 
(is_numeric($dateYear))) {

if (!checkdate($dateMonth, $dateDay, $dateYear)) {
return false;
} else {

return($dateYear./.$dateMonth./.$dateDay);
}
} else {

return false;
}
}

function dateCheckForm($date) {

list($dateYear, $dateMonth, $dateDay) = explode(-, $date);

if ((is_numeric($dateDay))  (is_numeric($dateMonth)) 
(is_numeric($dateYear))) {

return($dateDay./.$dateMonth./.$dateYear);
} else {
return false;
}
}

Many Thanks
Brett

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



Re: [PHP-DB] How to print doc

2004-01-13 Thread Cal Evans
Assuming you mean from PHP, you can't directly do that. PHP is server 
side, Printing is client side.  If you are working in a browser 
environment, you can explore your options within Javascript.

Let me know how I may be of service,
=C=
* Cal Evans
* http://www.eicc.com
* We take care of your IT,
* So you can take care of your business.
*
* I think inside the sphere.
wan wrote:
Hi all,

How to print document without display/open that document, Only click the button print, document printing.

TQ

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


Re: [PHP-DB] How to print doc

2004-01-13 Thread Sai Hertz And Control Systems
Dear Cal Evans,

Assuming you mean from PHP, you can't directly do that. PHP is server 
side, Printing is client side.  If you are working in a
Printing is possible on server side PHP has some print functions but 
that works on Windows only that also on serverside not the client side
In  javascript  you may do something like
a href=# OnClick='window.print()'Click to print /a
Regards,
Vishal Kashyap

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


Re: [PHP-DB] date problem in MySQL DB

2004-01-13 Thread Justin Patrin
Brett King wrote:

Hi Angelo

Yes you will have to reformat and he is something that may help you.
Hope it does
	function dateCheckMysql ($date) {

list($dateDay, $dateMonth, $dateYear) = explode(/, $date);
if ((is_numeric($dateDay))  (is_numeric($dateMonth)) 
(is_numeric($dateYear))) {
if (!checkdate($dateMonth, $dateDay, $dateYear)) {
return false;
} else {
return($dateYear./.$dateMonth./.$dateDay);
}
} else {
return false;
}
}
	function dateCheckForm($date) {

		list($dateYear, $dateMonth, $dateDay) = explode(-, $date);

if ((is_numeric($dateDay))  (is_numeric($dateMonth)) 
(is_numeric($dateYear))) {
return($dateDay./.$dateMonth./.$dateYear);
} else {
return false;
}
}
Many Thanks
Brett
Wow, that's lots of code. I'd recommend something simpler. Like:

$mysqlDate = date('Y-m-d', strtotime($myDate));

$myDate = date('m/d/Y', strtotime($mysqlDate));

No checking involved, just one line of code.

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


Re: [PHP-DB] csv export...?

2004-01-13 Thread David T-G
Andre, et al --

[Sorry for the delay...]

...and then Andre Speelmans said...
% 
% Hi David,

Hi!


% 
% On Fri, Jan 09, 2004 at 11:04:21AM -0500, David T-G wrote:
%  
%header (Content-Type: application/csv;) ;   # this is a CSV
%header (Content-disposition: attachment; filename=authorized-visitors.$d.csv) 
; # file name
%...
%  [suck in file and dump into $a array]
%  foreach ( array_keys($a) as $ak )   # walk thru the array
%{ print \$a[$ak]\, ; }# print the field 
(yes, even if blank)
% 
% But this would go wrong if $a[$ak] contained a double quote. Remember you have

Oooh; good point.  My input is all sanitized, so  becoamse quot; and so
on, but for raw data that would definitely be a factor.


% to escape those characters. Can't the database of OP do a dump, like MySQL
% can?

Well, in my case each record is a file on disk, so that doesn't apply.


Thanks  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


[PHP-DB] PHP Java problem

2004-01-13 Thread Donovan Hutchinson
Hi,

I've started putting together a site that uses PHP to access some custom
Java classes. While I'm not clear on what exactly the java classes are
doing, the programmer has given me an overview of the variables that I
should pass to them. However, I keep getting this error:

java.lang.IllegalArgumentException: argument type mismatch

The java programmer has no knowledge of PHP and so is unable to help locate
the source of the problem (tbh I'm don't have experience in large php
projects myself). The code I'm writing is in the following format:

$newobject = new Java('com.company.Class', $names, (String) $ssn, (int)
$time);

In the above example, $names is an object, $ssn a string and $time an
integer. The object $names is created in a similar way above this example.
Someone mentioned that I should be passing objects as arrays, but I'm not
clear on how this is done.

I've tested a very basic class to be sure it works, and had success, however
when I try to pass objects into classes, and multiple variables, it doesnt
work. I hope someone can shed some light on where I might be going wrong.

Many thanks,

Don

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



[PHP-DB] Database abstraction

2004-01-13 Thread Malte Starostik
Hi,

I've read several posts touching this subject, but I didn't find one that
asks a simple question I've been wondering about since I first used PHP and
that is also one of the two really really bad things about PHP (the other
being lack of OO):
Why isn't there a DB abstraction layer right in PHP, so people writing some
web app for redistribution don't have to care about the different DBs
themselves?
Why is there no modularization in this area, such that it'd be the _normal_
way not to write things like $dbh = ibase_pconnect( ... ), but $dbh =
sql_connect( Firebird, ... )
and that would internally check if a Firebird/InterBase driver is available
and if so, use it.
Surely there are some differences in SQL conformance and syntax extensions,
but even that could be handled by such a layer to some extent.

Thanks for any insight,
-Malte

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



[PHP-DB] php includes

2004-01-13 Thread mayo
I'm new to php (I've been in the CF world the last few years) and have a
basic question regarding includes:

On my dev box (a fancy term for laptop) I have the following include:

 ?php include (navTop.php); ?

This doesn't work on the client's site. There I have to use:

?php include (/home/sites/www.abc.com/web/navTop.php); ?

I can't use relative links.

So is there any trick that people have so that I don't have to touch each of
my files before sending them up?

gil

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



[PHP-DB] Re: php includes

2004-01-13 Thread Justin Patrin
Mayo wrote:

I'm new to php (I've been in the CF world the last few years) and have a
basic question regarding includes:
On my dev box (a fancy term for laptop) I have the following include:

 ?php include (navTop.php); ?

This doesn't work on the client's site. There I have to use:

?php include (/home/sites/www.abc.com/web/navTop.php); ?

I can't use relative links.

So is there any trick that people have so that I don't have to touch each of
my files before sending them up?
gil
Please do not write a new post by replying to an old post and changing 
its subject and content. It screws up threading in the better e-mail 
clients (mutt, Thunderird, etc.) as it keeps the thread's headers.

It looks like your client doesn't have . in their include_path in the 
php.ini. They could change their php.ino to have . in it and fix 
things quick and simple.

Or, you can use ini_set() to set the value yourself. You'd probably want 
to do something like this in your files:

ini_set('include_path', '.:'.ini_get('include_path'));

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


Re: [PHP-DB] Database abstraction

2004-01-13 Thread Jason Wong
On Wednesday 14 January 2004 06:04, Malte Starostik wrote:

 Why is there no modularization in this area, such that it'd be the _normal_
 way not to write things like $dbh = ibase_pconnect( ... ), but $dbh =
 sql_connect( Firebird, ... )
 and that would internally check if a Firebird/InterBase driver is available
 and if so, use it.
 Surely there are some differences in SQL conformance and syntax extensions,
 but even that could be handled by such a layer to some extent.

Whilst there isn't a builtin database abstraction layer in PHP itself there 
are a number of projects which fills the gap. There's the semi-official 
PEAR-DB, also ADODB and Metabase.

-- 
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
--
/*
Will you loan me $20.00 and only give me ten of it?
That way, you will owe me ten, and I'll owe you ten, and we'll be even!
*/

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



Re: [PHP-DB] Database abstraction

2004-01-13 Thread Martin Marques
Mensaje citado por Malte Starostik [EMAIL PROTECTED]:

 Hi,
 
 I've read several posts touching this subject, but I didn't find one that
 asks a simple question I've been wondering about since I first used PHP and
 that is also one of the two really really bad things about PHP (the other
 being lack of OO):

PHP5 deals with this.

http://ar.php.net/manual/en/faq.general.php#faq.general.relation-versions

 Why isn't there a DB abstraction layer right in PHP, so people writing some
 web app for redistribution don't have to care about the different DBs
 themselves?

Use PEAR::DB or PEAR::MDB.

 Why is there no modularization in this area, such that it'd be the _normal_
 way not to write things like $dbh = ibase_pconnect( ... ), but $dbh =
 sql_connect( Firebird, ... )

With PEAR::DB all you have to do is build a string like this:

$dsn = pgsql://username:[EMAIL PROTECTED]/database_name;

And I will be running PostgreSQL so that later all I have to do is:

$db = DB::Connect($dsn);

$db-query(SELECT * FROM tabname);

 and that would internally check if a Firebird/InterBase driver is available
 and if so, use it.
 Surely there are some differences in SQL conformance and syntax extensions,
 but even that could be handled by such a layer to some extent.

See this:

http://pear.php.net/manual/en/package.database.db.intro-dsn.php

-- 
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-
Martín Marqués  |   Programador, DBA
Centro de Telemática| Administrador
   Universidad Nacional
del Litoral
-

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



Re: [PHP-DB] Database abstraction

2004-01-13 Thread Martin Marques
Mensaje citado por Jason Wong [EMAIL PROTECTED]:

 
 Whilst there isn't a builtin database abstraction layer in PHP itself there 
 are a number of projects which fills the gap. There's the semi-official 
 PEAR-DB, also ADODB and Metabase.

Why is it you say it's semi-official?
I have always felt PEAR as much official.

-- 
select 'mmarques' || '@' || 'unl.edu.ar' AS email;
-
Martín Marqués  |   Programador, DBA
Centro de Telemática| Administrador
   Universidad Nacional
del Litoral
-

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



Re: [PHP-DB] Database abstraction

2004-01-13 Thread Jason Wong
On Wednesday 14 January 2004 06:42, Martin Marques wrote:

 Why is it you say it's semi-official?
 I have always felt PEAR as much official.

Well it's not in the PHP manual so I treat it as semi-official ;-)

-- 
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
--
/*
QOTD:
It's a cold bowl of chili, when love don't work out.
*/

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



RE: [PHP-DB] PHP Java problem

2004-01-13 Thread Peter Lovatt
Hi

php has very loose typing. This means that you can use a string as a number
and visa versa. You could for example do (substr(1 day,0,1) + 5) and get
the answer 1+5=6

php actually converts on the fly to do the above. The downside is that you
cannot always be sure what type a variable is. Form variable are always
strings, even if they are numbers.

I am not a java engineer either but argument type mismatch might be that
you are  passing a string when it expects a number or visa versa.

Try using settype() to force the type

http://uk2.php.net/manual/en/function.settype.php

and see if this fixes it.

Just a guess though, hope it helps

Peter





-Original Message-
From: Donovan Hutchinson [mailto:[EMAIL PROTECTED]
Sent: 13 January 2004 20:49
To: [EMAIL PROTECTED]
Subject: [PHP-DB] PHP Java problem


Hi,

I've started putting together a site that uses PHP to access some custom
Java classes. While I'm not clear on what exactly the java classes are
doing, the programmer has given me an overview of the variables that I
should pass to them. However, I keep getting this error:

java.lang.IllegalArgumentException: argument type mismatch

The java programmer has no knowledge of PHP and so is unable to help locate
the source of the problem (tbh I'm don't have experience in large php
projects myself). The code I'm writing is in the following format:

$newobject = new Java('com.company.Class', $names, (String) $ssn, (int)
$time);

In the above example, $names is an object, $ssn a string and $time an
integer. The object $names is created in a similar way above this example.
Someone mentioned that I should be passing objects as arrays, but I'm not
clear on how this is done.

I've tested a very basic class to be sure it works, and had success, however
when I try to pass objects into classes, and multiple variables, it doesnt
work. I hope someone can shed some light on where I might be going wrong.

Many thanks,

Don

--
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: PHP Java problem

2004-01-13 Thread Justin Patrin
I don't know anything about Java in PHP myself, but here's a function 
that will convert an object to an associative array for you.

function objToAssoc($obj) {
  if(is_object($obj)) {
$arr = get_object_vars($obj);
  } else {
$arr = $obj;
  }
  if(is_array($arr)) {
foreach($arr as $key = $val) {
  $arr[$key] = objToAssoc($val);
}
  }
  return $arr;
}
Donovan Hutchinson wrote:

Hi,

I've started putting together a site that uses PHP to access some custom
Java classes. While I'm not clear on what exactly the java classes are
doing, the programmer has given me an overview of the variables that I
should pass to them. However, I keep getting this error:
java.lang.IllegalArgumentException: argument type mismatch

The java programmer has no knowledge of PHP and so is unable to help locate
the source of the problem (tbh I'm don't have experience in large php
projects myself). The code I'm writing is in the following format:
$newobject = new Java('com.company.Class', $names, (String) $ssn, (int)
$time);
In the above example, $names is an object, $ssn a string and $time an
integer. The object $names is created in a similar way above this example.
Someone mentioned that I should be passing objects as arrays, but I'm not
clear on how this is done.
I've tested a very basic class to be sure it works, and had success, however
when I try to pass objects into classes, and multiple variables, it doesnt
work. I hope someone can shed some light on where I might be going wrong.
Many thanks,

Don


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