Member Avatar for dami06

Hi,
does anyone know of a good php validator online. I used one called bermi.org and put my code in and gave me an error but i don't know what line the error is occuring. Perhaps someone could help me out.

This is the code
tutors.php

<?php /** * * INDEX - Tutor index * * */ require_once("../include/inc_global.php"); require_once(DOC__ROOT . "lang/en/generic.php"); require_once(DOC__ROOT . "lang/en/tutors/tutors.php"); check_user($_user, 'staff'); sadfasdfrasdf // -------------------------------------------------------------------------------- // Begin Page $UI->page_title = APP__NAME; $UI->menu_selected = 'home'; $UI->breadcrumbs = array ( 'home' => null , ); $UI->head(); $UI->body(); $UI->content_start(); echo '<p>' . WELCOME . '</p>'; echo '<p>' . SECTIONS__INTRO . '</p>'; ?> <table class="option_list" style="width: 500px;"> <tr> <td><a href="forms/"><img src="../images/icons/form.gif" width="32" height="32" alt="<?php echo MY__FORMS; ?>" /></a></td> <td> <div class="option_list"> <div class="option_list_title"><a class="hidden" href="forms/"><?php echo MY__FORMS; ?></a></div> <p><?php echo OPT__FORMS__DESC; ?></p> </div> </td> </tr> <tr> <td><a href="groups/"><img src="../images/icons/groups.gif" width="32" height="32" alt="<?php echo MY__GROUPS; ?>" /></a></td> <td> <div class="option_list"> <div class="option_list_title"><a class="hidden" href="groups/"><?php echo MY__GROUPS; ?></a></div> <p><?php echo OPT__GROUPS__DESC; ?></p> </div> </td> </tr> <tr> <td><a href="assessments/"><img src="../images/icons/assessments.gif" width="32" height="32" alt="<?php echo MY__ASSESSMENTS; ?>" /></a></td> <td> <div class="option_list"> <div class="option_list_title"><a class="hidden" href="assessments/"><?php echo MY__ASSESSMENTS; ?></a></div> <p><?php echo OPT__ASSESSMENTS__DESC ?></p> </div> </td> </tr> </table> <h2><?php echo GETTING__STARTED__TITLE ; ?></h2> <p><?php echo GETTING__STARTED__DESC ; ?></p> <?php $UI->content_end();?>

This is the error it produced

Ooops! There are some errors on the XHTML page

* XHTML is not well-formed. not well-formed (invalid token) on line 39

Showing XHTML code
page_title = APP__NAME; $UI->menu_selected = 'home'; $UI->breadcrumbs = array ( 'home' => null , ); $UI->head(); $UI->body(); $UI->content_start(); echo '

' . WELCOME . '
'; echo '

' . SECTIONS__INTRO . '
'; ?>
<?php echo MY__FORMS; ?>

<?php echo MY__GROUPS; ?>

<?php echo MY__ASSESSMENTS; ?>

content_end();?>

Member Avatar for ShawnCplus

You want to validate PHP or validate the page that is generated? You can validate PHP by running the script, if it runs it's valid :)

If you want to validate the page generated then use http://validator.w3.org/

Member Avatar for TopDogger

You can also turn on the error message. It does a good job of pinpointing most errors. Place it at the top of your script, just after the first opening PHP tag '<?php'

Do not leave this turned on for a live site. It may give too much information to hackers.

To turn on error messages:

error_reporting(E_ALL);

To turn off error messages:

error_reporting(0);

Member Avatar for dami06

You can also turn on the error message. It does a good job of pinpointing most errors. Place it at the top of your script, just after the first opening PHP tag '<?php'

Do not leave this turned on for a live site. It may give too much information to hackers.

To turn on error messages:

error_reporting(E_ALL);

To turn off error messages:

error_reporting(0);

How do i know how to get the error message as i have put the error_reporting(E_ALL); after the first opening PHP tag like this

<?php error_reporting(E_ALL); /** * * Edit Form * * * @copyright 2007 Loughborough University * @license http://www.gnu.org/licenses/gpl.txt * @version 1.0.0.0 * */ require_once("../../../include/inc_global.php"); require_once(DOC__ROOT. '/include/classes/class_form.php'); check_user($_user, 'staff'); // -------------------------------------------------------------------------------- // Process GET/POST $form_id = fetch_GET('f'); $command = fetch_POST('command'); // -------------------------------------------------------------------------------- $form =& new Form($DB); if ($form->load($form_id)) { $form_qs = "f={$form->id}"; } else { $form = null; } // -------------------------------------------------------------------------------- // Process Form $errors = null; if ( ($command) && ($form) ) { switch ($command) { case 'save': // Change of name $form->name = fetch_POST('form_name'); if (empty($form->name)) { $errors[] = 'You must give this form a name.'; } // If there were no errors, save the changes if (!$errors) { $form->save(); } break; // -------------------- case 'delete': $form->delete(); header('Location: '. APP__WWW .'/tutors/forms/index.php'); break; // -------------------- }// /switch } // -------------------------------------------------------------------------------- // Begin Page $page_title = ($form) ? "Edit form: {$form->name}" : 'Edit form'; $UI->page_title = APP__NAME . ' ' . $page_title; $UI->menu_selected = 'my forms'; $UI->breadcrumbs = array( 'home' => '../../' , 'my forms' => '../' , $page_title => null , ); $UI->set_page_bar_button('List Forms', '../../../../images/buttons/button_form_list.gif', '../'); $UI->set_page_bar_button('Create Form', '../../../../images/buttons/button_form_create.gif', '../create/'); $UI->set_page_bar_button('Clone a Form', '../../../../images/buttons/button_form_clone.gif', '../clone/'); $UI->head(); ?> <script language="JavaScript" type="text/javascript"> <!-- function do_command(com) { switch (com) { case 'delete' : if (confirm('This assessment form will be deleted.\n\nClick OK to confirm.')) { document.assessmentform_form.command.value = 'delete'; document.assessmentform_form.submit(); } break; case 'preview' : var popupwin; popupwin = window.open('preview_form.php?f=<?php echo($form->id); ?>','preview'); popupwin.focus(); break; default : document.assessmentform_form.command.value = com; document.assessmentform_form.submit(); } }// /do_command() //--> </script> <?php $UI->content_start(); $UI->draw_boxed_list($errors, 'error_box', 'The following errors were found:', 'No changes have been saved. Please check the details in the form, and try again.'); ?> <p>On this page you can change the name of this form, and add/remove assessment criteria.</p> <div class="content_box"> <?php if (!$form) { ?> <div class="nav_button_bar"> <a href="../"><img src="../../../images/buttons/arrow_green_left.gif" alt="back -"> back to forms list</a> </div> <p>The form you selected could not be loaded for some reason - please go back and try again.</p> <?php } else { ?> <form action="edit_form.php?<?php echo($form_qs); ?>" method="post" name="assessmentform_form"> <input type="hidden" name="command" value="none" /> <div class="nav_button_bar"> <table cellpadding="0" cellspacing="0" width="100%"> <tr> <td><a href="../"><img src="../../../images/buttons/arrow_green_left.gif" alt="back -"> back to forms list</a></td> <td align="right"><input class="warning_button" type="button" name="" value="preview form" onclick="do_command('preview');" /></td> <td align="right"><input class="danger_button" type="button" name="" value="delete form" onclick="do_command('delete');" /></td> </tr> </table> </div> <h2>Form Name</h2> <div class="form_section form_line"> <p>You can change this form's name using the box below. When you've made your changes, click the <em>save changes</em> button.</p> <table class="form" cellpadding="2" cellspacing="2"> <tr> <th><label for="form_name">Name</label></th> <td><input type="text" name="form_name" id="form_name" maxlength="100" size="40" value="<?php echo($form->name)?>" /></td> <td><input type="button" name="savebutton1" id="savebutton1" value="save changes" onclick="do_command('save');" /></td> </tr> </table> </div> <h2>Assessment Criteria</h2><a name="questions"></a> <div class="form_section"> <?php $question_count = (int) $form->get_question_count(); if ($question_count==0) { ?> <p>You have not added any assessment criteria to this form yet. You need to <a class="button" href="../edit/add_question/index.php?<?php echo($form_qs); ?>">add&nbsp;a&nbsp;new&nbsp;criterion</a> before the form can be used.</p> <?php } else { ?> <p>The group will rate themselves and each other against the assessment criteria you specify.</p> <p>e.g. <em>"Ability to communicate"</em> or <em>"Contribution to the analysis of the experimental data"</em>.</p> <p>You can edit a criterion by clicking on the <img src="../../../images/buttons/edit.gif" width="16" height="16" alt="edit question" title="edit" /> button, or you can <a class="button" href="../edit/add_question/index.php?<?php echo($form_qs); ?>">add&nbsp;a&nbsp;new&nbsp;criterion</a></p> <div class="obj_list"> <?php for($i=0; $i<$question_count; $i++) { $question_qs = "{$form_qs}&q=$i"; $question = $form->get_question($i); $edit_url = "edit_question/index.php?$question_qs"; ?> <div class="obj"> <table class="obj" cellpadding="0" cellspacing="0"> <tr> <td class="obj_info" valign="top"> <div class="obj_name"><a class="text" href="<?php echo($edit_url); ?>"><?php echo($question['text']['_data']); ?></a></div> <?php if (array_key_exists('desc', $question)) { $question_desc = (array_key_exists('desc', $question)) ? $question['desc']['_data'] : '' ; echo("<div class=\"obj_info_text\">$question_desc</div>"); } ?> <div class="obj_info_text">Scoring range: <?php echo($question['range']['_data']); ?></div> <?php foreach($question as $k => $v) { if (strpos($k,'scorelabel')===0) { $num = str_replace('scorelabel','',$k); echo("<div class=\"obj_info_text\">Score $num : {$v['_data']}</div>"); } } ?> </td> <td class="button"><a href="<?php echo($edit_url); ?>"><img src="../../../images/buttons/edit.gif" width="16" height="16" alt="edit question" title="edit" /></a></td> <td class="button" width="20"> <?php if ($i>0) { echo("<a href=\"question_action.php?{$question_qs}&a=up\"><img src=\"../../../images/buttons/arrow_green_up.gif\" width=\"16\" height=\"16\" alt=\"move up\" title=\"move up\" /></a>"); } else { echo('&nbsp;'); } ?> </td> <td class="button" width="20"> <?php if ($i<($question_count-1)) { echo("<a href=\"question_action.php?{$question_qs}&a=down\"><img src=\"../../../images/buttons/arrow_green_down.gif\" width=\"16\" height=\"16\" alt=\"move down\" title=\"move down\" /></a>"); } else { echo('&nbsp;'); } ?> </td> <td class="button" width="20"><a href="question_action.php?<?php echo($question_qs); ?>&a=delete"><img src="../../../images/buttons/cross.gif" width="16" height="16" alt="delete" title="delete" /></a></td> </tr> </table> </div> <?php } ?> </div> <?php } ?> </div> </form> <?php } ?> </div> <?php $UI->content_end(); ?>

