Jump to content

requinix

Administrators
  • Posts

    15,229
  • Joined

  • Last visited

  • Days Won

    427

Everything posted by requinix

  1. I removed your warning and reset you back to 0 warning points. Sorry about the misunderstanding.
  2. If you're not pulling in data from any other tables, and all you need from the transaction table is the date, then use MAX with a GROUP BY on the user. SELECT c.firstname, c.surname, c.regDate, MAX(t.lastTrans) AS lastTrans FROM confirmed c LEFT JOIN transaction t ON c.user_id = t.user_id WHERE c.status = 'confirmed' GROUP BY c.user_id ORDER BY MAX(t.lastTrans)
  3. Don't hijack threads. What are you talking about?
  4. Without duplicating the website? I don't know any way for you to keep four distinct sites, with support from search engines, without being penalized for duplication, in a way that you could feasibly have four logos. Duplicating the website is the only way you could have the four sites so each can have their own logo. Internationalization is probably the answer here. Why do you need four domains? What's the difference between them? You know that domain1 vs domain2 and .com vs .co.uk doesn't matter in any technical ways, right? One of those four combinations will be the most appropriate domain name for you to use. If you want to vary the logo but are willing to give up the association with the domain name, you could vary it by the user's IP address: domain1/2.com for US visitors, domain1/2.co.uk for non-US visitors. Or something like that.
  5. Clearly. But that's not what I asked about. Stop doing that. Set up a development environment on your own computer so you can do whatever you want to your code without having to worry about what is happening on the live site. No one will take you seriously as a PHP developer if you keep working directly on your live site. I'm sure. But, again, that's not what I'm asking about. 1. You are getting a 500 page. A 500 page means PHP is crashing. It is crashing because there is an error. You see the 500 page because PHP is not showing you the error message. You need to see the error message to know what is wrong. You cannot fix the problem if you do not know what the problem is. So change those two settings, perhaps with a custom php.ini or with .htaccess settings or with whatever other mechanism your hosting provider gives you to change PHP settings. Then try the page again. 2. What version of PHP are you using? If you do not know then you can use phpinfo.
  6. If you're getting a 500 error then it means you don't have your PHP installation properly set up for development. You are doing this on your own computer and not on a live site, right? Find your php.ini and change two settings: error_reporting = -1 display_errors = onThen restart your web server and try the page again. You should see an error message. Jumping ahead a bit, what version of PHP are you using?
  7. Possible? Sure. Though I'm not sure I understand what you want. Someone enters an email in a form and you send them a random color, code, and place? You're probably not using a database for anything. Make three files, each one with a different color, code, or place on each line. Then the PHP code picks a random line from each file and sends an email with them. Expensive? Depends what you consider to be expensive. It should take less than an hour for a knowledgeable PHP developer to do this.
  8. Use SimpleXML. Example: $xml = new SimpleXMLElement("URL", 0, true); foreach ($xml->property as $property) { // $node["key"] for attributes $reference = (string)$property["reference"]; // $node->name for sub nodes $type = (string)$property->property_type; $street = (string)$property->street; // multiple elements are accessed by their shared name $rooms = count($property->rooms->room); // room is basically an array of <room>s echo "Property {$reference} is a {$type} on {$street} with {$rooms} room(s).\n"; }
  9. If there are any redirections then it should be easy to spot: go to one domain, see if you're redirected to another domain. But if you don't have those redirections then you'll suffer with SEO: having four domains with the same content is not good. You should pick one and go with it, either by redirecting everyone to it or using a rel=canonical to point to the "main" domain's version of the page. Either way, though, search engines will only show one of the sites in their search results. Varying the image on www or non-www domains is... silly. I have no idea why you would want to do that. Varying by .co.uk or .com? Sure. But that sounds like an internationalization thing, and those kinds of issues are handled differently than showing the same site on multiple domains.
  10. What's the rest of the code? The stuff between the query you posted and where you output the date.
  11. Link to an online assignment? Picture of the homework? Something that proves you're not some evil person trying to create an actual phishing website. No offense, but you're new here and this wouldn't be the first time someone's asked for help with something criminal. Not using a proxy would be nice too. (if you don't want it public then you can IM it to me - which you should be able to do so let me know if not)
  12. The time is in there too. Are you sure the dtDate field is a DATETIME and not just a DATE?
  13. Okay. So. echo " <div class='podatak'>That's where the class needs to go. You already have $boja1="divclass1"; $boja2="divclass2";but I don't know which is the normal class and which is the highlight class so I'm just going to guess. Use an if to decide which class you should use. if ($redak['kolicina'] == 0) { $boja = $boja1; } else { $boja = $boja2; }Now put that variable into the HTML. echo " <div class='podatak {$boja}'>
  14. Alright so we're back to my original interpretation of your question. $redak['kolicina'] is the value. If the value is 0 then output one class, otherwise output another class. And as you already know the HTML markup will look like So put the right class name in there.
  15. Uh, what? We're going to need to see some proof of that if you want help.
  16. Then your code doesn't match up with your screenshot? Easiest way: do the query to get the data you want, like normal. Maybe SELECT naziv_lijeka, sifra, jedmjera, kolicina FROM stanje_lijekova WHERE some conditionThen do another query that looks similar but gets a count of how many rows have kolicina=0. SELECT COUNT(1) FROM stanje_lijekova WHERE some condition AND kolicina = 0The first value in the first row will tell you how many there are. So don't use mysql_num_rows() for it.
  17. if (mysql_num_rows($q)>0) { echo $boja1; } else { echo $boja2; }Or maybe I don't understand the question?
  18. Not really: shuffle() is random so you'd end up with a different quote every time. You'd need something more than that. The standard way to deal with this is to use PHP's random number generators (rand(), mt_rand()) but seeding, the way you could get a set of stable random results, isn't reliable anymore: srand() is disabled if PHP is installed with the Suhosin patch/extension and that's popular with shared hosting environments, while mt_srand() won't guarantee the stability because of what it can do to the seed number. A sort of pseudo-random shuffle would be fine: shuffle the items in the array so that quote #N doesn't always appear before quote #N+1. Something like function RandomQuoteByInterval($TimeBase, $QuotesArray){ // Make sure it is a integer $TimeBase = intval($TimeBase); // How many items are in the array? $ItemCount = count($QuotesArray); // Shuffle the array in a way that looks random // 1. Create an array of random strings for each quote $QuotesKeys = array(); foreach ($QuotesArray as $N => $Quote) { $QuotesKeys[$N] = md5($TimeBase . $Quote); } // 2. Sort the keys array normally, and at the same time // rearrange the quotes to match array_multisort($QuotesKeys, $QuotesArray); // By using the modulus operator we get a pseudo // random index position that is between zero and the // maximal value (ItemCount) $RandomIndexPos = ($TimeBase % $ItemCount); // Now return the random array element return $QuotesArray[$RandomIndexPos]; }The downside to using randomness is that a particular quote may show up twice (or more) in a row. There are ways to avoid that...
  19. Pretty simple: use a form to post a password to the page, then only show the page if the right password was sent. Basically, <!-- header of your page, up until the content area --> <?php if (!isset($_POST["password"]) || $_POST["password"] != "yourpasswordhere") { // no password or wrong password ?> <form action="" method="post"> <p>Password: <input type="password" name="password"> <button type="submit">Enter</button></p> </form> <?php } else { // correct password ?> <!-- normal page content --> <?php } ?> <!-- footer of your page -->Every time they visit the page they have to enter the password. It won't "remember" them.
  20. Correct. And it's not random: it cycles through each quote in order... with a limit of 12 quotes because the 'h' value has a range of 1-12. Almost. You have to do the modulus (%) on the total number, not on just the $TimeBase. $RandomIndexPos = ($TimeBase + $currentYear + $currentMonth + $currentDay) % $ItemCount;However, you don't have to do it in RandomQuoteByInterval. In fact I would not. Just call the function with the new number. And while I'm in the code, here's another way of getting the random result: $TimeValue = floor(time() / 3600); // number of hours since Jan 1 1970 // Example array with some random quotes $RandomQuotes = array( 'No animals were harmed in the making of this snippet.', 'Nice snippets', 'The modulus operator rocks!', 'PHP is cool.' ); print RandomQuoteByInterval($TimeValue, $RandomQuotes);As before this is not random: it will cycle through quotes in order. If you wanted it in "truly" random order then you'd need different code...
  21. What's the code for init_session()?
  22. Then rearrange the code so you determine the $mainNav before the header gets included.
  23. str_replace() works by doing each pair of replacements in turn. First, then second, then third, and so on. Since "TBD" will replace to something containing "TB", the "TB" replacement will also work on that. You have to make sure that the array is ordered so that doesn't happen. Moving TBD to the end should do it.
  24. How are you doing the replace? What's the rest of the 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.