RE: [PHP] mysql_fetch_array and row referencing under 4.0.4pl1

2001-02-13 Thread Scott Brown

oh hell.

Do I ever feel stupid now.  That explains that test script perfectly
now I just have to figure out whats wrong with the rest of my site

Obviously, too much "What-the-f..." and not enough "lets look at this
logically" occured.

Sorry about that.  I'll crawl back under my rock now.

> -Original Message-
> From: Steve Werby [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, February 13, 2001 12:26 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP] mysql_fetch_array and row referencing
> under 4.0.4pl1
>
>
> "Scott Brown" <[EMAIL PROTECTED]> wrote:
> > I grabbed an example of of php.net dealing with just arrays
> and it works
> ...
> >
> > Here's what I'm seeing - THIS WORKS:
>
> 
> > while ( $row = mysql_fetch_array($rslt) )
> > {
> > echo "\n";
> > echo "$row[ID]";
> 
>
> > But put any one of these $row[...] with quotes around their
> fieldnames and
> I
> > get:
> >
> > Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
> > `T_NUM_STRING' in /home/testnexus/public_html/test.php on line 16
> >
> > (when line 16 =
> > echo "$row["ID"]";
>
> The double quotes enclose the contents of the echo statement,
> but PHP chokes
> because you have double quotes inside the echo statement.  If
> the exact line
> above worked under PHP3.x I'm surprised.  Solutions include:
>
> escaping the double quotes
> echo "$row[\"ID\"]";
>
> using no quotes or single quotes:
> echo "$row['ID']";
> echo "$row[ID]";
>
> breaking apart the echo statement:
> echo "" . $row["ID"] . "";
>
> I don't think there's any way around this.  If you got it to work
> differently in PHP3 I'd like to know how.  If for some reason
> you have a ton
> of code you have to change now, you can write a PHP script which uses
> regular expressions to find the double quotes to replace,
> write out the new
> files and cycle through all your files.  It really wouldn't
> be that hard,
> but I still suspect that the double quotes would have been a
> problem in PHP3
> too.
>
> --
> Steve Werby
> COO
> 24-7 Computer Services, LLC
> Tel: 804.817.2470
> http://www.247computing.com/
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail:
> [EMAIL PROTECTED]
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mysql_fetch_array and row referencing under 4.0.4pl1

2001-02-12 Thread Steve Werby

"Scott Brown" <[EMAIL PROTECTED]> wrote:
> I grabbed an example of of php.net dealing with just arrays and it works
...
>
> Here's what I'm seeing - THIS WORKS:


> while ( $row = mysql_fetch_array($rslt) )
> {
> echo "\n";
> echo "$row[ID]";


> But put any one of these $row[...] with quotes around their fieldnames and
I
> get:
>
> Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
> `T_NUM_STRING' in /home/testnexus/public_html/test.php on line 16
>
> (when line 16 =
> echo "$row["ID"]";

The double quotes enclose the contents of the echo statement, but PHP chokes
because you have double quotes inside the echo statement.  If the exact line
above worked under PHP3.x I'm surprised.  Solutions include:

escaping the double quotes
echo "$row[\"ID\"]";

using no quotes or single quotes:
echo "$row['ID']";
echo "$row[ID]";

breaking apart the echo statement:
echo "" . $row["ID"] . "";

I don't think there's any way around this.  If you got it to work
differently in PHP3 I'd like to know how.  If for some reason you have a ton
of code you have to change now, you can write a PHP script which uses
regular expressions to find the double quotes to replace, write out the new
files and cycle through all your files.  It really wouldn't be that hard,
but I still suspect that the double quotes would have been a problem in PHP3
too.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] mysql_fetch_array and row referencing under 4.0.4pl1

2001-02-12 Thread Scott Brown



>
> I'd be curious to see others' answers on this because I
> upgraded everything
> the other day (been at php4 for a while though) and I don't
> have a problem
> with the quotes.
>

I've probably just putzed something somewhere during the build  it's
been one of those days.

But the thing is it's consistant... if I quote my field names (single or
double) I get an error... if I dont, I get my result.

(see my response to Steve...)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] mysql_fetch_array and row referencing under 4.0.4pl1

