HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Could anyone help me with this please?

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#12927 (In Topic #3264)

Fan in action

I'm currently working on my website and ran into a really wierd problem…..

For some odd reason, my $next variable isn't working for images '08' and '09', it gives me a undefined variable error…, but it works for 1-7 and 10 and I can't seem to figgure out why…

This file grabs several 'get' parameters, assigns variables to them and when combined, gets the array entry from another php file (via '$id') For this one, It's grabbing image #8 of entry '1011'

Code

index.php?page=imageview&mode=char&type=1&entry=1&series=1&image=08

Code

 $series    = "{$_GET['series']}";
 $type      = "{$_GET['type']}";
 $entry    = "{$_GET['entry']}";
 $image       = "{$_GET['image']}";
 $id      = "{$series}0{$type}{$entry}";

Code

 if ($image == 01) { $next = "02"; $prev = "10"; }
 if ($image == 02) { $next = "03"; $prev = "01"; }
 if ($image == 03) { $next = "04"; $prev = "02"; }
 if ($image == 04) { $next = "05"; $prev = "03"; }
 if ($image == 05) { $next = "06"; $prev = "04"; }
 if ($image == 06) { $next = "07"; $prev = "05"; }
 if ($image == 07) { $next = "08"; $prev = "06"; }
 if ($image == 08) { $next = "09"; $prev = "07"; }
 if ($image == 09) { $next = "10"; $prev = "08"; }
 if ($image == 10) { $next = "01"; $prev = "09"; }

 $next_url   = "<a href='index.php?page=imageview&mode=char&type={$type}&entry={$entry}&series={$series}&image={$next}'>Next</a>";
 $prev_url   = "<a href='index.php?page=imageview&mode=char&type={$type}&entry={$entry}&series={$series}&image={$prev}'>Prev</a>";
 $return_url = "index.php?page=charview&type={$type}&entry={$entry}&series={$series}";

Expand: php source code php source code


ocProducts :wub: :wub:

Click here to drop by my website!
Back to the top
 
Posted
Rating:
#12929
Avatar

Don't put leading 0's on those ($image ==) lines. By putting a leading 0 on you are saying you are specifying a number in octal. 08 is not an octal number (like A is not a decimal number).


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#12931

Fan in action

Cool. that fixed it!! Thanks :)

But why did it work for 01-07 though? :S I thought I had the 8 and 9 lines exactly like the 01-07 lines :S :(

ocProducts :wub: :wub:

Click here to drop by my website!
Back to the top
 
Posted
Rating:
#12933
Avatar

Because 01-07 are real octal numbers and correspond exactly to the decimal numbers.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#12935

Fan in action

ohh :o Thanks again :)

ocProducts :wub: :wub:

Click here to drop by my website!
Back to the top
 
Posted
Rating:
#12936
Avatar

I'd also replace those first 10 lines with something a little more compact:

Code

$next=$image+1;
$prev=$image-1;
if($next>10) $next=1;
if($prev<1) $prev=10;

:thumbs:

Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: