-
Posts
3,584 -
Joined
-
Last visited
-
Days Won
3
Everything posted by JonnoTheDev
-
Or, if you are Irish http://www.youtube.com/watch?v=i9VqIoOKIws
-
This is where you need to finish off your script yourself. The code snippet is an example of how to run a query based on selections made from checkboxes. To display your vehicles write a query that gets them from your database. Loop over the records and display to screen. I'm guessing that these will have the checkboxes next to each so include the checkbox element in the loop.
-
If you had the Internet when I was at school you had plenty of money to afford the phone bill. Would of had accounts with the likes of AOL & Compuserve.
-
I remember making sites like this in 97 using hotdog & frontpage 95 for IE 2/3, Netscape. It was all about how many animated gifs you could fit on a page. Amazing how far we have come really.
-
How to strip HTML tags, scripts, and styles from a web page
JonnoTheDev replied to senyo's topic in PHP Coding Help
Read on the function http://uk3.php.net/strip_tags -
There are hundreds of simple forums that you could download install and style up if that is your forte. Browse through hotscripts http://www.hotscripts.com/search/php/forum
-
This exact code produces an invalid date on your server? <?php $future = strtotime("+36 hour", strtotime("October 26th, 2009, 12:00pm")); print date('d-m-Y H:i:s', $future); ?> If so check the timezone environment variables on your php installation. What version are you running. You may need to use a US English date format. Read the description of the strtotime function http://uk.php.net/strtotime
-
There is no mistake. That is what it is meant to do. Only accept the numbered entries and ignore the rest.
-
The simple fact is nadeemshafi9 that this post is about letting others know who you are. Not diving into a massive post on promoting a framework using all kinds of buzzwords regarding software engineering processes such as, 'modular framework setup, coding and file structure and modification standards setup, versioning and backup, clustering and mirroring'. I mean come on. It looks like you have posted from a book or a university lecture slide. You are off on a tangent that makes people think that you are 'just going for it' posting anything. A lot of the members here are newbies to programming and won't have the slightest idea what you are on about.
-
You are tring to work to much using strings. This is not the best choice of data type.
-
If you take a look at the size of your conditional statement it is really poor. By storing data in an array you can easily check if values exist. By using an array in your form for storing checkbox entries (where users can select multiple values) it makes your code much more readable and easier to work with. Just think if you added another make of car i.e Fiat. You would need to alter your conditional statements in your code as well as add to your form. Wheras using an array only requires you to add the new value to your form (i.e a new checkbox field) if (!isset($_POST['Ford']) || (!$_POST['Mercedes']) || (!$_POST['Vauxhaull']) || (!$_POST['Citroen']) || (!$_POST['Peugeot']) || (!$_POST['Iveco']) || (!$_POST['FIAT']) || (!$_POST['Nissan']) || (!$_POST['Renault']) || (!$_POST['Volkswagen']) || (!$_POST['DAF, Isuzu, MAN, Moffet, Scania, Toyota, LDV, Land Rover, Daihatsu, Mitsubishi'])) { $Make = "Ford', 'Mercedes', 'Vauxhaull', 'Citroen', 'Peugeot', 'Iveco', 'FIAT', 'Nissan', 'Renault', 'Volkswagen', 'DAF', 'Isuzu', 'MAN', 'Moffet', 'Scania', 'Toyota', 'LDV', 'Land Rover', 'Daihatsu', 'Mitsubishi"; } Learn how you use arrays, looping through values, converting to strings, etc
-
PHP 5 factory method with dynamic parameters
JonnoTheDev replied to w3evolutions's topic in Application Design
The singleton pattern should return an object! Your objective is confusing. Take the following: <?php class base { public $params; function set($key, $val) { $this->params[$key] = $val; } function get($key) { return $this->params[$key]; } function createParams($array = array()) { foreach($array as $key => $val) { $this->set($key, $val); } } } class foo extends base { public function __construct($params) { $this->createParams($params); } } class bar extends base { public function __construct($params = array()) { $this->createParams($params); } } class factory { public static function getInstance($object, $params = array()) { return new $object($params); } } $x = factory::getInstance('foo', array(1,2,3)); print $x->get(0); ?> -
Thats the name of a button That is crazy. Can you understand my implementation. Very simple.
-
Then check your syntax. The following works perfectly: <?php $future = strtotime("+36 hour", strtotime("October 26th, 2009, 12:00pm")); print date('d-m-Y H:i:s', $future); ?> I notice you are enclosing varaibles in quotes as function parameters i.e. strtotime("$updatetime") This is bad syntax. Also validate the data that comes from your form. Is it a valid date string? print $_POST['updatebosstime']; If no valid date is contained within the post array the unix epoch date is used 01-01-1970
-
What is this? $_POST['DAF, Isuzu, MAN, Moffet, Scania, Toyota, LDV, Land Rover, Daihatsu, Mitsubishi'] Your code structure is poor as your form element naming & value pairs must be. Use proper arrays i.e. <?php // the form is submitted if(strlen($_POST['submit']) && $_POST['submit'] == 'submit') { if(is_array($_POST['make'])) { // options are selected $makes = array(); foreach($_POST['make'] as $make) { $makes[] = "'".$make."'"; } $result = mysql_query("SELECT * FROM models WHERE manufacturer IN (".implode(",",$makes).")"); } } ?> <form> Ford: <input type="checkbox" name="make[]" value="ford" /><br /> Vauxhall:<input type="checkbox" name="make[]" value="vauxhall" /><br /> Toyota: <input type="checkbox" name="make[]" value="toyota" /><br /> <input type="submit" name="submit" value="submit" /> </form>
-
$future = strtotime("+36 hour", strtotime($updatetime)); print date('d-m-Y H:i:s', $future);
-
I would log the invalid entries <?php $recipient = explode("\n", $_POST['recipient']); if(is_array($recipient)) { $results = array(); foreach($recipient as $number) { $number = trim($number); if(ereg('[0-9]+', $number, $regs)) { // number is valid $results['valid'][] = $number; } else { // entry is invalid $results['invalid'][] = $number; } } // check for invalid entries if(count($results['invalid'])) { print "The following entries are invalid:<br />".implode("<br />",$results['invalid'])."<br />"; } // display valid entries if(count($results['valid'])) { print "The following entries are valid:<br />".implode("<br />",$results['valid'])."<br />"; } } else { print "Missing input"; exit(); } ?>
-
PHP 5 factory method with dynamic parameters
JonnoTheDev replied to w3evolutions's topic in Application Design
Again, no matter how the object is created either instantiated via new or from a static method returning an object I cannot see where your issue lies with using params required (or optional) in the construct. -
PHP 5 factory method with dynamic parameters
JonnoTheDev replied to w3evolutions's topic in Application Design
I cannot see an issue -
Because input from a form is always a string so you cannot use is_int(). Use is_numeric() or ereg. Bricktop: nothing to do with trimming however good idea to trim each array element. if(ereg('[0-9]+', $number, $regs)) { print "Numeric"; }
-
I would add captcha to the registration process and comment post along with email validation. As you publish hard links this is a massive spam target.
-
PHP 5 factory method with dynamic parameters
JonnoTheDev replied to w3evolutions's topic in Application Design
Construct params are optional class foo { public function __construct($params = array()) { foreach($params as $key => $val) { $this->$key = $val; } } } $x = new foo(array('a' => 1, 'b' => 2)); -
<?php $recipient = explode("\n", $_POST['recipient']); foreach($recipient as $number) { if(is_numeric($number)){ echo "OK"; } else { echo "ERROR: NO INTEGER"; } } ?> Check loop & condition braces
-
Had a little free time on my hands so decided to take a look at CodeIgnitor. I must say I was impressed as it proves you can still have clean and efficient code written in PHP 4 without all the fancy elements of PHP 5.