Jump to content

Hailwood

Members
  • Posts

    51
  • Joined

  • Last visited

    Never

Everything posted by Hailwood

  1. hi there im am making a php validation class with sub classes that extend it, eg, mobile, suburb, credit_card, ect so, the idea is you can call $validation = new Validation('mobile'); $valid = $validation->validate($number); $validation->type('suburb'); $valid2 = $validation->validate($suburb); now my idea for doing this is having class Validation { private $v_type = null; function __construct($type) { $this->type($type); } public function type($type) { $this->v_type = new $type(); } public function validate($info) { return $this->v_type->validate($info); } } as a very basic example but is there a better way of doing this?
  2. hi there, well here is what i am doing: $flybuys: 6014359000000928 $check: 8 $total = (array_sum($odds))+$evens; $total = str_split($total); $check = 10 - $total[1]; echo $flybuys.' % '.$check.': '.$flybuys % $check.'<br />'; $res = $flybuys % $check; echo 'res: '.$res; and the output is: 6014359000000928 % 8: 7 res: 7 yet if i do: echo 6014359000000928 % 8; i get: 0;, which is correct so where is the 7 coming from?
  3. and in a whole is entirely unhelpful :|
  4. These type of micro optimizations are generally a waste of time. maybe so, but i am doing optimization on the entire code, so i might as well.
  5. so basically here is a set of if statements that i am trying to optimize, can you please tell me if there are any differences in processing between them if($id!="0" && $status!="" && $msg_body=="") if($id != 0 && !empty($status) && empty($msg_body)) AND if($message_type == 0 && $msg_link_id != "0" && $status=="" && $msg_body!="") if($message_type == 0 && $msg_link_id != 0 && empty($status) && !empty($msg_body)) AND if($message_type == 0 && $msg_link_id=="0" && $status=="" && $msg_body!="") if($message_type == 0 && $msg_link_id == 0 && empty($status) && !empty($msg_body))
  6. just normal date time i.e 2010-07-01 22:42:21
  7. thorpe do you ever sleep? haha but yeah, i thought about doing that, except this table has over 300 columns (not designed nor can be changed by me) and so the query is is select * ... while($row = mysql_fetch-assoc...) { foreach($row as $k => $v ) $$k = $v; so i cant really do it in the query cheers. came across using strtotime on it before using date
  8. hi there, how should i go about formatting a mysql datetime with php? i have tried Date('jS M Y', $qry['msg_add_date']) but i simply get 1st Jan 1970
  9. hi guys so, can anyone tell me why i end up with different results with each of these <product_display_price> </product_display_price> = [product_display_price] => SimpleXMLElement Object ( [0] => ) <product_display_price>Ham $5.00</product_display_price> = [product_display_price] => Ham $5.00 <product_display_price/> = [product_display_price] => SimpleXMLElement Object ( ) all i did was $xml = simplexml_load_string($this->xml_data); echo '<pre>'; print_r($xml->xpath('/menu/products_list/product')); die('</pre>'); so, why does an empty element give me an empty object ^ expected a element with a string in it give me a string ^expected yet a element with a " " string gives me an object with a " " string in it ^not expected i would have expected it to act as either a string or an empty element
  10. damn, i think ill rather rewrite the app than use that on every include... thanks anyway
  11. see one way i could do it is to call $content = ob_get_contents(); ob_end_clean(); //replace stuff here echo $content; which would work fine, as i could just put ob_start before the echo $content; but is there a tidier way to do this? so the entire thing to replace would actually be $content = ob_get_contents(); $headers = array(); if ( !headers_sent() ) $headers = apache_response_headers(); ob_end_clean(); //replace stuff here ob_start(); if ( !empty( $headers ) ) foreach ( $headers as $name => $value ) header( "$name: $value" ); echo $content;
  12. then what would you suggest for when you have a default page layout i.e <html> <head> <!--stylsheets here --> <!--javascript here --> </head> <body> <!--header div --> <!-- menu div --> <?php include($_GET['page.php']; ?> <!-- footer div --> </body> and its not pratical for your site to include the header, footer, and menu divs from anther file now in the the include file you want to change the site title, and include another style sheet, so my idea was to have a placeholder variable in the head which i could edit. i am already calling ob_start() at the beginning of every every page so could i use that to edit it?
  13. Hi guys, if i have a variable (lets call it $page for now) and i echo it here (echo $page;) and i include a page here how in the included page can i edit the text that was echoed above?
  14. 8D yeah just saw that, so it means that the actual link that was being created was <a href="messaging"> which explains it. I think i kinda deserve anything you give me now lol.
  15. That is the code there <a href="<?php $config->base['url_path']; ?>messaging">Messaging</a> the config class is just an empty class with magic methods for get and set so i define config things like so $config = new Config(); //BASE SETTINGS //------------------ $config->base = array(); $config->base['abs_path'] = $abs_path; $config->base['url_path'] = 'http://localhost/buzzil/'; $config->base['temp_dir'] = 'tmp/'; $config->base['env'] = 'dev'; so the expected output from accessing any url with this code in the file <a href="<?php $config->base['url_path']; ?>messaging">Messaging</a> is <a href="http://localhost/buzzil/messaging">Messaging</a> but instead from a url such as http://localhost/buzzil/templates/list/email i get <a href="http://localhost/buzzil/templates/list/messaging">Messaging</a> and yes thorpe, at midnight when i have had less than 3 hours sleep in the past 48 hours i do fail at spelling
  16. if i have this in a config file $config->base['url_path'] = 'http://localhost/buzzil/'; and i have this <a href="<?php $config->base['url_path']; ?>messaging">Messaging</a> any idea when i am on a page iwth a url like http://localhost/buzzil/templates/list/email why instead of the expected output of <a href="http://localhost/buzzil/messaging">Messaging</a> am i getting <a href="http://localhost/buzzil/templates/list/messaging">Messaging</a> dont know if it will help but here is my htaccess file Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?page=$1
  17. @Shadiadiph We were looking at something like that, just wondering if there was an easier way, thanks @5kyy8lu3: The HTTP_REFERER can be spoofed so it is unreliable
  18. Hi guys, what do i write in my htaccess file so that when a user visits mysite.com/login it actually loads mysite.com/index.php?page=login
  19. Hi there ive been looking into preg_replace, how do i validate a phone number in the format of ^+[0-9]$ is the closest i can get it needs to begin with a + can have as many numbers as needed but thats it.
  20. Hi guys, I have a page which submits a form via ajax the form submits to add a new user users can only access this page if they are logged in, so my question is how do we validate to make sure that the requests are coming only from that page? we thought about validating via the request ip but if the form is submitted via ajax would that not just be the clients ip? Regards, Hailwood
  21. ok, so you know the times when you feel really stupid? yeah this is one of them, i can get to them doing $this->config->database['name']; the error had nothing to do with me trying to access them, the error was because i was doing $this->$link by accident instead of $this->link
  22. Current Status Attempt: $this->config->database['name']; Error: cannot access empty property Attempt: $this->config->database->name; Error: cannot access empty property Attempt: $this->config[database][name]; Error: Cannot use object of type Config as array Attempt: $this->config->[database][name]; Error: Incorrect Syntax
  23. strange this is if i do this: $this->link = $this->config->database['pass']; //line 45 $this->$link = mysql_connect( //line 46 $this->config->database['host'], //Database Host $this->config->database['user'], //Database User $this->config->database['pass']); //Database Pass i get Fatal error: Cannot access empty property inC:\server\xampp\htdocs\buzzil2\classes\database.class.php on line 46so why dont i get this error on 45? wondering if one of the values was not set properly i went through and changed 45 to user/host/pass/ in turn, but still no error
  24. dunno if it will help but this is how i store the info //GET AN INSTANCE OF THE CONFIG CLASS $config = Config::getInstance(); //DATABASE SETTINGS //------------------ $config->database = array(); $config->database['host'] = 'localhost'; $config->database['user'] = 'root'; $config->database['pass'] = ''; $config->database['name'] = 'buzzil'; the config class has public static function getInstance() { if (self::$instance== null) self::$instance= new config(); return self::$instance; } public function __set($k, $v) {$this->$k = $v;} public function __get($k) {return $this->$k;}
×
×
  • 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.