-
Posts
234 -
Joined
-
Last visited
Never
Everything posted by matthewhaworth
-
strtotime() rather, not date.. my error.
-
Just skimmed this post so I could be wrong, but isn't it: http://uk3.php.net/manual/en/function.array-values.php You're after.
-
[SOLVED] side image doesn't extend in internet explorer
matthewhaworth replied to makaveli80's topic in HTML Help
They both load exactly the same in both browsers for me. -
[SOLVED] Call to undefined function mysql_connect()
matthewhaworth replied to jsucupira's topic in PHP Coding Help
[code][/code] put your code between them two tags so that it'll format correctly. -
Notice that when you posted your PHP it looked like this <?php // I am php echo "blah"; ?> if you put them in [code][/code] tags it'll look like this <?php // I am php echo "blah"; ?> And it is a lot easier to read. You can auto-insert these code tags by clicking the hash button in the menu located above where you type your post. <?php if(isset($session[userid])){ // Member is logged in so we have to display welcome message with userid and one logout link echo "<tr><td align=center'><strong><font color='#FFFFFF'>Welcome $session[username]</font></strong></td></tr> <tr> <td><font color='#FFFFFF'><strong><a href='logout.php'>LOGOUT[/url]</strong></font></td></tr> "; }else { // Member has not logged in so we can display the login form allowing member to login with user id and password echo "<form name='login' method='post' action='loginck.php' style='margin:0px'> <tr><td width='37%'><strong><font color='#FFFFFF'>Username</font></strong></td> <td width='58%'><input name='id' type='text' class='field' id='username22' size='14'></td> </tr> <tr><td><strong><font color='#FFFFFF'>Password</font></strong></td> <td><input name='pw' type='password' class='field' id='password227' size='14'></td> </tr> <tr><td> <a href='forgot.php'>Forgot password[/url]</td> </tr></form>"; } // End of else condtiion echo "</table>"; ?> Your code will look like that. After reading your code, realise that you can't end an <a> tag with [/url]. That's BBCode.
-
Put the picture inside a <div> and make it relative? How do you get the co-ordinates when it's not inside a picture?
-
MySQL forum, not this one. Though you could take all the data out, apply the function strtodate() and enter it all in again.
-
And it's not $session it's $_SESSION.
-
Ok. I have a factory that returns an object, however I want that object to send my data access object.. I don't know how to add arguments into factory produced classes.. look: abstract class userFactory { public static function getUser($levelname) { return new $levelname; } } Now I want to send the parameter ($db) to whatever $levelname produces.. how's that possible? Should I just create a new method that sends it and that is called directly after the construct?
-
In MySQL: (if that's relevant) I've got my 'users' table.. that looks a little like this : iD, email, password.. blah And I have my messages table (that I haven't created yet): iD, user_sent, user_received, message iD, is obviously the message iD. user_sent, is the user that sent it's iD user_recieved, is the user that's receiving it's id message is the message Now this just screams bad structure to me, what's a more logical approach?
-
I've realised it is now . Though I have a new problem, what's the difference between 'implements' and 'extends'.
-
Good some tutorials. We are not here to write code.
-
[SOLVED] Database class; On the right track?
matthewhaworth replied to hostfreak's topic in PHP Coding Help
Performance wise, I don't think it'll be significant, however you should only really have a parent class that's inherited.. (obviously, because it's a parent ) if it's going to be inherited more than once.. otherwise it defeats the idea of inheritance. Also, when using mysqli object orientedly.. you don't need a function to set db, it should be set by mysqli's constructor. And thinking about it, since you've now just got one method.. you should really put the connect method into the constructor. Meaning you've got no methods, just a constructor, therefore meaning lol, that you should just merge the two. -
If class 'user', inherits class 'guest', then can an instance of class 'user' reference class 'guest''s functions? I.e. class guest { function doSomething() { // does something } function doSomethingElse() { // does something else } } class user implements guest { function doEvenMore () { // does even more } } $user = new user; $user->doSomething(); Is that possible?
-
I've realised this to, I use PHP Designer 2007 and I was going to name my function fetch, but apparently, there's already one called fetch. I guess it doesn't matter because you always have to have a referrer when referencing the method. I mean, let's say I called my function mysql_connect.. I couldn't actually call that method by typing mysql_connect I'd have to take $class->mysql_connect or $this->mysql_connect or even parent::mysql_connect or class::mysql_connect.. I can never reference it without writing something before it.. therefore I think it's safe to do so, it's just the IDE trying to be clever lol.
-
[SOLVED] Database class; On the right track?
matthewhaworth replied to hostfreak's topic in PHP Coding Help
I always put my mysql_select_db in my connection method. Instead of having a separate one. Also, there's no point in having a subclass, one for connection one for queries etc, thats over organisation. -
Is this abstract factory made correctly?
matthewhaworth replied to matthewhaworth's topic in PHP Coding Help
You need to declare getUser public and static, and there's no point in having a case for 'user' if it's also your default. Other then that, there's not really anything wrong with it. Just remember that if you change the levelcodes or class names you also have to change switch block. I would personally suggest a little defensive programming: <?php public static function factory($level){ switch ($level){ case 0: return new Guest; break; case 1: return new Admin; break; case 2: return new User; default: throw new Exception('Invalid levelcode'); break; } } ?> It's less flexible, but if you insist on what I call 'hard class mapping', you'll need it. Alternatively you could simply return NULL, but do not use a default return type, that is asking for trouble. In some other languages a particular method can only return a particular type. Meaning you have to define a separate factory method for each type. So basically their is no real reason why you should not place the method elsewhere. One might still get some benefit from subclassing if you get a hierarchy of related factories. An alternative would be to place the factory method in a user Layer Supertype: <?php interface UserObject { public function doLogin(); } class User implements UserObject { public function login(){ //Do something $this->doLogin(); //Do something } public function doLogin(){ //Do something } public static function factory($level){ switch ($level){ case 0: return new Guest; break; case 1: return new Admin; break; case 2: return new User; default: throw new Exception('Invalid levelcode'); break; } } } class Admin extends User { public function doLogin(){ //Do something } } class Guest extends User { public function doLogin(){ //Do something } } ?> <?php $user = User::factory(0); $user->login(); ?> Thanks a lot for the elaborate reply. I was actually going to do the latter example, but I thought it was bad programming. Also, I was going to have my admin class inherit my user class and my user class inherit my guest class.. for permissions purposes.. I don't want guest to have access to my user methods. I realise, however, that what you were doing was just a passive example . Thanks a lot, it's helped loads. -
check this function... and help please
matthewhaworth replied to watthehell's topic in PHP Coding Help
Well it will do if the login form isn't in the if statement.. -
It's a unix epoch timestamp.. make it a variable, apply it to the function date() and it'll all make sense. <?php $time = 1188206122; $date = date("G\h-i\m-s\s d\d\a\y\s-m\m\o\\n\\t\h\s-y\y\e\a\\r\s",$time); echo $date; ?> Edit: realised I didn't put the time in lol. haha, i'm terrible with date functions
-
check this function... and help please
matthewhaworth replied to watthehell's topic in PHP Coding Help
<?php $login = is_user(); if($login != false) { ?> You are logged in. <?php } else { ?> You are not logged in <?php> } ?> -
Is this abstract factory made correctly?
matthewhaworth replied to matthewhaworth's topic in PHP Coding Help
Ah, I'd have to change a lot of code to pass a userLevelName.. as long as the other works.. then it's ok isn't it? Also, quick question.. why are userfactories in classes, why not just make them a function? -
[SOLVED] problem in PHP fetching & [DISPLAYING] data
matthewhaworth replied to watthehell's topic in PHP Coding Help
To spread the information dynamically over to cells dependant upon the font size, desktop-resolution of the user, allsorts would be very difficult.. look into a different way of implementing your design. -
check this function... and help please
matthewhaworth replied to watthehell's topic in PHP Coding Help
It is very hard to determine what this function does 'watthehell'. Though at a guess. I would say it checks to see if the user is logged in. Perhaps applies the user details to session variables? It depends what the check_session function does. Also, remember! Code tags. -
Set the values at the top of the page.. ... $name = $_GET['name'] ... etc. Then <input type="text" name="name" value="<?php echo $name; ?>"> Assuming the form targets the page it's on.