php-general Digest 1 May 2011 07:37:43 -0000 Issue 7291

2011-05-01 Thread php-general-digest-help

php-general Digest 1 May 2011 07:37:43 - Issue 7291

Topics (messages 312593 through 312606):

Re: postgresql database access failure
312593 by: Daniel Brown
312594 by: Daniel Brown

Re: dynamic copyright in page footer?
312595 by: Lars Nielsen
312597 by: Andre Polykanine
312605 by: Sharl.Jimh.Tsin
312606 by: Walkinraven

Re: Why Constants could Not be Array?
312596 by: Andre Polykanine
312598 by: Stuart Dallas

Re: Wiki formatting class or something similar
312599 by: Andre Polykanine
312600 by: Peter Lind

Spaces in filename or path
312601 by: Tim Streater
312602 by: Richard Quadling
312603 by: Tim Streater
312604 by: Ashley Sheridan

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
Readers?  Sounds like you spend too much time writing newsletters
(to the wrong address, since php-general-digest-h...@lists.php.net is
a self-help command list for digest-form subscriptions).  ;-P

On Sat, Apr 30, 2011 at 04:41, e-letter inp...@gmail.com wrote:
        ?php
                $db = pg_connect('dbname=databasename user=username');
                $query = 'SELECT * FROM databasename';
                $value=pg_fetch_result($query,1,0);
                echo 'export of database is ',$value,'';
        ?
        p
                why does this fail?

How is it failing?  What error(s) are you seeing on screen or in
your log files?  Noting that $value would contain an array, is that
the problem?  And why are you using ending quotes in your echo?  You
should just place the semicolon immediately after $value.

        /p
        /body
 /html

 The following php code produces the user agent:

        ?php
                echo '$_SERVER['HTTP_USER_AGENT']';
        ?

First of all, no it doesn't.  Placed inside single quotes, it'll
not only try to return it verbatim (i.e. - the variable would be
printed to screen), but it'll also cause a parse error, as you reuse
single quotes in the variable key container.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/
---End Message---
---BeginMessage---
On Sat, Apr 30, 2011 at 12:23, Daniel Brown danbr...@php.net wrote:

        ?php
                echo '$_SERVER['HTTP_USER_AGENT']';
        ?

    First of all, no it doesn't.  Placed inside single quotes, it'll
 not only try to return it verbatim (i.e. - the variable would be
 printed to screen), but it'll also cause a parse error, as you reuse
 single quotes in the variable key container.

Forgot the second of all before hitting send.

Second of all, what does this have to do with your PostgreSQL
problem?  Did I miss something?

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/
---End Message---
---BeginMessage---
lør, 30 04 2011 kl. 11:18 +, skrev dholmes1...@gmail.com:
 Something simple like this would work 
 $date=date('Y');
 $startdate='2011';
 if($date == $startdate) {
 echo $startdate
 } else {
 Echo $startdate;
 Echo '-';
 echo  $date;
 
 }
 Sent via BlackBerry from T-Mobile
 
 -Original Message-
 From: David Mehler dave.meh...@gmail.com
 Date: Sat, 30 Apr 2011 07:06:17 
 To: php-generalphp-gene...@lists.php.net
 Subject: [PHP] dynamic copyright in page footer?
 Hello,
 
 I am trying to use php to put a copyright notice in a page footer. I'm
 using the date function with the Y value for the year. Here's the
 code:
 
 ?php
 echo date ('Y');
 ?
 
 This works great for a site done in 2011 but next year I'm going to
 want to have 2011 and 2012 in the copyright notice, adding an
 additional year the site's up. I'd appreciate some suggestions i'm
 very likely overthinking this.
 
 Thanks.
 Dave.
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
Hi there,

I have been using the following little chunk:

