User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 422,664 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,654 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 709 | Replies: 3
Reply
Join Date: Oct 2006
Posts: 88
Reputation: dami06 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dami06 dami06 is offline Offline
Junior Poster in Training

php validator

  #1  
Feb 6th, 2008
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
  1. <?php
  2. /**
  3.  *
  4.  * INDEX - Tutor index
  5.  *
  6.  *
  7.  */
  8.  
  9. require_once("../include/inc_global.php");
  10. require_once(DOC__ROOT . "lang/en/generic.php");
  11. require_once(DOC__ROOT . "lang/en/tutors/tutors.php");
  12.  
  13. check_user($_user, 'staff');
  14.  
  15. sadfasdfrasdf
  16. // --------------------------------------------------------------------------------
  17. // Begin Page
  18.  
  19. $UI->page_title = APP__NAME;
  20. $UI->menu_selected = 'home';
  21. $UI->breadcrumbs = array (
  22. 'home' => null ,
  23. );
  24. $UI->head();
  25. $UI->body();
  26.  
  27. $UI->content_start();
  28. echo '<p>' . WELCOME . '</p>';
  29. echo '<p>' . SECTIONS__INTRO . '</p>';
  30. ?>
  31.  
  32. <table class="option_list" style="width: 500px;">
  33. <tr>
  34. <td><a href="forms/"><img src="../images/icons/form.gif" width="32" height="32" alt="<?php echo MY__FORMS; ?>" /></a></td>
  35. <td>
  36. <div class="option_list">
  37. <div class="option_list_title"><a class="hidden" href="forms/"><?php echo MY__FORMS; ?></a></div>
  38. <p><?php echo OPT__FORMS__DESC; ?></p>
  39. </div>
  40. </td>
  41. </tr>
  42. <tr>
  43. <td><a href="groups/"><img src="../images/icons/groups.gif" width="32" height="32" alt="<?php echo MY__GROUPS; ?>" /></a></td>
  44. <td>
  45. <div class="option_list">
  46. <div class="option_list_title"><a class="hidden" href="groups/"><?php echo MY__GROUPS; ?></a></div>
  47. <p><?php echo OPT__GROUPS__DESC; ?></p>
  48. </div>
  49. </td>
  50. </tr>
  51. <tr>
  52. <td><a href="assessments/"><img src="../images/icons/assessments.gif" width="32" height="32" alt="<?php echo MY__ASSESSMENTS; ?>" /></a></td>
  53. <td>
  54. <div class="option_list">
  55. <div class="option_list_title"><a class="hidden" href="assessments/"><?php echo MY__ASSESSMENTS; ?></a></div>
  56. <p><?php echo OPT__ASSESSMENTS__DESC ?></p>
  57. </div>
  58. </td>
  59. </tr>
  60. </table>
  61.  
  62. <h2><?php echo GETTING__STARTED__TITLE ; ?></h2>
  63. <p><?php echo GETTING__STARTED__DESC ; ?></p>
  64.  
  65.  
  66. <?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();?>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: New York state
Posts: 464
Reputation: ShawnCplus will become famous soon enough ShawnCplus will become famous soon enough 
Rep Power: 5
Solved Threads: 72
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: php validator

  #2  
Feb 6th, 2008
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/
GCS d- s+:+ a-->? C++(++++) UL+++ P+>+++ L+++ !E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r z+*
Reply With Quote  
Join Date: Aug 2005
Location: somewhere in time
Posts: 71
Reputation: TopDogger is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 3
TopDogger's Avatar
TopDogger TopDogger is offline Offline
Junior Poster in Training

Re: php validator

  #3  
Feb 8th, 2008
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);
Reply With Quote  
Join Date: Oct 2006
Posts: 88
Reputation: dami06 is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
dami06 dami06 is offline Offline
Junior Poster in Training

Re: php validator

  #4  
