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

whats wrong with my code please help!!!
this is the error


Warning: mysql_close(): supplied argument is not a valid MySQL-Link res

Displaying image pathname instead of image
Hello

Im trying to upload and then display images from a mysql database - Its only basic and

Splitting Attributes
SQL> SELECT I_NAME, substr(I_NAME,1,instr(I_NAME,'O')) "First part",

substr(I_NAME, IN

Basic Question Regarding PHP Includes
Hi

Just starting out with PHP.

Working on a site that uses some basic includes, these

Cron Job and Output
I have php codes running under a cron job.
But everytime i output (echo) , it comes out as comple

quick question
Hi ..

i have a question
how do i set a var so it displays via an echo
Code: $logo = '&a

How to change Time Zone
HI
I want to change the time zone of the server to another country.How can do that?

Thanks

pspell
using pspell, is it possible to get words that would be best in the current phrase?

For examp

Logic question
im wondering what's the best method to do the above list:

it is for alliance @ MMORPG game

Relative path
I have a absolute path to an image - like so: C:/Program Files/Apache Software Foundation/Apache2.2/

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