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
https://forums.phpfreaks.com/topic/159757-solved-variable-order-in-update/
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().

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.