Jump to content

Daniel0

Staff Alumni
  • Posts

    11,885
  • Joined

  • Last visited

Everything posted by Daniel0

  1. Well, that depends. If you're getting it from a database you could do something like this: $id = isset($_GET['id']) ? (int) $_GET['id'] : 0; // or you could do: $id = (int) filter_input(INPUT_GET, 'id', FILTER_UNSAFE_RAW) $result = mysql_query('SELECT * FROM users WHERE id = ' . $id . ' LIMIT 1'); if (mysql_num_rows($result)) { $user = mysql_fetch_assoc($result); // do stuff } else { echo 'User does not exist.'; }
  2. if (!isset($_GET['id'])) { echo 'hi'; }
  3. Well, say you have something like this in a form: <label for="pickupMonth">Month:</label> <select name="pickup[month]" id="pickupMonth"> <option value="1">January</option> <option value="2">February</option> <!-- etc. --> <option value="12">December</option> </select> <label for="pickupDay">Day:</label> <select name="pickup[day]" id="pickupDay"> <option value="1">1</option> <option value="2">2</option> <!-- etc. --> <option value="31">31</option> </select> <label for="pickupYear">Year:</label> <input type="text" name="pickup[year]" id="pickupYear"> Then you can do like this: if (!isset($_POST['pickup']['month']) || !isset($_POST['pickup']['day']) || !isset($_POST['pickup']['year'])) { echo 'please complete all fields'; } else if (!checkdate((int) $_POST['pickup']['month'], (int) $_POST['pickup']['day'], (int) $_POST['pickup']['year'])) { echo 'please enter a valid date'; } else { $mysqlDate = sprintf('%04d-%02d-%02d', $_POST['pickup']['year'], $_POST['pickup']['month'], $_POST['pickup']['day']); } To validate the date and make it fit a MySQL DATE field, which is stored in ISO 8901 format (that is YYYY-MM-DD).
  4. You have this: while($getmsg3=mysql_fetch_array($getmsg2)) { $message=' '; $message=Smiley($message); //Smiley faces print "<font color='teal'><b>$getmsg3[name]:</b></font> $getmsg3[message]<br>"; } It should be: while($getmsg3=mysql_fetch_array($getmsg2)) { $getmsg3['message'] = Smiley($getmsg3['message']); print "<font color='teal'><b>$getmsg3[name]:</b></font> $getmsg3[message]<br>"; }
  5. Something like $query = 'SELECT * FROM table'; $where = array(); if (!empty($first_name)) { $where[] = "first_name LIKE '%" . mysql_real_escape_string($first_name) . "%'"; } // same thing for the other fields if (count($where)) { $query .= 'WHERE ' . join(' OR ', $where); }
  6. Generate the query dynamically and only add those conditions if the user specified them via the form.
  7. You will have to do $getmsg3['message'] = Smiley($getmsg3['message']);
  8. Knock off your personal attacks. Both in PMs and here. You've been told the solution numerous times. I refuse to help you anymore.
  9. It makes perfect sense. In the latter you are making the red text a link. In the former you are trying to make the link red, but seeing as the link already has its own style it's not affected by the rule you're trying to apply. If you cannot (or will not) understand it, then there is nothing I can do about it. You can show me all the screenshots in the world, but that doesn't mean you are right. You cannot say X is Y, therefore Z is Y when X and Z aren't the same things.
  10. Seriously... Can you tell me the difference between these two things? <span style="color:red"><a href="#">foo</a></span> <a href="#"><span style="color:red">foo</span></a> Maybe you should stop acting smug when you don't know what you're doing.
  11. Right, that's what I'm telling you. It will not result in a red link. You have to style the link yourself, hence the reason why you should learn CSS. I don't build bridges without knowing physics either.
  12. You could also periodically load new messages using AJAX and generate the DOM elements. That would prevent refreshing.
  13. Plain <font color="red">foo <a href="#">bar</a></font> will never result in a red link. Things aren't horseshit because you don't know how to use them. On the contrary, one could attach certain adjectives to you because you are using the things incorrectly, but I shall refrain from doing so.
  14. Yeah, there is a reason. As I said, you should learn CSS. You need to apply rules to a selector called .se a otherwise the a will take precedence.
  15. Try something like this in your frame: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Test</title> </head> <body> <div> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br> foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo<br>foo </div> <script type="text/javascript"> window.onload = function() { window.scrollTo(0, document.body.scrollHeight); } </script> </body> </html>
  16. Oh alright So class="supercoolawesomelink" is better? Yeah, or "closed", or "important" or whatever.
  17. If it's as "good" as SMF's, good luck trying to integrate it with anything. These kind of things are typically written so you will have to build your site around them and not so you can use them as a library.
  18. Variable names cannot start with numbers. Maybe PHP is treating your regex back references as variables.
  19. Uh... yeah. It's built into every browser. Otherwise text that isn't explicitly styled by the web developer would be displayed all next to each other. I think what you should do is to learn about CSS. Amtran, class="red" is pointless. Classes should convey semantics, not presentation. What if you decide that all the links that have class="red" should later be blue?
  20. <div style="height:200px;overflow:auto" id="theDiv"> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br /> foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo<br />foo </div> <script type="text/javascript"> object = document.getElementById('theDiv'); object.scrollTop = object.scrollHeight; </script> Doesn't result in a noticeable lag between page load and scroll.
  21. Because it's a CSS issue, not a PHP issue. Just because you used PHP to output it doesn't mean it's where the problem is. You missed this part:
  22. The global keyword and the $GLOBALS superglobal variable are both one of the very bad ideas implemented in PHP. Just saying. Learn how to pass things by argument and how to return values from a function.
  23. You should have a strict DOCTYPE regardless. As for your problem, instead of using inline styles, define a class and then style it and the links within it. If you just try this: <span style="color:red">foo <a href="http://phpfreaks.com">test</a></span> you'll see that it will not result in a red link either. That's just not how things work.
×
×
  • 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.