Re: [PHP] PHP sessions expiring early

2011-09-07 Thread Paul Waring

On 07/09/11 13:42, Richard Quadling wrote:

On 7 September 2011 12:32, Paul Waring  wrote:

On 07/09/11 12:16, Richard Quadling wrote:


On 7 September 2011 11:20, Paul Waringwrote:


Can anyone suggest things which I could try? I cannot work out why this
problem is happening for some users but not me.


For browsers/extensions that do automatic read ahead (I load page A
and linked pages B and C are also retrieved).


I hadn't thought of that. However, we audit all user logins and logouts, as
well as all page requests. If the browser was pre-fetching the logout page,
we'd have 'user logout' entries in our logs, but the only notices we have
are for users logging in. If users were being logged out because of
pre-fetching, I'd expect to see each login entry have a corresponding logout
entry.


Is the potential for cached pages to be returned for a user NOT logged in?


Any pages which a user has viewed whilst logged in shouldn't be cached,
assuming the browser is respecting the headers. They are all sent with:

Cache-Control: no-store, no-cache, must-revalidate, post-check=0,
pre-check=0


How is your code determining if they need to be redirected back to the
login page?


The test is whether two $_SESSION elements are set and match ones in the 
database, plus whether the last page view by the user (stored in the 
database, updated on each request) was less than one hour ago.



What changes that information?


A page load changed the 'last page view time'. Nothing changes the other 
session data, except an explicit logout (which sets $_SESSION = array() 
and calls session_destroy).



Can you monitor it externally?


I'm not sure what you mean by 'externally'. Most of the site requires a 
login, so it's not possible for a third-party to monitor it if that's 
what you mean.


--
Paul Waring
http://www.phpdeveloper.org.uk

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



Re: [PHP] PHP sessions expiring early

2011-09-07 Thread Paul Waring

On 07/09/11 12:16, Richard Quadling wrote:

On 7 September 2011 11:20, Paul Waring  wrote:

Can anyone suggest things which I could try? I cannot work out why this
problem is happening for some users but not me.


For browsers/extensions that do automatic read ahead (I load page A
and linked pages B and C are also retrieved).


I hadn't thought of that. However, we audit all user logins and logouts, 
as well as all page requests. If the browser was pre-fetching the logout 
page, we'd have 'user logout' entries in our logs, but the only notices 
we have are for users logging in. If users were being logged out because 
of pre-fetching, I'd expect to see each login entry have a corresponding 
logout entry.



Is the potential for cached pages to be returned for a user NOT logged in?


Any pages which a user has viewed whilst logged in shouldn't be cached, 
assuming the browser is respecting the headers. They are all sent with:


Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0


--
Paul Waring
http://www.phpdeveloper.org.uk

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



Re: [PHP] PHP sessions expiring early

2011-09-07 Thread Paul Waring

On 07/09/11 12:20, vikash.i...@gmail.com wrote:

Just confirm once that you are not calling session_destroy somewhere.


The only place session_destroy is called is in the logout function, 
which itself is only called if a user clicks the logout link.


--
Paul Waring
http://www.phpdeveloper.org.uk

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



Re: [PHP] PHP sessions expiring early

2011-09-07 Thread Paul Waring

On 07/09/11 12:15, Richard Quadling wrote:

How do you handle multiple logins?

If I login using my laptop and get Session A for my account and then I
login using my desktop and get Session B for my account, does Session
A get killed?


Session A is killed, your last login is always the current one.


Do you allow multiple, simultaneous logins per account?


No, but then each user is accessing their account from a single machine 
and browser anyway (i.e. they don't switch from desktop to laptop and 
then back again), so we don't even have people trying to have 
simultaneous logins.


--
Paul Waring
http://www.phpdeveloper.org.uk

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



Re: [PHP] PHP sessions expiring early

2011-09-07 Thread Paul Waring

On 07/09/11 11:47, Nilesh Govindarajan wrote:

On 09/07/2011 03:50 PM, Paul Waring wrote:

I'm having trouble with a PHP website which requires users to be logged
in to access all content other than the home page and a couple of static
pages (about us, contact us etc.). Several users have said they are
being logged out every few minutes whilst using the site - they can
login but will be shown the login form again after a few minutes. I
can't confirm this myself as the site seems to work fine for me - even
using the same browser as they are and under their accounts - but I'm
wondering if this could be a problem with the session settings?



You have set gc_maxlifetime to 3600 seconds. How much expire time have
you set?
Because, every 3600 seconds, session data stored is considered as
garbage and php clears them out itself.


Yes, I'm aware of that. However, users are being logged out after a few 
minutes, not one hour of inactivity (which is what I'd expect with 3600 
seconds).



If your expiration time is more than 3600 seconds, then this will not
work. You need to increase gc_maxlifetime.


If you mean the expiration time of the session cookie, it is set to 0, 
which means it shouldn't be deleted until the browser is closed (or the 
user logs out, at which point it is deleted immediately).


Paul

--
Paul Waring
http://www.phpdeveloper.org.uk

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



[PHP] PHP sessions expiring early

2011-09-07 Thread Paul Waring
I'm having trouble with a PHP website which requires users to be logged 
in to access all content other than the home page and a couple of static 
pages (about us, contact us etc.). Several users have said they are 
being logged out every few minutes whilst using the site - they can 
login but will be shown the login form again after a few minutes. I 
can't confirm this myself as the site seems to work fine for me - even 
using the same browser as they are and under their accounts - but I'm 
wondering if this could be a problem with the session settings?


The current settings I have are:

session.auto_start  Off
session.bug_compat_42   On
session.bug_compat_warn On
session.cache_expire180
session.cache_limiter   nocache
session.cookie_domain   no value
session.cookie_httponly Off
session.cookie_lifetime 0
session.cookie_path /
session.cookie_secure   Off
session.entropy_fileno value
session.entropy_length  0
session.gc_divisor  100
session.gc_maxlifetime  3600
session.gc_probability  1
session.hash_bits_per_character 4
session.hash_function   0
session.namePHPSESSID
session.referer_check   no value
session.save_handlerfiles
session.save_path   /shared/sessions
session.serialize_handler   php
session.use_cookies On
session.use_only_cookiesOff
session.use_trans_sid   0

The only options I have changed from the defaults are gc_maxlifetime, 
gc_probability and save_path. There are several sites on the same 
server, some are https, others just plain http. They all use the same 
session options. session_start() is called once on every page.


The PHP version we're running is: PHP 5.2.6-1+lenny13 with Suhosin-Patch 
0.9.6.2 (cli) (built: Jul  1 2011 16:01:01). I'm aware it's an old 
version before anyone tells me to upgrade (it's the latest stable 
version in Debian Lenny). :)


Potential problems I have already ruled out:

