-
Posts
234 -
Joined
-
Last visited
Never
Everything posted by matthewhaworth
-
PHP returns invalid XML because of '&'
matthewhaworth replied to mesh2005's topic in PHP Coding Help
http://uk2.php.net/manual/en/function.htmlspecialchars.php That'll help. Edit: no it won't lol. -
<?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);
-
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.
-
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.
-
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 } ?>
-
[SOLVED] Using a class as a library of functions..
matthewhaworth replied to matthewhaworth's topic in PHP Coding Help
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(); -
[SOLVED] Using a class as a library of functions..
matthewhaworth replied to matthewhaworth's topic in PHP Coding Help
I might be. *stares at you blankly*. Yer. I'll research static functions. -
Quick question: selecting all but one.
matthewhaworth replied to matthewhaworth's topic in MySQL Help
But on mysql_fetch_assoc, that'll return the key 'password' still. -
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..
-
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.
-
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.
-
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.
-
[SOLVED] Will this work? Wrapped function for numrows.
matthewhaworth replied to matthewhaworth's topic in PHP Coding Help
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? -
[SOLVED] Will this work? Wrapped function for numrows.
matthewhaworth replied to matthewhaworth's topic in PHP Coding Help
*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.. -
[SOLVED] Will this work? Wrapped function for numrows.
matthewhaworth replied to matthewhaworth's topic in PHP Coding Help
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. -
[SOLVED] Will this work? Wrapped function for numrows.
matthewhaworth replied to matthewhaworth's topic in PHP Coding Help
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? -
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 ??
-
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..
-
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?
-
$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?
-
Well a moderator just asked you to do it, so you won't this time.
-
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 {.