Jump to content

NewBob

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

NewBob's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for all the help! Why don't you guys like the serialize/unserialize method? By making my own store/restore functions it feels I'd be reinventing the wheel. I tried the serialize function: echo serialize($object); which gave a string that looked a bit like I imagine the string from my functions would have looked like. Is there some drawback I've missed.. or does "I second the serialize / unserialize method." not mean that you don't like it? Hehe.. newb at both programming and english
  2. Hi! (not sure where to put this topic, here or in the "MySQL section) Background: I'm trying to design a simple php game just to put my newfound OO Modeling and Design skills to the test. Since I'm going OO all out there will be alot of classes and many objects will contain arrays of other objects which in turn have attributes that I will need to store somehow. I've worked with MySQL and PHP before when creating a calender and a login system, but at that time I didn't even realise that PHP could be used as a OO language. Problem: How do I store objects in a database that aren't of any primitive type. How do I store objects that contain other objects? I thought about giving each class a function called "storeMe" or something which returns an array or string of the attributes. That would require another function "restoreMe" to rebuild all the info again. However, I was hoping there would be an easier way. Also, is it possible to store pictures in a MySQL database?
  3. Perfect! Now it works just fine. Thanks alot!
  4. Hi all! My problem is that when I use 2 nested foreach loops on a 2d array and echo the contents of the inner loop I get doulbe output. Let me demonstrate: $posts = $database->getCalPostByUser('bob'); //returns array[id][row] where id is an int and row is another array foreach($posts as $id => $row) // $row should contain an array { foreach($row as $field => $info) //get the elements in the array $row { echo $field.': '.$info; b(); } } This should work because when I skipped the inner forloop and echoed $row the output was Array. Anywho, the output from the code above is: 0: 20070423 date: 20070423 1: bob username: bob 2: 09:30 start: 09:30 3: 12:00 end: 12:00 4: home location: home 5: stuff and junk description: stuff and junk 6: 1177488289 id: 1177488289 Why do i get the numeric keys 0-6? I have only ever used the string keys. And how can I get rid of the numeric key outputs? I just can't figure it out and I didn't find much on the interweb either. Thanx in advance! /Bob
  5. Hi! Don't quite know if this i an O.O.P question so I'll ask it here. In C++ one can create a global array and then access it from within functions. I'm in the process of designing a calender class but because it will be in swedish I need swedish names for the months. This is my solution: $monthname[1] = "Januari"; $monthname[2] = "Februari"; $monthname[3] = "Mars"; $monthname[4] = "April"; $monthname[5] = "Maj"; $monthname[6] = "Juni"; $monthname[7] = "Juli"; $monthname[8] = "Augusti"; $monthname[9] = "September"; $monthname[10] = "Oktober"; $monthname[11] = "November"; $monthname[12] = "December"; function getNameOfMonth($month) { return $monthname[$month] } Because the array is created in the global namespace I thought it would work fine. However, I get nothing. Not even an error message. I realize I could move the array inside the function since it's the only one that needs the array. But perhaps other functions will need it aswell later on and I still would like to know how to make this work Thanks in advance, /Bob I stumbled upon the solution so I thought I write it here for you people wondering the same thing. The array must be declared global inside the function so the function knows it should access the global array and not some array that was created inside the function namespace like so: function getNameOfMonth($month) { global $monthname; return $monthname[$month] } Now it works
  6. Thanks alot you all. There's alot to think about but now I got, as the swedish saying goes, "a little more meat on my bones" /Bob
  7. Hi everyone! I'm using a session class for holding information about the loged in user. At every page I have the server check if $session->logedIn is true or false. This is set at every pagerequest in the constructor of the session class. I'm not sure how exactly session variables are stored but I read something about it being stored in a cookie or the header? Anywho, my question is this: is it possible for someone to set his own session variable that is called logedIn and in that way make the server think that he is a loged in user granting him access to memberpages? How should I check if it is a loged in user otherwise? Thanks in advance, /Bob
×
×
  • 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.