Jump to content

scootstah

Staff Alumni
  • Posts

    3,858
  • Joined

  • Last visited

  • Days Won

    29

Everything posted by scootstah

  1. You can also use array_key_exists which is basically the same as isset() (for array's) except that it will return true even if the value of the key is null.
  2. Apart from the very poor design and way too many queries, what's the problem?
  3. No. That only serves to initialize the variable. If you don't do that and your foreach loop doesn't add anything to the array, the if statement below the foreach would throw an error because $add_tags would be undefined. Post all of functions.php.
  4. I'm assuming, then, that you want to create a row for each product ID from your form. You can do that using CodeIgniter's insert_batch() method.
  5. Have you tested it yourself with those browsers?
  6. You probably have an un-closed set of brackets somewhere.
  7. Really? This is the first I've ever heard of PDO. Then today is as good a time as ever to start using it.
  8. There is literally zero reason to not be using either mysqli or PDO. If you're still using mysql you are doing it wrong.
  9. You don't have to necessarily remove database examples - just don't actually communicate with a database. You can use session's to replicate the behavior but only for the specific user using it. This way no user can effect the outcome for another user, and no spam and junk. Another option is to just truncate the tables every so often with a cron job. For file uploads you can just not actually do anything with the file, just leave it in the tmp folder or manually remove it. If it's something that requires the full upload process you can just run a cron job to delete files every so often. Obviously you'd want to disable any script execution for that directory, as well as only allow file types specific to that demo. From glancing at your site, a lot of the snippets should be pretty easy to have demo's for. For a lot of it you can just use equivalent Javascript.
  10. I think you are confused because you have quotes in the variable, so you assume there will be quotes for the src attribute. This, as you can see, is not the case. You will need to add the quotes around the src attribute as Drummin has shown.
  11. You'll need some way of referencing the logged-in user. Usually this is done by adding the user's ID to a session variable. Once you have that you can select that user's information, thus getting his email from the database. From there it's just a matter of setting the $to variable to the email you pulled out.
  12. So how would this be stored in your database? Do you have one row for each element in the array?
  13. get_the_terms() only returns an array if the term is the "taxonomy" is found. Since there is no guarantee an array will be returned, you need to first check if one is before you start your foreach. Something like this ought to work: if ($terms = get_the_terms($post_id, 'post_tag')) { $add_tags = array(); foreach($terms as $term) { if (!in_array($term->slug, $tags_to_add)) { $add_tags[] = $term->slug; } } if (!empty($add_tags)) { wp_add_post_tags($post_id, implode(',', $add_tags)); } }
  14. What does var_dump($blog_posts); give you?
  15. The objects you are trying to access are located within the "data" object. So it looks like instead of foreach($blog_posts as $post) { you need foreach($blog_posts->data as $post) {
  16. He means that there is no way to reference that data from other tables. You'll need to use ID's and such so that you will be able to tell your feedback posts which item they belong to.
  17. If I'm understanding you correctly, you want mysqli_insert_id or the equivalent.
  18. You're trying to fetch additional results from a table that you have already fetched results from - this is completely unnecessary, you already have the information to work with. How are you determining what is a subcategory and what isn't? How many levels deep can your subcategories go?
  19. You probably have magic quotes on which attempts to automatically escape user input. Try turning it off in the php.ini.
  20. You didn't answer my question. EDIT: I see "json" in the URL so I'm guessing that's what you get back. Therefore, you can use file_get_contents to get the contents of the page (presumably a JSON string) which you can then work with. If it is a JSON string, you can use json_decode to turn it into an object.
  21. Is the data formatted in a special way (JSON, XML, etc) or is it just plain text?
  22. I would do something like http://site.com/product/826-EG400-Ergonomic-Chair
  23. It is a big part, but I think the biggest issue is the inconsistency with the language. I'm a mainly PHP programmer, but I can still see all of the silly inconsistencies with the language. Some function names have underscores while very similar ones do not. Some functions have "2" in the name, some have "to". Argument order is seemly random at times. It's not a huge deal for me, I work around it. My IDE shows me hints and such so that it's not a problem. But, it still gives the language bad reputation.
  24. You're probably going to want to have a stream_id column in your photos table, so that you can link it to the appropriate row in the stream.
×
×
  • 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.