Jump to content

Archived

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

Canman2005

sql issue (explode)

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

Share this post


Link to post
Share on other sites
I'm pretty sure that explode would result in $radio['name'] and not the numeric value of it.

Share this post


Link to post
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 :)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
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]

Share this post


Link to post
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

Share this post


Link to post
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..

Share this post


Link to post
Share on other sites

×

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.