2001-02-12 Thread Scott Brown



> Forgot to ask - does referencing an array with double quotes
> around the key work for arrays not associated with a MySQL
> result?  I doubt it's specific to MySQL result arrays, but
> it doesn't hurt to check.  Make a small array and test.

I grabbed an example of of php.net dealing with just arrays and it works ...

Here's what I'm seeing - THIS WORKS:



mysqltest


\n";
$rslt = mysql_query("select * from pricing");
while ( $row = mysql_fetch_array($rslt) )
{
echo "\n";
echo "$row[ID]";
echo "$row[ProdCode]";
echo "$row[Price_effdate]";
echo "$row[ProdSetup]";
echo "$row[ProdMonthly]";
echo "$row[5]";
echo "\n";
}
echo "\n";
?>




But put any one of these $row[...] with quotes around their fieldnames and I
get:

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or
`T_NUM_STRING' in /home/testnexus/public_html/test.php on line 16

(when line 16 =
echo "$row["ID"]";
)


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mysql_fetch_array and row referencing under 4.0.4pl1

2001-02-12 Thread Steve Werby

"Scott Brown" <[EMAIL PROTECTED]> wrote:
> $row["this_is_a_field_name"]
>
> Seems simple, right?
>
> Well - I compiled a new copy of Apache 1.3.17, pushed PHP up to 4.0.4pl1,
> and upgraded mysql to the new stable version at the same time...
>
> Now the above code doesnt work.  But if I do a:

Forgot to ask - does referencing an array with double quotes around the key
work for arrays not associated with a MySQL result?  I doubt it's specific
to MySQL result arrays, but it doesn't hurt to check.  Make a small array
and test.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mysql_fetch_array and row referencing under 4.0.4pl1

2001-02-12 Thread Steve Werby

"Scott Brown" <[EMAIL PROTECTED]> wrote:
> I have code which runs under PHP3.0.15, and PHP4.0.2 which references the
> result of a
> $row["this_is_a_field_name"]
>
> Well - I compiled a new copy of Apache 1.3.17, pushed PHP up to 4.0.4pl1,
> and upgraded mysql to the new stable version at the same time...
>
> Now the above code doesnt work.  But if I do a:

What error messages do you get?  Add this to beginning of your code and you
might get more error output that will help diagnose.



> $row[this_is_a_field_name]
>
> Then the code does work.

Odd.  I've noticed the non-quoted versions causing PHP to choke if
error_reporting() is set high enough.  I've never know the opposite to be
true.

> Have I messed up something in the PHP configuration that doesnt allow
these
> quoted identifiers anymore?
>
> Or is this just a new (less-than-compatible) upgrade to PHP that I've
missed
> reading about??

It could be a configuration option or a php.ini setting.  Create a page with
 in it and post your configuration options to the list.

--
Steve Werby
COO
24-7 Computer Services, LLC
Tel: 804.817.2470
http://www.247computing.com/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mysql_fetch_array and row referencing under 4.0.4pl1

2001-02-12 Thread Thomas Deliduka

I'd be curious to see others' answers on this because I upgraded everything
the other day (been at php4 for a while though) and I don't have a problem
with the quotes.

On 2/12/01 11:11 PM this was written:

> Have I lost something somewhere?
> 
> I have code which runs under PHP3.0.15, and PHP4.0.2 which references the
> result of a
> 
> $row = mysql_fetch_array($result_of_query);
> 
> by doing things like:
> 
> $row["this_is_a_field_name"]
> 
> Seems simple, right?
> 
> Well - I compiled a new copy of Apache 1.3.17, pushed PHP up to 4.0.4pl1,
> and upgraded mysql to the new stable version at the same time...
> 
> Now the above code doesnt work.  But if I do a:
> 
> $row[this_is_a_field_name]
> 
> Then the code does work.
> 
> Have I messed up something in the PHP configuration that doesnt allow these
> quoted identifiers anymore?
> 
> Or is this just a new (less-than-compatible) upgrade to PHP that I've missed
> reading about??
> 
> Heelp me ... I dont want to have to rebuild all my sites
> just because of these stupid quotes
> 

-- 

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]