Jump to content

Adam

Moderators
  • Posts

    5,717
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Adam

  1. if ($_GET["name"]!='' OR $_GET["name"]!='Name' OR $_GET["email"]!='' OR $_GET["email"]!='Email' ) { You should use "&&" (or "AND") here, as you want to only continue if ALL of the checks pass. At the moment only one has to evaluate to true for the inputs to be considered valid. Also instead of checking for an empty string like that, use the empty() function: if (!empty($_GET["name"]) && $_GET["name"] != 'Name' && !empty($_GET["email"]) && $_GET["email"] != 'Email') { Currently if $_GET['name'] or $_GET['email'] do not exist, you'll get a PHP error notice. empty() performs an implicit isset() check, so you're checking that it exists, and that it's not empty, in one go. Which of the errors do you get back?
  2. To use single quotes within single quotes, you just need to escape them with a \'backslash\'. check_username('document.getElementById('username').value'); However as you have quotes around the document.get(...) call, you're actually passing the entire thing as it's literal value - as a string - instead of the return object.
  3. Contradicting yourself completely there. No, MySQL only supports row-level update triggers. As I said you can check which column was updated using IF statements, but you can't define the trigger to only execute when a certain column is updated.
  4. There's no link to the forum rules right now
  5. This wouldn't be possible with JavaScript. You need to be able to connect to and query the forum's database, open and write to files, etc. JavaScript is a client-side technology, built-in to the browser. You need a server-side language like PHP. Personally I'd tackle this one problem at a time; first learn how to connect and query the database to find the right data you need. Then learn how to open and write to files in the Google Spreadsheet format (I have absolutely no experience working with Google documents like this, so I can't offer any advice here). Then figure out how to combine the two to produce what you need. Unfortunately, unless you're lucky enough to come across someone that's wanting to accomplish something similar, you won't find somebody willing to do this for you for free. However as I said, tackle it one step a time and it'll be easier..
  6. MySQL only supports row level triggers, like most database platforms. You can check if a column was updated however using the NEW. and OLD. values: IF OLD.col_name <> NEW.col_name THEN ... END IF That should allow you to only perform further statements in certain situations. Was that your second question?
  7. A 'wildcard' is a character that can take any value. What does the ampersand indicate here? Looks like you're trying to parse out the text after it?
  8. $url = $_SERVER['PHP_SELF']; $path = pathinfo($url); $filename = $path['filename'] . "." . $path['extension']; // Is the same as.. $filename = basename($_SERVER['PHP_SELF']); Issue I'd raise with this, is that if you change the file name or want to re-use the code you have a very limited implementation. Personally I'd check for a flag within the header (which is the filename to redirect to), but define that within the code that includes the header. For example (and only guessing certain parts of your code obviously)... successful_login.php: [...] // Set the redirect flag $javascript_redirect = '01.php'; // Include the header require_once 'header.php'; [...] header.php: [...] <?php if (!empty($javascript_redirect)) { ?> <script type="text/javascript"> function delayedRedirect(){ window.location = '<?php echo $javascript_redirect; ?>'; } </script> <?php } ?> [...] This also has the benefit of splitting the application - "business" - logic from the template - "view" - logic, whilst making it easily re-usable. As I think I made fairly clear I'm not a fan of this kind of thing, but if you want to do it may as well do it well Edit Forgot to mention, the onload event would also need an !empty() check on the flag, but I'd recommend assigning that within the same block of JavaScript: window.onload = function() { // ... }
  9. I doubt you'll suffer much with performance then. When you say 'some dozen' - is that all at once, repetitively?
  10. Do you need to redirect the user like that? Like the META refresh tag they can get users "stuck" temporarily when trying to go back in the browser's history. It's bad for usability and quite a dated concept these days - I mean do you really need to be told you have logged in after you just filled out a login form? Why not just take them straight back to the page they were at before? That's what the user really wants; speed and ease!
  11. Adam

    if exists

    Show us the PHP you're using to make the query.
  12. Adam

    if exists

    Well then you should just let the query return 0 rows and check for an empty result set within the application.
  13. Yeah you just need to feed in the variable where you have it saved: $headers = "From: {$from_email}\r\n";
  14. Inserting into the table alone, whilst still obviously taking longer than a thinner table, shouldn't be much of an issue. Do you have any indexes on the table however?
  15. Adam

    if exists

    You cannot use an IF statement in MySQL out of a routine (i.e. stored procedure or function). Also EXISTS is for use on sub-queries. What exactly is it's purpose in being there?
  16. echo number_format(3.40, 4, '.', ''); That should, and for me does, return 3.4000.
  17. Yeah that's the kind of reasoning I was looking for. You could do it this way then: <table> <?php foreach ($item_num as $key => $item) { ?> <tr> <td><input value="<?php echo $item; ?>" name="item[]" size="9"></input></td> <td><input value="<?php echo $item_disc[$key]; ?>" name="disc[]" size="33"></input></td> </tr> <?php } ?> </table>
  18. I guess you didn't put any thought into what I said. I was suggesting a better to way to structure the array, that would make looping through it simpler. All you'd have to do with that type of structure is: <table> <?php foreach ($items as $item) { ?> <tr> <td><input value="<?php echo $item[0]; ?>" name="item[]" size="9"></input></td> <td><input value="<?php echo $item[1]; ?>" name="disc[]" size="33"></input></td> </tr> <?php } ?> </table>
  19. Wouldn't a better structure for the array then be: $items = array( array( "00000", "Some info for 0" ), array( "00001", "Some info for 1" ), array( "00002", "Some info for 2" ) ); By the way what you had before was not a multi-dimensional array.
  20. You need to set the 'From' header and pass it in to the mail() function as the 4th "additional headers" parameter: $headers = "From: [email protected]\r\n"; mail(.., .., .., $headers); As you may have noticed the headers are a string and delimited between a CRLF (Carriage return/linefeed - "\r\n"). You can add other headers to the string too, like 'Reply-To': $headers = "From: [email protected]\r\n"; $headers .= "Reply-To: [email protected]\r\n";
  21. I love the Shutterstock(?) watermark lines on your blog header
  22. If I understand you right, with or without jQuery, you'd need to preserve the DIV state(s) by passing a parameter(s) within the pagination links. As an example: <a href="pagination.php?page=2&show_more=1">Next</a> Then at the end of your <body>: <?php if (!empty($_GET['show_more']) && $_GET['show_more']) { ?> <script type="text/javascript"> document.getElementById('my_div').style.display = 'block'; </script> <?php } ?> That's just to demonstrate the logic a little, fitting it into your own code will require some work. I wouldn't use this method myself though as it relies upon JavaScript to show the contents - though I'm not certain I followed your explanation well.
  23. When you set the src of the image, add a few random digits on the filename like you would parameters for a normal page: document.getElementById("img").src = link + '?rid=' + Math.random(); It'll still point to the same image, but the browser will cache it separately.
  24. The first script defines functions that are then used within the second, so the order is required.
×
×
  • 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.