Page 1 of 1

Inserting php code within php code

Posted: Wed Jul 19, 2006 4:24 pm
by croniccoder
I am getting a parse error from the code snippet below:

Code: Select all

<?php
   if ($job_row['updatepostdate'] != NULL)
   {
         print "<td class="tdForm"><?php echo($job_row['updatepostdate'])?></td>";
   }
   else
   {
        print "<td class="tdForm"><?php echo($job_row['posted'])?></td>";
   }
?>
Specifically, in <?php echo($job_row['updatepostdate'])?>

What would be the correct way to insert php inside of php?[/b]

Posted: Wed Jul 19, 2006 4:28 pm
by RobertGonzalez
You need to escape your quotes and not try to use PHP inside of other PHP. Change this...

Code: Select all

print "<td class="tdForm"><?php echo($job_row['updatepostdate'])?></td>";
To this

Code: Select all

print '<td class="tdForm">' . $job_row['updatepostdate'] . '</td>';

Posted: Wed Jul 19, 2006 4:34 pm
by croniccoder
Fantastic Everah!

Thanks for the help! :D