?php
$startYear = 2010;
$curYear = date(Y);
echo copy; .$startYear.(($startYear!=$curYear)?' -
'.$curYear : ''); 
?

Regards 
Lars Nielsen

http://www.lfweb.dk

---End Message---
---BeginMessage---
Hello Dave,

echo pCopyright © Dave Mehler, 2011 — .date(Y)./p;

-- 
With best regards from Ukraine,
Andre
Skype: Francophile
My blog: http://oire.org/menelion (mostly in Russian)
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

 Original message 
From: David Mehler dave.meh...@gmail.com
To: php-general
Date created: , 2:06:17 PM
Subject: [PHP] dynamic copyright in page footer?


  Hello,

I am trying to use php to put a copyright notice in a page footer. I'm
using the date function with the Y value for 

php-general Digest 1 May 2011 20:28:24 -0000 Issue 7292

2011-05-01 Thread php-general-digest-help

php-general Digest 1 May 2011 20:28:24 - Issue 7292

Topics (messages 312607 through 312609):

Re: postgresql database access failure
312607 by: e-letter
312608 by: Ashley Sheridan
312609 by: e-letter

Administrivia:

To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
php-gene...@lists.php.net


--
---BeginMessage---
On 30/04/2011, Daniel Brown danbr...@php.net wrote:
 Readers?  Sounds like you spend too much time writing newsletters
 (to the wrong address, since php-general-digest-h...@lists.php.net is
 a self-help command list for digest-form subscriptions).  ;-P

 On Sat, Apr 30, 2011 at 04:41, e-letter inp...@gmail.com wrote:
?php
$db = pg_connect('dbname=databasename user=username');
$query = 'SELECT * FROM databasename';
$value=pg_fetch_result($query,1,0);
echo 'export of database is ',$value,'';
?
p
why does this fail?

 How is it failing?  What error(s) are you seeing on screen or in
 your log files?  Noting that $value would contain an array, is that
 the problem?  And why are you using ending quotes in your echo?  You
 should just place the semicolon immediately after $value.


I looked at the error file located at '/var/log/httpd/error_log',
which identifies an error:

...Apache/2.2.6 (Mandriva Linux/PREFORK-8.2mdv2008.0) PHP/5.2.4 with
Suhosin-Patch mod_put/2.0.8 configured -- resuming normal
operations...

...PHP Parse error:  syntax error, unexpected T_VARIABLE, expecting
',' or ';'...

The file was changed as follows which caused the parse error shown above:

?php
$db = pg_connect('dbname=webcuttings user=httpd');
$query = 'SELECT * FROM articles';
$value=pg_fetch_result($query);
echo 'all files' $value;
?

The file was copied from the manual page, without understanding that
an array was being used.

/p
/body
 /html

 The following php code produces the user agent:

?php
echo '$_SERVER['HTTP_USER_AGENT']';
?

 First of all, no it doesn't.  Placed inside single quotes, it'll
 not only try to return it verbatim (i.e. - the variable would be
 printed to screen), but it'll also cause a parse error, as you reuse
 single quotes in the variable key container.


My mistake; with the command:

?php
echo $_SERVER['HTTP_USER_AGENT'];
?

the result is:

Opera/9.80 (X11; Linux i686; U; en-GB) Presto/2.6.30 Version/10.61
---End Message---
---BeginMessage---
On Sun, 2011-05-01 at 09:24 +0100, e-letter wrote:

 I looked at the error file located at '/var/log/httpd/error_log',
 which identifies an error:
 
 ...Apache/2.2.6 (Mandriva Linux/PREFORK-8.2mdv2008.0) PHP/5.2.4 with
 Suhosin-Patch mod_put/2.0.8 configured -- resuming normal
 operations...
 
 ...PHP Parse error:  syntax error, unexpected T_VARIABLE, expecting
 ',' or ';'...
 
 The file was changed as follows which caused the parse error shown
 above:
 
 ?php
 $db = pg_connect('dbname=webcuttings user=httpd');
 $query = 'SELECT * FROM articles';
 $value=pg_fetch_result($query);
 echo 'all files' $value;
 ?
 
 The file was copied from the manual page, without understanding that
 an array was being used. 


The problem you've got there is a missing string concatenator in your
echo line. You should change that line to read:

echo 'all files' . $value;

note the . character? However, as you said, $value is actually an array,
so you would be better of using something like print_r() or var_dump()
on it. 

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk


---End Message---
---BeginMessage---
The file was changed:

... $value=pg_fetch_result($query,1,1);
echo 'all files' . var_dump($value);
...

The resultant web page produces:

bool(false) all files

The php file was changed again:

... $value=pg_fetch_result($query);
echo 'all files' . var_dump($value);
...

The resultant web page produces:

NULL all files

The error log shows:

...PHP Warning:  pg_fetch_result(): supplied argument is not a valid
PostgreSQL result resource...

The objective is to learn how to extract data from a database and
print to a web browser, but not much progress made so far..!
---End Message---


[PHP] Re: dynamic copyright in page footer?

2011-05-01 Thread Walkinraven

On 04/30/2011 07:06 PM, David Mehler wrote:

Hello,

I am trying to use php to put a copyright notice in a page footer. I'm
using the date function with the Y value for the year. Here's the
code:

?php
echo date ('Y');
?

This works great for a site done in 2011 but next year I'm going to
want to have 2011 and 2012 in the copyright notice, adding an
additional year the site's up. I'd appreciate some suggestions i'm
very likely overthinking this.

Thanks.
Dave.
From the view of copyright itself, the year in the notice means 'last 
modified date', NOT the current year. So I think you may set a timestamp 
field in your database, with last update time in it, and use the year 
(not current year), for your notice.


--
http://walkinraven.name

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



Re: [PHP] postgresql database access failure

2011-05-01 Thread e-letter
On 30/04/2011, Daniel Brown danbr...@php.net wrote:
 Readers?  Sounds like you spend too much time writing newsletters
 (to the wrong address, since php-general-digest-h...@lists.php.net is
 a self-help command list for digest-form subscriptions).  ;-P

 On Sat, Apr 30, 2011 at 04:41, e-letter inp...@gmail.com wrote:
?php
$db = pg_connect('dbname=databasename user=username');
$query = 'SELECT * FROM databasename';
$value=pg_fetch_result($query,1,0);
echo 'export of database is ',$value,'';
?
p
why does this fail?

 How is it failing?  What error(s) are you seeing on screen or in
 your log files?  Noting that $value would contain an array, is that
 the problem?  And why are you using ending quotes in your echo?  You
 should just place the semicolon immediately after $value.


I looked at the error file located at '/var/log/httpd/error_log',
which identifies an error:

...Apache/2.2.6 (Mandriva Linux/PREFORK-8.2mdv2008.0) PHP/5.2.4 with
Suhosin-Patch mod_put/2.0.8 configured -- resuming normal
operations...

...PHP Parse error:  syntax error, unexpected T_VARIABLE, expecting
',' or ';'...

The file was changed as follows which caused the parse error shown above:

?php
$db = pg_connect('dbname=webcuttings user=httpd');
$query = 'SELECT * FROM articles';
$value=pg_fetch_result($query);
echo 'all files' $value;
?

The file was copied from the manual page, without understanding that
an array was being used.

/p
/body
 /html

 The following php code produces the user agent:

?php
echo '$_SERVER['HTTP_USER_AGENT']';
?

 First of all, no it doesn't.  Placed inside single quotes, it'll
 not only try to return it verbatim (i.e. - the variable would be
 printed to screen), but it'll also cause a parse error, as you reuse
 single quotes in the variable key container.


My mistake; with the command:

?php
echo $_SERVER['HTTP_USER_AGENT'];
?

the result is:

Opera/9.80 (X11; Linux i686; U; en-GB) Presto/2.6.30 Version/10.61

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



Re: [PHP] postgresql database access failure

2011-05-01 Thread Ashley Sheridan
On Sun, 2011-05-01 at 09:24 +0100, e-letter wrote:

 I looked at the error file located at '/var/log/httpd/error_log',
 which identifies an error:
 
 ...Apache/2.2.6 (Mandriva Linux/PREFORK-8.2mdv2008.0) PHP/5.2.4 with
 Suhosin-Patch mod_put/2.0.8 configured -- resuming normal
 operations...
 
 ...PHP Parse error:  syntax error, unexpected T_VARIABLE, expecting
 ',' or ';'...
 
 The file was changed as follows which caused the parse error shown
 above:
 
 ?php
 $db = pg_connect('dbname=webcuttings user=httpd');
 $query = 'SELECT * FROM articles';
 $value=pg_fetch_result($query);
 echo 'all files' $value;
 ?
 
 The file was copied from the manual page, without understanding that
 an array was being used. 


The problem you've got there is a missing string concatenator in your
echo line. You should change that line to read:

echo 'all files' . $value;

note the . character? However, as you said, $value is actually an array,
so you would be better of using something like print_r() or var_dump()
on it. 

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] postgresql database access failure

