[PHP] tutorial failure

2010-08-18 Thread e-letter
Readers,

Copy below of message sent 15 August to php install digest list, but
to date not including in mail archive?

The tutorial example:


  
  php test
  
  
  Hi, I am a PHP script';
  ?>
  
  this is a test
  
  


is saved to the normal user temporary folder as 'test.php' and then
copied to the folder '/var/www/html/' using the root user account. The
web browser is directed to url 'http://localhost.test.php, to show:

Hi, I am a PHP script

'; ?>

this is a test

What is the error please?

Urpmi was used to install so the php version installed is not known.
How to obtain this please

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



Re: [PHP] tutorial failure

2010-08-18 Thread e-letter
I changed the code as follows:



php test




Hi, I am a PHP script";
?>

this is a test




The result (http://localhost/test.php):

Hi, I am a PHP script

"; ?>

this is a test

If I use single quotes characters:

Hi, I am a PHP script

'; ?>

this is a test

The phpinfo instruction does not seem to be recognised. What else
should I check?

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



Re: [PHP] tutorial failure

2010-08-18 Thread e-letter
On 18/08/2010, chris h  wrote:
> php is not processing the file.  There's a few reasons for this, but the
> first thing I would check is the permissions of the file.  From the
> directory try
>
> $ ls -oa
>
The file permission was confirmed as root, since it was copied (as
root) from a normal user account directorp 'temporary' to the
directory '/var/www/html'

> This should tell you who owns the file and what it's permissions are.  You
> mentioned that you copied it as root, you could change it's ownership to
> www-data.
>
This fails:

[r...@localhost html]# chown www-data test.php
chown: `www-data': invalid user

So I repeated this with a normal user account and the change in
permission occurs. However, the html file containing the php script
remains unchanged.

The instruction:

...

...

Does not show the version of php.

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



Re: [PHP] tutorial failure

2010-08-18 Thread e-letter
On 18/08/2010, Peter Lind  wrote:
> On 18 August 2010 12:47, e-letter  wrote:
>> On 18/08/2010, chris h  wrote:
>>> php is not processing the file.  There's a few reasons for this, but the
>>> first thing I would check is the permissions of the file.  From the
>>> directory try
>>>
>>> $ ls -oa
>>>
>> The file permission was confirmed as root, since it was copied (as
>> root) from a normal user account directorp 'temporary' to the
>> directory '/var/www/html'
>>
>>> This should tell you who owns the file and what it's permissions are.
>>>  You
>>> mentioned that you copied it as root, you could change it's ownership to
>>> www-data.
>>>
>> This fails:
>>
>> [r...@localhost html]# chown www-data test.php
>> chown: `www-data': invalid user
>>
>> So I repeated this with a normal user account and the change in
>> permission occurs. However, the html file containing the php script
>> remains unchanged.
>>
>> The instruction:
>>
>> ...
>> 
>> ...
>>
>> Does not show the version of php.
>>
>
> Your webserver might not be configured to process php files - which
> server are you using?
>
Apache. Below is an extract of an (to now) unanswered question:

...

   SetHandler application/x-httpd-php
http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] tutorial failure

2010-08-18 Thread e-letter
On 18/08/2010, chris h  wrote:
> What are the actual file permissions when you run ls -o?
>
root
>
> Do you know if PHP is installed as an apache mod or cgi? Also you might
> check what user apache is running as.
>
No. How to verify?

> possibly...
> $ vi /etc/apache2/envvars
>
No apache2 on my computer, only '/usr/lib/apache' which contains only .so files.

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



Re: [PHP] tutorial failure

2010-08-18 Thread e-letter
On 18/08/2010, chris h  wrote:
> On Wed, Aug 18, 2010 at 7:10 AM, e-letter  wrote:
>
>> On 18/08/2010, chris h  wrote:
>> > What are the actual file permissions when you run ls -o?
>> >
>> root
>>
>
> What's the entire output of ls -o?
>
[r...@localhost html]# ls -o *
-rwxr-xr-x 1 root  182 2010-08-18 11:33 test.php*

