Jump to content

edit field problem


steve012345

Recommended Posts

I currently have a page interacting with a questions database for a questionnaire site.

 

I can add questions fine but the edit questions part is giving me the error within the code and not updating the question table. here is the code,

 

 

<?

  if(isset($_POST['Submit']))

  {

 

  $question=$_POST['txtquestion'];

 

  if($_GET['editid']!="")

{

$sql="update question set question=$question where questionid=".$_GET['editid'];

 

}

else

{

$sql="insert into question(question) values ('$question')";

}

$res=mysql_query($sql,$link);

if($res)

{

echo "<script>alert('Successfully Added!');</script>";

echo "<meta http-equiv='refresh' content='0;url=managequestion.php'>";

exit();

}

else

{

echo "Question not Added/Updated";

}

 

  }

?>

 

please help!

Link to comment
https://forums.phpfreaks.com/topic/108412-edit-field-problem/
Share on other sites

What error(s) are you getting? Is it the Question not Added/Updated message?

 

If so there is more than likely a problem with your query change:

$res=mysql_query($sql,$link);

to:

$res=mysql_query($sql,$link) or die('MySQL Query Error!<br />Query: <tt>' . $sql . '</tt><br >Error: ' . mysql_error());

If there is a problem within your sql query then an error will be displayed.

Link to comment
https://forums.phpfreaks.com/topic/108412-edit-field-problem/#findComment-555781
Share on other sites

yes the error is

 

MySQL Query Error!

Query: update question set question=The aims of the unit were clearxcvcx where =1

Error: 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 'aims of the unit were clearxcvcx where =1' at line 1

Link to comment
https://forums.phpfreaks.com/topic/108412-edit-field-problem/#findComment-555806
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.