1. I don't think it's a browser problem as the users have a variety of 
browsers and versions (we log the user agent for each login, they're 
mostly IE7/8 on XP/Vista/7 with a few Chrome users), and I can't 
reproduce the problem using the same browsers on my machine.


2. The server time is correct.

3. The sessions aren't stored in a directory which is being regularly 
cleared out, such as /var/lib/php5 or /tmp.


4. The web server has permission to write to the save_path directory, 
and I can see session files being created.


5. No output buffering functions are being used.

Can anyone suggest things which I could try? I cannot work out why this 
problem is happening for some users but not me.


Thanks in advance.

Paul

--
Paul Waring
http://www.phpdeveloper.org.uk

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



Re: [PHP] How to code in PHP an onchange event in a ?

2010-11-05 Thread Paul Waring

On 04/11/10 20:23, Tomás Corrales Lemoine wrote:

I have this two files (“index.php” and “include.php”). They both work
fine, but I want to substitute the code for de onchange event in the
 tag. Can I use PHP to code this event? How?


xajax will allow you to call PHP code as if it was JavaScript:

http://www.xajax-project.org/

Paul

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



Re: [PHP] PHP sessions - users being automatically logged out

2010-11-04 Thread Paul Waring

On 04/11/10 14:56, Alexander Holodny wrote:

Inc session.cache_expire. You have only 3 minutes.
This means browser will drop cookie containing session id in three
minutes, or even less, of clients inactivity.


According to the PHP manual:

"session.cache_expire specifies time-to-live for cached session pages in 
minutes, this has no effect for nocache limiter."


So the value of session.cache_expire should be ignored, as 
session.cache_limiter is set to nocache.


Paul

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



[PHP] PHP sessions - users being automatically logged out

2010-11-04 Thread Paul Waring
I'm having trouble with a PHP site whereby some users are being logged 
out on a regular basis. This will usually happen after they have been 
using the site for a few minutes, they can login without any problems 
and access a few pages, but then suddenly they will request a page and 
be sent to the login form, which suggests that their session no longer 
exists. However, this doesn't affect all users - I can login and use the 
application without any problems, as can some other users.


According to phpinfo(), the following session values are set (all are 
what I'd expect - either the default or something I've deliberately 
changed):


session.auto_start = Off
session.bug_compat_42 = On
session.bug_compat_warn = On
session.cache_expire = 180
session.cache_limiter = nocache
session.cookie_domain = no value
session.cookie_httponly = Off
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_secure = Off
session.entropy_file = no value
session.entropy_length = 0
session.gc_divisor = 100
session.gc_maxlifetime = 1440
session.gc_probability = 1
session.hash_bits_per_character = 4
session.hash_function = 0
session.name = PHPSESSID
session.referer_check = no value
session.save_handler = files
session.save_path = /shared/sessions
session.serialize_handler = php
session.use_cookies = On
session.use_only_cookies = Off
session.use_trans_sid = 0

I've tried checking a few obvious things:

* IP addresses - the site doesn't use the IP address as part of the 
authentication process, and almost all our users (including the ones 
experiencing problems) have static IP addresses anyway.


* Number of sessions - there are between 40-60 session files on disk at 
any one time, so I doubt there's a "maximum number of session files" 
limit being broken, if such a configuration option exists.


* Permissions - the web server user (www-data) has read/write 
permissions to the directory where the sessions are stored and all the 
files within it, and they are all owned by this user.


Is there anything else obvious which could be causing the problem? This 
seemed to occur when we moved hosts, and I haven't changed the site's 
session handling code for some time, so I suspect it might be a 
configuration issue but can't figure out what.


Thanks,

Paul

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



Re: [PHP] Converting floats to ints with intval

2010-05-06 Thread Paul Waring

David McGlone wrote:

On Thursday 06 May 2010 07:19:48 Paul Waring wrote:

David Otton wrote:

On 6 May 2010 11:52, Paul Waring  wrote:

If I was designing the system from scratch, that's what I'd do.
Unfortunately this is an add-on to a legacy system where currency values
are already stored as strings in the database (yes, not ideal I know,
but you have to work with what you've got).

I don't know much about your situation, but it does sound like you
need to fix the root problem. I'd use a decimal type, and lean on the
database to do the maths.

As I said, unfortunately it's a legacy system, so I can't just change
the database to use a different type (there are dozens of columns set up
like this, with thousands of values already set).


Would It be possible to write a script to extract everything from that 
database and insert it into a database with the correct columns and values, 
then all you would need to do is change the db connection information.


Possible, yes. Practical, no. :)

--
Paul Waring
http://www.pwaring.com

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



Re: [PHP] Converting floats to ints with intval

2010-05-06 Thread Paul Waring

David Otton wrote:

On 6 May 2010 11:52, Paul Waring  wrote:


If I was designing the system from scratch, that's what I'd do.
Unfortunately this is an add-on to a legacy system where currency values are
already stored as strings in the database (yes, not ideal I know, but you
have to work with what you've got).


I don't know much about your situation, but it does sound like you
need to fix the root problem. I'd use a decimal type, and lean on the
database to do the maths.


As I said, unfortunately it's a legacy system, so I can't just change 
the database to use a different type (there are dozens of columns set up 
like this, with thousands of values already set).


--
Paul Waring
http://www.pwaring.com

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



Re: [PHP] Converting floats to ints with intval

2010-05-06 Thread Paul Waring

Ashley Sheridan wrote:

Why don't you store them as integer values and add in the decimal point
with something like sprintf() afterwards? Store the values as pence and
then you won't have any rounding problems.


If I was designing the system from scratch, that's what I'd do. 
Unfortunately this is an add-on to a legacy system where currency values 
are already stored as strings in the database (yes, not ideal I know, 
but you have to work with what you've got).


--
Paul Waring
http://www.pwaring.com

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



Re: [PHP] Converting floats to ints with intval

2010-05-06 Thread Paul Waring

Ashley Sheridan wrote:

It's part of the rounding problem you get with most languages out there.
Why can't you compare the floating point values though? Currency should
only have one decimal place anyway.


You can't compare floating point values because if you have, for 
example, a user-entered value of '37.12' and add that to '0.18' it won't 
necessarily be equal to '37.30'.


Currency must have two decimal places, otherwise how would you represent 
five pounds and sixteen pence (£5.16) for example?


--
Paul Waring
http://www.pwaring.com

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



[PHP] Converting floats to ints with intval

2010-05-06 Thread Paul Waring
I've got the following script which demonstrates a problem I'm having 
with floating point numbers and intval:


$times100 = (-37.12 * 100);
print $times100 . "\n";

$intval100 = intval($times100);
print $intval100 . "\n";

print ($intval100 / 100) . "\n";

I expect the output to be:
-3712
-3712
-37.12

However, the actual output I'm getting (on several systems, so it's not 
just my machine) is:

-3712
-3711
-37.11

Is there a reason for this, and a better way I should be doing it? 
Basically I need to add up a list of floats, representing currency 
values, and see if they're equal to another float, but I need to convert 
 them to ints first because I can't guarantee than there won't be 
something after the second decimal place.


Thanks,

Paul

--
Paul Waring
http://www.pwaring.com

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



Re: [PHP] Javascript detection

2007-01-01 Thread Paul Waring

On Mon, 1 Jan 2007 16:14:06 -0500, tedd <[EMAIL PROTECTED]> wrote:
> Does this technique work to detect your browser's javascript setting?

Not for me, it says "Javascript has not been detected on the client." when in 
fact I've got JavaScript enabled (Firefox 1.5.0.8 on Ubuntu Linux).

Paul

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



Re: [PHP] Snow on the logo

2007-01-01 Thread Paul Waring

On Mon, 1 Jan 2007 10:50:04 -0500, tedd <[EMAIL PROTECTED]> wrote:
> However, does the php logo change for those in the southern
> hemisphere? In other words, for oz programmers, do they see a
> different logo? If so, how does one (or can) detect the user's
> hemisphere?

Detecting a user's geographical location is a bit hit and miss, but there are 
some databases (both free and paid for) that you can use to map an IP address 
to a country and at that level it's usually fairly accurate (the further you 
try to narrow it down, the less accurate your results will be). Have a look at 
these databases, and a search for 'geoip' or 'libgeoip' on Google should get 
you some more results:

http://www.hostip.info/
http://www.maxmind.com/app/geoip_country

Hope this helps.

Paul

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



Re: [PHP] PHP suddenly stops working on FreeBSD

2006-05-10 Thread Paul Waring

On 10/05/06, Richard Collyer <[EMAIL PROTECTED]> wrote:

Does this do the same with PHP5? Remember mod_php5 has gone from ports
so lang/php5 then make config and select build apache option.


I've no idea whether it does that with PHP5, but I'm not ready to
upgrade to that version yet (perhaps over the summer when I have a bit
more spare time I'll attempt it).

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] PHP suddenly stops working on FreeBSD

2006-05-10 Thread Paul Waring

On 10/05/06, Riemer Palstra <[EMAIL PROTECTED]> wrote:

These are rather recent versions of both, so I'm suspecting an upgrade
was done recently which didn't make PHP all that happy. This is PHP
built from the port /usr/ports/lang/php4? Go to that dir, type 'make
config', make sure the APACHE knob is checked, en deinstall/reinstall
that port. Be sure the LoadModule line above is then uncommented and try
a restart again.


Cheers, I checked make config (highly useful command, didn't know you
could do that) and for some reason the APACHE option wasn't checked -
I have absolutely no idea why because it's always worked in the past,
perhaps it's disabled by default now or something. Anyway, after
rebuilding PHP it created the shared object file and a quick
shutdown/restart of Apache later everything was working.

Thanks for the help everyone, especially the FreeBSD-specific stuff
that I probably wouldn't have seen otherwise. :)

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] PHP suddenly stops working on FreeBSD

2006-05-10 Thread Paul Waring

On 10/05/06, Jochem Maas <[EMAIL PROTECTED]> wrote:

the php may be being loaded in via an include conf file 
do you havbe a line in httpd.conf that start with 'Include' ?


Only one, and that includes some virtual host files (I don't think
those are the problem, as Apache usually complains if there's an
actual error in the configs).


what is the configure line used to build php? (does it contain a configure 
option
'--with-apxs2' ?)


I don't know, I'm building it with FreeBSD ports so I don't see the
configure line. I do see this in the log though:

Configuring SAPI modules
checking for AOLserver support... no
checking for Apache 1.x module support via DSO through APXS... no
checking for Apache 1.x module support... no
checking for mod_charset compatibility option... no
checking for Apache 2.0 filter-module support via DSO through APXS... no
checking for Apache 2.0 handler-module support via DSO through APXS... no


does the php error log OR the apache error log mention anything related to
php start up when you have the 'LoadModule' in httpd.conf commented out?


The Apache log has:

[Wed May 10 14:15:50 2006] [notice] caught SIGTERM, shutting down
[Wed May 10 14:15:53 2006] [notice] mod_python: Creating 8 session
mutexes based on 150 max processes and 0 max threads.
[Wed May 10 14:15:54 2006] [notice] Apache/2.0.58 (FreeBSD)
mod_python/3.2.8 Python/2.4.3 configured -- resuming normal operations
[Wed May 10 14:27:25 2006] [notice] caught SIGTERM, shutting down
[Wed May 10 14:27:28 2006] [notice] mod_python: Creating 8 session
mutexes based on 150 max processes and 0 max threads.
[Wed May 10 14:27:29 2006] [notice] Apache/2.0.58 (FreeBSD)
mod_python/3.2.8 Python/2.4.3 configured -- resuming normal operations
[Wed May 10 14:48:01 2006] [notice] caught SIGTERM, shutting down
[Wed May 10 14:48:04 2006] [notice] mod_python: Creating 8 session
mutexes based on 150 max processes and 0 max threads.
[Wed May 10 14:48:05 2006] [notice] Apache/2.0.58 (FreeBSD)
mod_python/3.2.8 Python/2.4.3 configured -- resuming normal operations
[Wed May 10 14:49:52 2006] [notice] caught SIGTERM, shutting down

Which isn't terribly helpful.

Paul

--
Data Circle
http://datacircle.org

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



[PHP] PHP suddenly stops working on FreeBSD

2006-05-10 Thread Paul Waring

I restarted Apache this morning in order to allow some new virtual
hosts to be recognised, and now I've got a problem whereby all of my
PHP scripts are being served up as source code instead of being
executed by the web server. I don't know why this is, as far as I'm
aware I haven't changed anything PHP-related for a while and
everything was running fine until this morning. Running

grep php /usr/local/etc/apache2/httpd.conf

Gives me:

#LoadModule php4_modulelibexec/apache2/libphp4.so
DirectoryIndex index.html index.htm index.php
#AddType application/x-httpd-php .php
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

So there's definitely an AddType directive for PHP scripts. If I
uncomment the LoadModule line I get the error:

Cannot load /usr/local/libexec/apache2/libphp4.so into server: Cannot
open "/usr/local/libexec/apache2/libphp4.so"

But I think that line has always been uncommented (and libphp4.so
doesn't exist anywhere on the machine). I've tried rebuilding PHP, but
it hasn't made any difference.

Does anyone have any ideas as to what might have gone wrong? I'm at a
loss as to how things could suddenly have broken when they were
working fine before.

Some version numbers in case it helps:

php -v
PHP 4.4.2 (cli) (built: May 10 2006 14:40:03)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

httpd -v
Server version: Apache/2.0.58
Server built:   May  7 2006 10:42:02

Thanks in advance,

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] Session_destroy

