Jump to content

[SOLVED] variable order in update


Walker33

Recommended Posts

Hi.  When updating my row with two variables, the order ' ".$reso.",".$licen." ' works perfectly fine.  But when I flip them to ' ".$licen.",".$reso." ' it only updates the $licen variable and ignores the $reso.  $licen is a string consisting of, say, S01,S02,S03,R01,R02,R03 .  $reso returns a single variable, in this case S04.  So I want the row to update to S01,S02,S03,R01,R02,R03,S04 (S04 at the end).  But I can only manage to get it to update to S04,S01,S02,S03,R01,R02,R03 (S04 at the beginning).  Any ideas?

 

<?php
$que = pg_query("SELECT sublicenses FROM sublicenses WHERE license = '$striplic'");
$getarr = pg_fetch_assoc($que);
$licen = $getarr['sublicenses'];

$string="$licen";
$domain3=strrchr($string,"S");
$string2=split(",",$domain3);
$res = $string2['0'];

$number = (int) $res[2];
$new_number = $number+1;
$reso = substr_replace($res, $new_number, 2);

$intosubs2 = pg_query ("UPDATE sublicenses SET sublicenses = ' ".$reso.",".$licen." ' WHERE license = '$striplic' ");
?>

 

So code above works fine.  Don't understand why I can't flip the $reso $licen over to $licen $reso.  Would really appreciate any help.  Thanks!

 

Link to comment
Share on other sites

hmm.  Yes that should work, but it didn't.  I echoed that, and I got:

 

S01,S02,S03,S04,R01,R02 ,S05

 

So what I'm noticing is that there is an additional space after R02.  Maybe that's the issue somehow, that additional space in my $licen variable?

Link to comment
Share on other sites

hmm.  Yes that should work, but it didn't.  I echoed that, and I got:

 

S01,S02,S03,S04,R01,R02 ,S05

 

So what I'm noticing is that there is an additional space after R02.  Maybe that's the issue somehow, that additional space in my $licen variable?

 

OK, that's fine. Better than before! Now just use trim() or str_replace().

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.