Jump to content

maxxd

Gurus
  • Posts

    1,726
  • Joined

  • Last visited

  • Days Won

    57

Everything posted by maxxd

  1. I'm not entirely sure what you're trying to accomplish with everything after the mysqli_query (also, you may want to look into PDO as it's much easier), but what does this give you: die("<pre>".var_export($result, true)."</pre>"); if you put it right after the mysqli_query line?
  2. PHP is a server-side language, so it only knows the timezone the server is in. As requinix says, you have to tell it what timezone to use. There are a couple different ways to do it - either ask the user or use a JavaScript library and pass the data to the PHP.
  3. You'll need to look into AJAX. Basically, using JavaScript you trigger a call (ajax or fetch) to a php script on your server - in the call you pass the selected value. The php script will use this passed value to determine what to show in the next drop-down and return that to the JavaScript which will then display that data to the user as a second drop-down.
  4. You get the data to the server by submitting the form. You can do it traditionally or via AJAX, but either way the data has to be submitted to get to the PHP. I don't know cake, but if you normally get the request data via $this->request->getData() but it's empty in this case then something's wrong elsewhere.
  5. There's probably a Cake-specific method of creating form fields with an array-enabled name, but I don't have the slightest notion what it would be. To answer your other question, you'll need to submit the form data. Whether you do it via AJAX or a traditional HTML submit doesn't matter - send the data to the PHP script and process it there. I'm not going to lie, given what you've described I'm hard-pressed to believe that what you're doing is actually what you want to do, but then again I don't know your project.
  6. You haven't set a value for the drag12 element, so there's nothing for the JS to get.
  7. The data you're sending from AJAX doesn't include a 'submit' index, which loginizer.php requires to do anything.
  8. You can set the domain (and path, even) for cookies.
  9. So CPANEL is a dependency package that you've not included in your script. I don't use cPanel so I'm not sure how it's set up, but there should be a require or include directive in the script somewhere - either it'll include the script directly, or it'll include an autoloader file in which case you'll see a use statement naming the CPANEL class.
  10. Sorry, but this is completely incorrect. Single quotes in PHP will not interpolate variables, while double quotes will. So this: echo '$var'; will output $var , and echo "$var"; will output value
  11. I didn't read all your code, but on a macro-level you have a couple choices. Either get all the information on page load and use PHP to put it into JS variables or HTML data attributes, or use AJAX on the mouse over event and do it dynamically (slower, but IMO a better choice).
  12. It looks like you're trying to combine cURL CLI and cURL php. They aren't interchangeable or compatible. Follow the link gw1500se gave you, then consider NotionCommon's advice.
  13. maxxd

    PHP Objects

    What you've done is create an array of strings. The Book objects that represent 'Moby Dick' and 'Wuthering Heights' are $first_book and $second_book. So this is what you're looking for: $book = array($first_book, $second_book);
  14. In your select query, limit the result by the user ID. I assume you're tracking user ID along with list item, yeah?
  15. Perhaps consider changing to mysqli? Though, truth be told, PDO is easier...
  16. It means that either the body property of your response object doesn't exist or isn't an object. Try putting this at line 11: die('<pre>'.var_export($response, true).'</pre>');
  17. If you're pulling data from WordPress but not using it as the CMS (so basically, it's headless) then your page doesn't know what to do with the WordPress functions you're calling. That's what I mean by mixing CMSs, you're relying on the PHPjabbers stuff to handle the bracketed text replacement and WordPress to hand the_posts(), the_title(), the_excerpt(), etc. Pick one - make sure you include the proper WordPress handler code, or use WordPress and include the PHPjabber script in the WordPress template file and use it there.
  18. It looks like you're mixing CMSs? WordPress by itself doesn't understand mustache notation, so {SCMS_CONTENT_2} means nothing to it unless you're using a theme or plugin that parses that code. the_title() will echo by default - you can turn echo off by passing false to the third parameter.
  19. It's very easy to do that with WordPress if you're not careful. Hit the codex. The documentation for WordPress is actually quite good.
  20. create_callback is the function that's been deprecated - neither preg_replace nor preg_replace_callback have. The second bit of code looks OK from a cursory glance. What's the actual error message you're seeing from it?
  21. What error have you gotten from both lines?
  22. Personally I like to refine and/or finesse the data as necessary in the controller before it reaches the view. This sets up basically very dumb views where any business logic is taken care of before the view is rendered. However, part of the system I'm currently working on does pretty much what you describe and passes raw data directly to the view where it decides what to display and how and it works just fine. As requinix points out, some degree of coupling is pretty much unavoidable so I guess it depends on what's easiest for you reason about.
  23. You're going to have to deal with JavaScript for the fingerprint scanning - try Googling "javascript biometric authentication" .
  24. The first code block doesn't work because of variable scope in PHP. The $fcont inside the class is not the same $fcont as the one outside the class. There are several ways to fix the issue, and given where you appear to be in learning PHP your solution in the second code block is fine albeit not ideal. Another solution is to build the string in the class method and return it to the calling code, which then prints the result. The best and most advanced option is to use a templating language like Twig or Blade, though that's probably going to be a topic for the future.
  25. You shouldn't have multiple elements with the same ID. In your case, your input is being duplicated and the id is "chat_message_{to_user_id}", so when there are multiple instances of the input element they're all assigned the same id - in this case, "chant_message_13".
×
×
  • 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.