2006-04-19 Thread Paul Waring
On 19/04/06, Shannon Doyle <[EMAIL PROTECTED]> wrote:
> Trying to get a session to destroy correctly, however the darn thing just
> refuses to destroy. I call the following in a separate webpage in a effort
> to destroy the session, only to find that the session still persists.
>
>  session_start();
> session_unset();
> session_destroy();
> Header("Location: index.php");
> ?>

First of all, if you're using $_SESSION or $HTTP_SESSION_VARS, the PHP
manual will tell you to use unset($_SESSION['key']) rather than
session_unset(). Personally though, I've found the following code
works well for completely destroying a session:



Also, when using redirects, you should specify the complete absolute
URL, not a relative one. You can sometimes get away with using a
relative one but it's bad practice and breaks section 14.30 of RFC
2616 (the HTTP/1.1 specification).

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] php 3 to 5 upgrade: foreach loop no longer working

2006-04-19 Thread Paul Waring
On 18/04/06, Vernon Webb <[EMAIL PROTECTED]> wrote:
> I've recently upgraded a server from Fedora Core 3 to Core 5 in the process 
> php had
> been upgraded from either 3 or 4 to php 5. In doing so I had to do a major 
> overhaul of
> a web site as many things stopped working (.i.e $HTTP_POST_VAR, etc).

There is actually an option in php.ini to switch on the $HTTP_*_VAR
variables, although it's off by default in PHP 5. It's still better in
my opinion to use the $_* superglobals ($_POST, $_GET etc), but if
you've got hundreds of scripts and no time to convert them (or you're
running phpBB, which relies on the deprecated behaviour), then enabled
register_long_arrays in php.ini.

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] Pushing Vars into $_SESSION

2006-04-18 Thread Paul Waring
On 18/04/06, Chris Grigor <[EMAIL PROTECTED]> wrote:
> Was wondering if there is an easier way to get returned variables into
> the $_SESSION rather than going through each one??

First of all, why are you using mysql_fetch_object and then passing in
MYSQL_ASSOC? You should be using $line = mysql_fetch_array($result)
instead. If you get the row data as an associative array, you can then
simply do:

foreach ( $line as $key => $value )
{
$_SESSION[$key] = $value;
}

That way, whatever columns you select from the database will
automatically be loaded into session variables, so if you change the
SQL, you'll also change the sessions. I think this is what you're
asking for, apologies if I'm misinterpreted the question.

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] SELECT?

2005-12-30 Thread Paul Waring
On 12/30/05, Richard Lynch <[EMAIL PROTECTED]> wrote:
> The suggestions so far are good, but watch out for this:
>
> If you do one record at a time, and are using LIMIT, and then
> something gets inserted into the original table...
>
> Boom!

You could always lock the tables whilst performing the update - not
very useful if the database has to be up all the time but it's
probably the safest way of doing it.

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] SELECT?

2005-12-28 Thread Paul Waring
On 12/28/05, William Stokes <[EMAIL PROTECTED]> wrote:
> I have one MySQL table with about 500 rows. I need to read the table one row
> at a
> time, make some changes to data in one field and then store the changed data
> to another table.
>
> I'm using PHP to change the data but I have no idea how to select one row at
> a time from the DB table. There's one auto-increment id field in the table
> but the id's doesn't start from 1 and are not sequential.
>
> Any ideas or help is much appreciated!

Can you not just fetch all the data at once like so:

$result = mysql_query("SELECT * FROM mytable");

then iterate over the results:

while ( $row = mysql_fetch_assoc($result) )
{
mysql_query("INSERT INTO othertable (column1) VALUES (" .
$row['column_x'] . ");
}

The only thing you'd have to be careful with is the maximum execution
time settings if you're running this script over the web, as opposed
to on the command line. If you're only making changes to 500 rows
though it shouldn't take too long - I've restored thousands of rows to
a database before and that took less than a second.

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] mysqli module in php 4

2005-12-28 Thread Paul Waring
On 12/28/05, Bagus Nugroho <[EMAIL PROTECTED]> wrote:
> Is mysqli module enable by default on php 4 as mysql module.

No, because it's a PHP5 module (if you look at the documentation for
it, all the php.ini settings for it have only been available since
5.0.0).

> If not enable by default, where I can get this module(hopefully  a direct 
> link to download)

I've heard rumours of people getting it installed/running under PHP 4,
but I'm not sure if you really can or not. There is no direct
download, the installation section of the mysqli extension page tells
you how to get it to work:

http://www.php.net/mysqli

Paul

--
Data Circle
http://datacircle.org

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



Re: [PHP] PDF documentation

2005-12-25 Thread Paul Waring
On 12/25/05, John Meyer <[EMAIL PROTECTED]> wrote:
> Hi,  does the PHP document come in a PDF form?

No, it comes in the online format, HTML for offline viewing and
Windows HTML help. However, there is a guide to editing the XML
sources that can be found at the following URL:

http://doc.php.net/php/dochowto/

You might be able to use the sources and some tools to convert the
documentation to PDF.

Paul

--
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Re: SOAP and PHP

2005-11-16 Thread Paul Waring
On Wed, Nov 16, 2005 at 12:40:21PM +0100, Petr Smith wrote:
> Who uses PEAR? Mess of old unsupported and undocumented libraries which 
> only their authors (maybe) can use?

I use PEAR for a few things, such as database abstraction. I admit that
a lot of the less popular modules haven't been updated/documented in a
long time though, which is a shame.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Security Issues - Where to look?

2005-11-08 Thread Paul Waring
On Mon, Nov 07, 2005 at 01:50:59PM -0800, Richard wrote:
> I've heard that php is not particularly secure, making it problematic if you
> intend to create a web site with commerce, etc. Is there a particular news
> group that addresses security issues? I'm looking for some guidlines on
> ensuring that my site is secure from malicious hackers.

Other people have already addressed issues about writing secure code,
but if you're concerned about PHP itself being inherently insecure you
could always take a look at Hardened-PHP:

http://www.hardened-php.net/

I haven't used it myself, so can't vouch for how secure it actually is.
Obviously any system is only going to be as strong as its weakest link,
so if you have users with guessable passwords then you'd want to address
that before worrying about whether PHP is secure or not (and of all the
vulnerabilities that I've seen exploited on servers, the two major
problems are insecure scripts - such as phpBB - not being kept up to
date, and users choosing poor passwords or giving out their login
details to other people).

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Adding to a numeric variable, how?

2005-11-05 Thread Paul Waring
On Sat, Nov 05, 2005 at 01:23:01PM +0200, Dotan Cohen wrote:
> How can I shorten it to something like this:
>  print $number." ".$number+2."\n";
> ?>

Try:



I think putting the $number + 2 in brackets will cause PHP to evaluate
that part of the expression before printing it.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Looking for a string function

2005-11-02 Thread Paul Waring
On Wed, Nov 02, 2005 at 02:35:47PM -0700, Phillip S. Baker wrote:
> I seem to remember a built in php function that will take a huge block of
> text.
> Then just spit out X number of characters from it and follow it with an
> additional string value.
> But I cannot remember what it is.

I don't know if there's a built-in PHP function to do what you want, but
I wrote this function for one of the sites I run that does the same
thing. Feel free to use it (or expand it to use a custom 'cut off'
string) if you want.

function crop_text($text, $max_length)
{
 return strlen($text) > $max_length ? substr($text, 0,
$max_length - 3) 
. '...' : $text;
}

$excerpt = crop_text($input_text, 200);

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] php mail function vs smtp server

2005-10-31 Thread Paul Waring
On Mon, Oct 31, 2005 at 12:56:01PM +0200, Clive wrote:
> Thanks I actually want to send 24 000 emails with 2 meg attachments.

Oh. You definitely don't want to be using an external SMTP server if you
can help it then, and you should really be splitting those up into
chunks (no more than 1,000 at a time really) using something like PEAR
Queue as has already been suggested.

> There also another option with the class: using the sendmail program, 
> but  won't the php mail function use sendmail anyway

As far as I know, mail() just sends stuff to whatever the sendmail
binary is on your system, although I haven't really looked into it. Of
course you don't have to be running sendmail as most MTA will install
binaries such as /usr/sbin/sendmail which actually point to postfix or
qmail or whatever you're running.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] php mail function vs smtp server

2005-10-31 Thread Paul Waring
On Mon, Oct 31, 2005 at 12:38:09PM +0200, Clive wrote:
> what I mean is: im using a class called phpmailer and it has the option 
> to sent to a smtp server, I suppose this means that they do open a 
> socket to the smtp server.

All that means is that you can specify an external SMTP server (e.g.
mail.myisp.com), whereas mail() will use localhost instead. In this case
mail() would probably be quite a bit faster (though only if you're
sending thousands and thousands of emails) because it won't have to send
stuff out beyond the local machine.

Depending on what you want to do and how much control you have over the
machine your PHP scripts are running on, you might want to run a local
mail server that just relays everything to an external source (whatever
SMTP server you're currently using) - that way you can send everything
to that and your PHP script should return control a bit faster.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] php mail function vs smtp server

2005-10-31 Thread Paul Waring
On Mon, Oct 31, 2005 at 12:10:02PM +0200, Clive wrote:
> does anyone know whats better/uses less resource etc:
> 
> If I run a loop to send a 1000 emails, should I use php's mail fucntions 
> or send directly to the servers smtp server.

What do you mean by "send directly"? Are you thinking of sending mail
manually through making a socket connection or something?

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Php, Rails and ajax

2005-10-24 Thread Paul Waring
On Mon, Oct 24, 2005 at 03:34:23PM +0200, Jacob Friis Saxberg wrote:
> Is it possible to use Php, Rails and ajax via some open source system?
> How do you do it?

I don't know what exactly you mean by "rails", as it seems to be a
buzzword for half a dozen different things at the moment. However, I did
come across this site in one of the RSS feeds that I subscribe to:

http://www.phpontrax.com

PHPonTrax claims to be "a web-application and persistance framework that
is based on Ruby on Rails", though having not used it myself I can't
speak for how accurate that claim is.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] No redirect with header()

2005-10-16 Thread Paul Waring
On Sun, Oct 16, 2005 at 05:25:12PM +0200, Dotan Cohen wrote:
> You say that it worked for you? Where did it take you? It _should_
> take you to another lyrics site. Did you stay on http://lyricslist.com
> or go somewhere else?

If I go to lyricslist.com and click the logo or the "Song Lyrics" link,
then I get redirected to lyricsfreak.com. No blank pages, and the URL in
my address bar changes too.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] No redirect with header()

2005-10-16 Thread Paul Waring
On Sun, Oct 16, 2005 at 05:04:09PM +0200, Dotan Cohen wrote:
> header ("Location: ".$url);
> ?>
> 
> Does this seem like it should work? It doesn't. What is the correct
> syntax for these things?

That code should work, and the example on your site seems to work for
me. The only thing you should make sure is that $url is an absolute URL,
even if you're redirecting within your own site (e.g. you shouldn't use
../lyrics/ or /lyrics/) - you may be able to get away without doing this
but it's not the "correct" way to do things.

You may want to change your code to this:

header("Location: $url"); // no point in concatenating since double
quotes will interpolate the value of $url anyway
exit();

I can't remember why, but calling the exit(); function fixed a problem I
was having a while back when I was being sent to the right URL but the
old one was staying in my browser address bar.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] What's the safest way to destory/wipe out the arrays within the associative arrays?

2005-10-13 Thread Paul Waring
On Wed, Oct 05, 2005 at 03:12:51PM -0400, Scott Fletcher wrote:
> What is the safest way to destroy or take out the
> $xml['NEWSFEED']['0']['MESSAGE']['2']. associative arrays starting with
> ['2'] and those arrays inside of the ['2'] array path?
> 
> The unset() would make it not possible to reassign the data to this array
> once again, that is what I do not want.

Could you not just do:

$xml['NEWSFEED']['0']['MESSAGE']['2'] = null;

I think that would still keep the array element open, but there would be
no data there.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Guide for C programmer

2005-10-13 Thread Paul Waring
On Thu, Oct 13, 2005 at 02:13:37PM +0300, Turgut Hakk? ?ZDEM?R wrote:
> I'm looking for a document describing differences between C and PHP,
> important points for programmers who already know C,C++, and things that
> must be taken care.
> I'm googling for about an our but i can't find anything. Any suggestions.?

I don't see why anyone would write such a document. Other than sharing a
similar syntax and flow control (curly braces, if/else blocks, while
loops etc.), they're different languages. For a start C is compiled
whereas PHP is interpreted, and you can't just jump between the two. You
also don't have to bother, most of the time, with using the right
variable types in PHP because it will handle conversions automatically.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Removing Items from an Array

2005-10-12 Thread Paul Waring
On Wed, Oct 12, 2005 at 05:24:11PM +0100, Alan Lord wrote:
> I'm really struggling here! I have a large, multi-dimensional array that
> I want to "clean-up" a bit before committing to a database.

How big an array? You could just go create another array of the same
structure and copy the values across (and the keys too if it's an
associative array) then remove all references to the old array and
commit the new one to the database..

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Generating a 404 status message with header()