addon-modules:
total 4
lrwxrwxrwx 1 root  51 2010-01-11 22:03 apache-mod_svn_view-0.1.0 ->
../../../../usr/share/doc/apache-mod_svn_view-0.1.0
lrwxrwxrwx 1 root  52 2010-01-11 22:03 apache-mod_transform-0.6.0 ->
../../../../usr/share/doc/apache-mod_transform-0.6.0
-rw-r--r-- 1 root 115 2007-09-07 21:47 HOWTO_get_modules.html

>
>> >
>> > Do you know if PHP is installed as an apache mod or cgi? Also you might
>> > check what user apache is running as.
>> >
>> No. How to verify?
>>
>> > possibly...
>> > $ vi /etc/apache2/envvars
>> >
>> No apache2 on my computer, only '/usr/lib/apache' which contains only .so
>> files.
>>
>
> there's no /etc/apache either?
>
No

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



Re: [PHP] tutorial failure

2010-08-18 Thread e-letter
On 18/08/2010, Ashley Sheridan  wrote:
> On Wed, 2010-08-18 at 12:10 +0100, e-letter wrote:
>
>> On 18/08/2010, chris h  wrote:
>> > What are the actual file permissions when you run ls -o?
>> >
>> root
>> >
>> > Do you know if PHP is installed as an apache mod or cgi? Also you might
>> > check what user apache is running as.
>> >
>> No. How to verify?
>>
>> > possibly...
>> > $ vi /etc/apache2/envvars
>> >
>> No apache2 on my computer, only '/usr/lib/apache' which contains only .so
>> files.
>>
>
>
> ls -o doesn't give one word answers, so again, what is the output of an
> ls -o call in your shell?
>
> I assume that root is the owner of the file here, and the fact that
> you're getting some output from it seems to suggest that at least read
> permissions are available for group and other, but you should check to
> see if the permissions are indeed something like 664 (-rw-rw-r--)
>
> What OS are you using? I'm assuming a Linux distro of some kind here,
> but it could also be another Unix variant. Have you tried using the
> package manager within the distro (if it is Linux) to install PHP and
> Apache together? That makes it a lot easier to get up and running with a
> decent configuration, especially if you're unfamiliar with the more
> complicated details.
>
I used urpmi with mandriva

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



Re: [PHP] tutorial failure

2010-08-18 Thread e-letter
On 18/08/2010, Bob McConnell  wrote:
> From: e-letter
>
>> On 18/08/2010, chris h  wrote:
>>> On Wed, Aug 18, 2010 at 7:10 AM, e-letter  wrote:
>>>
>>>> On 18/08/2010, chris h  wrote:
>>>> > What are the actual file permissions when you run ls -o?
>>>> >
>>>> root
>>>>
>>>
>>> What's the entire output of ls -o?
>>>
>> [r...@localhost html]# ls -o *
>> -rwxr-xr-x 1 root  182 2010-08-18 11:33 test.php*
>>
>> addon-modules:
>> total 4
>> lrwxrwxrwx 1 root  51 2010-01-11 22:03 apache-mod_svn_view-0.1.0 ->
>> ../../../../usr/share/doc/apache-mod_svn_view-0.1.0
>> lrwxrwxrwx 1 root  52 2010-01-11 22:03 apache-mod_transform-0.6.0 ->
>> ../../../../usr/share/doc/apache-mod_transform-0.6.0
>> -rw-r--r-- 1 root 115 2007-09-07 21:47 HOWTO_get_modules.html
>>
>>>
>>>> >
>>>> > Do you know if PHP is installed as an apache mod or cgi? Also you
> might
>>>> > check what user apache is running as.
>>>> >
>>>> No. How to verify?
>>>>
>>>> > possibly...
>>>> > $ vi /etc/apache2/envvars
>>>> >
>>>> No apache2 on my computer, only '/usr/lib/apache' which contains
> only .so
>>>> files.
>>>>
>>>
>>> there's no /etc/apache either?
>>>
>> No
>
> Some distributions have really screwed up the locations of various
> applications. This is compounded by the decision to rename the Apache 2
> directories to httpd. Look for /etc/httpd, /home/httpd or
> /usr/lib/httpd. If worse comes to worst, try
>
In '/etc/httpd/conf' there is an empty directory 'addon-modules'. In
/usr/lib/apache-extramodules there is 'mod_php5.so'.

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



