php-general Digest 19 Dec 2010 20:35:38 -0000 Issue 7094
Topics (messages 310138 through 310151):
Upgraded system and now $_SERVER['SERVER_NAME'] is not more working
310138 by: Michelle Konzack
All records not displaying...
310139 by: Gary
310141 by: Tamara Temple
310146 by: [email protected]
Problem with Include
310140 by: Bill Guion
310144 by: Govinda
310145 by: Tamara Temple
310148 by: [email protected]
310150 by: Bill Guion
Re: HTML id attribute and arrays
310142 by: Martin C
310143 by: Martin C
310147 by: Benjamin Hawkes-Lewis
Performance Improvement on Calling C++ executable from PHP
310149 by: shiplu
310151 by: shiplu
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Hello *,
I upgraded one of my servers from Debian/Etch to Lenny and now the var
$_SERVER['SERVER_NAME'] is not more working.
Did I have overseen something?
The offending code sniplet is this:
----8<------------------------------------------------------------------
T_setlocale(LC_MESSAGES, $locale);
$domain=$_SERVER['SERVER_NAME'];
T_bind_textdomain_codeset($domain, $encoding);
T_bindtextdomain($domain, LOCALE_DIR);
T_textdomain($domain);
----8<------------------------------------------------------------------
and the error messge is here:
http://vserver01.tamay-dogan.net/
Thanks, Greetings and nice Day/Evening
Michelle Konzack
--
##################### Debian GNU/Linux Consultant ######################
Development of Intranet and Embedded Systems with Debian GNU/Linux
itsyst...@tdnet France EURL itsyst...@tdnet UG (limited liability)
Owner Michelle Konzack Owner Michelle Konzack
Apt. 917 (homeoffice)
50, rue de Soultz Kinzigstraße 17
67100 Strasbourg/France 77694 Kehl/Germany
Tel: +33-6-61925193 mobil Tel: +49-177-9351947 mobil
Tel: +33-9-52705884 fix
<http://www.itsystems.tamay-dogan.net/> <http://www.flexray4linux.org/>
<http://www.debian.tamay-dogan.net/> <http://www.can4linux.org/>
Jabber [email protected]
Linux-User #280138 with the Linux Counter, http://counter.li.org/
signature.pgp
Description: Digital signature
--- End Message ---
--- Begin Message ---
I have an issue that the first record in a query is not being displayed. It
seems that the first row in alphabetical order is not being brought to the
screen.
I have run the query in the DB and it displays the correct result, so it has
to be in the php.
I have a MySQL DB that lists beers. I have a column for 'type' of beer
(imported, domestic, craft, light). The queries:
$result = MySQL_query("SELECT * FROM beer WHERE type = 'imported' AND stock
= 'YES' ORDER by beername ");
When I run the query
if (mysql_num_rows($result) == !'0') {
$row = mysql_fetch_array($result);
echo '<h3>Imported Beers</h3>';
echo '<table width="100%" border="0" cellspacing="1" cellpadding="1"
id="tableone" summary="">
<th>Beer</th>
<th>Maker</th>
<th>Type</th>
<th>Singles</th>
<th>6-Packs</th>
<th>Cans</th>
<th>Bottles</th>
<th>Draft</th>
<th>Size</th>
<th>Description</th>';
while ($row = mysql_fetch_array($result)) {
echo '<tr ><td>' . $row['beername'].'</td>';
echo '<td>' . $row['manu'] . '</td>';
echo '<td>' . $row['type'] . '</td>';
echo '<td width="40">' . $row['singles'] . '</td>';
echo '<td width="20">' . $row['six'] . '</td>';
echo '<td width="40">' . $row['can'] . '</td>';
echo '<td width="20">' . $row['bottles'] . '</td>';
echo '<td width="40">' . $row['tap'] . '</td>';
echo '<td>' . $row['size'] . '</td>';
echo '<td>' . $row['descrip'] . '</td>';
'</tr>';
}
echo '</table><br />';
}
All but the first row in alphabetical order are displayed properly.
Can anyone tell me where I am going wrong?
--
Gary
BTW, I do have a bonus question that is about javascript in this same file,
so if anyone want to take a stab at that, I'll be happy to post it.
__________ Information from ESET Smart Security, version of virus signature
database 5715 (20101219) __________
The message was checked by ESET Smart Security.
http://www.eset.com
--- End Message ---
--- Begin Message ---
On Dec 19, 2010, at 9:46 AM, Gary wrote:
I have an issue that the first record in a query is not being
displayed. It
seems that the first row in alphabetical order is not being brought
to the
screen.
I have run the query in the DB and it displays the correct result,
so it has
to be in the php.
I have a MySQL DB that lists beers. I have a column for 'type' of
beer
(imported, domestic, craft, light). The queries:
$result = MySQL_query("SELECT * FROM beer WHERE type = 'imported'
AND stock
= 'YES' ORDER by beername ");
When I run the query
if (mysql_num_rows($result) == !'0') {
$row = mysql_fetch_array($result);
echo '<h3>Imported Beers</h3>';
echo '<table width="100%" border="0" cellspacing="1" cellpadding="1"
id="tableone" summary="">
<th>Beer</th>
<th>Maker</th>
<th>Type</th>
<th>Singles</th>
<th>6-Packs</th>
<th>Cans</th>
<th>Bottles</th>
<th>Draft</th>
<th>Size</th>
<th>Description</th>';
while ($row = mysql_fetch_array($result)) {
echo '<tr ><td>' . $row['beername'].'</td>';
echo '<td>' . $row['manu'] . '</td>';
echo '<td>' . $row['type'] . '</td>';
echo '<td width="40">' . $row['singles'] . '</td>';
echo '<td width="20">' . $row['six'] . '</td>';
echo '<td width="40">' . $row['can'] . '</td>';
echo '<td width="20">' . $row['bottles'] . '</td>';
echo '<td width="40">' . $row['tap'] . '</td>';
echo '<td>' . $row['size'] . '</td>';
echo '<td>' . $row['descrip'] . '</td>';
'</tr>';
}
echo '</table><br />';
}
All but the first row in alphabetical order are displayed properly.
Can anyone tell me where I am going wrong?
--
Gary
BTW, I do have a bonus question that is about javascript in this
same file,
so if anyone want to take a stab at that, I'll be happy to post it.
This code will totally eliminate the first row of data.
if (mysql_num_rows($result) == !'0') {
$row = mysql_fetch_array($result);
Fetches the first row, but is not output. Because:
while ($row = mysql_fetch_array($result)) {
Fetches the second row before you do any output of the data.
Eliminate the first fetch_array and you're code should work fine.
BTW, if you put the <td> attributes 'width="n"' in the preceding <th>
tags, you won't have to output them for each row. You should also put
the units those numbers are associated with.
--- End Message ---
--- Begin Message ---
I'm not sure what this line us all about:
if (mysql_num_rows($result) == !'0')
You're basically saying; if the number of rows is equal to the not of the
string 0, what I think you may want in this case is just != 0.
The next line is causing your problem though. You're grabbing the first row
with that $row= line, and not doing anything with it. Take that out and it
should be ok.
Thanks,
Ash
http://www.ashleysheridan.co.uk
----- Reply message -----
From: "Gary" <[email protected]>
Date: Sun, Dec 19, 2010 15:46
Subject: [PHP] All records not displaying...
To: <[email protected]>
I have an issue that the first record in a query is not being displayed. It
seems that the first row in alphabetical order is not being brought to the
screen.
I have run the query in the DB and it displays the correct result, so it has
to be in the php.
I have a MySQL DB that lists beers. I have a column for 'type' of beer
(imported, domestic, craft, light). The queries:
$result = MySQL_query("SELECT * FROM beer WHERE type = 'imported' AND stock
= 'YES' ORDER by beername ");
When I run the query
if (mysql_num_rows($result) == !'0') {
$row = mysql_fetch_array($result);
echo '<h3>Imported Beers</h3>';
echo '<table width="100%" border="0" cellspacing="1" cellpadding="1"
id="tableone" summary="">
<th>Beer</th>
<th>Maker</th>
<th>Type</th>
<th>Singles</th>
<th>6-Packs</th>
<th>Cans</th>
<th>Bottles</th>
<th>Draft</th>
<th>Size</th>
<th>Description</th>';
while ($row = mysql_fetch_array($result)) {
echo '<tr ><td>' . $row['beername'].'</td>';
echo '<td>' . $row['manu'] . '</td>';
echo '<td>' . $row['type'] . '</td>';
echo '<td width="40">' . $row['singles'] . '</td>';
echo '<td width="20">' . $row['six'] . '</td>';
echo '<td width="40">' . $row['can'] . '</td>';
echo '<td width="20">' . $row['bottles'] . '</td>';
echo '<td width="40">' . $row['tap'] . '</td>';
echo '<td>' . $row['size'] . '</td>';
echo '<td>' . $row['descrip'] . '</td>';
'</tr>';
}
echo '</table><br />';
}
All but the first row in alphabetical order are displayed properly.
Can anyone tell me where I am going wrong?
--
Gary
BTW, I do have a bonus question that is about javascript in this same file,
so if anyone want to take a stab at that, I'll be happy to post it.
__________ Information from ESET Smart Security, version of virus signature
database 5715 (20101219) __________
The message was checked by ESET Smart Security.
http://www.eset.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
In an effort to clean up some code, I tried taking four lines out of
6 or 7 programs and putting them into an include file. The file
structure is
Root
data
clubs.php
include
fmt.inc
Originally, clubs.php had the following code:
<?PHP
$file_name= basename($_SERVER['PHP_SELF']);
$last_modified = filemtime($file_name);
print("This page last modified ");
print(date("m/j/y", $last_modified));
?>
This code works - on the web page I get
This page last modified 12/18/2010
which is correct.
So then I did the following:
Create an include file, fmt.inc with the following code:
$file_name= basename($_SERVER['PHP_SELF']);
$last_modified = filemtime($file_name);
print("This page last modified ");
print(date("m/j/y", $last_modified));
and then in the original file, I have
<?PHP
include "../include/fmt.inc";
?>
On my web page, I then get
$file_name= basename($_SERVER['PHP_SELF']);$last_modified =
filemtime($file_name);print("This page last modified ");
print(date("m/j/y", $last_modified));
(all on one line).
I would really like to understand why the include construct doesn't
give the same results as the original?
-----===== Bill =====-----
--- End Message ---
--- Begin Message ---
$file_name= basename($_SERVER['PHP_SELF']);
$last_modified = filemtime($file_name);
print("This page last modified ");
print(date("m/j/y", $last_modified));
you need to wrap the contents ^^^ of the include file with <?
php .... ?>
------------
Govinda
--- End Message ---
--- Begin Message ---
On Dec 19, 2010, at 10:43 AM, Bill Guion wrote:
In an effort to clean up some code, I tried taking four lines out of
6 or 7 programs and putting them into an include file. The file
structure is
Root
data
clubs.php
include
fmt.inc
Originally, clubs.php had the following code:
<?PHP
$file_name= basename($_SERVER['PHP_SELF']);
$last_modified = filemtime($file_name);
print("This page last modified ");
print(date("m/j/y", $last_modified));
?>
This code works - on the web page I get
This page last modified 12/18/2010
which is correct.
So then I did the following:
Create an include file, fmt.inc with the following code:
$file_name= basename($_SERVER['PHP_SELF']);
$last_modified = filemtime($file_name);
print("This page last modified ");
print(date("m/j/y", $last_modified));
and then in the original file, I have
<?PHP
include "../include/fmt.inc";
?>
On my web page, I then get
$file_name= basename($_SERVER['PHP_SELF']);$last_modified =
filemtime($file_name);print("This page last modified ");
print(date("m/j/y", $last_modified));
(all on one line).
I would really like to understand why the include construct doesn't
give the same results as the original?
-----===== Bill =====-----
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Whenever you see PHP code emitted to the web page, it means it wasn't
wrapped in <?php..?>. If your include file above is complete, it's
missing these tags.
--- End Message ---
--- Begin Message ---
Is your server even set up to recognise .inc files as php? You can't just put
any old extension on and expect the server to know what to do with it.
Thanks,
Ash
http://www.ashleysheridan.co.uk
----- Reply message -----
From: "Tamara Temple" <[email protected]>
Date: Sun, Dec 19, 2010 17:07
Subject: [PHP] Problem with Include
To: "Bill Guion" <[email protected]>
Cc: <[email protected]>
On Dec 19, 2010, at 10:43 AM, Bill Guion wrote:
> In an effort to clean up some code, I tried taking four lines out of
> 6 or 7 programs and putting them into an include file. The file
> structure is
>
> Root
> data
> clubs.php
> include
> fmt.inc
>
> Originally, clubs.php had the following code:
>
> <?PHP
> $file_name= basename($_SERVER['PHP_SELF']);
> $last_modified = filemtime($file_name);
> print("This page last modified ");
> print(date("m/j/y", $last_modified));
>
> ?>
>
> This code works - on the web page I get
>
> This page last modified 12/18/2010
>
> which is correct.
>
> So then I did the following:
> Create an include file, fmt.inc with the following code:
>
> $file_name= basename($_SERVER['PHP_SELF']);
> $last_modified = filemtime($file_name);
> print("This page last modified ");
> print(date("m/j/y", $last_modified));
>
> and then in the original file, I have
>
> <?PHP
> include "../include/fmt.inc";
> ?>
>
> On my web page, I then get
>
> $file_name= basename($_SERVER['PHP_SELF']);$last_modified =
> filemtime($file_name);print("This page last modified ");
> print(date("m/j/y", $last_modified));
>
> (all on one line).
>
> I would really like to understand why the include construct doesn't
> give the same results as the original?
>
> -----===== Bill =====-----
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
Whenever you see PHP code emitted to the web page, it means it wasn't
wrapped in <?php..?>. If your include file above is complete, it's
missing these tags.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
Many, many thanks to Tamara, Govinda, and Ashley. Adding the php tags
<?php ?> to the include file solved the problem.
-----===== Bill =====-----
--- End Message ---
--- Begin Message ---
How should I follow the HTML specification while having the passed
parameters automatically converted to arrays in PHP?
The "name" attribute, not the "id" attribute, is used as the key when
submitting form values.
The "name" and "id" attributes do not have to be the same.
Thank you, I thought it should be the same (for same reason, maybe
compatibility between XHTML and HTML). But could not find anything on
the net which states this. So my memories might be corrupted :)
Based on first tests, it works (but have not checked the W3C validator yet).
Thanks,
Martin
--- End Message ---
--- Begin Message ---
How should I follow the HTML specification while having the passed
parameters automatically converted to arrays in PHP?
The "name" attribute, not the "id" attribute, is used as the key when
submitting form values.
The "name" and "id" attributes do not have to be the same.
Thank you, I thought it should be the same (for same reason, maybe
compatibility between XHTML and HTML). But could not find anything on
the net which states this. So my memories might be corrupted :)
Based on first tests, it works (but have not checked the W3C validator yet).
Thanks,
Martin
--- End Message ---
--- Begin Message ---
On Sun, Dec 19, 2010 at 4:57 PM, Martin C <[email protected]> wrote:
>> The "name" and "id" attributes do not have to be the same.
>
> Thank you, I thought it should be the same (for same reason, maybe
> compatibility between XHTML and HTML). But could not find anything on the
> net which states this. So my memories might be corrupted :)
You're probably thinking of:
http://www.w3.org/TR/html401/struct/links.html#h-12.2.3
"The id and name attributes share the same name space. This means that
they cannot both define an anchor with the same name in the same
document. It is permissible to use both attributes to specify an
element's unique identifier for the following elements: A, APPLET,
FORM, FRAME, IFRAME, IMG, and MAP. When both attributes are used on a
single element, their values must be identical."
Confusing, the "name" attribute on a form field ("input", "textarea",
"select", etc) is different to the "name" attribute on a "a" or "form"
element, so this rule does not apply to it.
--
Benjamin Hawkes-Lewis
--- End Message ---
--- Begin Message ---
Hello Everybody,
I am developing a php application that interfaces with an external
executable binary. The program is written in C++.
I open the program (say a.out) using proc_open. Write some command at
its stdin and fetch data stdout. Then close the program.
The timing of only "a.out" is
real 490ms
usr 160ms
sys 290ms
When I invoke it using proc_open in php-cli, the timing becomes
real 530ms
usr 50ms
sys 450ms
Look closely, the cpu time and the real elapsed time increases. I run
the php version from command line. As an apache handler this will
surly take more time.
My question is, how can I improve invoking this a.out? Is there any
best practice?
The command is something like
$ ./a.out --option value --option value < script.txt
The program a.out can not be converted in php unless I write an
extension. But this will need a lot of effort to write it in PHP.
Some of my ideas are,
1. Create a standalone multi-threaded server that calls a.out and php
calls that server.
2. Call a.out as a CGI and convert it that way.
Any ideas?
--
Shiplu Mokadd.im
My talks, http://talk.cmyweb.net
--- End Message ---
--- Begin Message ---
===============================================================================
Recently I my this php-general doesn't accept my mail for some
reason. So I send it again from anther email
===============================================================================
Hello Everybody,
I am developing a php application that interfaces with an external
executable binary. The program is written in C++.
I open the program (say a.out) using proc_open. Write some command at
its stdin and fetch data stdout. Then close the program.
The timing of only "a.out" is
real 490ms
usr 160ms
sys 290ms
When I invoke it using proc_open in php-cli, the timing becomes
real 530ms
usr 50ms
sys 450ms
Look closely, the cpu time and the real elapsed time increases. I run
the php version from command line. As an apache handler this will
surly take more time.
My question is, how can I improve invoking this a.out? Is there any
best practice?
The command is something like
$ ./a.out --option value --option value < script.txt
The program a.out can not be converted in php unless I write an
extension. But this will need a lot of effort to write it in PHP.
Some of my ideas are,
1. Create a standalone multi-threaded server that calls a.out and php
calls that server.
2. Call a.out as a CGI and convert it that way.
Any ideas?
--
Shiplu Mokadd.im
--- End Message ---