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
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 :)
Link to comment
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
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]
Link to comment
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.