February 18, 201016 yr Ohai. So, I'm trying to cURL all of the f2p items, and put them into a session. I've added all of the items so they look like $_SESSION['fur'] = ge_item(6814) (Thanks Peter :mrgreen: )Now I just need to figure out how to use them so that I can just echo $_SESSION['fur'] on any page so that it outputs what it's supposed to be (78)? This is what I have so far:http://pastebin.com/m6ef72a5b Thank you very much. http://forum.tip.it/blog/231-summthings-coming/
February 19, 201016 yr Addsession_start();Just under the <?php tag on every page you need the session data on. [hide=Drops]Dragon Axe x11Berserker Ring x9Warrior Ring x8SeercullDragon MedDragon Boots x4 - all less then 30 kcGodsword Shard (bandos)Granite Maul x 3Solo only - doesn't include barrows[/hide][hide=Stats][/hide]
February 19, 201016 yr Indeed, make sure that session_start() is before anything is printed. That means that this will not work:<!doctype html> <head><title>Blah</title></head> <html> <body> <?php session_start(); //Rest of your code here ?> </body> </html>Because session_start() needs to send the headers, if headers are sent before it's called, you'll get an error (Headers already sent in file.php on line X). This is how you'd do it: <?php session_start(); ?> <!doctype html> <head><title>Blah</title></head> <html> <body> <?php //Rest of your code here ?> </body> </html>
February 19, 201016 yr Author Okay, I've added that, but when I try <?php session_start(); echo $_SESSION['fur']; ?>The page is blank. Any idea why? I apologize for my ineptitude #-o http://forum.tip.it/blog/231-summthings-coming/
February 20, 201016 yr I believe he's using his code with permission. "It's not a rest for me, it's a rest for the weights." - Dom Mazzetti
February 21, 201016 yr Okay, I've added that, but when I try <?php session_start(); echo $_SESSION['fur']; ?>The page is blank. Any idea why? I apologize for my ineptitude #-o Make sure you set the session variable before echoing it. Try checking if it's set.<?php session_start(); if(isset($_SESSION['fur'])) { echo $_SESSION['fur']; } else { echo "It's not set"; } ?>
February 24, 201016 yr ...why does it say that PureMageUK wrote this? I wrote the functions gp_convert() and ge_item() (the latter of which he's modified) and he's using them with my permission. I'd also like to point out that although I know you're new to PHP that:This isn't the most efficient way to retrieve lots of items as curl_close() is called every time and then it has to be initiated again for the next item.Caching could be used to greatly improve page load times since you won't be pulling from Jagex on every load. Your issue should be sorted by including session_start(); like dsavi said. Ensure you're calling it in the page with the ge_item() calls as well. The session needs to be started for you to be able to assign session variables.
Create an account or sign in to comment