Jump to content

matthewhaworth

Members
  • Posts

    234
  • Joined

  • Last visited

    Never

About matthewhaworth

  • Birthday 08/23/1990

Contact Methods

  • MSN
    matthew_haworth@hotmail.com
  • Website URL
    http://matthewhaworth.wordpress.com

Profile Information

  • Gender
    Male
  • Location
    Blackburn, United Kingdom

matthewhaworth's Achievements

Member

Member (2/5)

0

Reputation

  1. I have two tables. user_employment employment The relationship is on the field "employID" many user_employments to one employment. The basic structure (just the field that matter) are as follows: user_employment['employID', 'userID'] employment['employID', ... ,'current'] The field 'current' is enum(0, 1) (i.e. it can only be 0 or 1). What I want my query to do is find the employment record that is equal to 1 for a specific user, and make it equal to 0. Pseudo Code: UPDATE employment SET current = 0 WHERE employID = [the employID that is associated with the specified user, $userID] Thanks
  2. Of course! I'm half asleep, in the second example I did mean to use the comparison operator, not the assignment operator.. which makes a mokery of my whole question really.. but any more answers will be appreciated as I still don't feel satisfied. Thanks so far.
  3. Okay, look at the following code: #1 <?php if ( $link = mysql_connect($host, $user, $pass) ) { echo "The connection was successful"; } #2 <?php $link = mysql_connect($host, $user, $pass); if ( $link = FALSE) { echo "The connection was successful"; } Which one should I use? When assigning variables within if statements does it return TRUE is the assignment was successful or does it return TRUE is the content of the variables is TRUE?
  4. Can I just say that your variable names are a bit, OTT lol
  5. ClassName::function() calls a static function, which means you don't have to initialise the class to use it ClassName->function() calls a function from an object that exists
  6. For a while now I've been creating user objects on every page load and filling them with session data about the user i.e. $_SESSION['user']['name'].. now instead, I want to keep the user details in the object, and pass the object through sessions.. but I'm having a bit of a problem with doing that. Do I check to see if a user object already exists on every page? Or do I check it within the user object's constructor?.. but then again.. I shouldn't have constructed the user object if one already exists.. so in that case, the constructor should never run. So it'll have to check if the user object exists, and if not, create one? Another problem I'm having is, I believe objects don't save data when passed through sessions and that you have to somehow, recreate it through __wakeup.. how would I go about that? Edit: I figure something like <?php if(!is_object($_SESSION['user'])) { $_SESSION['user'] = new user; } ?> Would work?
  7. <?php $dataset = array(1, 2, 3, 4, 5, 6, 7, 8, 9); $taken = array(3, 6, 5, 2, 4); $nottaken = array_diff($dataset, $taken); $nottaken = array_values($nottaken); print_r($nottaken); ?> Does in fact output: Array ( [0] => 1 [1] => 7 [2] => 8 [3] => 9 ) I don't really like that solution though lol, I don't know why. I don't imagine it to be much faster than the first solution because in the background it's doing the same thing, except this one has to run an extra function.. so if anything, it's slower.. but the speed differences would be so small that it doesn't really matter.. pick whichever.. though to be honest, I think the TS has given up on this thread because he/she didn't get a reply within 10 minutes lol.
  8. If you use MSN, feel free to add me. I say that knowing perfectly well that you have a Yahoo address, but apparently they're linked now. I.e. MSN contacts can add Yahoo contacts and vice versa.
  9. <?php $dataset = array(1, 2, 3, 4, 5, 6, 7, 8, 9); $taken = array(3, 6, 5, 2, 4); $nottaken = array_diff($dataset, $taken); print_r($nottaken); ?> Using what Ken said. Hey, you learn something new everyday when you help people. However, there is a disadvantage to this because the array will have indexes that aren't.. together.. if you will. I.e. when I ran that I got: Array ( [0] => 1 [6] => 7 [7] => 8 [8] => 9 ) Instead of the other way were I got: Array ( [0] => 1 [1] => 7 [2] => 8 [3] => 9 )
  10. <?php $taken = array(3, 6, 5, 2, 4); $nottaken = array(); for($i=1; $i<10; $i++) { if(!in_array($i, $taken)) { $nottaken[] = $i; } } print_r($nottaken); ?> Something like that.
  11. You've defined $city as a string and you're trying to call a static method from it. Perhaps you need to call $city something else if it's the same name as the 'city' object?
  12. http://www.zend.com/en/services/certification/ That's the nearest you'll get.
  13. Is that actually any good? I don't see at all in things like phpBB or Joomla coding.. but then again, they use a template system
  14. Hey Thank you for your reply. I appreciate your help.. what I don't appreciate however is your sarcasm.. I told you what the website did.. it is not necessary to know who submitted it and to which thread that they submitted it to. Thanks once again.
×
×
  • 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.