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

Blogging s/w
heya frndz!!! i want to start a blog.... m looking for a s/w like oscommerce which is thr for e-comm

Insert to MySQL inside foreach
Hey.
I am parsing some html, and putting inside an html db.
I need to create a randomized inte

mails going in spam??
The mails I sent to folks in my database using mail(function) are going in spam??

Any idea ho

Request for tunning the below query
Hi,

Can any one help me on the below query while improving the performance,

php mail form text wont appear / javascript included
Guys/gals...

I am running into a problem whereby I have a great piece of javascript code that

How to calculate days from variable date?
This will be easy for one of you gurus. I want to fetch the date from a variable date, for example:<

Number Format
Hi All,

I have number '000000000050085' I want to format it to 500.85 Can any one give me

Display search result
Hi!

I have a SQL database with information about albums and track (music).

This is wh

Warning: session_start() [function.session-start]: Cann.....
hi, can someone help me with this? I keep getting this error....

Warning: session_start() [fu

Delete all files in folder except with certain name
I have a script that I want to delete all files in a folder (taken from a database) except for one n

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