Jump to content

JasonLewis

Members
  • Posts

    3,347
  • Joined

  • Last visited

Posts posted by JasonLewis

  1. If you're going for the first option, it's fine to have multiple echos like that but you might want to look at the heredoc syntax.

     

    echo <<<html
    <html>
       <head>
          <title></title>
       </head>
       <body>
       </body>
    </html>
    html;

    Just remember that there can't be any whitespace before the ending of the heredoc syntax, so this is invalid:

    echo <<<html
    This is some output.
       html;

     

    Another thing to note is that if you are using something like this you may encounter header errors when attempting to set cookies or redirect the page because output has already been sent to the browser.

  2. yeah I have worked through all the other issues. This is my last one. I dont even know if its possible to put the output of a dom xpath into an array. I was hoping a veteran php-er would see what im trying to do and explain how to fix it if at all possible.

     

    Hire someone then.

  3. Still a little hazy as to what you're exactly trying to achieve, I see you have another thread though...

     

    Is your code failing? Errors? Not creating correct output? What is your output?

     

    Perhaps this line is giving you an error due to the space?

    $address[$ii->nodeName] = $ii ->nodeValue;

  4. Why don't you just set the HTML attribute type to password instead of text? Even though it will say "********" by default, I'm pretty sure people will realize it's a password, even more so if it's below a text box that says "Username".

     

    As to your question for a PHP solution to your problem. No there isn't. It needs to be client-side, so JavaScript.

  5. It shouldn't require any more changing then what you would need if you were using TAL or Smarty. Creating templates without Smarty or TAL is exactly the same as if you were doing it with Smarty or TAL, it's just faster because you don't need to it to parse and execute into PHP. It all depends on how you implement it as to how much editing would be required if you change something, and that falls back on to how well it was coded.

  6. There is a learning curve with any of those 3 options. If you're going to use smarty, you may as well use just your standard PHP. And I find with templating it's easier to use the alternate syntax with PHP. Even with TAL, there is a learning curve.

     

    <?php foreach($names as $name): ?>
    <tr>
       <td><?php echo $name['last']; ?></td>
       <td><?php echo $name['first']; ?></td>
    </tr>
    <?php endforeach; ?>

     

    Just my opinion, I think if the designer is going to learn something like TAL or Smarty, why not just learn the same things in PHP?

  7. Bet they thought they didn't need your instructions. They're too good for instructions. Heck, if it was a guy that did it, it is true that guys don't read the instructions until they try it themselves and fail about a dozen times. That's when you pull out the instructions.

  8. If you're going to have a really, really long query string, may I suggest using POST instead. Only if it's like really long though, so long that it takes you a while to scroll back through to find the start.

  9. It must be noted though that each different kind of loop is useful in many different circumstances, you just need to pick the one that will suit it best. And often the same thing can be achieved far easier by actually looking at what you need to loop over, and how you need to loop over it before you go ahead and do it with your favorite kind of loop.

     

    The best explanation can be found on the manual:

    while

    for

    foreach

     

    And one that is often overlooked, do-while.

     

  10. I prefer the standard PHP way, it's cleaner and it's faster. If you are giving this to someone that doesn't know PHP or something, then you shouldn't worry, because either way (like ignace said) there will be a learning curve regardless.

  11. Last time I did something like this was for an online store, and I needed to change product prices to the users correct currency. The European Central Bank has a free foreign exchange rates XML file that is updated on a daily basis, so it's not live. But from what I can recall if you want a frequently updated list you'll need to pay for it.

     

    The ECB XML can be found at: http://www.ecb.int/stats/exchange/eurofxref/html/index.en.html

     

    It also includes an example PHP script on how to read the XML file, although I'd use an XML parser.

  12. Note quite sure I follow you exactly, but you want a new window to popup that will show tips for the page they are on. But not all pages have tips, is that right?

     

    If so, you can manually define which pages do not have tips in an array.

     

    $no_tips = array('page_title_1','page_title_2','page_title_3');
    if(in_array($_GET['title'], $no_tips)){
       echo 'There are no tips to this page.';
    }

  13. You can't use update as a field name in MySQL, as it's a reserved word. If you surround it with those inverted ticks (`) then it should work, however it is recommended you select a different name for your field. Like date_update or something.

  14. You have if's and else's all over the place. If you indent your code correctly it becomes easier to notice where you open and close if statements. You actually open an if statement and close it straight away, which is probably causing the problem. You could also join the first two statements so it is:

     

    if(isset($_SESSION['admin2']) && $_SERVER['REQUEST_METHOD'] == 'POST'){

    If you take a look here:

    if(mysql_num_rows($rrr) > 0) {
        } echo '<p class="info" id="error"><span class="info_inner">CHECKING DATABASE: Error, Short Name is taken.</span></p>';

    You are opening the if statement then closing it straight away, then trying to use an else on it which is probably throwing it all off.

  15. Ah, yeah. Easy, instead of doing it like this:

    $id = 80;
    include('path/to/file.php');

    Use:

    $_GET['id'] = 80;

     

    Then the code I showed you before in posts.php can be almost changed back, but we'll use something a bit different.

     

    if(isset($_GET['id']) && preg_match('/[0-9]+/', $_GET['id'])){
      $id = $_GET['id'];
    }else{
      $id = 2;
    }

     

    That checks to see if the ID has been set and that it is a number, you could also use is_numeric if you wanted to instead of the regular expression.

  16. You might need to write a few extra lines, but in the long run it could save you lines. It also removes any overhead from creating multiple queries, because it allows you to bind more params to the statement then execute it again. Most people tend to just use MySQL, however I would recommend switching to at least MySQLi, but I myself prefer to use PDO, as it gives you the added functionality of switching to a different database driver without having to go through and change up all your 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.