Whats wrong with this code?

Whats wrong with this code?

am 11.04.2008 08:39:11 von Ronald Raygun

$cssfile = (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.cs s';
echo
"


This is a test

Hello world!


" ?>

It dosen't display generate the correct HTML for display in my browser

Re: Whats wrong with this code?

am 11.04.2008 08:44:29 von Floris

Ronald Raygun wrote:
> > $cssfile =
> (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.cs s';
> echo
> "
>
>
> This is a test
>
> Hello world!
>
>
> " ?>
>
> It dosen't display generate the correct HTML for display in my browser

The problem is .
You should escape your double-quotes like so: \".

Floris

Re: Whats wrong with this code?

am 11.04.2008 08:47:48 von Ronald Raygun

Floris wrote:

> Ronald Raygun wrote:
>
>> >> $cssfile =
>> (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.cs s';
>> echo
>> "
>>
>>
>> This is a test
>>
>> Hello world!
>>
>>
>> " ?>
>>
>> It dosen't display generate the correct HTML for display in my browser
>
>
> The problem is .
> You should escape your double-quotes like so: \".
>
> Floris

thanks Floris - I made the change, but the result is still:

Hello world! " ?>

In the browser - am I missing something?

Re: Whats wrong with this code?

am 11.04.2008 08:50:03 von Ronald Raygun

Ronald Raygun wrote:

>
>
> Floris wrote:
>
>> Ronald Raygun wrote:
>>
>>> >>> $cssfile =
>>> (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.cs s';
>>> echo
>>> "
>>>
>>>
>>> This is a test
>>>
>>> Hello world!
>>>
>>>
>>> " ?>
>>>
>>> It dosen't display generate the correct HTML for display in my browser
>>
>>
>>
>> The problem is .
>> You should escape your double-quotes like so: \".
>>
>> Floris
>
>
> thanks Floris - I made the change, but the result is still:
>
> Hello world! " ?>
>
> In the browser - am I missing something?



My corrected code (according to tip from Floris) is:

$cssfile = (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.cs s';
echo
"


This is a test

Hello world!

"
?>

Re: Whats wrong with this code?

am 11.04.2008 09:15:06 von Lars Eighner

In our last episode, <_o6dnQ3XA4bNl2LanZ2dnUVZ8tHinZ2d@bt.com>, the lovely
and talented Ronald Raygun broadcast on comp.lang.php:



> Ronald Raygun wrote:

>>
>>
>> Floris wrote:
>>
>>> Ronald Raygun wrote:
>>>
>>>> >>>> $cssfile =
>>>> (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.cs s';
>>>> echo
>>>> "
>>>>
>>>>
>>>> This is a test
>>>>
>>>> Hello world!
>>>>
>>>>
>>>> " ?>
>>>>
>>>> It dosen't display generate the correct HTML for display in my browser
>>>
>>>
>>>
>>> The problem is .
>>> You should escape your double-quotes like so: \".
>>>
>>> Floris
>>
>>
>> thanks Floris - I made the change, but the result is still:
>>
>> Hello world! " ?>
>>
>> In the browser - am I missing something?



> My corrected code (according to tip from Floris) is:

> > $cssfile = (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.cs s';
> echo
> "
>
>
> This is a test
>
> Hello world!
>
> "
> ?>

First your html is invalid. BODY can only contain block elements (fix by
placing Hello world! in a block element like P. Second, your HTML tag is
not correct for XHTML, but /> is used to close the (empty) LINK tag.

Your PHP problem is that you did not end the echo statement with ;,
but if you cannot write valid HTML for a document as simple as this, you
have more serious problems.


--
Lars Eighner usenet@larseighner.com
Countdown: 284 days to go.

Re: Whats wrong with this code?

am 11.04.2008 09:16:10 von alvaroNOSPAMTHANKS

Ronald Raygun escribió:
> thanks Floris - I made the change, but the result is still:
>
> Hello world! " ?>
>
> In the browser - am I missing something?

First of all, always check the actual output generated by PHP, not what
the browser renders. In Firefox go to View-> Page source

It seems that you haven't configured PHP to display errors. Edit your
php.ini file and set these directives:

display_errors = On
error_reporting = E_ALL

Re: Whats wrong with this code?

am 11.04.2008 09:20:57 von piotr

Ronald Raygun wrote:
> > $cssfile =
> (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.cs s';

You are missing closing square bracket: $_SERVER['HTTP_USER_AGENT']

besides that, it should work fine i think

best regards
Piotr

Re: Whats wrong with this code?

am 11.04.2008 09:32:56 von Ronald Raygun

Álvaro G. Vicario wrote:

> Ronald Raygun escribió:
>
>> thanks Floris - I made the change, but the result is still:
>>
>> Hello world! " ?>
>>
>> In the browser - am I missing something?
>
>
> First of all, always check the actual output generated by PHP, not what
> the browser renders. In Firefox go to View-> Page source
>
> It seems that you haven't configured PHP to display errors. Edit your
> php.ini file and set these directives:
>
> display_errors = On
> error_reporting = E_ALL


Álvaro, Piotr, thanks very much for your patience. I had made a number
of silly typing errors hich I have now fixed. The code works fine now.
Many thanks for your help

Re: Whats wrong with this code?

am 11.04.2008 14:46:46 von Jerry Stuckle

Ronald Raygun wrote:
> > $cssfile =
> (stristr($_SERVER['HTTP_USER_AGENT','msie'))?'ie.css':'ff.cs s';
> echo
> "
>
>
> This is a test
>
> Hello world!
>
>
> " ?>
>
> It dosen't display generate the correct HTML for display in my browser
>

And finally, please don't multipost. Crosspost instead.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================