[PHP] Timestamps and strftime

2009-06-04 Thread John Comerford

Hi,

I am having a problem trying to use a date that I take from a MySQL 
database.  The field is defined as a timestamp in the database.  I 
extract it using PDO and I am trying to use the value with strftime as 
follows:


foreach ($stmt-fetchall(PDO::FETCH_ASSOC) as $row) {
 echo strftime(%j,$row['UpdateDate']);
}

but it returns the following error:

PHP Notice:  A non well formed numeric value encountered...

I understand that this is because strftime is expecting a numeric value 
and that ,$row['UpdateDate'] is a character but I am not sure how to 
resolve the issue.  Any help would be apprecaited.


TIA,
 JC


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



Re: [PHP] Timestamps and strftime

2009-06-04 Thread John Comerford

Thanks Jonathan,

Thats exactly what I needed.

I appreciate the help,
 JC

Mayer, Jonathan wrote:

Off the top of my head, would strtotime work?

ie

strftime(%j,strtotime($row['UpdateDate']))

-Original Message-
From: John Comerford [mailto:jo...@optionsystems.com.au] 
Sent: 04 June 2009 07:10

To: php-general@lists.php.net
Subject: [PHP] Timestamps and strftime

Hi,

I am having a problem trying to use a date that I take from a MySQL 
database.  The field is defined as a timestamp in the database.  I 
extract it using PDO and I am trying to use the value with strftime as 
follows:


foreach ($stmt-fetchall(PDO::FETCH_ASSOC) as $row) {
  echo strftime(%j,$row['UpdateDate']);
}

but it returns the following error:

PHP Notice:  A non well formed numeric value encountered...

I understand that this is because strftime is expecting a numeric value 
and that ,$row['UpdateDate'] is a character but I am not sure how to 
resolve the issue.  Any help would be apprecaited.


TIA,
  JC


  



--
Option Systems Pty. Ltd.
53 Waverley Road, Malvern East, VIC 3145
PO Box 7, Caulfield East, VIC 3145
Phone: 03 9571 0100  Fax: 03 9571 0500

The information in this e-mail is confidential and is intended solely for the addressee. 
Any views or opinions presented are solely those of the author 
and do not necessarily represent those of Option Systems Pty.Ltd.

If you are not the intended recipient, please delete this message and
contact the sender.


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



[PHP] Pear DB

2008-07-10 Thread John Comerford

Hi Folks,

I have just successfully lobbied for the company I work for to use 
PHP/MySQL for our next website.  My Question is regarding DB abstraction 
.  I know there is a Pear DB module, is this the best to use ?  I have a 
vague memory of reading somewhere that there is a newer lib or something 
which is considered better ?


TIA,
 JC

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



[PHP] PHPNews Vs phpns

2008-07-02 Thread John Comerford
I am looking at including news on a website I am putting together.  From 
my google searches it seems the two main players are PHPNews and phpns.


Are these the main open source news systems ?
Is one considered better than the other ?
Anyone got any real world experiences with either of these products ?
Anyone recommend an alternative ?

TIA,
 JC

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



Re: [PHP] Re: Log files

2008-07-02 Thread John Comerford
If you are logging errors, then maybe you should look at using a file 
instead of a database table.  I have seen an instance where a system 
used a table for error logging and writing to the log table caused and 
error, you can guess where that left things.


Shawn McKenzie wrote:

Mark Bomgardner wrote:

I am writing an application in which I want to create log files.  I am
weighing the difference between using text files and using a database to
house the data.  It appears to me that there is really no advantage 
either

way or is there?  There are pros and cons to both methods, but I am
concerned about opening and closing a text file some many times that 
it may

cause and issue. The file may be opened and closed 1,000 or more times a
day.

 


Opinions please..

 


markb




Using a database you're hitting a file the same number of times (the 
database is in a file or files) but you have the mem/cpu overhead of 
the db itself.  Having said that, if you are using a database already 
for the site then might as well log to it.  I wouldn't implement a 
database only for the purpose of logging.


-Shawn




--
Option Systems Pty. Ltd.
53 Waverley Road, Malvern East, VIC 3145
PO Box 7, Caulfield East, VIC 3145
Phone: 03 9571 0100  Fax: 03 9571 0500