2005-08-09 Thread Paul Waring
On Mon, Aug 08, 2005 at 04:37:12PM -0400, Eric Gorr wrote:
> Should it? Is it possible to write a doesexists.php script which would 
> cause the 404 directive to be triggered?
> 
> I also tried: header("Status: 404 Not Found"); but this did not work either.

Try searching the archives for this list, I'm sure this question, or one
very similar to it, was asked and answered fairly recently.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] About Get_meta_tags()

2005-08-08 Thread Paul Waring
On Mon, Aug 08, 2005 at 05:10:27PM -0700, Jimmie wrote:
> But an errors occurred when the page run. Some information liked this:
> 
>   Warning: get_meta_tags(): php_network_getaddresses: gethostbyname failed
> in d:\apache\htdocs\meta_tag.php on line 3
> 
> Warning: get_meta_tags(http://www.pconline.com.cn): failed to open stream:
> No such file or directory in d:\apache\htdocs\meta_tag.php on line 3

The first error means that PHP can't resolve the domain name
pconline.com.cn, i.e. it doesn't know what IP address that site is
hosted on. As a result, it can't connect to the site and open a file
stream to read the page you want to get the meta tags for, which is what
the second error is about. I would suggest getting up a command prompt
on the machine you are using (if this is possible) and seeing if you can
resolve the domain manually by running 'nslookup pconline.com.cn'
(without the quotes). If you can't, then there's almost certain a
problem with one of your DNS resolvers, as I can resolve the hostname
from here.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] PHP 4.0.6 documentation

2005-08-05 Thread Paul Waring
On Fri, Aug 05, 2005 at 03:53:41PM +0200, Sabine wrote:
> may anybody give me a tip where to find a documentation for 4.0.6?
> Perhaps I'm a little bit blind, but I don't find it.
> Unfortunatedly I have to develop an application on this release.

Does the documentation at php.net not suffice? It usually says when
particular functions were introduced/changed, e.g.:

http://www.php.net/pg_escape_string
pg_escape_string
(PHP 4 >= 4.2.0, PHP 5)

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



[PHP] Amazon Web Services 4 wrapper

2005-07-31 Thread Paul Waring
Does anyone know of an open source wrapper class for the Amazon Web
Services API (version 4)? The only ones I can find are either years out
of date (such as Amazon_Services in PEAR) and so no longer work, or they
require me to parse the XML myself. All I want is something relatively
simple that I can give my developer token and a search term (99% of the
time this will be the ISBN of a book) and get back a data structure
(preferably an associative array) with the product information.

Thanks in advance,

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk


pgpKTk92OcyHO.pgp
Description: PGP signature


Re: [PHP] AJAX & PHP

2005-07-21 Thread Paul Waring
On Thu, Jul 21, 2005 at 11:22:25AM +0530, balwant singh wrote:
> Have anybody tried PHP & AJAX, may please share your experience.  also 
> pls. suggest good link of tutorial on this.

I haven't tried it myself, but this looks rather good, article on how to
implement Google Suggest in PHP:

http://tinyurl.com/dxs8b

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] My Project

2005-07-19 Thread Paul Waring
On Tue, Jul 19, 2005 at 09:50:06AM -0700, George B wrote:
> My money is being stored in a database. And I want everythign to be in 
> PHP, no java script. And the BUY!! Button is a input button from a form. :)

Well in that case you probably want something like this (after you've
checked to see whether the user is logged in etc):

$sql = "UPDATE users SET money = money - 10 WHERE id = " .
$_SESSION['user_id'];

assuming of course that you have a table called users where the money
for each one is stored and you're keeping the user_id in the $_SESSION
superglobal.

It's a bit difficult to help further without a bit more information. :)

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] My Project

2005-07-19 Thread Paul Waring
On Tue, Jul 19, 2005 at 09:39:21AM -0700, George B wrote:
> And I have 100 points. How would I make it so when I click BUY!! 
> My money automaticaly subtracts from 100 to 90. How do I do that?

Where is your money being stored? In a database? A text file? A cookie?
Do you want the "buy" link to work on the client side using Javascript
or AJAX or have it submit to a PHP script?

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] error when trying to delete a record

2005-07-11 Thread Paul Waring
On Mon, Jul 11, 2005 at 03:25:33PM +0100, Mark Rees wrote:
> with no single quotes round it. Putting quotes round integer values is
> counter-intuitive - is it necessary in some cases?

If the field is a numeric type (e.g. INT) as opposed to numeric data
being stored in a character field (e.g. a telephone number) then it is
not only unnecessary to quote the value, it's also incorrect useage of
SQL, although you'd probably get away with it in most database systems.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] getting the email addresses in a sendable format.

2005-07-11 Thread Paul Waring
On Mon, Jul 11, 2005 at 11:20:05AM +0100, Ross wrote:
> But I have having trouble assiging them to the variable $recipients. Really 
> what i want is to convert
> 
> $email_addresses[0] = [EMAIL PROTECTED]
> $email_addresses[1] = [EMAIL PROTECTED]
> $email_addresses[2] = [EMAIL PROTECTED]
> 
> into
> 
> $recipients= "[EMAIL PROTECTED], [EMAIL PROTECTED], [EMAIL PROTECTED]";

You want the implode() function using a line like this:

$recipients = implode(', ', $email_addresses);

This will create a string of all the values in each element of the
$email_addresses array, separated by a comma and a space (of course you
can change this to anything you want). You can find more information
about the function here:

http://www.php.net/implode

> (ii) does the space between addresses matter? I would rather have it as my 
> user could see the recipeints more clearly.

As far as I'm aware, any standards compliant mail server will just
ignore the extra whitespace so you are free to insert spaces if you so
desire.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] $_SESSION and header()

2005-06-26 Thread Paul Waring
On Sun, Jun 26, 2005 at 04:33:30PM +0200, Alessandro Rosa wrote:
> But, when I'm in the new page of (c), the $_SESSION variables stored
> in (a) are no longer available and I can get anymore their values then,
> (I can't say if they have been unset or erased).

You have to pass the session ID between pages, either by setting
session.use_cookies = 1 (so that the session ID is passed using a
cookie where possible) or append the session ID to the URL you are
redirecting to as part of the query parameters.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] send email at certain hour

2005-06-25 Thread Paul Waring
On Sat, Jun 25, 2005 at 06:29:16PM +0300, vlad georgescu wrote:
> i want to make a "reminder" application which sends emails at certain hour 
> in php. is this posibile ? if not, what else can I use ?

It's sort of possible - I know vBulletin uses a hidden image or
something to call a file called cron.php which runs certain tasks every
X hours or so. I haven't looked at it in detail though.

