Jump to content


Photo

sql issue (explode)


  • Please log in to reply
7 replies to this topic

#1 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 15 March 2006 - 04:03 PM

Hi all

Can anyone help me? My sql statement won't seem to work, my statement uses a exlode for a radio button

        $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;


Any help would be great

Thanks

Ed

#2 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 15 March 2006 - 04:11 PM

I'm pretty sure that explode would result in $radio['name'] and not the numeric value of it.

#3 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 15 March 2006 - 04:14 PM

$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;

Try that :)
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#4 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 15 March 2006 - 04:20 PM

[!--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) View Post[/div][div class=\'quotemain\'][!--quotec--]
$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;

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) View Post[/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

#5 Gaia

Gaia
  • Members
  • PipPipPip
  • Advanced Member
  • 95 posts
  • LocationCanada

Posted 15 March 2006 - 04:29 PM

Try this.

$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;


#6 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 15 March 2006 - 04:39 PM

$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;

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?

$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;

www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#7 Canman2005

Canman2005
  • Members
  • PipPipPip
  • Advanced Member
  • 669 posts

Posted 15 March 2006 - 05:05 PM

[!--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) View Post[/div][div class=\'quotemain\'][!--quotec--]
$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;

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?

$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;
[/quote]
Thanks all, couldnt get it to work, will do it another way

#8 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 15 March 2006 - 05:34 PM

$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..
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users