The information in this e-mail is confidential and is intended solely for the addressee. 
Any views or opinions presented are solely those of the author 
and do not necessarily represent those of Option Systems Pty.Ltd.

If you are not the intended recipient, please delete this message and
contact the sender.


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



[PHP] Restricting access to a file

2008-05-28 Thread John Comerford

Hi Folks,

This may not be strictly a PHP question but there may be something in 
PHP to do what I want.  I am in the process of putting together a pretty 
basic website using MySql and PHP on a third party host.  One of the 
function is to allow known stockist download a catalogue (.pdf).  I am 
fine to do login   etc.  but I am not sure how to approach restricting 
the catalogue.  I can do it so that the link is only visible if the user 
logins in, but that doesn't stop the link being downloadable even if it 
is not visible.  I was thinking I could put it in a location not visible 
to the public and transfer it to a location that is when the user logs 
in, something with a cryptic name etc...  but that doesn't really sit 
right with me and at very least gives me some house keeping issues


Anybody got a suggestion as to the best way to handle this ?

TIA,
 JC

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



[PHP] Graphical Site Map

2008-04-30 Thread John Comerford

Hi Folks,

Does anybody know of a product (php or otherwise) that enables the 
creation of a graphical site map ?  I have had a shimmy around the web 
but just keep finding classes to create the .xml format site maps.


TIA,
 JC

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



[PHP] Parameter

2008-03-12 Thread John Comerford

Hi Folks,

I am thinking of putting together a class to handle passing parameters 
to a class. Basically when you define a class you would define your 
class to extend the parameter class.
The parameter class would be JSON compliant so in the end when you call 
a class it you could pass the parameters as a JSON string.

(rough) eg.

myClass(label:test,title:this is text);

the parameter class would allow you to do something like:
echo  myClass-get(label);

The advantages are:
- You don't have to have a declaration for every variable used within 
your class
- I could make the parameter class case independent (I know I need a 
flame suit for this but case dependency get on my nerves)
- I can wrap a lot of functionality into the parameter class, stuff like 
'ifNotNull(label) ...'


So far disadvantages are:
- Eclipse etc.  has code completion, which means all the parameters you 
pass to a function can be presented to the developer as part of  code 
completion


I'd like to know:
- Have any of you guys already done something like I am talking about.
- As developers do you reckon losing code completion is worth the 
advantages of a parameter class

- Have I overlooked something major ?

Let me know what you think,
 JC


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



Re: [PHP] avoid calling php script

2008-03-12 Thread John Comerford

May the get_Browser function could tell you if it's from the .swf ?

http://us.php.net/manual/en/function.get-browser.php


H u g o H i r a m wrote:

Hello

I have a swf that runs a PHP script that generates a XML, on the PHP 
is there any way to detect if the file is being called from the swf or 
from the browser? because I want to avoid the file being run directly 
from the browser or from any other file than the swf.


regards,
Hugo.




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



[PHP] Array Push question

2007-07-12 Thread John Comerford

Hi Folks,

Is there a better way of doing the following:

$Rows[] = array();
$currentRow = count($Rows) - 1;
$Rows[$currentRow]['test'] = this is a test;

Specifically I am wonder if I can avoid having to use 'count'.

TIA,
 JC

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



Re: [PHP] Array Push question

2007-07-12 Thread John Comerford
As you guys can probably guess from the question I'm still getting to 
grips with some parts of php.


I had stripped down the code for my original post, maybe this will clear 
things up a bit:


$Rows[] = array();
$currentRow = count($Rows) - 1;
$Rows[$currentRow]['test'] = this is a test;
$Rows[$currentRow]['Data'] = array();
$Rows[$currentRow]['Config'] = This is the row config;

So from what you guys have said I have changed it to be the following:

$Rows[] = array('test' = 'this is a test', 'Data' = array(), 'Config' 
= 'This is the row config');


Which seems to be doing what I want.

Thanks for the replies,
 JC


Jim Lucas wrote:

John Comerford wrote:

Hi Folks,

Is there a better way of doing the following:

$Rows[] = array();
$currentRow = count($Rows) - 1;
$Rows[$currentRow]['test'] = this is a test;


