Jump to content

matthewhaworth

Members
  • Posts

    234
  • Joined

  • Last visited

    Never

Everything posted by matthewhaworth

  1. http://uk2.php.net/manual/en/function.htmlspecialchars.php That'll help. Edit: no it won't lol.
  2. <?php /** *userFactory.class.php * *User Factory *To return either, guest, user or admin objects. * *Matthew Haworth - Copyright 2007 */ abstract class userFactory { private function getUser($level) { switch ($level) { case 0: return new guest; break; case 1: return new user; break; case 2: return new admin; break; default: return new user; break; } } } ?> Is this created correctly? Or is there a major flaw? It's called like this: $user = userFactory::getUser($usermg->_userlevel);
  3. I've gathered that, it's more of a dynamic body that confuses me.. I mean.. how can I implement each.. module say.. one by one.
  4. Now, most PHP sites I've seen recently don't create the website in html and then implement bits of php. They render the site bit by bit by concatenating html onto a variable that is echo'd at the very end. Where can I seek advice on how to go about this? Or can you give me some ideas.. the subject throws me. Completely, throws me.
  5. That is essentially what mine did. Look: <?php // This code here is used so we can prepare for the make time function. // This date function takes the day that the blog was created on, an adds 5 days to it, moving over to the next month or even next // year if it needs. $day = date("d",$strtotime("+5 days",$database_timestamp); $month = date("m",$strtotime("+5 days",$database_timestamp)); $year = date("y",$strtotime("+5 days",$database_timestamp)); // This is the data that the button should not longer appear after $expire = mktime(0,0,0,$month,$day,$year); // This compares the current time, time(), with the expiration time and the displays the button if it hasn't expired. if (time() < $expire) { // show button } ?>
  6. Yes. I believe we are talking static functions (functions that can be accessed outside of the class context). Can I append the return variable to a variable still? (Something I may have misunderstood in the information I just read). Like.. $error = class::function();
  7. I might be. *stares at you blankly*. Yer. I'll research static functions.
  8. But on mysql_fetch_assoc, that'll return the key 'password' still.
  9. Say I have, iD, username, password, aboutme, name, age, blah. And I want to select * BUT password, how can I do it? Edit: without listing them..
  10. i believe CMS is done by php here i dont get you guys???? I don't get why he's using template variables.. think about it, it sounds like he's using a .tpl in something like phpbb.. .tpl can't process php.
  11. Okay. I know that technically, a class is almost defined as a library of functions, but what I mean is that I want to use the functions from the class without initiating it in anyway. Like: <?php class usermg { public function login ($user, $pass) { // return user class or admin class } public function register ($userdetails) { // add user to the database } public function sessions($key, $value, $action="add") { // add/remove/kill all sessions } } $login = usermg::login($user,$pass) ?> Or is that bad programming? I know it's similar to an abstract factory. But I don't think it is one.
  12. I don't see what's wrong with my code.. lol, I mean, it's slightly longer but it's a lot easier to comprehend.
  13. I've noticed a lot of people do that, any reason why, and weren't you the person complaining about longer processing.. that'd take longer wouldn't it?
  14. *sigh*. I know. I have switched to an if statement. function numrows($table, $condition) { $sql = "SELECT * FROM " . $table . " WHERE " . $condition; $query = $this->_db->query($sql); //return ($query != false) ? $query:"Error in numrows"; if ($query != false) { return $query; } else { return "Error in numrows"; } } Thanks for the argument guys. . Note: the weird formatting accorded after I'd posted it..
  15. You want us to do the hard part of thinking it out for you, so you don't have to actually use the code you've written? No. I simply did not know if I was using the 'ternary' operator correctly. The function is used within the class. The $_db is a mysqli object.
  16. I'd have to call the class and set everything up.. or use test data, when I was hoping for a quick answer on here?
  17. <?php function numrows($table, $condition) { $sql = "SELECT * FROM " . $table . " WHERE " . $condition; $query = $this->_db->query($sql); return ($query != false) ? $query:"Error in function numrows"; } ?> I'm just not confident with the ? operator.
  18. Lol, I'm always coming out with these elaborate ideas, then there turns out to be like.. a one line method of doing it. You should be in the PHP, not the CMS ??
  19. Something like this. <?php $day = date("d",$strtotime("+5 days",$database_timestamp); $month = date("m",$database_timestamp); $year = date("y",$database_timestamp); $expire = mktime(0,0,0,$month,$day,$year); if (time() < $expire) { // show button } ?> Compare the $expire date to the current date..
  20. You missed one <?php //Name of the Person $namenew = $_GET['name']; //Email Id of the person $emailnew = $_GET['email']; //Feedback detail $feedbacknew = $_GET['feedback']; // multiple recipients $to = '[email protected]'; // note the comma // subject $subject = 'rLD-i.com Form Feedback'; // message $message = ' <html> <style type="text/css"> <!-- body { font-family: Arial, Helvetica, sans-serif; font-size: 11px; color: #999999; text-align: justify; } --> </style> <head> <title>rLD-i.com</title> </head> <body> <p>Got a new feedback from '.$namenew.'. Ele submeteu a seguinte informação:</p> <table> <tr> <td>Email: ' . $emailnew . '</td> </tr> <tr> <td>Detailss: '.$feedbacknew.'</td> </tr> </table> </body> </html> '; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers $headers .= 'To: Mary <[email protected]>, Kelly <[email protected]>' . "\r\n"; $headers .= 'From: rLD-i.com <[email protected]>' . "\r\n"; // Mail it mail($to, $subject, $message, $headers); ?> Also, I changed the variables round, $_GET['feedback'] might have been an array, but i doubted it.. look at the beginning of the script, you've already renamed the variables so why put the old ones into the $message var?
  21. http://en.wikipedia.org/wiki/Data_Access_Object Yes it is my database class you were referring to, I can now review my design and pass it an object instead of implementing it.
  22. Okay, can someone at least explain the data access object in context, unless it WAS my db class you were referring to?
  23. $queryb = SELECT code, id,name,price,description FROM dbtable WHERE status = 'A' AND code = 'E'"; Needs ".. but i know that's not the problem Also, why isn't $earcode = $_POST['earcode']; in php tags?
  24. Well a moderator just asked you to do it, so you won't this time.
  25. Do you get an error message? If so, what? $queryb = "SELECT code,id,name,price,description FROM dbtable WHERE status = 'A' AND cat_code = 'E' AND ear_code = '$earcode'" ; Space between end of the line and semicolon. Infact.. if ($earcode == "ALL") { $queryb = "SELECT code, id,name,price,description FROM dbtable WHERE status = 'A' AND code = 'E';"; } else { $queryb = "SELECT code,id,name,price,description FROM dbtable WHERE status = 'A' AND cat_code = 'E' AND ear_code = '".$earcode."';"; } $result = mysql_query($queryb) or die('Query not successfully processed: ' . mysql_error()); Always use {.
×
×
  • 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.