Jump to content
#StayAtHome ×


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by maxxd

  1. At the top of your code, add the following: if(!empty($_POST)){ print("<pre>".print_r($_POST,true)."</pre>"); }else{ print("<p>\$_POST is empty</p>"); } Just to make sure your post variables are being set like you think they are. The code looks like it should work (of course, I could be overlooking something obvious - I have a new puppy and am a bit sleep deprived), so making sure everything in post is set and indexed as expected should help a bit.
  2. There are a couple different ways, right off the top of my head. The easiest would be to convert the $year variable that you set earlier into a DateTime object, then pull the year right from that. No fuss, no muss. You could always use substr(), but I do think the first option is going to be easier.
  3. Another benefit to using interfaces is that you can type hint to the interface, like so: interface iMyInterface{ function sayHello(); } class TestOne implements iMyInterface{ function sayHello(){ return '<p>Good day!</p>'; } } class testTwo implements iMyInterface{ function sayHello(){ return "<p>'sup?</p>"; } } class EverybodyPolite{ public static function greet(iMyInterface $greeting){ print($greeting->sayHello()); } } $p1 = new TestOne(); $p2 = new TestTwo(); EverybodyPolite::greet($p1); EverybodyPolite::greet($p2); While you can drop the type hint from the public static greet() method, having it there increases readability of the code and the possibilities that the code will function as expected because you know that the object passed in to the calling method functions (at it's base) in a defined way.
  4. maxxd

    php c

    You're not using variable in your while() loop at all. Also, you don't assign a value to $i, which should produce a division by zero error on every iteration of the loop. It's way too early for me to do math, but figure out what value to assign to $i, and make k and i variables in your while loop like so: while($k){ if($k%$i == 0){ echo 0; } if($k == $i){ echo 1; } }
  5. Explain 'not working'. The cookie isn't being set at all, the value isn't being read from elsewhere, the value is not what you expected to see, what? And are you trying to set a cookie, or a session variable? It seems like you don't know, and there are differences between the two that can dictate which is the proper choice.
  6. You want a switch statement. Basically: switch($var1){ case 1: $var2 = 'a'; break; case 2: $var2 = 'b'; break; case 3: $var2 = 'c'; break; }
  7. There are a lot of possible places this is going wrong - from putting the code in the wrong file to never queuing it in your WordPress theme to never actually outputting the built strings. Are you using a theme you bought/downloaded, are you creating a theme yourself, where is the listed code found (what files, where are they located, etc.), what relevant code is in the functions file, and so on. Giving us a fuller picture might help point someone in the right direction to help.
  8. From the Codex: wp_get_attachment_image_src(). $returnValue[1] = width, [2] = height.
  9. Typically WYSIWYG editors like TinyMCE are JavaScript, not php. I'd check to make sure that you've got the JS set up correctly to initialize and display the editor on the form.
  10. OK - there's a couple things I see right off the bat. First, your form doesn't have fields named 'name' or 'id', so those aren't getting passed via $_POST. You're checking $_GET['id'], then assigning $_REQUEST['id'] to $id, then overwriting that value with an apparently non-existent value: $_POST['name']. Where you've got the output checks for $_GET['id'] right before your form, add the following: print(empty($id) ? "\$id is empty or null" : "This is \$id: {$id}"); and that should output '$id is empty or null'. You're submitting the form to the same page via $_POST. Because you've specifically given the form an 'action' parameter, that means any $_GET variables aren't being carried over - check the location bar before and after you hit the submit button. You'll need to create a hidden input field and assign the value of 'id' to that field. Right after your opening form tag, insert this: <input type='hidden' name='id' value='<?= htmlentities($_GET['id']); ?>' /> Assuming that there's a value in $_GET['id'], when you submit the form from that page, you can access the value using $id = $_POST['id']; Now, if you omit the 'action' parameter of the form, it'll post to itself by default - the interesting thing here is that it means the URL will still be intact including your $_GET variables. So, if you remove the "action='createworkorder.php'" parameter from your opening form tag, things should work as expected right up until the point where you overwrite the value with $_POST['name'], which (as stated above) doesn't actually exist.
  11. I think I see what you're saying now. *I think*. So, you're saying the initial two blocks of code in your original post are on the page with the form output, and the third block of code is on the processing page (the value of the form action property), correct? My question is, where in the script are $date, $installer, $salesman, $category, and $status set and how? Are the values passed from the form via _POST or _GET? The id value should be in there, assuming it's in the form somewhere (this is usually done with a hidden field in the form itself or pulled directly from a session variable). Perhaps it would help if you posted a bit more code, like the form itself and the code before the "if($valid){" line.
  12. You're mixing and matching SQL approaches. Replace this bit: $sql = "INSERT INTO workorder (name, date, installer, salesman, category, status) values('$id', ?, ?, ?, ?, ?);"; $q = $pdo->prepare($sql); $q->execute(array($date,$installer,$salesman,$category,$status)); with this: $sql = "INSERT INTO workorder (name, date, installer, salesman, category, status) values(?, ?, ?, ?, ?, ?);"; $q = $pdo->prepare($sql); $q->execute(array($id,$date,$installer,$salesman,$category,$status)); And it should work. As an aside, why are you checking the id value in _GET and then assigning it from _REQUEST? If somehow there's an 'id' index in both _GET and _POST, one of them is going to overwrite the other. If the value is set in _GET, pull it from _GET.
  13. You can shorten it a bit like so: <?php if( is_single() || is_home() || is_page() ): ?> <div class='container'></div> <?php endif; ?> Or you can just put the div in the template pages controlling those particular pages. I think (off the top of my head, so check the template hierarchy on the WordPress site), you'd be looking at index.php for the blog (home) page, single.php or page.php for the other two. I haven't had my second cup of coffee yet and just logged on at work, so I may be mistaken about which files you'll need to target.
  14. If you Google 'javascript password strength meter' you'll find several things already in development. I've not used any of them, but this one looks like it could work well...
  15. maxxd


    http://php.net/manual/en/class.datetimezone.php That's not to say it's easy to deal with time zones - in my experience, it's kind of a massive pain in the butt. However, using DateTime and DateTimezone objects does make it a better experience.
  16. It shouldn't be - I still don't see where you're defining $storeID in getProductList(). Unless the code has changed, you should still be getting the undefined variable error.
  17. This is untested, but should work: $parms = array( array( ':id', $idnr, PDO::PARAM_INT ), array( ':name', $name1, PDO::PARAM_STR ) ); Of course, whether it's actually shorter or not is up for debate....
  18. It sounds like you're looking for information on AJAX. You can send information from JavaScript to php, process it on the server side in php, and return data to your client-side JavaScript. Here's information on using JQuery - it makes AJAX calls easier to deal with.
  19. PDO is a full API that integrates and abstracts several different database connection types into a unified and standard interface. While it's not technically a framework, and I'm sure many here would disagree with my statement, it's kind of close to a framework in itself - well, in a way that makes sense to me anyway, so there you go. If you're looking for something a bit more abstracted with more convenience methods, bells, and whistles, you might want to check out the Doctrine Project DBAL classes.
  20. Make the text input name an array. That way you can simply loop through the values in your php script. Like so: //in the form itself for ($i=0;$i<$lim;$i++){ print("<input type='text' name='custUrserInput[]' id='{$i}' />"); } //processing script foreach($_POST['custUrserInput'] as $userValue){ print("<p>\$_POST['custUrserInput'][] is {$userInput}</p>"); } This way, in your processing script, you don't need to know how many fields the user has added. Just loop through the number that are there and process them individually.
  21. maxxd

    footer placer

    I use this or this technique depending. Typically I've used Ryan Fait's in the past, but I just found the second and haven't tested it as thoroughly - where I have tested it, though, it's worked wonderfully.
  22. In Profile::make_array(), you're calling $database_profile->run_query(), not $this->data_profile->run_query().
  23. You need to convert the minutes into a decimal value. For instance, 14 hours, 30 minutes equates to 14.5 * 15 = 217.50.
  24. Dang - I got size and maxlength confused. NewDLR, if you're trying to set the width of the field, do as requinix suggested and use CSS.
  • 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.