PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?
include "connect.php";
mysql_query("insert into dotable(hero) values('$hero')");
echo "OK";
?>
The database is connected, but when I press submit the data doesn’t insert into the table.
What’s wrong, is it the data type?
What is the suitable data type for radio, actually? Im new in php
Last edited by Benjamin on Wed May 27, 2009 10:04 am, edited 1 time in total.
Reason:Changed code type from text to php.
<td width=60%><font face="Arial">This is the first question.<br><br>
<INPUT TYPE="radio" NAME="group1" VALUE="a"><a href="#Definitions" title="Click for more information.">Choice1</a>
<!--These insert a non breaking space (similar to using tab in a text document).-->
<INPUT TYPE="radio" NAME="group1" VALUE="b"><a href="#Definitions" title="Click for more information.">Choice2</a>
<INPUT TYPE="radio" NAME="group1" VALUE="c"><a href="#Definitions" title="Click for more information.">Choice3</a>
<INPUT TYPE="radio" NAME="group1" VALUE="d"><a href="#Definitions" title="Click for more information.">Choice4</a>
<INPUT TYPE="radio" NAME="group1" VALUE="e"><a href="#Definitions" title="Click for more information.">Choice5</a><br><br>
//other code here
$query = "INSERT INTO data VALUES ('$answer1','$answer2','$answer3','$comment1','$comment2', '$comment3','','','','','','$test')";
mysql_query($query);
It will access the database, but when I look in the database, the only thing written are the '' entries and $test which is hardcoded.
Is my syntax incorrect somewhere?
Last edited by Benjamin on Fri May 29, 2009 10:22 am, edited 1 time in total.
Reason:Added [code=php] tags.
1. The method in the form tag was set to "link" instead of "post"
2. I had some extra 's' characters in my answer variables ($answers1 instead of $answer1) so it did not output on the next page
3. I forgot the variable $test had to be unique - there was an entry in the database with $test=1 so it wasn't writing my data
4. The variable comment1 in the first code was in the wrong place (not in the <textarea> tag)
I think those are all of the errors I found.
It's amazing what errors one can find if they leave the code alone for awhile
lmg wrote:1. The method in the form tag was set to "link" instead of "post"
I did say
lmg wrote:Here are the problems I found:
1. The method in the form tag was set to "link" instead of "post"
2. I had some extra 's' characters in my answer variables ($answers1 instead of $answer1) so it did not output on the next page
3. I forgot the variable $test had to be unique - there was an entry in the database with $test=1 so it wasn't writing my data
4. The variable comment1 in the first code was in the wrong place (not in the <textarea> tag)
I think those are all of the errors I found.
It's amazing what errors one can find if they leave the code alone for awhile
Thanks for posting your findings, as it will help others in the future.