Jump to content

POST with form


smsulliva

Recommended Posts

Can someone tell me what is wrong with this?

<?
//if ($_POST['update'] == "help")
//echo "Thank you! Information updated.";
//} 

if ($_POST['update'] == "help")
   {
   
      $name = $_POST["name"];
  $category = $_POST["category"];
      $entry = $_POST["entry"];
      $related_entries = $_POST["related_entries]";
      $required_level = $_POST["required_level"];
      $changed_by = $_POST["related_entries"]; // Need to change
      $last_changed = $_POST["related_entries"]; // Need to change

      $sql = "UPDATE helpfiles SET category='$category',entry='$entry', related_entries='$related_entries', required_level='$required_level',changed_by='$changed_by', last_changed='$last_changed', WHERE name=$name";

      $result = mysql_query($sql);
      echo "Thank you! Information updated.";
   }
?>

 

The variables on the form input types are being filled out correctly elsewhere in the code.

<form name="form_Add_rating" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="hidden"  name="update" value="help">
<table align='center' width='95%'>
<tbody>
<tr>
<td class="tableBar" colspan="2"> </td>
</tr>
<tr>
<td><label for="name">Name</label></td>
<td><input name="name" readonly="true" value="<?php echo $item ?>"  size="25" type="text" style="background-color:#EFEFEF"> You  cannot edit this field.</td>
</tr>
<tr>
<td><label for="category">Category</label></td>
<td><input name="category" value="<?php echo $helpArr['category'] ?>"  size="25" type="text"></td>
</tr>
<tr>
<td><label for="entry">Description</label></td>
<td><textarea name="entry" cols="73" rows="10" value="<?php echo parse_string($helpArr['entry']) ?>" ><?php echo parse_string($helpArr['entry']) ?></textarea>
</tr>
<tr>
<td><label for="related_entries">Related Entries</label></td>
<td><input name="related_entries" value="<?php echo parse_string($helpArr['related_entries']) ?>" size="68" type="text"></td>
</tr>
<tr>
<td><label for="required_level">Required Level</label></td>
<td><input name="required_level" value="<?php echo parse_string($helpArr['required_level']) ?>" maxlength="1" size="25" type="text"></td>
</tr>
<tr>
<td><label for="changed_by">Changed By</label></td>
<td><input name="changed_by" readonly="true" value="{USERNAME}" size="25" type="text" style="background-color:#EFEFEF"> You cannot edit this field.</td>
<!--
<td><input name="changed_by" readonly="true" value="<?php echo parse_string($helpArr['changed_by']) ?>" size="25" type="text" style="background-color:#EFEFEF"> You cannot edit this field.</td>
-->
</tr>
<tr>
<td><label for="last_changed">Last Changed</label></td>
<td><input name="last_changed" readonly="true"  value="<?php echo $t_date ?>" size="25" type="text" style="background-color:#EFEFEF"> You cannot edit this field.</td>
<!--
<td><label for="last_changed">Last Changed</label></td>
<td><input name="last_changed" readonly="true" value="<?php echo parse_string($helpArr['last_changed']) ?>" size="25" type="text" style="background-color:#EFEFEF"> You cannot edit this field.</td>
-->
</tr>
<tr>
<td align="center" colspan="2"><input value="Update" type="submit"> <input name="reset" value="Reset" type="reset"> <input type="button" value="Cancel" onclick="javascript:hideBlock('editform')"></td>
<!--
<td align='center' colspan='2'><input name='submit' value='Edit ".$item."' type='submit'> <input name='reset' value='Reset' type='reset'> <input type='button' value='Cancel' onClick='javascript:hideBlock(\"editform\")'><input type='hidden' name='cmd' value='edit'></td>
-->
</tr>
</tbody>
</table>
</form>

Link to comment
Share on other sites

I figure out why is wasn't posting but I am now getting a syntax error here.

Can anybody see what I am doing wrong.


      $sql = "UPDATE helpfiles SET category='$category',entry='$entry', related_entries='$related_entries', required_level='$required_level',changed_by='$changed_by', last_changed='$last_changed', WHERE name = '".$name."'";

 

I get this error

mysql_query(): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE name = 'Building_credit''

Link to comment
Share on other sites

$sql = "UPDATE helpfiles SET category='$category',entry='$entry', related_entries='$related_entries', required_level='$required_level',changed_by='$changed_by', last_changed='$last_changed', WHERE name = '".$name."'";

 

im guessing it was the , before the where part of the sql statement.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.