But when i type in the localhost/webpaos/tutors/....edit_form.php
nothing happens...

Member Avatar for Mganda

Hi,
does anyone know of a good php validator online. I used one called bermi.org and put my code in and gave me an error but i don't know what line the error is occuring. Perhaps someone could help me out.

This is the code
tutors.php

<?php /** * * INDEX - Tutor index * * */ require_once("../include/inc_global.php"); require_once(DOC__ROOT . "lang/en/generic.php"); require_once(DOC__ROOT . "lang/en/tutors/tutors.php"); check_user($_user, 'staff'); sadfasdfrasdf // -------------------------------------------------------------------------------- // Begin Page $UI->page_title = APP__NAME; $UI->menu_selected = 'home'; $UI->breadcrumbs = array ( 'home' => null , ); $UI->head(); $UI->body(); $UI->content_start(); echo '<p>' . WELCOME . '</p>'; echo '<p>' . SECTIONS__INTRO . '</p>'; ?> <table class="option_list" style="width: 500px;"> <tr> <td><a href="forms/"><img src="../images/icons/form.gif" width="32" height="32" alt="<?php echo MY__FORMS; ?>" /></a></td> <td> <div class="option_list"> <div class="option_list_title"><a class="hidden" href="forms/"><?php echo MY__FORMS; ?></a></div> <p><?php echo OPT__FORMS__DESC; ?></p> </div> </td> </tr> <tr> <td><a href="groups/"><img src="../images/icons/groups.gif" width="32" height="32" alt="<?php echo MY__GROUPS; ?>" /></a></td> <td> <div class="option_list"> <div class="option_list_title"><a class="hidden" href="groups/"><?php echo MY__GROUPS; ?></a></div> <p><?php echo OPT__GROUPS__DESC; ?></p> </div> </td> </tr> <tr> <td><a href="assessments/"><img src="../images/icons/assessments.gif" width="32" height="32" alt="<?php echo MY__ASSESSMENTS; ?>" /></a></td> <td> <div class="option_list"> <div class="option_list_title"><a class="hidden" href="assessments/"><?php echo MY__ASSESSMENTS; ?></a></div> <p><?php echo OPT__ASSESSMENTS__DESC ?></p> </div> </td> </tr> </table> <h2><?php echo GETTING__STARTED__TITLE ; ?></h2> <p><?php echo GETTING__STARTED__DESC ; ?></p> <?php $UI->content_end();?>

This is the error it produced

Ooops! There are some errors on the XHTML page

* XHTML is not well-formed. not well-formed (invalid token) on line 39

Showing XHTML code
page_title = APP__NAME; $UI->menu_selected = 'home'; $UI->breadcrumbs = array ( 'home' => null , ); $UI->head(); $UI->body(); $UI->content_start(); echo '

' . WELCOME . '
'; echo '

' . SECTIONS__INTRO . '
'; ?>
<?php echo MY__FORMS; ?>

<?php echo MY__GROUPS; ?>

<?php echo MY__ASSESSMENTS; ?>

content_end();?>

MGANDA

Member Avatar for almostbob

ran a page consisting of <?php phpinfo(); ?> and got error messages, ran it again and got "This page is Valid XHTML" ran it 3rd time and got error messages
suggest the w3c validator http://validator.w3.org/ which gives location of errors at least

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.