Jump to content

requinix

Administrators
  • Posts

    15,232
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. Make your AJAX return not just HTML but JSON that includes the HTML. Also include in that JSON the latest ID returned. It'll look something like {"latest":123,"html":"whatever it returns now"}Track that "latest" ID somewhere and stick the "html" into the main_page. When they click the Load More button again you can stick that ID in the URL you request. Remember to set the default value of that latest ID with the very same <?php echo $id; ?> thing you were considering using (though it'll be in a slightly different place). Word of advice: don't use the ID to sort items. Use an actual date field. Then make sure you update all the stuff to not use an ID but the latest date value instead. (Pretty much the exact same code, just using a different column for the value.) Oh, and addslashes() is not safe. Use mysql_real_escape_string. Even better would be to stop using the mysql extension and its mysql_* functions and to switch to PDO or mysqli instead.
  2. You can't put HTML in the middle of PHP code. Use <?php to switch from HTML to PHP mode, then ?> to switch back. <?php if($_SESSION['uid'] == 'X') { ?> html and some <?php code and ?> more html <?php } else { ?> more html and <?php code and ?> stuff <?php } ?>
  3. $cTemp is the variable holding the Celsius value. You can round it in two places: 1. When you calculate it 2. When you output it #2 is the best choice: leave the math be as exact as possible and make it only show the one decimal place. That idea of not modifying a value early on and instead waiting until you need to do so (and to do it without permanently modifying the original value) is a good habit to get into as it will help you later with other concepts. Instead of outputting $cTemp, output the result of the round() function; "$val" is the value and "$precision" is the number of decimal places to round to. round($cTemp, 1)
  4. Well, you're not trying to use it anywhere so I don't know what to tell you about why it's not working... round
  5. Unless I'm missing something, all you need to do is make an if/else block for those two conditions, put your existing code in the top half, then copy/paste it into the bottom half and make the couple changes you need. Literally if($_SESSION['uid'] == 'X') { // your existing code } else { // your existing code with a few changes }
  6. Your list of $headers needs a Content-Type with charset=UTF-8. "But I have that already!" You did, but then you overwrote it on the very next line. $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion()."\r\n" . 'Content-Type: text/html; charset=UTF-8'."\r\n";Word of advice: don't try to do mail()ing by yourself. Get something like PHPMailer to do that because it will do a better job than you and for less effort.
  7. $_SESSION['photo'] is empty, right? So where's the code where you set it?
  8. The photo isn't set in there. The problem is in the place where you try to set it, not where you try to use it.
  9. The best style (for PHP) is "consistently". I don't care if you put them on new lines or not, just make sure you do it like that everywhere.
  10. Don't implement sayHello() or sayBye() in your Programming class and see what happens. The result you get is one of the main advantages to interfaces.
  11. file_put_contents Depending on your system you may need to give PHP the permissions to create files in whatever folder: with *nix you can chmod 0777 (not optimal but gets you working quickly) and on Windows it... depends. on things.
  12. Put that thought on hold: if you're starting out then you need to use the PDO or mysqli extension. Not the mysql extension and its mysql_* functions: it's been deprecated for various reasons including it being slow and not as feature-rich as the others. The cause of your problem is how you're calling mysql_query(), but that's moot since you'll be changing the database code.
  13. Where is $cue_brand coming from? Is it from outside the function or did you pass it in as an argument? Or in other words, how about posting a bit more of your code? Namely the entire function definition and the place where you call it.
  14. It kinda sounds like a mobile app would be better suited for this. The device will have the camera and app to scan barcodes, and they're portable so the user can simply go over to the battery to look up its information.
  15. ->bids is an array, ->bids[0] is a CpcBid object, and ->bids[0]->bid is a Money object. $adGroupCriterion->biddingStrategyConfiguration->bids[0]->bid->microAmount
  16. Windows uses semicolons to separate paths. Linux is the one that uses colons.
  17. Any particular reason? Probably not. But a combination of reasons may play a part, such as - Rarely ever makes sense in an true OOP sense. When used it generally violates the idea that a class represents an entity by making a class encapsulate functionality, such as adding database connectivity or providing a "default" implementation for an interface. - Ambiguity of having multiple parents. Like, if two parents both inherit from one single ancestor and each override a particular method, which implementation does a child receive? - Lack of a need. PHP has traits which allows you to "import" functions into classes as if they were written natively. (The concept is also called "mixins".) - Awkwardness. How do you refer to a particular parent from a child? parent won't work as-is and you can't use the parent class's name as that looks like a static method call.
  18. Yup. Whitespace is recommended (a single space) but not required.
  19. Yep. You bet. There are tons of scripts out there that are specifically written to match your database tables, show the content exactly the way you want, and most of them will even apply these "filter" things you speak of with no additional work needed on your part! Amazing, huh? All you have to do is search for "php script that does everything I want" and take your pick
  20. You keep trying this idea of yours of executing multiple queries at once, realizing it's not working, and then insisting that you have to do it with multiple queries. You don't, if for the simple reason that it won't work. Run a query to get the "root" headline elements. Loop over that. Inside the loop you can get the individual bits of data you want. foreach headline as $headline { $category = get the category from the $headline $text = get the text from the $headline output whatever you want }
  21. And? What did you do to actually try to get data from the XML? Have you seen the SimpleXML examples in the documentation?
  22. Do separate queries. Because the alternative is looking at each node and figuring out which of the patterns it matches. And that's just silly since you had DOMXPath do all that work for you already only a second earlier.
  23. I meant the code having to do with searching your database. Because that's where the problem is.
  24. Post code.
  25. You're open to SQL injection and it has nothing to do with your URL rewriting (which I don't think you're using quite the way you wanted to use... but more on that later). What's your PHP code?
×
×
  • 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.