I imagine that you are doing other actions between the above three 
lines? Correct?


Really, the simplest way of doing this is to call this over and over 
again.


$Rows[]['test'] = this is a test;

it will give you the same results as array_push, but without a 
function call


$Rows[]['test'] = this is a test;
$Rows[]['test'] = this is another test;
$Rows[]['test'] = this is even another test;

print_r($Rows);

this will show you that it does what you are doing in the above code, 
but again, the question.
What are you doing between all the lines of code that made you think 
that you had to do it your example way?  Are you using count() and 
doing math with it?  or something else?




Specifically I am wonder if I can avoid having to use 'count'.

TIA,
 JC



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



Re: [PHP] System wide variable

2007-05-23 Thread John Comerford

How about a table using the mysql memory engine ?

Darren Whitlen wrote:

Hi,
I have a PHP script that reads and updates either a small file or a 
mysql database. This script is called from several places every .5 
seconds.


I would like to move this file to a variable for extra speed as the 
file  is causing a few problems being accessed so many times.
Is it possible to have a writeable variable that has the scope of 
EVERY script that is run through the parser?


Thanks,
Darren



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



Re: [PHP] Cannot connect to an MySQL database using Named Pipes (resolved)

2007-05-16 Thread John Comerford
I got as reply on another forum which resolved this issue.  The command 
should be:


$mysqli = new mysqli(., $username,$password, 
$database,null,/tmp/mysql.sock);


NB. host is a dot

John Comerford wrote:

Hi Folks,

I have a database running on Window XP, that I want to disable network 
connections to and enable 'named pipes'.  I am running MySQL 5.0.27   
and my.ini looks like...


[client]
#password= your_password
port= 3306
socket= /tmp/mysql.sock

[mysqld]
#port= 3306
socket= /tmp/mysql.sock
#Allow connections via named pipes (Windows NT+ only). Note: you can 
specify a pipe name on the advanced network page, if required.

enable-named-pipe
#Don't allow connections via TCP/IP.
skip-networking



I can connect to the DB using the MySQL GUI tools if I set my pipe 
name to '/tmp/mysql.sock' using the login dialog box.
However when I try and connect using PHP I get an error.  I have tried 
several variants of the connect command and I get various errors but 
all are along the lines of:

Unknown MySQL server host '/tmp/mysql.sock' (11004)  or
Can't connect to MySQL server on 'localhost' (10061)

I have tried
$mysqli = new mysqli(null, $username,$password, $database);
$mysqli = new mysqli(localhost:/tmp/mysql.sock, $username,$password, 
$database);
$mysqli = new mysqli(localhost, $username,$password, 
$database,3306,/tmp/mysql.sock);
$mysqli = new mysqli(localhost, $username,$password, 
$database,/tmp/mysql.sock);

$mysqli = new mysqli(/tmp/mysql.sock, $username,$password, $database);

I have also tried the above commands using mysqli_connect ?  I have 
done a few searches of the web but seem to always come up with 
something like the above?  Anybody have any ideas why it won't connect 
in PHP ?


TIA,
JC




--

1^st Floor, 184 -186 Glenferrie Road, Malvern VIC 3144

PH:*(03) 9500 1466*
FX :*(03) 9500 1469*
Email: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
Web:  www.styleman.com.au http://www.styleman.com.au

The information in this e-mail is confidential and is intended solely 
for the addressee. Any views or opinions presented are solely those of 
the author and do not necessarily represent those of Option Systems Pty 
Ltd. If you are not the intended recipient, please delete this message 
and contact the sender.


[PHP] Cannot connect to an MySQL database using Named Pipes

2007-05-15 Thread John Comerford

Hi Folks,

I have a database running on Window XP, that I want to disable network 
connections to and enable 'named pipes'.  I am running MySQL 5.0.27   
and my.ini looks like...


[client]
#password= your_password
port= 3306
socket= /tmp/mysql.sock

[mysqld]
#port= 3306
socket= /tmp/mysql.sock
#Allow connections via named pipes (Windows NT+ only). Note: you can 
specify a pipe name on the advanced network page, if required.

enable-named-pipe
#Don't allow connections via TCP/IP.
skip-networking



I can connect to the DB using the MySQL GUI tools if I set my pipe name 
to '/tmp/mysql.sock' using the login dialog box.
However when I try and connect using PHP I get an error.  I have tried 
several variants of the connect command and I get various errors but all 
are along the lines of:

Unknown MySQL server host '/tmp/mysql.sock' (11004)  or
Can't connect to MySQL server on 'localhost' (10061)

I have tried
$mysqli = new mysqli(null, $username,$password, $database);
$mysqli = new mysqli(localhost:/tmp/mysql.sock, $username,$password, 
$database);
$mysqli = new mysqli(localhost, $username,$password, 
$database,3306,/tmp/mysql.sock);
$mysqli = new mysqli(localhost, $username,$password, 
$database,/tmp/mysql.sock);

$mysqli = new mysqli(/tmp/mysql.sock, $username,$password, $database);

I have also tried the above commands using mysqli_connect ?  I have done 
a few searches of the web but seem to always come up with something like 
the above?  Anybody have any ideas why it won't connect in PHP ?


TIA,
JC

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



[PHP] Find a what class a variable is

2007-04-27 Thread John Comerford

Hi Folks,

Is is possible to detect what class a variable is eg.

$JC1 = new Button();
$JC2 = new TickBox();


Is it possible to find out what class $JC1 is ?

TIA,
 JC

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



[PHP] Alternative/Addition to using a CAPTCHA

2007-03-29 Thread John Comerford
I was reading the current tread on CAPTCHA and possible cracks and I 
thought maybe I'd throw this out to the group to see what you think.  
Recently I saw a forum where in order to post you first had to click on 
a div that was placed at a random location on the page, it read 
something like, Click here if you are human.  I was thinking that 
maybe you could put together a system that looks something like this:


http://people.aapt.net.au/JComerford/ClickMe.htm

I was thinking you could use it in a couple of ways:

1) As a replacement to a CAPTCHA image
2) When you click the image a CAPTCHA image is loaded into the 'Click 
Me' container


The main problem is how to tell the server that the div has been 
clicked, in a way that can't be simulated.  I am not an expect with 
either JS or PHP, but maybe some of the bigger brains out there could 
throw in their 2 cents..


JC

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



[PHP] Check a string does not contain invalid characters

2007-03-21 Thread John Comerford

Hi Folks,

I am new to php.

I want to accept a character string which I will use as a unique user 
id.  I want to check the string to ensure the user has not typed 
characters that I consider to be invalid as part of a user id.  I was 
thinking of doing something along the lines of:


if (strpbrk($userid, '[EMAIL PROTECTED]*()_+=-{}[]\\|;\':?,./`')  null) { 
blah, blah, blah..


but I think that would still leave me open to control characters. 
I am thinking maybe I should loop through the string character by 
character and check it's ascii value (using ord) is within the range of 
a-z and A-Z ?
Is this the best way of achieving this ?  Is there a php command to do 
something similar ?  I have done a few web searches and haven't come up 
with much.


TIA,
 JC


[PHP] _Construct question

2007-03-20 Thread John Comerford

Hi Folks,

I am still pretty new to PHP and I have a question regarding classes and 
using _construct.  Up until now I have been creating my classes as follows:


class test1 {
var $name;
function test1($pName) {
  $this-name = $pName;
}
}

So I when I create a new class I can assign 'name' by doing '$t1 = new 
test1(test1);'


As part of another thread I noticed the _construct function which (if I 
am correct) does more or less the same thing:


class test2 {
var $name;
function _construct($pName) {
  $this-name = $pName;
}
}

I have fished around a bit and cannot find why one might be better than 
the other.  The only thing I can think is that maybe you need to use 
_construct to be able to use extends ?


Is this the case ?   What is the advantage/disadvantage of using 
_construct as opposed to using a function with the classname ?


Thanks,
 JC

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



[PHP] Log Lib Recommendation

2007-03-18 Thread John Comerford

Hi Folks,

Could someone recommend a good library for error logging.  What I am 
looking for is something that handles:


1) Error Log written to a DB (mysql)
2) Logging of PHP errors
3) Logging of MySQL errors
4) Logging of Custom errors/events
5) A log viewer would be nice but not really essential.

I have done some searches but it's kinda hard to see the wood for the 
trees...


Thanks,
 JC 


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



Re: [PHP] needed Yahoo like window for db query.

2007-02-18 Thread John Comerford

You can use their JS Scripts, Check out:

http://developer.yahoo.com/yui/

http://developer.yahoo.com/yui/container/



Chris Carter wrote:

Need some help on getting some database result in a css popup like yahoo. The
requirement is to open a div or a window similar to yahoo one. As you can
see from the link below.

http://news.yahoo.com/s/ap/20070218/ap_on_go_co/us_iraq

On this if you click on the Images next to the links Iraq, President
Bush, Hillary Rodham Clinton, Pentagon, etc. This opens a div within
the page with the search result. They are using some JavaScript to achieve
this.

Is there anyone with idea of where to find a code for a similar kind of
window. I need to present data from database in a similar kind or window.

Any link, text to search in google or code would do :-|

Thanks in advance,

Chris
  



--

1^st Floor, 184 -186 Glenferrie Road, Malvern VIC 3144

PH:*(03) 9500 1466*
FX :*(03) 9500 1469*
Email: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
Web:  www.styleman.com.au http://www.styleman.com.au

The information in this e-mail is confidential and is intended solely 
for the addressee. Any views or opinions presented are solely those of 
the author and do not necessarily represent those of Option Systems Pty 
Ltd. If you are not the intended recipient, please delete this message 
and contact the sender.


Re: [PHP] CHMOD a file in windows server 2003

2007-01-11 Thread John Comerford

Check out the CACLS command

HTH,
 JC


Kencana wrote:

Hi all,

anybody knows how to CHMOD a file to 777 or 666 or etc. in windows server
2003?

thank you

Regards,
Kencana
  


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



Re: [PHP] Closing a connection to browser without exiting the script

2006-11-02 Thread John Comerford
You could also use an Ajax call from the main window to start the 
processing without opening a second window.


HTH,
 John

Ed Lazor wrote:

Here's another idea:

display your message in the original browser window, launch a new 
browser window for the processing script, have the window set behind 
the first with javascript.  When your script is finished, have it 
output javascript that closes the processing window.



On Nov 2, 2006, at 12:37 PM, [EMAIL PROTECTED] wrote:


 Original Message 
Subject: [PHP] Closing a connection to browser without exiting the
script
From: David NĂ©grier [EMAIL PROTECTED]
Date: Wed, November 01, 2006 2:24 pm
To: php-general@lists.php.net

Hello there,

I'm having a somewhat unusual question here, and I cannot find any way
to solve it.

I have a PHP page that displays a message, and then, performs a very
long operation. Note that it displays the message first.
I do not intend to give some feedback to the user when the operation is
done.

I've seen I can use ignore_user_abort() to prevent the user from
stopping the ongoing operation, but that solves only part of my 
problem.
Because as long as the page is not fully loaded, the mouse cursor in 
the

user's browser is showing a watch.

So ideally, what I would like is to be able to close the connection 
from

the server-side, but without using the exit() function, so my script
keeps running afterwards.

I know I could use a system() call to launch another process to do the
processing, but I would like to avoid doing that, because there are 
many

variables in the context that I cannot easily pass in parameter.

I also tried to use the register_shutdown_function() to perform my
operation after the page is displayed but since PHP 4.1.0, the
connection is closed after the function is called

Would any of you have an idea on how I could close that connection?

Thanks a lot,
David
www.thecodingmachine.com


It's a bit different of an idea, but you could put your reqest to
perform the operation in a text file in some directory.  Then you have
a seperate PHP script that checks that directory for any files that
would tell it to operate.  Then you tell Cron to run that script every
minute, 10 minutes, whatever works best for you.

With this idea you can write out the file and then tell the person that
you have submitted a request.  Then the cron job checks for the request
and performs it.  You could use a database instead of a file as well
with the idea of a queue.  That would probably work better, because
then if you needed to you can keep track of which user's process was
run, and then update the user table.  Say the user table has a
column processing with three possible values.  0 (not processed), 1
(in processing), 2 (finished processing).  You could probably expand
upon that idea quite a bit more if you need to.

It's no single magic bullet function call, but that's how I'd probably
do it.

Ray

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



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



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