Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9193355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:08:32+00:00 2026-06-17T21:08:32+00:00

I have been working with code for hours and just cannot see where I

  • 0

I have been working with code for hours and just cannot see where I have an error. This is the offending code

$answercreatequery = pg_query("INSERT INTO answer (answerid, questionid, adescription, afilelocation, iscorrect) VALUES( default, '".$thisquestionid."', '".$adescription1."', '".$afilelocation."', '".$iscorrect1."' ");

And this is the error reported

Warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax
error at end of input LINE 1: …on, iscorrect) VALUES( default, ’37’,
‘kyfhdkj’, ‘none’, ” ^ in
/ceri/homes1/m/mtp4/public_html/mmp/Quizmaker/Clientside/questioncreatescript.php
on line 167

I am wondering if there is something simple I am missing? I have suspected it was because $iscorrect1 is type boolean and I have tried editing it in many ways but still I get the same kind of error.

/d answer table

Column     |          Type          |                         Modifiers                         
---------------+------------------------+-----------------------------------------------------------

 answerid      | integer                | not null default nextval('answer_answerid_seq'::regclass)
 questionid    | integer                | not null
 adescription  | character varying(200) | not null
 afilelocation | character varying(200) | not null
 iscorrect     | boolean                | not null
Indexes:
    "answer_pkey" PRIMARY KEY, btree (answerid)
Foreign-key constraints:
    "answer_questionid_fkey" FOREIGN KEY (questionid) REFERENCES question(questionid)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T21:08:34+00:00Added an answer on June 17, 2026 at 9:08 pm

    You forgot a ) at the end of your query:

    $answercreatequery = pg_query("INSERT INTO answer (answerid, questionid, adescription, afilelocation, iscorrect) VALUES( default, '".$thisquestionid."', '".$adescription1."', '".$afilelocation."', '".$iscorrect1."' ");
    ........................................................................................................................................................................................................insert ) here ^
    

    Besides that, you can simply omit the column where you want the default value to be used:

    $answercreatequery = pg_query("INSERT INTO answer
      (questionid, adescription, afilelocation, iscorrect) VALUES
      ('".$thisquestionid."', '".$adescription1."', '".$afilelocation."', '".$iscorrect1."')");
    

    Additionally, you should really use pg_query_params (instead of escaping or having a sql injection hole):

    $answercreatequery = pg_query_params('INSERT INTO answer
      (questionid, adescription, afilelocation, iscorrect) VALUES ($1, $2, $3, $4)',
      array($thisquestionid, $adescription1, $afilelocation, $iscorrect1));
    

    Doing so also makes your code much more readable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been working on this for hours, and I just can't figure it
Hi I have been working on this code that creates a table with radio
Have been working on this question for a couple hours and have come close
I have been working on this app for at least 3-4 months and just
I have been working on this for the past 5 hours. For some reason
I am getting a headache! I've been working on this code for hours now,
I have been at this for hours and MUST get this working! It is
I have been trying to get this code to update, and it just will
I have been working on some code to submit an uploaded image to PHP
I am new to github. I have been working on a code that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.