Jump to content

Code Help on a Form


Hartley

Recommended Posts

I have a form that is included within a template. This form calls to a mysql database that has 9 different rows filled with different application requirements. However, when the page runs, it just stops altogether. I can't find where I may have messed up. This is a private form that administrators update on the website for various positions.

 

<form name="recruitedit" action="index.php?p=recruitcommit" method="post">

<?php

$dbhost = 'xxxxx';
$dbuser = 'xxxxx';
$dbpass = 'xxxxx';
$dbname = 'xxxxx';

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db($dbname);

$query = "SELECT * FROM wow";
$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))
{
// Define Variables
$class = "{$row['class']";
$vacancy = "{$row['need']}";
$posted = "{$row['posted']}";
$position = "{$row['position']}";
$functions = "{$row['functions']}";
$qualifications = "{$row['qualifications']}";

    echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"750\">
<tr><td class=\"app-$class\"><img src=\"images/site/clear.gif\" width=\"1\" height=\"1\" border=\"0\" alt=\"Spacer\" /></td></tr>
<tr><td class=\"app-body\">

<b><i>Last Updated: $posted.</i></b><br /><br />

<b>Total Vacancies</b><br />
<input name=\"$class-vacancies\" size=\"1\" type=\"text\" value=\"$vacancy\"><br /><br />

<b>General Position Description</b><br />
<textarea cols=\"78\" name=\"$class-position\" value=\"$position\" rows=\"4\"><br /><br />

<b>Essential Functions of Position</b><br />
<textarea cols=\"78\" name=\"$class-functions\" value=\"$functions\" rows=\"4\"><br /><br />

<b>Preferred Qualifications</b><br />
<textarea cols=\"78\" name=\"$class-qualifications\" value=\"$qualifications\" rows=\"4\">


</td></tr>
<tr><td class=\"app-body\" style=\"border-top: 0px\" colspan=\"3\"><input name=\"commit\" type=\"submit\" value=\"Commit Changes\"></td></tr>
<tr><td class=\"app-foot\"><img src=\"images/site/clear.gif\" width=\"1\" height=\"1\" border=\"0\" alt=\"Spacer\" /></td></tr></table>

<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">
  <tr>
  <td height=\"5\"><img src=\"images/site/clear.gif\" width=\"1\" height=\"1\" border=\"0\" alt=\"Spacer\" /></td>
  </tr>
</table>";

}

mysql_close($conn);

?>

</form>

 

Thanks in advance! For some reason the code block is ignoring the very first backslash. It's there, just not showing up.

Link to comment
https://forums.phpfreaks.com/topic/57386-code-help-on-a-form/
Share on other sites

For debugging purposes, flip 'DISPLAY_ERRORS' on

 

change ' .... $result = mysql_query($query); ..... ' to ' .... $result = mysql_query($query) OR die(mysql_error()); ....'

 

change '..... $class = "{$row['class']"; ....' to '.... $class = "$row['class']"; ....'  (this declaration wouldn't be valid because it is missing the closing "}" brace)

 

Also, remove all the curly braces " { } " from your variable declarations (starting right below //DEFINE VARIABLES)

 

 

Link to comment
https://forums.phpfreaks.com/topic/57386-code-help-on-a-form/#findComment-283905
Share on other sites

^^ Dont follow that advice.

The problem is with this

cho "<table cellpadding="0\" 

The " hasnt been escaped.

 

The original poster said that the escape is there and that the forum wasn't letting it show up ...

 

"Thanks in advance! For some reason the code block is ignoring the very first backslash. It's there, just not showing up."

 

(its at the very bottom of the first post)

 

:)

Link to comment
https://forums.phpfreaks.com/topic/57386-code-help-on-a-form/#findComment-283909
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.