Feb 9th, 2008
Originally Posted by TopDogger View Post
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

  1.  
  2. <?php
  3. error_reporting(E_ALL);
  4. /**
  5.  *
  6.  * Edit Form
  7.  *
  8.  *
  9.  * @copyright 2007 Loughborough University
  10.  * @license http://www.gnu.org/licenses/gpl.txt
  11.  * @version 1.0.0.0
  12.  *
  13.  */
  14. require_once("../../../include/inc_global.php");
  15. require_once(DOC__ROOT. '/include/classes/class_form.php');
  16.  
  17. check_user($_user, 'staff');
  18.  
  19. // --------------------------------------------------------------------------------
  20. // Process GET/POST
  21.  
  22. $form_id = fetch_GET('f');
  23.  
  24. $command = fetch_POST('command');
  25.  
  26. // --------------------------------------------------------------------------------
  27.  
  28.  
  29. $form =& new Form($DB);
  30. if ($form->load($form_id)) {
  31. $form_qs = "f={$form->id}";
  32. } else {
  33. $form = null;
  34. }
  35.  
  36.  
  37. // --------------------------------------------------------------------------------
  38. // Process Form
  39.  
  40. $errors = null;
  41.  
  42. if ( ($command) && ($form) ) {
  43. switch ($command) {
  44. case 'save':
  45. // Change of name
  46. $form->name = fetch_POST('form_name');
  47. if (empty($form->name)) { $errors[] = 'You must give this form a name.'; }
  48.  
  49.  
  50.  
  51. // If there were no errors, save the changes
  52. if (!$errors) {
  53. $form->save();
  54. }
  55. break;
  56. // --------------------
  57. case 'delete':
  58. $form->delete();
  59. header('Location: '. APP__WWW .'/tutors/forms/index.php');
  60. break;
  61. // --------------------
  62. }// /switch
  63. }
  64.  
  65.  
  66. // --------------------------------------------------------------------------------
  67. // Begin Page
  68.  
  69. $page_title = ($form) ? "Edit form: {$form->name}" : 'Edit form';
  70.  
  71.  
  72. $UI->page_title = APP__NAME . ' ' . $page_title;
  73. $UI->menu_selected = 'my forms';
  74. $UI->breadcrumbs = array(
  75. 'home' => '../../' ,
  76. 'my forms' => '../' ,
  77. $page_title => null ,
  78. );
  79.  
  80. $UI->set_page_bar_button('List Forms', '../../../../images/buttons/button_form_list.gif', '../');
  81. $UI->set_page_bar_button('Create Form', '../../../../images/buttons/button_form_create.gif', '../create/');
  82. $UI->set_page_bar_button('Clone a Form', '../../../../images/buttons/button_form_clone.gif', '../clone/');
  83.  
  84.  
  85. $UI->head();
  86. ?>
  87. <script language="JavaScript" type="text/javascript">
  88. <!--
  89.  
  90. function do_command(com) {
  91. switch (com) {
  92. case 'delete' :
  93. if (confirm('This assessment form will be deleted.\n\nClick OK to confirm.')) {
  94. document.assessmentform_form.command.value = 'delete';
  95. document.assessmentform_form.submit();
  96. }
  97. break;
  98. case 'preview' :
  99. var popupwin;
  100. popupwin = window.open('preview_form.php?f=<?php echo($form->id); ?>','preview');
  101. popupwin.focus();
  102. break;
  103. default :
  104. document.assessmentform_form.command.value = com;
  105. document.assessmentform_form.submit();
  106. }
  107. }// /do_command()
  108.  
  109. //-->
  110. </script>
  111. <?php
  112. $UI->content_start();
  113.  
  114. $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.');
  115.  
  116. ?>
  117.  
  118. <p>On this page you can change the name of this form, and add/remove assessment criteria.</p>
  119.  
  120. <div class="content_box">
  121.  
  122. <?php
  123. if (!$form) {
  124. ?>
  125. <div class="nav_button_bar">
  126. <a href="../"><img src="../../../images/buttons/arrow_green_left.gif" alt="back -"> back to forms list</a>
  127. </div>
  128.  
  129. <p>The form you selected could not be loaded for some reason - please go back and try again.</p>
  130. <?php
  131. } else {
  132. ?>
  133. <form action="edit_form.php?<?php echo($form_qs); ?>" method="post" name="assessmentform_form">
  134. <input type="hidden" name="command" value="none" />
  135.  
  136. <div class="nav_button_bar">
  137. <table cellpadding="0" cellspacing="0" width="100%">
  138. <tr>
  139. <td><a href="../"><img src="../../../images/buttons/arrow_green_left.gif" alt="back -"> back to forms list</a></td>
  140. <td align="right"><input class="warning_button" type="button" name="" value="preview form" onclick="do_command('preview');" /></td>
  141. <td align="right"><input class="danger_button" type="button" name="" value="delete form" onclick="do_command('delete');" /></td>
  142. </tr>
  143. </table>
  144. </div>
  145.  
  146. <h2>Form Name</h2>
  147. <div class="form_section form_line">
  148. <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>
  149. <table class="form" cellpadding="2" cellspacing="2">
  150. <tr>
  151. <th><label for="form_name">Name</label></th>
  152. <td><input type="text" name="form_name" id="form_name" maxlength="100" size="40" value="<?php echo($form->name)?>" /></td>
  153. <td><input type="button" name="savebutton1" id="savebutton1" value="save changes" onclick="do_command('save');" /></td>
  154. </tr>
  155. </table>
  156. </div>
  157.  
  158. <h2>Assessment Criteria</h2><a name="questions"></a>
  159. <div class="form_section">
  160. <?php
  161. $question_count = (int) $form->get_question_count();
  162. if ($question_count==0) {
  163. ?>
  164. <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>
  165. <?php
  166. } else {
  167. ?>
  168. <p>The group will rate themselves and each other against the assessment criteria you specify.</p>
  169. <p>e.g. <em>"Ability to communicate"</em> or <em>"Contribution to the analysis of the experimental data"</em>.</p>
  170. <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>
  171.  
  172. <div class="obj_list">
  173. <?php
  174. for($i=0; $i<$question_count; $i++) {
  175. $question_qs = "{$form_qs}&q=$i";
  176. $question = $form->get_question($i);
  177.  
  178. $edit_url = "edit_question/index.php?$question_qs";
  179. ?>
  180. <div class="obj">
  181. <table class="obj" cellpadding="0" cellspacing="0">
  182. <tr>
  183. <td class="obj_info" valign="top">
  184. <div class="obj_name"><a class="text" href="<?php echo($edit_url); ?>"><?php echo($question['text']['_data']); ?></a></div>
  185. <?php
  186. if (array_key_exists('desc', $question)) {
  187. $question_desc = (array_key_exists('desc', $question)) ? $question['desc']['_data'] : '' ;
  188. echo("<div class=\"obj_info_text\">$question_desc</div>");
  189. }
  190. ?>
  191. <div class="obj_info_text">Scoring range: <?php echo($question['range']['_data']); ?></div>
  192. <?php
  193. foreach($question as $k => $v) {
  194. if (strpos($k,'scorelabel')===0) {
  195. $num = str_replace('scorelabel','',$k);
  196. echo("<div class=\"obj_info_text\">Score $num : {$v['_data']}</div>");
  197. }
  198. }
  199. ?>
  200. </td>
  201.  
  202. <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>
  203.  
  204. <td class="button" width="20">
  205. <?php
  206. if ($i>0) {
  207. 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>");
  208. } else {
  209. echo('&nbsp;');
  210. }
  211. ?>
  212. </td>
  213.  
  214. <td class="button" width="20">
  215. <?php
  216. if ($i<($question_count-1)) {
  217. 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>");
  218. } else {
  219. echo('&nbsp;');
  220. }
  221. ?>
  222. </td>
  223.  
  224. <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>
  225. </tr>
  226. </table>
  227. </div>
  228. <?php
  229. }
  230. ?>
  231. </div>
  232. <?php
  233. }
  234. ?>
  235. </div>
  236.  
  237. </form>
  238. <?php
  239. }
  240. ?>
  241. </div>
  242.  
  243.  
  244. <?php
  245. $UI->content_end();
  246. ?>
  247.  
But when i type in the localhost/webpaos/tutors/....edit_form.php
nothing happens...
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 2 (0 members and 2 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 4:23 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC