Summthing Posted February 18, 2010 Share Posted February 18, 2010 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/ Link to comment Share on other sites More sharing options...
JoeDaStudd Posted February 19, 2010 Share Posted February 19, 2010 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] Link to comment Share on other sites More sharing options...
dsavi Posted February 19, 2010 Share Posted February 19, 2010 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> Link to comment Share on other sites More sharing options...
Summthing Posted February 19, 2010 Author Share Posted February 19, 2010 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/ Link to comment Share on other sites More sharing options...
Slayr Posted February 20, 2010 Share Posted February 20, 2010 ...why does it say that PureMageUK wrote this? Link to comment Share on other sites More sharing options...
obfuscator Posted February 20, 2010 Share Posted February 20, 2010 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 Link to comment Share on other sites More sharing options...
Slayr Posted February 21, 2010 Share Posted February 21, 2010 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"; } ?> Link to comment Share on other sites More sharing options...
MageUK Posted February 24, 2010 Share Posted February 24, 2010 ...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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now