2011-05-01 Thread e-letter
The file was changed:

... $value=pg_fetch_result($query,1,1);
echo 'all files' . var_dump($value);
...

The resultant web page produces:

bool(false) all files

The php file was changed again:

... $value=pg_fetch_result($query);
echo 'all files' . var_dump($value);
...

The resultant web page produces:

NULL all files

The error log shows:

...PHP Warning:  pg_fetch_result(): supplied argument is not a valid
PostgreSQL result resource...

The objective is to learn how to extract data from a database and
print to a web browser, but not much progress made so far..!

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



[PHP] passing control to a separate script

2011-05-01 Thread Jim Giner
I have a large script that does a certain function for me.  I have a second 
script that gets called and does its thing and when I'm done with it I'd 
like to pass control to the first script.  I don't need this 'included' in 
my second script - I just want to pass control to it and let it take over 
again.

Is this do-able? 



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



Re: [PHP] passing control to a separate script

2011-05-01 Thread Stuart Dallas
On Monday, 2 May 2011 at 02:17, Jim Giner wrote:
I have a large script that does a certain function for me. I have a second 
 script that gets called and does its thing and when I'm done with it I'd 
 like to pass control to the first script. I don't need this 'included' in 
 my second script - I just want to pass control to it and let it take over 
 again.
 
 Is this do-able?

To clarify, you have something like this...

one.php
---
echo 'do one thing';
// pass control to two.php
echo 'do another thing';
---

two.php
---
echo 'do something else';
// pass control back to one.php
---

If that's correct then simply include two.php from one.php, like so...

one.php
---
echo 'do one thing';
include 'two.php';
echo 'do another thing';
---

If not then I've misunderstood what you're after. Can you give us an example?

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/






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



Re: [PHP] postgresql database access failure

2011-05-01 Thread David Robley
e-letter wrote:

 The file was changed:
 
 ...   $value=pg_fetch_result($query,1,1);
 echo 'all files' . var_dump($value);
 ...
 
 The resultant web page produces:
 
 bool(false) all files
 
 The php file was changed again:
 
 ...   $value=pg_fetch_result($query);
 echo 'all files' . var_dump($value);
 ...
 
 The resultant web page produces:
 
 NULL all files
 
 The error log shows:
 
 ...PHP Warning:  pg_fetch_result(): supplied argument is not a valid
 PostgreSQL result resource...
 
 The objective is to learn how to extract data from a database and
 print to a web browser, but not much progress made so far..!

There is a good example of how to use pg_fetch_result in the docs at
http://php.net/manual/en/function.pg-fetch-result.php.

On the basis of the code shown here, it's a bit hard to determine exactly
what your problem is; however the odds are that the error supplied
argument is not a valid PostgreSQL result resource results from a SQL
syntax error, or possibly that you have failed to open a connection to
pgsql. However, there are some tools to help you; see
http://php.net/manual/en/function.pg-result-error.php

For future reference, it helps to post all the code that is relevant to your
problem, so in this case it would help, for example, to see how you are
making the connection to pgsql and how the $query variable is populated.



Cheers
-- 
David Robley

A seminar on Time Travel will be held two weeks ago.
Today is Boomtime, the 49th day of Discord in the YOLD 3177. 


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



Re: [PHP] passing control to a separate script

2011-05-01 Thread Jim Giner
No - I don't want to include either one in the other one.  They are separate 
things that interesect once.  I really am just trying to do this separately 
as I said.

script1
work
work
work
(done)

script2
do something
user response
do something (write data)
execute script 1
(done.

Script 2 doesn't need a response - no return to it.  I'm trying to keep from 
having the user interact with it one more time just to have a form  button 
that uses its' action= to run script 1. 



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



Re: [PHP] passing control to a separate script

2011-05-01 Thread Stuart Dallas
On Monday, 2 May 2011 at 02:44, Jim Giner wrote:
No - I don't want to include either one in the other one. They are separate 
 things that interesect once. I really am just trying to do this separately 
 as I said.
 
 script1
 work
 work
 work
 (done)
 
 script2
 do something
 user response
 do something (write data)
 execute script 1
 (done.
 
 Script 2 doesn't need a response - no return to it. I'm trying to keep from 
 having the user interact with it one more time just to have a form  button 
 that uses its' action= to run script 1.

In script2 you have the user responding in the middle of execution - this is 
not possible. PHP runs a script and returns the output to the client. The user 
then takes action which may cause another PHP script to be executed. There is 
no way to pause execution of a web-based PHP script and wait for a user action.

In what you've given us above I'm unclear on how script1 and script2 interact 
with each other. Can you elaborate?

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/





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



Re: [PHP] passing control to a separate script

2011-05-01 Thread tedd

At 9:17 PM -0400 5/1/11, Jim Giner wrote:

I have a large script that does a certain function for me.  I have a second
script that gets called and does its thing and when I'm done with it I'd
like to pass control to the first script.  I don't need this 'included' in
my second script - I just want to pass control to it and let it take over
again.

Is this do-able?


Yes, this is do-able.

But don't be afraid of the include statement.

Here's an example that can be easily made to do what you want:

http://www.webbytedd.com/bb/php-run-php/

After the first script runs, it includes the second script that then 
runs, which then includes the first script to continue.


If you don't want to use a $_POST to trigger the critter, then use 
location, such as:


// first script
if($to_second_script)
  {
   header('Location: http://www.example.com/second.php');
   exit();
   }

// second script
if($to_first_script)
  {
   header('Location: http://www.example.com/first.php');
   exit();
   }


Either those will work depending upon the trigger you need.

Cheers,

tedd

--
---
http://sperling.com/

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