If you have access to a server where you can run cron jobs though, I'd
recommend doing things that way above anything else, as PHP isn't really
the best way to implement a "do something every X " solution.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Stop spreading PEAR FUD; WAS Re: [PHP] Re: PHP web archeticture

2005-06-25 Thread Paul Waring
On Sat, Jun 25, 2005 at 10:32:41AM -0400, Matthew Weier O'Phinney wrote:
> If somebody could offer some *constructive* criticism of PEAR -- PEAR as
> it is TODAY, not "3 years ago, when I last tried it" -- these comments
> would have more weight. As it is, I feel they're just FUD based on
> ignorance.

The documentation for some of the less well known packages is poor or
non-existant, or at least that's what I've always noticed and has been
my major bug bear with PEAR for a long time. For example, I want to use
the DB_Pager module but there is *no* end user documentation, all I have
to work with is some poorly formatted information pulled from the API
comments.

There are also a lot of packages (again, less well known ones) that
haven't been updated in a long time, in some cases several years. I'm
not saying that PEAR in general is a stale project, or that it's no good
(on the contrary, I use several of the packages on my sites and they're
very useful), but I do get the feeling that the non-core packages have
been left to rot both in terms of updates and documentation.

I've used both PEAR and CPAN for a few years now and I've noticed that
CPAN tends to win hands down in terms of documentation and updates. That
might just be down to the particular packages I've happened to use but
given a choice I know which one I'd rather use.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] SIMPLExml problem....

2005-06-20 Thread Paul Waring
On Mon, Jun 20, 2005 at 10:48:41AM +0200, Cruonit wrote:
> I tryed this simple PHP script that uses SimpleXML control:


In future, please don't post the same thing to the list three times,
there really is no point. If your post isn't showing up, at least have
the patience to wait a few minutes before re-sending if you think it
hasn't got through.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Re: Getting help on using the PHP lists

2005-06-11 Thread Paul Waring
On 6/10/05, Leila Lappin <[EMAIL PROTECTED]> wrote:
> Have you tried changing the subscription options through the website?  I
> think you can do it by just checking the type of list you're interested in
> subscribing.

I don't know about other people, but I've had lots of problems trying
to subscribe through the web site - I never got the confirmation
emails and in the end I just subscribed via email using
php-general-subscribe.

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] newbie error message i don't understand....please help

2005-06-08 Thread Paul Waring
On 6/8/05, Greg M. Price <[EMAIL PROTECTED]> wrote:
> Please help - I got " Error message:
> 
> "Your PHP version does not have support for MySQL"
> 
> when I did http://x.x.x.x/install.php on windows 2003 with Php 5.04 and
> MySQL 5.0.

PHP 5 doesn't come with the MySQL client libraries built-in. See:

http://uk.php.net/manual/en/faq.databases.php#faq.databases.mysql.php5

for more details.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] HELP! form validation

2005-06-08 Thread Paul Waring
On 6/8/05, Dave Sayer <[EMAIL PROTECTED]> wrote:
> What would be the best method of validation a large (8 stages) form written
> in php? The form validates using php at the moment but it only displays the
> errors in a group, what we want it to do is highlight the fields or labels
> for the incorrect entries (if that makes sense.) so the user can easily see
> where to correct their mistakes. Any advice, or links to good resources
> would be great!! I do not really know javascript so a php solution would be
> preferable.

You might want to have a look at the following links:

http://kalsey.com/simplified/form_errors/
http://www.sitepoint.com/print/practical-xml-form-validation
http://simon.incutio.com/archive/2003/06/17/theHolyGrail

I use a slightly modified version of Kalsey's method on my weblog and
it works quite well.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] looping through an array problem

2005-06-05 Thread Paul Waring
On 6/5/05, Jack Jackson <[EMAIL PROTECTED]> wrote:
> I'd like to stop the NY Sun from appearing twice! What have i missed here?

There's nothing wrong with your PHP code as such (although you could
filter out duplicates there if you wanted), all you should need to do
is add the DISTINCT keyword to your SQL query on the appropriate colum
like so:

SELECT art.art_id,art.publisher_id, DISTINCT publisher.publisher_name,
FROM art
LEFT JOIN publisher
ON publisher.publisher_id=art.publisher_id

I believe the DISTINCT keyword is part of the SQL standard, so it
should work on MySQL, Postgres etc.

Hope this helps.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Re: stripping html tags

2005-06-05 Thread Paul Waring
On 6/5/05, Dotan Cohen <[EMAIL PROTECTED]> wrote:
> I don't want to strip out all the tags, just certain ones.

You can use strip_tags() and tell it not to strip certain tags if you
want, that feature has been available since PHP 3.

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] php forum and (almost certainly 0T) client editor

2005-05-31 Thread Paul Waring
On 5/31/05, Ryan A <[EMAIL PROTECTED]> wrote:
> Can anybody recommend a real bare bones forum that i can modify

I don't know what you mean by "bare bones" exactly (how stripped down
are you looking for?) but here are three fairly small forum systems
you might want to have a look at:

punBB - http://www.punbb.org/ (used it myself in the past, very nice
and slimmed down)
miniBB - http://www.minibb.net (powers the Textpattern forums)
bbPress - http://bbpress.org/ (powers the Wordpress forums, not really
stable yet as far as I can tell but looks promising)

Obviously you might have to put in a bit of work to make them
authenticate against a different database structure, shouldn't be too
difficult though.

> a tutorial for creating a forum