Re: [PHP] tutorial failure

2010-08-19 Thread e-letter
On 19/08/2010, David McGlone  wrote:

> Yes it is. But your computer needs the correct software to view that php
> file in a web browser as if it was a web page. If you do not have this
> software installed, then the web browser will ask you if you want to
> download the file instead.
>
The web browser views the php file as described previously; there is
no prompt to download the file.

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



Re: [PHP] tutorial failure

2010-08-19 Thread e-letter
On 19/08/2010, David McGlone  wrote:
> On Wed, 2010-08-18 at 23:08 +0100, e-letter wrote:
>> On 18/08/2010, David McGlone  wrote:
>> > On Wed, 2010-08-18 at 21:54 +0100, e-letter wrote:
>> >> On 18/08/2010, David McGlone  wrote:
>> >> >
>> >> > Do you have php5 installed?
>> >> >
>> >> Yes, but don't know how to confirm; I used urpmi to install.
>> >
>> > Use the command in a terminal: rpm -q php5
>> >
>> No package by this name in the repository; have libphp5_common5 installed.
>
> Ok let me ask you this, When you try to view a php file on your server
> does it ask you if you would like to download it?

I don't understand: isn't the example I provided a php file?

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



Re: [PHP] tutorial failure

2010-08-19 Thread e-letter
On 19/08/2010, Ashley Sheridan  wrote:
> I think it's fairly clear that for whatever reason, PHP isn't properly
> configured with Apache. You've mentioned you're using Mandriva, which,
> coincidentally, is what i've just recently installed on my home machine.
> It has a very good graphical package manager that you can use to install
> PHP and Apache. I'm not at my home machine right now, so I don't recall
> the exact name, but it's found somewhere in the Computer Settings main
> menu dialogue. From here, you can install Apache and PHP, which will
> configure Apache as well to recognise PHP scripts and execute them.
>
mcc (mandriva linux control centre) is the command (or more
specifically, rpmdrake)

To my knowledge, using this tool, all necessary files are installed. I
suspect that there is a fault with the way that mandriva builds the
packages.

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



Re: [PHP] tutorial failure

2010-08-19 Thread e-letter
On 19/08/2010, Ashley Sheridan  wrote:
> As Colin suggested on another email, check to see if apache-mod_php was
> installed too. It seems likely that it wasn't for some reason.

How to verify please? Also, the instruction to use task-lamp; it seems
this is for mysql but the database to be used is postgresql?

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



Re: [PHP] tutorial failure

2010-08-19 Thread e-letter
On 19/08/2010, HallMarc Websites  wrote:
> I agree with the earlier take on this situation; you need to start at the
> beginning and learn the basics regarding the technologies BEFORE you try and
> manage them. You're trying to drive a car when you don't even know what or
> car is and how to operate one so you keep crashing.
>
> Here are some great sites to check out:
> http://wiki.mandriva.com/en/
> http://www.pcstats.com/articleview.cfm?articleID=1868
> http://www.wikivs.com/wiki/MySQL_vs_PostgreSQL
> http://www.w3schools.com/
> There are some great books out there as well to help you learn and I
> recommend getting the reference guides as well. Since the gist of this
> thread seems to be focused on the LAPP set-up and mainly an Apache (?)
> configuration issue you might try the forums and mailing lists found there
> as well.
>
No response from apache forum. Looking at the web browser output from
the processing of the php file, the partial success of processing the
file suggests that the problem is with php; if it was due to apache,
html code would be affected as well?

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



Re: [PHP] tutorial failure

