Jump to content

matthewhaworth

Members
  • Posts

    234
  • Joined

  • Last visited

    Never

Everything posted by matthewhaworth

  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.
  15. I've searched high and low for this.. but nothing. I decided that the code on my site is quite inefficient.. so I thought that I'd put it to the test and time how long it takes to create the page on the server side.. I got different answers on each refresh varying from 0.05 seconds to 0.08. Is this good or bad? Also, I saw on another thread that somebody had submitted a log from an online program that apparently searches for vulnerabilities in websites.. anyone know what this is? Many Thanks. matthewhaworth.
  16. No tabs is standard? wtf? I couldn't even imagine typing four spaces before each line... I couldn't be bothered, it'd proper produce RSI lol. I don't understand why that is necessary at all. And is it saying that you don't have to use ?> at the end of PHP-only documents?
  17. I'm quite interested in this Zend framework.. any good resources? I visited the website but it seems to throw everything onto you at once.
  18. I am getting really bored of looking through content display systems and template systems and nothing appealing to me. A template system is far too much work for my site I think.. and a lot of people seem to be going off them.. people have suggested using a page class that is initiated on each page and add content to it through methods before rendering it at the end. But that presents the problem of putting HTML into classes : P which is 'bad technique'. (And I hate using bad technique). I just want someone to show me more alternatives *sigh* though I'm being a bit too picky.. I just don't know which way I want to go about it. Presently.. just to keep me doing something, I've created a new php page for each like module of my website.. and each module seems to have its own class which is a really a library of functions for that page. I'm a mess.. any advice?
  19. My post contained information that was incorrect. Please ignore it.
  20. http://www.geekpedia.com/tutorial242_Object-Oriented-Programming.html Something I wrote a while back.
  21. You're better off using a switch/case if you want to have lots of different messages. <?php switch(date("G")) { case "7": echo "It is 7.00am"; break; case "12": echo "It is 12.00pm - Midday : ]"; break; case "0": echo "It is midnight!"; break; default: echo "This will display if the date function returns a value that hasn't been dealt with previously"; break; } ?> Orr... if you really want to stick to the if .. else.. method.. <?php if(date("G") == "0") { echo "it is midnight"; } elseif(date("G") == "7") { echo "it is 7.00am"; } elseif(date("G") == "[YOUR TIME HERE]") { echo "..."; } else { echo "This will display if the date function returns a value that hasn't been dealt with previously"; } ?> It works on a twenty four hour clock, you just simply change the numbers "0" or "7" to whatever time you want on a twenty four hour clock To schlo_50: No, because the date output is not in the format HH:MM. It simply returns H in 24 hour clock format.. you can however change the date function's parameters to produce such an output if you wished and then do it like that though.
  22. You'd have more luck with the date() function because there are an infinite amount of times in which it is midnight. <?php if(date("G") == "0") { echo "it's midnight"; } ?> and so on.. P.s. not that it matters, but strictly speaking 12.00pm is midday lol. 12.00am is midnight.
  23. Okay, I'm new to creating layouts by using <div>s, I've always used tables before.. but now I want to be more 'compliant', 'web 2.0' etc lol. However, the problem I am having, is that the left and right columns of the page (the 'content') is on top of the footer. Which is placed below it in the HTML. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" /> <meta name="author" content="matthewhaworth" /> <link rel="stylesheet" type="text/css" href="style.css" /> <title>Matthew Haworth</title> </head> <body> <!-- Header --> <div id="header"> <div id="logo"> <h1>Matthew Haworth</h1> </div> <div id="menu"> <ul> <li><a href="#">Home</a></li> <li><a href="#">Projects</a></li> <li><a href="#">About Me</a></li> </ul> </div> </div> <!-- Main Content --> <div id="content"> <div id="left"> LEFT COLUMN </div> <div id="right"> RIGHT COLUMN </div> </div> <!-- Footer --> <div id="footer"> FOOTER </div> </body> </html> stylesheet: * { margin: 0px 0px 0px 0px; padding: 0px; } body { font-family: "Tahoma"; background: url(images/img01.jpg) repeat-x left top; margin: 10px; } /* Header */ #header #logo { background: url(images/logo.png); height: 100px; width: 800px; margin: 0px auto; text-align: center; } #header #logo h1 { /* Logo written as text settings */ padding: 25px; color: #FFFFFF; } #header #menu { margin: 20px auto; height: 50px; width: 850px; background: #454545; color: #FFFFFF; } #header #menu ul { list-style:none; line-height: normal; padding: 15px; text-align: center; } #header #menu li { display: inline; float: left; padding: 0px 15px; } #header #menu a { text-decoration: none; text-transform: lowercase; display: block; color: #FFFFFF; } #header #menu a:hover { color: #ABABAB; } /* Body */ #content { margin: 0 auto; width: 850px; } #content #left { float: left; width: 215px; background: #FF0000; } #content #right { float: right; width: 620px; background: #0000FF; } /* Footer */ #footer { margin: 0 auto; width: 850px; height: 20px; text-align: center; background: #00FF00; } I gave all the divs primary colour backgrounds to see exactly where they were (not that I like the colours together lol) Here is a screenshot, as you can see the footer is 'on top' of the content.
  24. Query unsuccessful: INSERT INTO members('email', 'password', 'username', 'joindate', 'birthdate', 'auth')VALUES('matthewhaworth@hotmail.com', '8ab752bb333186f0b1e6a35125ff0995', 'thomas', '1215835593', '651366000', '1'); You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''email', 'password', 'username', 'joindate', 'birthdate', 'auth')VALUES('matthew' at line 1 I found an error message, I can take it from here. Thanks guys.
×
×
  • 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.