It would be quite difficult to write one of those to be honest,
there's an awful lot you need to take into account for even the
smallest of forums, unless you want something *very* simple like
WWWBoard (http://www.scriptarchive.com/wwwboard.html - written in Perl though).

> I will need a kind of "client editor" for when people write their messages
> into the forum,
> eg: make this bold and that italics and that centered and that with an image
> and so on
> I had actually seen a (dhtml, I think) form some time back where you could
> preview your
> message at the side as you made changes...somewhat like what google has for
> their
> ad-cents accounts where you can change the colors of your ad and immediatly
> it shows the
> changes at the side in a box.

Have a look at the code for the larger bulletin board systems - phpBB
(http://www.phpbb.com/) has this feature and it's open source (I would
recommend vBulletin as well but it's proprietory unfortunately). I
imagine someone out there has probably written a standalone module for
it too - try searching for "bb code wysiwyg" on Google or something
like that.

Hope this helps.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] SUBSCRIPTION

2005-05-31 Thread Paul Waring
On 5/31/05, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> I am changing my e-mail address and I tried to suscribe to this list through 
> the php.net automated subscription service.  It didn't work.  Suggestions?

Try emailing [EMAIL PROTECTED] from the new address
that you want to subscribe with (a blank message will do). I had
problems signing up with the web based list manager as well.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Compiling Phpcap

2005-05-28 Thread Paul Waring
On 5/28/05, Gary C. New <[EMAIL PROTECTED]> wrote:
> I am trying to compile phpcap-0.2e with php-4.2.3 and get the following
> configure error:

Is there a *really* good reason why you're still running 4.2.3? It's
over two years out of date and a lot of bugs and security holes have
been fixed since then.

Paul

-- 
Rogue Tory
http://www.roguetory.org.uk

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



Re: [PHP] Question about handling credit cards

2004-10-05 Thread Paul Waring
On Tue, 5 Oct 2004 12:29:53 -0400, Gary Hotko <[EMAIL PROTECTED]> wrote:
>Could you provide more information, code example or a how to to do this..

Have a look at the Mcrypt functions in PHP (you need to complie
support for this extension to access these features):

http://www.php.net/manual/en/ref.mcrypt.php

Paul

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



Re: [PHP] Extrange behavior with Header('Location')

2004-09-21 Thread Paul Waring
> Just, the result returned by the fuinction is mainly used to creatre
> links in the pages, only in some very special cases will be used with
> the header function. Just I use the & entity in links because I
> want all my pages being validated by the W3C validator service.

As well as that, you should send absolute URIs when you're using
headers, so instead of:

header('Location: ' . $url);

you should use

header('Location: http://www.mysite.com' . $url);

if you want to adhere to the HTTP standard.

Paul

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



Re: [PHP] Re: whois with php

2004-09-13 Thread Paul Waring
> If you have other suggestions, please tell us!

Lots of people have written classes/functions to see whether domain
names are available for pretty much every top level domain and country
code. One that I've used in the past is:

http://phpclasses.vextron.com/browse/package/360.html

there are several others - Net::Whois in PEAR (http://pear.php.net/)
is one that springs to mind.

Paul

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



Re: [PHP] Re: how to redirect ?

2004-09-11 Thread Paul Waring
> I think you used header() after put out some data or php installed on server
> as CGI. Because send header possible only if php installed as apache module.

Not so - I've used header('Location: http://www.xyz.com/'); with PHP
as a CGI binary under both Apache 1 and Apahce 2 without problems.

Paul

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



Re: [PHP] problem with Header("Location: home.php");

2004-09-09 Thread Paul Waring
> the following error occuring in above line.
> Warning: Cannot modify header information - headers already sent by
> (output started at E:\PHPMySql scripts\bugtrack\connection.php:3)
>  in E:\PHPMySql scripts\bugtrack\index.php on line 117

Have you got any space before you output anything to the browser? I've
found that often I've saved a file with a newline at the end by
accident - meaning that PHP thinks I'm ready to start sending output
and therefore any functions that modify the headers won't work because
they've already been sent.

Check connection.php around line 3 to see if there is anything sending
output before you call session_* or Header().

BTW, you shouldn't use relative URIs in Location: headers, try using:

header('Location: http://www.mydomain.com/path/to/home.php');

instead (this won't fix anything, but it's the correct way to do it
according to the HTTP/1.1 standard).

Hope this helps,

Paul

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



Re: [PHP] Rsync + ssh

2004-09-08 Thread Paul Waring
> Tell me how t use the rsync command with ssh and without prompting for password

A little bit of politeness (including the word 'please') would go a long way...

Paul

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



[PHP] PHP OOP Question

2004-09-08 Thread Paul Waring
> Is it bad practice for a class to have a variable and method of the same name?

Well, it's a matter of opinion what is and isn't bad practice, but
personally I would never give a variable and a function the same name
- if only to avoid confusion (PHP shouldn't mind if you do so though).

Paul

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



Re: [PHP] Re: Does any one else get this?

2004-09-05 Thread Paul Waring
I get bounces from both addresses mentioned, but not every time it
seems (must only happen why I reply to one of their questions and CC
them I think). I also used to get vacation messages off someone but
that's stopped now.

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



Re: [PHP] Win32 can't get PEAR to work

2004-09-04 Thread Paul Waring
> Tried installing PEAR. But "pear" is an unknown command after the
> install in my DOS box. There's no "pear.bat" file anywhere. There's an
> "pear.bat_old" file but no "pear.bat".

Last time I installed PHP on Win32, I didn't have to run any commands
to install PEAR. You just need to alter your include_path directive in
php.ini (it's fairly well documented in the comments in the file) to
point to the folder with PEAR.php in (e.g. C:\php\pear) and you'll be
able to do:

require 'PEAR.php';

without any problems. If you want to install any other modules
(provided they don't require any kind of Linux/Unix support) just
extract the zip files into the PEAR directory and they'll be picked
up. Most of PEAR (that I've used anyway) is just PHP files that you
include anyway.

Paul

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



Re: [PHP] PHP site ?

2004-09-04 Thread Paul Waring
> When I use the variable it shows the numbers like 192.168.10.25 (I know this
> is an internal network address, it is just for example.)

Use $_SERVER['REMOTE_HOST'] to get the hostname instead of the IP
address. This will only work if Apache has HostNameLookups enabled.

See:

http://uk.php.net/manual/en/reserved.variables.php#reserved.variables.server

for more details.

Be aware that this will still show the IP address for people like
myself who don't have reverse DNS enabled and also you will be making
at least one lookup request for each page request - hence why it is
disabled by default in Apache (see the comments in httpd.conf for more
information). Only enable it if you *really* need it.

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



Re: [PHP] [Newbie Guide] For the benefit of new members

2004-08-30 Thread Paul Waring
> The problem with that request is that some employers require you to have a
> vacation message set.

They can use another email account or mail from home then, it's not
like there's a shortage of free web-based email providers.

Paul

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



Re: [PHP] [Newbie Guide] For the benefit of new members

2004-08-30 Thread Paul Waring
Another thing I'd like to add: if you're on a public mailing list
don't leave a vacation message set when you go away, it's *extremely*
annoying.

Paul

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



Re: [PHP] newbie questions

2004-08-29 Thread Paul Waring
> The constructor for Content accepts an
>  object ... why is &$db used instead of $db?

&$variable means to pass the variable by reference (as opposed to
passing by value, which is the default). Instead of making a copy of
the variable, you are telling $this->db to point to the same point in
memory as the original $db - in effect you are using two names to
point to the same data. If you modify $this->db, $db will also be
modified and vice versa.

Only the author of the code could tell you exactly why they chose to
do things this way, but one possible reason is that when you close the
database link (using $this->db->disconnect() if it's PEAR::DB) it will
disconnect all the pointers to that link rather than just the one
local to the class (which would be the case if it was passed in by
value). Passing a reference rather than a copy also means you're not
storing multiple database links in memory which could affect
performance if the code was called often (e.g. on a busy web site).

Hope this helps,

Paul

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