values not being entered into table


Posted on 16th Feb 2014 07:03 pm by admin

hi. I;ve created a form, so that when a user enters data into it, it gets added to a table in a database. the form submits some data to one table, and other data to another table. my problem is that the data only gets added to the first table, but data doesnt enter correnctly into the other one.
Code: <?PHP

$questionno = $_POST['questionno'];
$question = $_POST['question'];
$quizref = $_POST['quizref'];
$answerno = $_POST['answerno'];
$answer = $_POST['answer'];
$answervalue = $_POST['answervalue'];

pg_connect("host=database.*******.uk
port=5432 dbname=***** user=***** password=******");
?>

<html>
<head>
<title>Add </title>
</head>
<body>

<?php

$query="INSERT INTO questions (questionno, question, quizref)VALUES ('".$questionno."', '".$question."', '".$quizref."')";

pg_query($query) or die ('Error adding new question');

echo "The question has been added to the quiz";
$queryanswers="INSERT INTO answers (answerno, answer, answervalue, questionno, quizref)VALUES ('".$answerno."', '".$answer."','".$answervalue."', '".$questionno."', '".$quizref."')";

pg_query($queryanswers) or die ('Error adding new answers');

echo "The answers has been added to the question";
?>
<form method="post" action="">

quizref: <br/>
<input type="text" name ="quizref" size="5" /><br/>

Question Number: <br/>
<input type="text" name="questionno" size="5" /><br/>

Question: <br/>
<input type="text" name="question" size="60" /><br/>

Answers<br/><br/>

Answer number:<br/>
<input type="text" name ="answerno" size="5" /><br/>

Answer<br/>
<input type="text" name ="answer" size="60" /><br/>

Answer value<br/>
<input type="text" name ="answervalue" size="5" /><br/>
<br/><br/>
Answer number:<br/>
<input type="text" name ="answerno" size="5" /><br/>

Answer<br/>
<input type="text" name ="answer" size="60" /><br/>

Answer value<br/>
<input type="text" name ="answervalue" size="5" /><br/>
<br/><br/>
Answer number:<br/>
<input type="text" name ="answerno" size="5" /><br/>

Answer<br/>
<input type="text" name ="answer" size="60" /><br/>

Answer value<br/>
<input type="text" name ="answervalue" size="5" /><br/>
<br/><br/>
Answer number:<br/>
<input type="text" name ="answerno" size="5" /><br/>

Answer<br/>
<input type="text" name ="answer" size="60" /><br/>

Answer value<br/>
<input type="text" name ="answervalue" size="5" /><br/>
<br/><br/>

<input type="submit" value="Send and Add another Add Questions" />
<a href="addfinish.php"><input type="submit" value="Add and finish" /></a>

</form>

</body>
</html>
Any help would be great.

thanks

No comments posted yet

Your Answer:

Login to answer
315 Like 28 Dislike
Previous forums Next forums
Other forums

Code error with Index.php
Error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/runevid/public_

PHP, Arrays & A Lot Of Confusion
I've been doing basic PHP work on sites for a few years now, but I've never been tempted to learn ho

PHP hyperlinks generator
Hi

I need some help to get this done using php:


1 - I have few hyperlinks say 500

re calling a function without including file
Hi,
i am new to programming in php, i was just checking the wordpress code and found out in the w

chat
hello i'm amir i need a chat source code in asp.net 2.0 without Ajax. anybody can help me?

Help with captcha script needed
Hello,

I am working on a script where reCAPTCHA or a similar form of CAPTCHA will be used, f

Data Function is Its Not working IN IE8
This is my first time to use formums. I hope i can get solution for this problem. view plaincopy to

remove trailing slash from array
I have the following array which contains trailing slashes I need to remove. What is the best way to

Converting RGB values to HEX
Code: <?PHP

$file_handle = fopen("colors/rgb.csv", "r");

wh

mr8m - reverse document
Friends,

I'm trying to reverse a document held by MIRO, but it reports the message balan

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash