giba Posted February 22, 2007 Share Posted February 22, 2007 Hi, Freak Addicted! I have a form to input data into my database, and recently wanted to add a radio button to improve service, but now I can't add anything to my database. (I'd like to make clear that other variables used before were working fine. I am trying to use these radio buttons to insert yes/no to a new field of my database (client): Client:<input name="client" type="radio" value="yes" /> Non-client:<input name="client" type="radio" value="no" /> And I have this code into my insertion page: (I summarized taking away other fields keeping just the new one here) <?php mysql_connect($conn); $cliente=$_POST['client']; mysql_select_db($database) or die( "Your are not connected to database!"); $query = "INSERT INTO form VALUE ('$client')"; mysql_close(); ?> I read a lot of explanations about this but none helped! Please, someone could help me!? Link to comment https://forums.phpfreaks.com/topic/39641-about-inserting-data-using-radio-buttons/ Share on other sites More sharing options...
pikemsu28 Posted February 22, 2007 Share Posted February 22, 2007 just looking at your code you have a spelling mistake where youre posting to your variable $cliente = $_POST['client']; should be $client = $_POST['client']; Link to comment https://forums.phpfreaks.com/topic/39641-about-inserting-data-using-radio-buttons/#findComment-191363 Share on other sites More sharing options...
giba Posted February 22, 2007 Author Share Posted February 22, 2007 Sorry and thanks! That's because I had to translate this to you help me (I'm brazilian client=cliente) Link to comment https://forums.phpfreaks.com/topic/39641-about-inserting-data-using-radio-buttons/#findComment-191374 Share on other sites More sharing options...
boo_lolly Posted February 22, 2007 Share Posted February 22, 2007 are you sure you've setup the right connection to the database? try adding 'OR die(mysql_error())' to the end of your query to see if your problem stems from a connection first. Link to comment https://forums.phpfreaks.com/topic/39641-about-inserting-data-using-radio-buttons/#findComment-191388 Share on other sites More sharing options...
giba Posted February 22, 2007 Author Share Posted February 22, 2007 No, It's correctly set and working! Link to comment https://forums.phpfreaks.com/topic/39641-about-inserting-data-using-radio-buttons/#findComment-191407 Share on other sites More sharing options...
giba Posted February 22, 2007 Author Share Posted February 22, 2007 Thanks, I solved it. I was with PhpMyAdmin running and testing my script, I don't know why but after I closed it worked! SOLVED Link to comment https://forums.phpfreaks.com/topic/39641-about-inserting-data-using-radio-buttons/#findComment-191495 Share on other sites More sharing options...
craygo Posted February 22, 2007 Share Posted February 22, 2007 Might be working but unless the form table has only one field in it, this line is wrong $query = "INSERT INTO form VALUE ('$client')"; The query will insert that into the first field of the table. Possibly going into the wrong field use this $query = "INSERT INTO form (`fieldname`) VALUES ('$client')"; change fieldname to the field you want to insert it into Ray Link to comment https://forums.phpfreaks.com/topic/39641-about-inserting-data-using-radio-buttons/#findComment-191502 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.