Jump to content

UrbanDweller

Members
  • Posts

    123
  • Joined

  • Last visited

About UrbanDweller

  • Birthday 04/20/1989

Profile Information

  • Gender
    Male
  • Location
    New Zealand - Christchurch

UrbanDweller's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey, I have this code below which seems to completely fail sending my laptop cpu fan on a frenzy. All I am wanting to do is find whether the id in the url is located inside the array below else state its not in an error saying its not a valid id (for people who change the url shown below). At the moment it doesnt like the else statement if the isset clause it not true. (I have also tried, array_key_exists) All I can think is that it get stuck looking for an id that doesnt exist inside the array but keeps searching though I dont know much about arrays etc. Besides this when a id is inside the array the script works like I want it to. Any ideas would be much appreciated as this is hold me back at the moment //url: http://localhost/website/shop.php?id=10197 // Array is built from table prior to this as it will grow in size $_SESSION['storesProducts'] = Array ( [10197] => 0 [10198] => 0 [10199] => 1 [10200] => 1 [10201] => 1 [10202] => 1 [10205] => 0 [10206] => 1 [10207] => 1 ) if(isset($_SESSION['storesProducts'][$id])){ $storesProducts = $_SESSION['storesProducts'][$id]; if($storesProducts == 0){ $list = $this->displayCategories($id); }else{ $createProducts = new constructProducts(); $products = $createProducts->pagination($id); } }else{ $list = "ITS NOT HERE"; } $output = new outputShop(); $output->display($list, $products);
  2. Hey, In my script I am currenlty working on I have 2 classes one which calls the second in the hope it will return a value to it but doesnt send the variable back. The example code below give you and idea of what I am looking for as my script it too long to add. class oneClass{ function bar(){ $var1 = "test" $two = twoClass(); $result = $two->foo($var1); echo $result; } } class twoClass{ function foo($var1){ $result = $var1 . ' is successful!'; $this->fooTwo($result); } function fooTwo($result){ $result = $result . ' Pass me back now?'; return($result); //Want to pass the variable back to "oneClass->bar();" } } // Starts script $testme = new oneClass(); $testme->bar(); This is a very simple example but states what i am wanting to. Any ideas would be much appreciated! Thanks
  3. I decided to re-look over my code and have completely reworked it into a cleaner look without having to back in to previous classes. Thanks for comment
  4. Yeah it is but how I started coding this, I may have to reconsider moving some functions out of class a into class b instead as the variable pass through will get messier than i want it.
  5. Ive always had a bit of trouble with php and effectively talking between classes, as the example below shows I want to call a first class->function that will later call a different class and its function then call the previous class again. I havent been able to find any examples that state how to do this if possible. <?php class A{ function b(){ //does required code etc... $B = new B(); $B->BA(): } function AB(){ echo "I WANT TO END UP HERE, from class B function BA"; } } class B{ function BA(){ //does required code etc... // //Unsure how to call class/function A->AB } } $a = new A(); $a->AB(); ?> Is this possible as it helps separate my code in to nice and easy to read Thanks
  6. Thanks for the input the main issue was retrieving the previous category name which I had to use the database as I found was the best/easiset solution for my dynamic page as the admin could add more and more categories. So i worked back from the current page via the category parent id all the way to home page which seems to have worked perfectly. I dropped the refeerer idea to as its too risky to create crumb urls
  7. Sorry for double post but, is $_SERVER["HTTP_REFERER"} safe to use to get previous page link for my crumbs as ive heard a lot about it being untrustworthy or is that just external urls?
  8. Yeah i have always thought about caching but my knowledge isnt ready to start diving into new areas like that yet as my customer base isnt large enough nor is my coding skills.
  9. Hey, I'm currently planning on how i will code some breadcrumbs for a shopping site where the admin can add more options/levels to the database which in turn store products. I understand how to get the url of the previous options/level but am stuck on retrieving the name of the level and can only imagine retrieving it from the database. Though Its possible to do so is there any other method as relying on the database for crumbs seems like a easy way out or am i just picky? the typical url is like so: website.com/shop.php?cat_id=1004, so i cant retrieve the name from it unless i cross reference it to its database name and dont know how to retreive from their <a href> tag. On a side note is there a graph that can show a general outline of how many db queries a server can make per second etc depending on its hardware? Thanks.
  10. Could you expand on cron or give a url?
  11. Hey all, Im currently working on a site which I save a cookie on users computer for 1 month as well a row in a table with the 1 month expiring date plus cookie id. What I would like to know is if theres a way to make the server check the table every day at say 12pm to see if any corresponding user cookies in each row have expired on that day as to remove them from the table to match the expiring cookie on the users computer? I would like not to have to rely on a user/admin accessing in to make a script run instead have something thats timed to go off automatically instead? Is there anyway of doing this? Thanks!
  12. Errr got it... ; silly me
  13. Hey, I have just started using cookies and have got the basic idea of creating and accessing the simple cookies but now I am wanting to be able to check if a cookie already exists on the users computer before overwriting the current one. <?php if(!isset($_COOKIE['testCookie'])){ setcookie("TestCookie", "username", time() + (24 * 60) ) } ?> <html>....</html> At the moment my page just doesn't get past this piece of code any ideas? Cheers
  14. Well i found a good example on global variable which seems tidy and is working too.
  15. WELL, it doesnt seem to be working.
×
×
  • 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.