Page 1 of 1

function

Posted: Fri Dec 29, 2006 5:49 am
by hrubos
how have I donw wrong???
so I received this message "Fatal error: Call to undefined function top_title() in D:\htdocs\BP\temp\function_temp.php on line 4"
function.php

Code: Select all

<?php
function top_title() {
echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">';
           echo '<tr>';
                echo '<td height="26" align="left" valign="top">&nbsp;</td>';
              echo '</tr>';
          echo '<tr>';
            echo '<td width="168" align="left" valign="top"> ';
            echo '</td>';
             echo '<td align="left" valign="top"><table width="573" border="0" cellspacing="0" cellpadding="0">';
              echo '<tr>';
                echo '<td height="26" align="left" valign="top">&nbsp;</td>';
              echo '</tr>';
              echo '<tr>';
                echo '<td align="center" valign="middle" bgcolor="#B97429" style="font-size:10px; color:#FFF;">&nbsp;</td>';
                echo '</tr>';
              echo '<tr>';
                echo '<td align="left" valign="top">&nbsp;</td>';
              echo '</tr>';
              echo '<tr>';
                echo '<td align="left" valign="top" style="text-align:justify;">';

}

function bottom_title() {
         echo   '</td>';
              echo '</tr>';
              
              echo '<tr>';
                echo '<td align="left" valign="top">';
                
                echo '</td>';
              echo '</tr>';
            echo '</table></td>';
          echo '</tr>';
        echo '</table>';

}
?>
funtion_temp.php

Code: Select all

<?php
include ("header_page.php");
include ("menu_index.php");
top_title();
include ("../autorizace/registrace_display.php");
bottom_title();
?>

Posted: Fri Dec 29, 2006 5:56 am
by Corvin
You have to include function.php.

Posted: Fri Dec 29, 2006 6:09 am
by hrubos
Corvin wrote:You have to include function.php.
yeah, thank

and so too can use require

Posted: Fri Dec 29, 2006 6:14 am
by volka
hrubos wrote:and so too can use require
Yes, and if your script will unconditionally fail with a fatal error if the file cannot be included I'd rather use require than include

Posted: Fri Dec 29, 2006 8:40 am
by Ollie Saunders
top_title can be written as

Code: Select all

function top_title() {
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">';
   <tr>
        <td height="26" align="left" valign="top">&nbsp;</td>
    etc....
<?php
}
Which saves on all that echoing and quoting. If you need to use php in the middle just open the tag <?php and close it again ?> when you're done.

Posted: Fri Dec 29, 2006 11:16 am
by hrubos
so html can be wrtitten in function?Really I don't know it

and I have a question about CSS, when I require so css doesn't run.
I have written a page student_page.php, and I use aplication CSS here, but when I try only student_page.php, it's ok, but when I require, so only there is HTML.

I don't know where are errors???


Code: Select all

else if($isAdmin =='2' ) {
              //  echo "<a href='../temp/student_page.php'>Rezervace </a>";
          //    include ('../temp/header_page.php');
          //echo "hello you here";

        
               include ("../temp/student_menu.php");
               top_title();
               bottom_title(); 

              
             //echo "<p>		<a href='../temp/student.php'> </a> </p>";
                $_SESSION['valid_user']=$login;      
                 return $return_array;
                }         
 }