2010-08-20 Thread e-letter
On 19/08/2010, Ashley Sheridan  wrote:
> No, because Apache doesn't need to process HTML in the same way it needs
> to process PHP. The tag  browser as HTML (view the source on the page you're browsing to) and
> interpreted as a tag by your browser, hence what appears to be partially
> processed output.
>
> It's fairly clear by now that Apache does not know about your PHP
> install (if there even is one)
>
> I've just set up and installed PHP and Apache on my Mandriva box since
> I've been at home, and it took all of 5 minutes from within the package
> manager. Trust me, it's far easier to go that route than install the
> packages one-by-one as you seem to be doing as, unless you know exactly
> what packages you need, it's all too easy to miss installing something.
>
Yes that is what I was inspecting; I plan to re-install the entire OS.

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



Re: [PHP] tutorial failure

2010-08-26 Thread e-letter
On 20/08/2010, Ashley Sheridan  wrote:
> You don't have to reinstall the entire OS, that's a very Windows
> approach to the problem. I played around a bit last night with urpmi and
> you should be able to just list the packages you need with urpmq --fuzzy
> package_name, and then install the ones listed you think you need. I did
> notice that urpmi doesn't install the DB when you install the Apache mod
> for that DB, so you might need to install that separately, but other
> than that, you should be good to go if you install the Apache php mod.
>
>
True with respect to the windoze mentality but I had other reasons to
reformat the pc so this was a good opportunity.

The resultant web page is:

Hi, I am a PHP script

this is a test

However, the manual page implies to me that the web page should have
shown the html code, i.e.


 
 php test
 
 
 Hi, I am a PHP script
 this is a test
 


The source code of the web page:


 
 php test
 
 
 Hi, I am a PHP script
 this is a test
 
 


Is this an error with the explanation of the manual or is the
apache-php configuration still at fault?

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



[PHP] postgresql database access failure

2011-04-30 Thread e-letter
Readers,

A postgresql database (local disk installation) is successfully
accessed as a normal user:

psql -U username databasename

However, creating a php file to access the database has not been successful.





why does this fail?




The following php code produces the user agent:



-- 
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  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  wrote:
>>>$db = pg_connect('dbname=databasename user=username');
>>$query = 'SELECT * FROM databasename';
>>$value=pg_fetch_result($query,1,0);
>>echo 'export of database is ',$value,'';
>>?>
>>
>>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:



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

>>
>>
>> 
>>
>> The following php code produces the user agent:
>>
>>>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:



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



Re: [PHP] postgresql database access failure

2011-05-02 Thread e-letter
The query was:

$query = 'SELECT * FROM databasetablename';

So, database access seems to be the problem. Using the superuser
account 'postgres', a user 'httpd' was created and all privileges were
granted to the target database using the postgresql 'grant' command.
However the user 'httpd' is not the owner of the database so perhaps
that is the problem, although if this user could not access the
database that would cause an error in the log (but no such error is
seen)?

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



[PHP] Re: postgresql database access failure

2011-05-02 Thread e-letter
>
>Here's the URL of the relevant manual page:
>http://www.php.net/manual/en/function.pg-fetch-result.php
>

The manual page did not explain the purpose of the text 'die', so was
ignored (;)). Anyway, the php code was amended as follows:



The result is a web page which shows:

list of files12345\n

where '12345' corresponds correctly to an equivalent value in row 100
of the database table. However, the query requests the entire table.

The php code was then amended as follows, which produces output from
the database:



>My personal recommendation, however, is to drop old-style procedural
>drivers and switch to PDO - it's much more convenient to use, IMO. If
>you use PDO, you don't need to study the API of various different DB
>drivers, and your code can easily switch from one database to another.

What does PDO mean, so the relevant parts of the manual can be
reviewed? Thank you.

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



[PHP] Re: php-general Digest 5 May 2011 21:55:09 -0000 Issue 7299

2011-05-05 Thread e-letter
Readers,

Looking through the mail lists archives, only the following message
seems to advise about the possibility to use gnuplot:
http://marc.info/?l=php-general&m=96248542218029&w=2

Is it possible to start gnuplot using php, to plot a graph from
postgresql data. For example, a table is created in the required
gnuplot data file format so the command for gnuplot would be something
like:

plot <"SELECT * FROM gnuplotdatatable;"

But can't see a php command to start gnuplot in the first step. Any help please?

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