Canman2005 Posted March 15, 2006 Share Posted March 15, 2006 Hi allCan anyone help me? My sql statement won't seem to work, my statement uses a exlode for a radio button[code] $radio=explode(',',$_POST['name']); $sql ="UPDATE details SET firstname = '$radio[0]' AND last = '$radio[1]' WHERE id = ".$_POST['useid']; @mysql_query($sql, $connection) or die(mysql_error()); header("Location: index.php"); exit;[/code]Any help would be greatThanksEd Link to comment https://forums.phpfreaks.com/topic/5043-sql-issue-explode/ Share on other sites More sharing options...
Gaia Posted March 15, 2006 Share Posted March 15, 2006 I'm pretty sure that explode would result in $radio['name'] and not the numeric value of it. Link to comment https://forums.phpfreaks.com/topic/5043-sql-issue-explode/#findComment-17843 Share on other sites More sharing options...
shocker-z Posted March 15, 2006 Share Posted March 15, 2006 [code]$radio=explode(',',$_POST['name']);$sql ="UPDATE details SET firstname = '$radio[0]' AND last = '$radio[1]' WHERE id = '$_POST[useid]'";@mysql_query($sql, $connection) or die(mysql_error());header("Location: index.php");exit;[/code]Try that :) Link to comment https://forums.phpfreaks.com/topic/5043-sql-issue-explode/#findComment-17844 Share on other sites More sharing options...
Canman2005 Posted March 15, 2006 Author Share Posted March 15, 2006 [!--quoteo(post=355379:date=Mar 15 2006, 04:14 PM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 15 2006, 04:14 PM) [snapback]355379[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]$radio=explode(',',$_POST['name']);$sql ="UPDATE details SET firstname = '$radio[0]' AND last = '$radio[1]' WHERE id = '$_POST[useid]'";@mysql_query($sql, $connection) or die(mysql_error());header("Location: index.php");exit;[/code]Try that :)[/quote]Nope, that didnt seem to work, any other suggestions?[!--quoteo(post=355378:date=Mar 15 2006, 04:11 PM:name=Gaia)--][div class=\'quotetop\']QUOTE(Gaia @ Mar 15 2006, 04:11 PM) [snapback]355378[/snapback][/div][div class=\'quotemain\'][!--quotec--]I'm pretty sure that explode would result in $radio['name'] and not the numeric value of it.[/quote]Nope, it ends in a number as I have one bullet that carries both [0] and [1] values, the bullets look like<input name="name" type="radio" value="david,brookson" so the [0] takes david and the [1] takes brooksonIt's just getting them to update I cant seem to do with my sql statement Link to comment https://forums.phpfreaks.com/topic/5043-sql-issue-explode/#findComment-17846 Share on other sites More sharing options...
Gaia Posted March 15, 2006 Share Posted March 15, 2006 Try this.[code]$radio=explode(',',$_POST['name']);$sql ="UPDATE details SET firstname = '$radio[0]', last = '$radio[1]' WHERE id = '$_POST[useid]'";@mysql_query($sql, $connection) or die(mysql_error());header("Location: index.php");exit;[/code] Link to comment https://forums.phpfreaks.com/topic/5043-sql-issue-explode/#findComment-17849 Share on other sites More sharing options...
shocker-z Posted March 15, 2006 Share Posted March 15, 2006 [code]$radio=explode(',',$_POST['name']);$sql ="UPDATE details SET firstname = '".$radio[0]."' AND last = '".$radio[1]."' WHERE id = '$_POST[useid]'";@mysql_query($sql, $connection) or die(mysql_error());header("Location: index.php");exit;[/code]Try that because im not sure if it has to see [0] and [1] rather than ['0'] and ['1']or maby to be safe just set them as seperate variables?[code]$radio=explode(',',$_POST['name']);$fname=$radio[0];$lname=$radio[1];$sql ="UPDATE details SET firstname = '$fname' AND last = '$lname' WHERE id = '$_POST[useid]'";@mysql_query($sql, $connection) or die(mysql_error());header("Location: index.php");exit;[/code] Link to comment https://forums.phpfreaks.com/topic/5043-sql-issue-explode/#findComment-17853 Share on other sites More sharing options...
Canman2005 Posted March 15, 2006 Author Share Posted March 15, 2006 [!--quoteo(post=355390:date=Mar 15 2006, 04:39 PM:name=shocker-z)--][div class=\'quotetop\']QUOTE(shocker-z @ Mar 15 2006, 04:39 PM) [snapback]355390[/snapback][/div][div class=\'quotemain\'][!--quotec--][code]$radio=explode(',',$_POST['name']);$sql ="UPDATE details SET firstname = '".$radio[0]."' AND last = '".$radio[1]."' WHERE id = '$_POST[useid]'";@mysql_query($sql, $connection) or die(mysql_error());header("Location: index.php");exit;[/code]Try that because im not sure if it has to see [0] and [1] rather than ['0'] and ['1']or maby to be safe just set them as seperate variables?[code]$radio=explode(',',$_POST['name']);$fname=$radio[0];$lname=$radio[1];$sql ="UPDATE details SET firstname = '$fname' AND last = '$lname' WHERE id = '$_POST[useid]'";@mysql_query($sql, $connection) or die(mysql_error());header("Location: index.php");exit;[/code][/quote]Thanks all, couldnt get it to work, will do it another way Link to comment https://forums.phpfreaks.com/topic/5043-sql-issue-explode/#findComment-17861 Share on other sites More sharing options...
shocker-z Posted March 15, 2006 Share Posted March 15, 2006 $radio=explode(',',$_POST['name']);$fname=$radio[0];$lname=$radio[1];$sql ="UPDATE details SET firstname = '$fname', last = '$lname' WHERE id = '$_POST[useid]'";@mysql_query($sql, $connection) or die(mysql_error());header("Location: index.php");exit;You not tryed that also? thats almost identical to Gaia's post and i thinks thats right that you need , instead of AND.. Link to comment https://forums.phpfreaks.com/topic/5043-sql-issue-explode/#findComment-17870 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.