Jump to content

sql issue (explode)


Canman2005

Recommended Posts

Hi all

Can 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 great

Thanks

Ed
Link to comment
https://forums.phpfreaks.com/topic/5043-sql-issue-explode/
Share on other sites

[!--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 brookson

It'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

[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

[!--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

$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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.