Jump to content

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

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.