Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php il else

Status
Not open for further replies.

999000333

Programmer
Nov 20, 2006
39
Hello
I have a php file and in it I just added this piece of code to print an image if DocNum(document's number) is set else print another image:


<td>
<?php if (!( $row_Elenco['DocNum'])){
<IMG SRC="../myred.jpg" ALT="Ricerca"> } else {<IMG SRC="../greenp.jpg" ALT="Ricerca"> } ?>
</td>

Now when I run it I get this error "Parse error: parse error, unexpected '<' in Box/myFile"

Can anyone tell me what is wrong?
Thank you
Paola
 
You can just output HTML like that you either need to use print or echo.

Code:
<?php 
if  (!( $row_Elenco['DocNum'])){
  [blue]echo[/blue][red] "<IMG SRC='../myred.jpg' ALT='Ricerca'>";[/red] 
} else {
  [blue]echo[/blue][red]"<IMG SRC='../greenp.jpg'  ALT='Ricerca'>";[/red] 
}  
?>


Also try using indentation. its hard to read code thats all in one line.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Thanks vacunita.... by using the echo it works fine..

Thank you soooo much
Paola
 
You are welcome. Glad I could help.

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
999000333,

I think it would be worth you working through a PHP tutorial such as to understand the basics of PHP.

Clive
Runner_1Revised.gif

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer." (Paul Ehrlich)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top