|
Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com |
php-general Digest 21 Nov 2006 17:10:31 -0000 Issue 4472
php-general-digest-help
lists.php.net
Date: Tue Nov 21 2006 - 11:10:31 CST
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
php-general Digest 21 Nov 2006 17:10:31 -0000 Issue 4472
Topics (messages 244940 through 244966):
Re: default postgreSQL schema
244940 by: Alain Roger
mime type
244941 by: Fernando Viadero
244948 by: testkonto
XML parser error ..
244942 by: onewaylife
Re: Coding Standards Document
244943 by: Roman Neuhauser
244951 by: tedd
244952 by: tedd
244959 by: Jochem Maas
244963 by: tedd
Re: Converting array keys to variables?
244944 by: Ford, Mike
Re: Space in regex
244945 by: Ford, Mike
Re: odd behavior of stripos() with === operator *LAST POST*
244946 by: Ford, Mike
multiple upload files?
244947 by: testkonto
244949 by: Stut
244950 by: David O'Brien
Re: I'm getting ordered lists in my fieldsets - template help
244953 by: Jochem Maas
Re: Programmer needed
244954 by: tedd
244955 by: Chris
244956 by: Dave Goodchild
Useful function for file download (i.e. MP3)
244957 by: Brad Fuller
Help with typecasting by default in the function parameter list
244958 by: Jared Farrish
244960 by: Stut
244961 by: Jochem Maas
Re: Smart Quotes not so smart
244962 by: Larry Garfield
newbie problem - extraneous newlines inserted in PHP-generated HTML form source
244964 by: Mark White
244965 by: Edward Kay
244966 by: Richard Lynch
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscribe
lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscribe
lists.php.net
To post to the list, e-mail:
php-general
lists.php.net
----------------------------------------------------------------------
attached mail follows:
thanks a lot.
I also find that i can setup it directly to DB thanks to alter command.
I was thinking that maybe PHP had a special command for that, but it seems
not.
Alain
On 11/21/06, Chris <dmagick
gmail.com> wrote:
>
> Alain Roger wrote:
> > Hi,
> >
> > I would like to know if under PHP i can setup the default schema for a
> > PostgreSQL database ?
> >
> > e.g if my database name is 'mydb', my schema 'immense', i would like to
> > avoid :
> >
> > immense.my_function_name(parameter1, parameter2,..)
> >
> > ...
> > select * from immense.table1 WHERE immense.table1.field1 =
> > immense.table2.field5;
>
> Definitely not a php thing but here's a page with how to do it:
>
> http://www.postgresql.org/docs/8.1/interactive/ddl-schemas.html
>
> Basically you need to do:
>
> pg_query('SET search_path TO myschema,public');
>
> straight after your pg_connect call.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
--
Alain
------------------------------------
Windows XP SP2
PostgreSQL 8.1.4
Apache 2.0.58
PHP 5
attached mail follows:
hello
is this code OK???
"fotos" is an array of uploaded files (images)..
i want to process them in case they are images...if not, don't process..
is myme type case sensitive??
some of our customers, have problems uploading images...
thanks in advance..
$tipo = $HTTP_POST_FILES["fotos"]["type"][$a];
$tipo = ( strstr($tipo, '; name') ) ? str_replace(strstr($tipo, ';
name'), '', $tipo) : $tipo; //some opera patch¿¿¿
if (
($tipo == "image/png") ||
($tipo == "image/jpeg") ||
($tipo == "image/jpg") ||
($tipo == "image/bmp") ||
($tipo == "image/gif")ç
)
{
//process.
}
else
{
//do nothing
}
attached mail follows:
Am Dienstag, 21. November 2006 09:22 schrieb Fernando Viadero:
> hello
>
>
> is this code OK???
> $tipo = $HTTP_POST_FILES["fotos"]["type"][$a];
Did you ever examine the content of $tipo after this call?
Please do so.
Regards,
Oliver
attached mail follows:
Hi all
I am novice in XML. I have just started to creating PHP parser for XML
files. I am using SAX.
the file is : -
<html>
<head>
<basefont face="Arial">
</head>
<body>
<?php
// cdata handler
function characterDataHandler($parser, $data)
{
echo $data . "<p>";
}
// PI handler
function PIHandler($parser, $target, $data)
{
// if php code, execute it
if (strtolower($target) == "php")
{
eval($data);
}
// otherwise just print it
else
{
echo "PI found: [$target] $data";
}
}
// XML data
$xml_data = <<<EOF
<?xml version="1.0"?>
<article>
<header>insert slug here</header>
<body>insert body here</body>
<footer><?php print "Copyright UNoHoo Inc," . date("Y", mktime());
?></footer>
</article>
EOF;
// initialize parser
$xml_parser = xml_parser_create();
// set cdata handler
xml_set_character_data_handler($xml_parser, "characterDataHandler");
// set PI handler
xml_set_processing_instruction_handler($xml_parser, "PIHandler");
if (!xml_parse($xml_parser, $xml_data))
{
die("XML parser error: " .
xml_error_string(xml_get_error_code($xml_parser)));
}
// all done, clean up!
xml_parser_free($xml_parser);
?>
</body>
</html>
it give this output " XML parser error: Reserved XML Name"
even i created two more php files but it give same message as out put.
I am unable to understand why its come.
Please help me out.
onewaylife
--
View this message in context: http://www.nabble.com/XML-parser-error-..-tf2677513.html#a7467514
Sent from the PHP - General mailing list archive at Nabble.com.
attached mail follows:
# kevin
oceania.net / 2006-11-21 06:07:45 +1100:
> This one time, at band camp, "Eric Butera" <digital.tarsier
gmail.com> wrote:
>
> > You might check out the Zend Framework coding standards.
> > http://framework.zend.com/manual/en/coding-standard.html
> Zend Framework coding standards fails for me here...
> "Use an indent of 4 spaces, with no tabs."
>
> The use of tabs is dynamic, where as with the static tabs you can easily
> set you editor to handle them any way you wish, assuming you have a
> decent editor such as vi(m).
> :set ts=4
The text editor typically isn't the only client that needs to display
the source code. Various web-based tools such as ViewVC depend on the
way their clients interpret the HTML and/or CSS, patches in emails are
displayed by different MUAs, there's print...
With spaces, the sole configuration one needs to assume from the
client(s) is proper display of a monospaced font, and that's much more
reliable than praying for a uniform tab display. Twice so if you choose
to use ts=4 because most software (at least out of the set I use) places
tabstops at 8-char intervals.
> The real key to successful "standards" is consistency, regardless of what
> method you choose.
That seems inconsistent with your tab/space-based dismissal of the ZF CS.
--
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man. You don't KNOW.
Cause you weren't THERE. http://bash.org/?255991
attached mail follows:
At 11:41 PM +0100 11/20/06, Jochem Maas wrote:
>everyone should be coding to my standards.
>
I agree with that. After all it's my standards that I have to live with.
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
At 6:56 PM -0600 11/20/06, Richard Lynch wrote:
>For the record, I also think it's daft to require spaces for tabs in
>2006 coding standards...
I agree.
Plus, not everyone see's code the same -- some of us have vision
issues, some are dyslexic, some are both. I write and organize code
so that I can understand and use it. I would not function well in a
strict "follow my way of coding" environment.
>Sure, we all have our preferences for K&B or whatever, but, really,
>that sort of thing could almost be handled by some sort of "style
>sheet" for coding to present what you prefer for your layout rather
>than forcing everbody to use the same...
I've been a proponent of style sheets for coding ever since I heard of css.
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
tedd wrote:
> At 11:41 PM +0100 11/20/06, Jochem Maas wrote:
>> everyone should be coding to my standards.
>>
>
> I agree with that. After all it's my standards that I have to live with.
now your just being clever - I should have been more explicit:
everyone should be coding to Jochem's standards
please note I only provide my standards in moving-target-which-way-is-the-wind-blowing format.
;-P
PS - we too have to live with your standards ;-)
>
> tedd
attached mail follows:
At 3:48 PM +0100 11/21/06, Jochem Maas wrote:
>tedd wrote:
>> At 11:41 PM +0100 11/20/06, Jochem Maas wrote:
>>> everyone should be coding to my standards.
>>>
>>
>> I agree with that. After all it's my standards that I have to live with.
>
>now your just being clever -
There's a first.
>PS - we too have to live with your standards ;-)
Nah, no one wants my code.
Cheers,
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On 20 November 2006 22:55, Richard Lynch wrote:
> On Fri, November 17, 2006 10:23 am, Ashley M. Kirchner wrote:
> > [hours] => Array
> > (
> > [0] => Array
> > (
> > [file] => capture.0400.jpg
> > [path] => spool/.2006/11/17/04
> > [year] => 2006
> > [month] => 11
> > [day] => 17
> > [hhmm] => 0400
> > )
> ...
> > Is there a way that I can simply loop through each array and
> > convert the keys into variables? I want to avoid having to write
> > lines of:
>
> foreach($array['hours'] as $key => $image_meta){
> list($file, $path, $year, $month, $day, $hhmm) = $image_meta;
> //Do whatever you want with the variables.
> }
>
> I personally would avoid 'extract' function, as a matter of principle,
> as it's to easy to add something to an array and not realize it, and
> then you start over-writing variables you didn't mean to, because your
> key name matches some other variable you didn't mean to over-write...
That's what the extract_type and prefix parameters are for.
Although I wouldn't use extract() either, as I'd just address the array elements directly using a full set of subscripts.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford
leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
attached mail follows:
On 20 November 2006 23:12, Richard Lynch wrote:
> . means *ANY* character, unless you escape it for PCRE
>
> \. is what PCRE needs.
Not in a character class -- inside [], "." means ".".
> So, in PHP, to get the \ down to PCRE, you want 2 \:
>
> Then there is the issue that '-' looks like a "range" character (A-Z
> etc) so you should put it at the end.
>
> And there is no need to use the confusing (to me) ::xyz:: stuff...
>
> '/[A-Za-z0-9\\'\\.& _-]/'
Except now you have a syntax error, as you've failed to notice (as did several others) that the \' in the original string is to escape the ' for PHP because the whole pattern string itself is single quoted.
>
> You can simplify this a bit to:
> '/[A-Z0-9\\'\\.& _-]/i'
So the syntactically-correct simple version of this is '/[A_Z0-9\'.&_-]/i'.
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford
leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
attached mail follows:
On 21 November 2006 00:23, Michael wrote:
> At 10:12 AM 11/17/2006 , Ford, Mike wrote:
> >
> > (integer)===TRUE -- is always FALSE
> > (integer)!==TRUE -- is always TRUE
> >
> > (integer)===FALSE -- is always FALSE
> > (integer)!==FALSE -- is always TRUE
>
> Which brings me to the original point of the post, (which is now
> burried in a heap of discussion) a heads-up to the unwary...
>
> If there is any chance that the needle you are looking for in the
> haystack will be found at the first position (index 0), using ===
> will NEVER return true,
What rot, this is a perfectly valid piece of PHP code in which the === will return TRUE if $a does not contain the string 'abc' (and so execute the die()):
if (strpos($a, 'abc')===FALSE):
die('Invalid string');
endif;
> do not do this :
>
> if ( stripos("abcde","abc")=== TRUE ) {echo "abc found!"} this will
> NEVER be true.
No of course not -- why in the world would you do that when TRUE is not one of the documented return values of strpos()??
Sorry, but I think you're still missing the essential point, which is that the opposite of testing for !==FALSE is *not* ===TRUE, but ===FALSE -- in other words, !($x!==FALSE) is the same as ($x===FALSE), or in other other words you invert *only* the *test*, not the *operand*. And it's like this because === and !==, unlike == and !=, do not coerce their operands to Boolean, so something that is !==FALSE is not *necessarily* ===TRUE (although it *is* necessarily ==TRUE).
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS, LS6 3QS, United Kingdom
Email: m.ford
leedsmet.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm
attached mail follows:
Hello list,
I wonder if it's possible to load more than one file up to a web server - with
a single form submision.
Does anybody know if yes/no?
Regards,
Oliver
attached mail follows:
testkonto wrote:
> I wonder if it's possible to load more than one file up to a web server - with
> a single form submision.
>
> Does anybody know if yes/no?
>
Yes.
-Stut
attached mail follows:
http://www.php.net/manual/en/features.file-upload.php
-D
-----Original Message-----
From: testkonto [mailto:testkonto
block-online.eu]
Sent: Tuesday, November 21, 2006 7:49 AM
To: php-general
lists.php.net
Subject: [PHP] multiple upload files?
Hello list,
I wonder if it's possible to load more than one file up to a web server
- with
a single form submision.
Does anybody know if yes/no?
Regards,
Oliver
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
attached mail follows:
Chuck Reynolds wrote:
> I don't understand how to rebuild the template so I don't have ordered
I don't understand why you are repeatedly posting questions
about PEAR code to the php *general* mailing list.
> lists
> for each fieldset when using HTML_QuickForm_Renderer_Tableless.
>
> outputted source code looks like this:
>
> <form action="/estimate.php" method="post" name="frmEstimate"
> id="frmEstimate">
> <div style="display: none;"></div>
> <fieldset>
> <legend>Your Information</legend>
> <ol>
> <li><label for="txtFullName" class="element"><span
> class="required">*</span>Full Name:</label><div class="element"><input
> id="txtFullName" name="txtFullName" type="text" /></div></li>
>
>
> I'd like to know how to change that and I simply can't get the renderer to
> work.
have you noticed that you could have written the form by hand about 3 times
in the time it's taken to get as far as you have with 'QuickForm'? with the
added bonus that the code is much more readable/manageable and the html output
is actually controllable (i.e. you don't have to wave dead chickens about
get rid of ordered lists...
if you ask me QuickForm is the product of some clever and very sadistic coders...
right now you are their b****. ;-)
you best bet is something like this:
find / -name '*QuickForm*' -exec rm -rf \{\};
(if you run that cmdline without know what it does then you deserve to experience
the resulting horror)
>
> Thanks
>
>
attached mail follows:
At 7:05 PM -0500 11/20/06, Jeff wrote:
>If anyone is interested in working on making a mysql database.. it's
>like a dating site, so the typical inputs - Age, height, about,
>upload a couple of pictures, etc.
>Able to have other members comment, send messages back / forth.
>
>If anyone is capable (which I'm sure there are plenty!) of doing
>this, your help would be greatly apprecated. Please give me approx.
>how many hours, and your rate.
>I've tried, and I think it's well over my head.
>Once running, if anything needs tweaking, your time will be paid for.
>Thanks a bunch!
>
>Jeff
Jeff:
Check out the osDate stuff here:
http://www.tufat.com/
You know for $5, you can't go too wrong.
I've purchased some other code there, and it's been good code with
good support.
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
attached mail follows:
On Tue, 2006-11-21 at 15:48, tedd wrote:
> Check out the osDate stuff here:
>
> http://www.tufat.com/
>
> You know for $5, you can't go too wrong.
>
> I've purchased some other code there, and it's been good code with
> good support.
I`ll second that....paid for Flashchat and some Flash galleries from
them...well worth it...
Regards
--
Chris Blake
Cell: 082 775 1492
Work: +27 11 880 2825
Fax : +27 11 782 0841
Mail: chris
pixcel.co.za
Good night, Austin, Texas, wherever you are!
attached mail follows:
Contact me off-list to discuss further, I have just completed a national
events directory that follows the same kind of model.
On 11/21/06, tedd <tedd
sperling.com> wrote:
>
> At 7:05 PM -0500 11/20/06, Jeff wrote:
> >If anyone is interested in working on making a mysql database.. it's
> >like a dating site, so the typical inputs - Age, height, about,
> >upload a couple of pictures, etc.
> >Able to have other members comment, send messages back / forth.
> >
> >If anyone is capable (which I'm sure there are plenty!) of doing
> >this, your help would be greatly apprecated. Please give me approx.
> >how many hours, and your rate.
> >I've tried, and I think it's well over my head.
> >Once running, if anything needs tweaking, your time will be paid for.
> >Thanks a bunch!
> >
> >Jeff
>
>
> Jeff:
>
> Check out the osDate stuff here:
>
> http://www.tufat.com/
>
> You know for $5, you can't go too wrong.
>
> I've purchased some other code there, and it's been good code with
> good support.
>
> tedd
>
> --
> -------
> http://sperling.com http://ancientstones.com http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
http://www.web-buddha.co.uk
attached mail follows:
Hey guys,
Someone had asked about how to "output an mp3 file"...
> readfile(), depending on your PHP version, is going to suck in the whole
MP3 before it starts spewing out bytes.
I have had this function in my library for quite some time now, can't
remember where I got it but it's proven very useful if you want to have a
user download a large file without giving a direct link to the file. This
function will only use up 1K of memory no matter how big the file is.
Enjoy!
function readfile_chunked($filename,$retbytes=true) {
$chunksize = 1*(1024*1024); // how many bytes per chunk
$buffer = '';
$cnt =0;
$handle = fopen($filename, 'rb');
if ($handle === false) {
return false;
}
while (!feof($handle)) {
$buffer = fread($handle, $chunksize);
echo $buffer;
ob_flush();
flush();
if ($retbytes) {
$cnt += strlen($buffer);
}
}
$status = fclose($handle);
if ($retbytes && $status) {
return $cnt; // return num. bytes delivered like readfile() does.
}
return $status;
}
-B
attached mail follows:
Is this legal? Note where the typecasting occurs: In the function parameter
list, before the variable.
<code>
function doSomething( (int) $int1, (int) $int2 ) {
//blah blah
}
</code>
This would take the place of:
<code>
function doSomething($int1, $int2) {
$int1 = (int) $int1;
$int2 = (int) $int2;
}
</code>
Is this possible?
--
Jared Farrish
Intermediate Web Developer
Denton, Tx
Abraham Maslow: "If the only tool you have is a hammer, you tend to see
every problem as a nail." $$
attached mail follows:
Jared Farrish wrote:
> Is this legal? Note where the typecasting occurs: In the function
> parameter
> list, before the variable.
>
> <code>
> function doSomething( (int) $int1, (int) $int2 ) {
> //blah blah
> }
> </code>
>
> This would take the place of:
>
> <code>
> function doSomething($int1, $int2) {
> $int1 = (int) $int1;
> $int2 = (int) $int2;
> }
> </code>
>
> Is this possible?
No, but maybe worth suggesting to the internals list for 6. I'd
certainly like to see it.
-Stut
attached mail follows:
Jared Farrish wrote:
> Is this legal?
> Note where the typecasting occurs: In the function parameter
> list, before the variable.
>
> <code>
> function doSomething( (int) $int1, (int) $int2 ) {
> //blah blah
> }
> </code>
>
> This would take the place of:
>
> <code>
> function doSomething($int1, $int2) {
> $int1 = (int) $int1;
> $int2 = (int) $int2;
> }
> </code>
>
> Is this possible?
have you taken 5 seconds to run the code and find out?
>
attached mail follows:
On Monday 20 November 2006 18:19, Richard Lynch wrote:
> You are correct. They are not "real" UTF-8 nor UTF-16 characters.
> Catch the data somewhere in PHP and use the functions from the User
> Contributed code on http://php.net/str_replace to replace the MS Word
> chars with their ASCII or HTML equivalents -- Both versions are in the
> User Contributed notes, plus variations on this theme.
>
> You may have trouble with REAL UTF-8 and UTF-16 charsets, however, as
> I suspect that MS Word smart quotes may "collide" with those charsets
> (codepages?) in a way that makes one indistinguishable from the other.
Actually, I couldn't get any string-replacement techniques to work. None of
them seemed to properly catch the characters involved, either in this PHP app
or in a Perl app I was working on personally at the same time by coincidence.
However, I discovered that at least part of the problem is at the HTTP level.
It seems like the data was being corrupted before it even got to the server.
Although we already had the Content type charset set to UTF-8 in the HTTP
header, the browser (IE, Firefox, and Konqueror) was still defaulting to
Latin1/Western, and I believe then *sending* data as that. When we set a
<meta> tag to also set the content type and charset, however, the browser
(all of them) switched into UTF-8 and submitted the data, and then displayed
the smart quotes correctly (that is, without funky accented characters). It
only seemed to work if the browser was set to UTF-8 both to submit the data
and to read it. The existing pages remained borked.
For the time being it seems the meta tag is working, but I'm quite curious as
to why the browser would listen to that and NOT to the HTTP header. It also
still doesn't explain why the string-replace method is still not working,
even when everything is set to UTF-8.
If anyone has an idea in that regard, please share. :-)
--
Larry Garfield AIM: LOLG42
larry
garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson
attached mail follows:
hi
I am VERY new to this, so please be gentle.
I am trying to use PHP to generate an HTML form for editing an
uncomplicated XML document. I can parse the xml information
successfully. However, when it comes to building the form, where I have
a pair of double quotes (one escaped) to open the insertion of an array
variable for a form value there is also a newline character inserted in
the generated HTML form source code. Firefox and Safari ignore the
'breaks' in the code lines but it causes Explorer 5.2 (Mac) to fail to
display the values.
I have tried replacing the escaped double quote with a single quote - no
change, the HTML source still includes the extra newline. I've tried
removing and inserting spaces either side of the '.' without luck. I've
also checked the xml document in Textwrangler and it is 'clean' of
unwanted hidden characters.
There are two oddities about this. Firstly, the array[0] postion record
set form doesn't produce this 'broken' generated HTML, yet subsequent
records each show breaks in the HTML source in exactly the same place.
The other strangeness is that if I tab the original xml document for
clarity I get tabs inserted in the HTML along with the extra return ....
but again, only from record 2 (array[1]) onwards.
Here is part of the xml -
<?xml version="1.0"?>
<teachingstaff>
<person>
<name>name 1</name>
<status>headteacher</status>
<class>1</class>
<history>words here</history>
<picture>1.jpg</picture>
</person>
<person>
<name>name 2</name>
<status>teacher</status>
<class>2</class>
<history>words here</history>
<picture>2.jpg</picture>
</person>
<person>
<name>name 3</name>
and so on ... and here is some of the php to generate the HTML editing
form -
<?
loadteachingstaff();
echo "<div id=\"container\">";
echo "<div class=\"head\"><h2>Edit staff listing</h2></div><div>\n";
if($tstaffid < count($teachingstaff)) {
echo "<form action=\"tstaffsave.php\" method=\"POST\">";
echo "<input type=\"hidden\" name=\"tstaffid\" value=\"$tstaffid\">";
echo "<table>\n<tr><td class=\"labelr\">Name: </td><td><input
type=\"text\" name=\"newname\" size=\"50\"
value=\"".$teachingstaff[$tstaffid]['name']."\"></td></tr><br />\n";
echo "<tr><td class=\"labelr\">Role: </td><td><input type=\"text\"
name=\"newstatus\" size=\"50\"
value=\"".$teachingstaff[$tstaffid]['status']."\"></td></tr><br />\n";
echo "<tr><td class=\"labelr\">Class(es): </td><td><input type=\"text\"
name=\"newclass\" size=\"50\"
value=\"".$teachingstaff[$tstaffid]['class']."\"></td></tr><br />\n";
echo "<tr><td class=\"labelr\" valign=\"top\">Experience:
</td><td><textarea name=\"newhistory\" rows=\"5\" cols=\"50\"
align=\"left\">" . $teachingstaff[$tstaffid]['history'] .
"</textarea></td><br /></tr>\n";
and so on ...
The (**NEWLINE**) 'break' in the generated HTML source appears at the
following point in each of the echoed lines -
...
name=\"newstatus\" size=\"50\"
value=\""**NEWLINE**.$teachingstaff[$tstaffid]['status']."\"></td></tr><br
/>\n";
...
... but NOT if $tstaffid is 0 ...
Sorry to be so long-winded. I've checked the FAQ archives and can't find
anything which helps.
Mark
attached mail follows:
Do a var_dump() on $teachingstaff and see what is actually in the PHP array.
(I'd recommend putting the output in <pre> tags for readability).
Edward
> -----Original Message-----
> From: Mark White [mailto:mwdesign
clara.co.uk]
> Sent: 21 November 2006 16:32
> To: php-general
lists.php.net
> Subject: [PHP] newbie problem - extraneous newlines inserted in
> PHP-generated HTML form source
>
>
> hi
>
> I am VERY new to this, so please be gentle.
>
> I am trying to use PHP to generate an HTML form for editing an
> uncomplicated XML document. I can parse the xml information
> successfully. However, when it comes to building the form, where I have
> a pair of double quotes (one escaped) to open the insertion of an array
> variable for a form value there is also a newline character inserted in
> the generated HTML form source code. Firefox and Safari ignore the
> 'breaks' in the code lines but it causes Explorer 5.2 (Mac) to fail to
> display the values.
>
> I have tried replacing the escaped double quote with a single quote - no
> change, the HTML source still includes the extra newline. I've tried
> removing and inserting spaces either side of the '.' without luck. I've
> also checked the xml document in Textwrangler and it is 'clean' of
> unwanted hidden characters.
>
> There are two oddities about this. Firstly, the array[0] postion record
> set form doesn't produce this 'broken' generated HTML, yet subsequent
> records each show breaks in the HTML source in exactly the same place.
> The other strangeness is that if I tab the original xml document for
> clarity I get tabs inserted in the HTML along with the extra return ....
> but again, only from record 2 (array[1]) onwards.
>
> Here is part of the xml -
>
> <?xml version="1.0"?>
>
> <teachingstaff>
> <person>
> <name>name 1</name>
> <status>headteacher</status>
> <class>1</class>
> <history>words here</history>
> <picture>1.jpg</picture>
> </person>
> <person>
> <name>name 2</name>
> <status>teacher</status>
> <class>2</class>
> <history>words here</history>
> <picture>2.jpg</picture>
> </person>
> <person>
> <name>name 3</name>
>
> and so on ... and here is some of the php to generate the HTML editing
> form -
>
> <?
> loadteachingstaff();
> echo "<div id=\"container\">";
> echo "<div class=\"head\"><h2>Edit staff listing</h2></div><div>\n";
> if($tstaffid < count($teachingstaff)) {
> echo "<form action=\"tstaffsave.php\" method=\"POST\">";
> echo "<input type=\"hidden\" name=\"tstaffid\" value=\"$tstaffid\">";
> echo "<table>\n<tr><td class=\"labelr\">Name: </td><td><input
> type=\"text\" name=\"newname\" size=\"50\"
> value=\"".$teachingstaff[$tstaffid]['name']."\"></td></tr><br />\n";
> echo "<tr><td class=\"labelr\">Role: </td><td><input type=\"text\"
> name=\"newstatus\" size=\"50\"
> value=\"".$teachingstaff[$tstaffid]['status']."\"></td></tr><br />\n";
> echo "<tr><td class=\"labelr\">Class(es): </td><td><input type=\"text\"
> name=\"newclass\" size=\"50\"
> value=\"".$teachingstaff[$tstaffid]['class']."\"></td></tr><br />\n";
> echo "<tr><td class=\"labelr\" valign=\"top\">Experience:
> </td><td><textarea name=\"newhistory\" rows=\"5\" cols=\"50\"
> align=\"left\">" . $teachingstaff[$tstaffid]['history'] .
> "</textarea></td><br /></tr>\n";
>
> and so on ...
>
> The (**NEWLINE**) 'break' in the generated HTML source appears at the
> following point in each of the echoed lines -
> ...
> name=\"newstatus\" size=\"50\"
> value=\""**NEWLINE**.$teachingstaff[$tstaffid]['status']."\"></td>
> </tr><br
> />\n";
> ...
>
> ... but NOT if $tstaffid is 0 ...
>
> Sorry to be so long-winded. I've checked the FAQ archives and can't find
> anything which helps.
>
> Mark
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
attached mail follows:
On Tue, November 21, 2006 10:31 am, Mark White wrote:
> I am VERY new to this, so please be gentle.
>
> I am trying to use PHP to generate an HTML form for editing an
> uncomplicated XML document. I can parse the xml information
> successfully. However, when it comes to building the form, where I
> have
> a pair of double quotes (one escaped) to open the insertion of an
> array
> variable for a form value there is also a newline character inserted
> in
> the generated HTML form source code. Firefox and Safari ignore the
> 'breaks' in the code lines but it causes Explorer 5.2 (Mac) to fail to
> display the values.
>
> I have tried replacing the escaped double quote with a single quote -
> no
> change, the HTML source still includes the extra newline. I've tried
> removing and inserting spaces either side of the '.' without luck.
> I've
> also checked the xml document in Textwrangler and it is 'clean' of
> unwanted hidden characters.
>
> There are two oddities about this. Firstly, the array[0] postion
> record
> set form doesn't produce this 'broken' generated HTML, yet subsequent
> records each show breaks in the HTML source in exactly the same place.
> The other strangeness is that if I tab the original xml document for
> clarity I get tabs inserted in the HTML along with the extra return
> ....
> but again, only from record 2 (array[1]) onwards.
>
> Here is part of the xml -
>
> <?xml version="1.0"?>
>
> <teachingstaff>
> <person>
> <name>name 1</name>
> <status>headteacher</status>
> <class>1</class>
> <history>words here</history>
> <picture>1.jpg</picture>
> </person>
> <person>
> <name>name 2</name>
> <status>teacher</status>
> <class>2</class>
> <history>words here</history>
> <picture>2.jpg</picture>
> </person>
> <person>
> <name>name 3</name>
>
> and so on ... and here is some of the php to generate the HTML editing
> form -
>
> <?
> loadteachingstaff();
> echo "<div id=\"container\">";
It is much clearer to break in/out of PHP "mode" than to have all
these echo statements.
?>
<div id="container">
<div class="head"><h2>Edit staff listing</h2></div>
<div><?php
if ($tstaffid < count($teachingstaff)) {
?>
<form action="tstaffsave.php" method="POST">
...
</form>
<?php
}
?>
</div>
</div>
This may or may not help with the newlines in your data...
> echo "<div class=\"head\"><h2>Edit staff listing</h2></div><div>\n";
> if($tstaffid < count($teachingstaff)) {
> echo "<form action=\"tstaffsave.php\" method=\"POST\">";
> echo "<input type=\"hidden\" name=\"tstaffid\" value=\"$tstaffid\">";
> echo "<table>\n<tr><td class=\"labelr\">Name: </td><td><input
> type=\"text\" name=\"newname\" size=\"50\"
> value=\"".$teachingstaff[$tstaffid]['name']."\"></td></tr><br />\n";
> echo "<tr><td class=\"labelr\">Role: </td><td><input type=\"text\"
> name=\"newstatus\" size=\"50\"
> value=\"".$teachingstaff[$tstaffid]['status']."\"></td></tr><br />\n";
> echo "<tr><td class=\"labelr\">Class(es): </td><td><input
> type=\"text\"
> name=\"newclass\" size=\"50\"
> value=\"".$teachingstaff[$tstaffid]['class']."\"></td></tr><br />\n";
> echo "<tr><td class=\"labelr\" valign=\"top\">Experience:
> </td><td><textarea name=\"newhistory\" rows=\"5\" cols=\"50\"
> align=\"left\">" . $teachingstaff[$tstaffid]['history'] .
> "</textarea></td><br /></tr>\n";
>
> and so on ...
>
> The (**NEWLINE**) 'break' in the generated HTML source appears at the
> following point in each of the echoed lines -
> ...
> name=\"newstatus\" size=\"50\"
> value=\""**NEWLINE**.$teachingstaff[$tstaffid]['status']."\"></td></tr><br
> />\n";
> ...
>
> ... but NOT if $tstaffid is 0 ...
>
> Sorry to be so long-winded. I've checked the FAQ archives and can't
> find
> anything which helps.
You need to first be 100% sure that you don't have newlines in the
data itself.
If status should have no whitespace before/after it, you could also
just http://php.net/trim it for now, and figure out where the newline
is coming from later. But you'll want to track it down, as this will
likely not go away until you understand where it comes from.
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]