Re: [PHP] What did I do wrong to cause a parse error?
Hi there, On Thu, 2003-07-10 at 21:53, Phil Powell wrote: foreach ($profileArray[$i][attributes] as $key = $val) { ^^ You should quote the word 'attributes': http://www.php.net/manual/en/language.types.array.php#language.types.array.donts Sorry...that link might wrap. Anyway, I doubt that's the problem... $singleProfileHTML .= $key . =\ . str_replace(', '#039;', str_replace('', 'quot;', $val)) . \\n; } No idea. All I did was copy-paste your code and add a test definition for the other vars, and I just got this: [Script] ?php error_reporting(E_ALL); ini_set('display_errors', true); ini_set('html_errors', true); $profileArray = array('1' = array('attributes' = array('height' = '168 cm', 'weight' = '\'65\' kg'))); $singleProfileHTML = ''; $i = 1; foreach ($profileArray[$i][attributes] as $key = $val) { $singleProfileHTML .= $key . =\ . str_replace(', '#039;', str_replace('', 'quot;', $val)) . \\n; } print_r($singleProfileHTML); ? [Output] Notice: Use of undefined constant attributes - assumed 'attributes' in /home/torben/public_html/phptest/__phplist.html on line 36 height=168 cm weight='65' kg The parsing error occurs in the $singleProfileHTML.. line. I'm completely don't get it; I see absolutely nothing wrong with this, what did I miss? Phil I don't see anything wrong. Perhaps you have a non-printable control character embedded in your code? Try copy-pasting the above code (but quote that array key) and see if that helps. Also, check the code before that line for unclosed quotes and braces/parens or other problems; some parse errors can show up far from where they actually occurred. Other than that, without knowing anything else, it's hard to say off the top of my head. -- Torben Wilson [EMAIL PROTECTED]+1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com - Boycott Starbucks! http://www.haidabuckscafe.com - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What did I do wrong to cause a parse error?
On Fri, 11 Jul 2003 00:53:32 -0400, you wrote: foreach ($profileArray[$i][attributes] as $key = $val) { $singleProfileHTML .= $key . =\ . str_replace(', '#039;', str_replace('', 'quot;', $val)) . \\n; } The parsing error occurs in the $singleProfileHTML.. line. I'm completely don't get it; I see absolutely nothing wrong with this, what did I miss? Line 1 - attributes should have a $ in front of it, or be a string literal. BTW, that's a really nasty line. Maybe it would be easier to read as : foreach ($profileArray[$i][$attributes] as $key = $val) { $val = str_replace('', 'quot;', $val); $val = str_replace(', '#039;', $val); $singleProfileHTML .= $key=\$val\\n; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] What did I do wrong to cause a parse error?
Thanx I got it to work, however, I have no idea why it works now considering I did nothing different: $singleProfileHTML .= !--\n; foreach ($profileArray[$i][attributes] as $key = $val) { $singleProfileHTML .= strtolower($key) . '=' . str_replace(', '#039;', str_replace('', 'quot;', stripslashes($val))) . \\n; } $singleProfileHTML .= --\n; Beats the heck out of me! Phil - Original Message - From: David Otton [EMAIL PROTECTED] To: Phil Powell [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Sent: Friday, July 11, 2003 2:48 AM Subject: Re: [PHP] What did I do wrong to cause a parse error? On Fri, 11 Jul 2003 00:53:32 -0400, you wrote: foreach ($profileArray[$i][attributes] as $key = $val) { $singleProfileHTML .= $key . =\ . str_replace(', '#039;', str_replace('', 'quot;', $val)) . \\n; } The parsing error occurs in the $singleProfileHTML.. line. I'm completely don't get it; I see absolutely nothing wrong with this, what did I miss? Line 1 - attributes should have a $ in front of it, or be a string literal. BTW, that's a really nasty line. Maybe it would be easier to read as : foreach ($profileArray[$i][$attributes] as $key = $val) { $val = str_replace('', 'quot;', $val); $val = str_replace(', '#039;', $val); $singleProfileHTML .= $key=\$val\\n; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] What did I do wrong to cause a parse error?
-Original Message- From: Phil Powell [mailto:[EMAIL PROTECTED] Sent: 11 July 2003 05:54 foreach ($profileArray[$i][attributes] as $key = $val) { $singleProfileHTML .= $key . =\ . str_replace(', '#039;', str_replace('', 'quot;', $val)) . \\n; } The parsing error occurs in the $singleProfileHTML.. line. I'm completely don't get it; I see absolutely nothing wrong with this, what did I miss? Well, I can see nothing wrong with that line, so I can't help there. I do, however, wonder why you aren't using htmlentities() instead of those two ugle str_replace()s. And I hope you have a constant defined called attributes, otherwise that array index must be either quoted (e.g. 'attributes'), or $attributes. Cheers! Mike - Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] What did I do wrong to cause a parse error?
foreach ($profileArray[$i][attributes] as $key = $val) { $singleProfileHTML .= $key . =\ . str_replace(', '#039;', str_replace('', 'quot;', $val)) . \\n; } The parsing error occurs in the $singleProfileHTML.. line. I'm completely don't get it; I see absolutely nothing wrong with this, what did I miss? Phil