yanviau Posted October 19, 2010 Share Posted October 19, 2010 Hello i try to explain my situation, I have a dynamic table so i need to build a dynamic radiobutton list and build a dynamic sql req. First of all i build my table with radio button in a while So the radio button is named rdYanViau ( in the html it's working no prob with that ) $name = $row2['FirstName'].$row2['LastName']; <input type="radio" name="rd<?php echo $name; ?>" value="1"> <input type="radio" name="rd<?php echo $name; ?>" value="2"> And in the same while i build a portion of my dynamic sql like that $valueDeclare .= $row2['FirstName'].$row2['LastName'].', '; So in my insert this variable give me the FieldName and in the same while i build my $_POST variable for my sql sentence $valueRadio .= "'".'".$_POST['."'".'rd'.$row2['FirstName'].$row2['LastName']."'".']."'."', "; This value is '".$_POST['rdYanViau']."' After that i build my sql with those 2 variables, the problem is when i execute my sql insert where he's supose to insert my rdButton value ... it's insert the string '".$_POST['rdYanViau']."' who give me a 0 in the table, he's not getting the value of '".$_POST['rdYanViau']."' he's inserting the string in the table. Here's the echo of my sql sentence : INSERT INTO sondage (idSondage, username, idMatch, YanViau, YanViau2, YanViau3) VALUES (NULL , 'admin', '1', '".$_POST['YanViau']."', '".$_POST['YanViau2']."', '".$_POST['YanViau3']."') my echo should look like : INSERT INTO sondage (idSondage, username, idMatch, YanViau, YanViau2, YanViau3) VALUES (NULL , 'admin', '1', '1', '2', '1') How i can build this dynamic sentence and have the radiobutton value and not the string value ... I hope you can understand my problem. Yan. Quote Link to comment Share on other sites More sharing options...
Vettel Posted October 19, 2010 Share Posted October 19, 2010 Do this: VALUES({var1}, {$var2}) Quote Link to comment Share on other sites More sharing options...
yanviau Posted October 19, 2010 Author Share Posted October 19, 2010 same problem as before, because i put de {} on my variable concatenation so the { is in the string and not a php code Quote Link to comment Share on other sites More sharing options...
Vettel Posted October 19, 2010 Share Posted October 19, 2010 I'm pretty sure that there should be nothing wrong with this: mysql_query("INSERT INTO sondage (idSondage, username, idMatch, YanViau, YanViau2, YanViau3) VALUES (NULL, 'admin', '1', {$_POST['YanViau']}, {$_POST['YanViau2']}, {$_POST['YanViau3']})") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 i would single-quote all values in SQL. '1', '{$_POST['YanViau']}', '{$_POST['YanViau2']}', etc. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.