Jump to content

Jenk

Members
  • Posts

    778
  • Joined

  • Last visited

    Never

Posts posted by Jenk

  1. Your own post shows pretty much why :)

    you have to specify indices by type and when you use braces, you are extrapolating the variable they encompass. Whe using braces, this reverts back to how you must use them on the php scope, as you should be able to see in your example, all three will throw a notice error because PHP will think you are specifying the Constant called 'variable' and not specifying the string value of 'variable'

    e.g.:
    [code]<?php

    $array['var'] = 'foo'; //indice is a String, as denoted by the apostrophies.

    $string = "blah $array[var] blah"; //works - 'var' is still a string here, because the variable is within a string.

    ?>[/code]
  2. [code]<?php

    $p = '';
    if (!empty($_GET['p'])) $p = $_GET['p'];

    switch ($p) {

        case 'cat_1':
            include $p . '.php';
            break;

        /* snip.. */

        default:
            include 'default.php';

    }


    //etc.[/code]
  3. Actually, I forgot about that. Scrap OSCommerce from my list as it is now very much a dated application and does infact break in most instances off the shelf, requiring several user contributions to be installed (awkwardly in some cases) post main installation which is nothing shy of a PITA.
  4. I'm going to guess you are having problems with the insert and receiving a mysql error message?

    Question (and hopefully you'll be able to figure out the problem from this..)

    Where are your variables defined?
  5. You could use PHP to execute a ping request or similar, and you could even script it to SSH to the box to verify the webserver is running, but over HTTP you will not be able to request the page without it registering a hit - UNLESS the 'hit scoring' system has an exceptions list and you can add a domain/ip/mac-address/login/authentication/etc. clause.
  6. no, just use explicit declarations/definitions such as:
    [code]<?php

    $products = $_POST['products'];

    ?>[/code]

    or just go straight for:
    [code]<?php

    foreach ($_POST['products'] as $product) {
    //etc

    ?>[/code]

    but remember to sanitise your input for its relevant purpose, and to check if there is any input in the first place.
  7. Urgency is something that a project this large does not accomodate, this is not a quick fix/job and you will need to spend considerable time planning.

    Start with: Everytime something needs retrieving, adding or modifying to your database tables, you'll need to generate and execute an SQL statement.
  8. use file system strings, not http:// urls.

    Relative path's can also be used.

    e.g. if your includes are in "/var/www/includes/" but your document root is "/var/www/docroot/" and you want to use an include file in your main index, you can use:

    [code]<?php

    include '../includes/ClassFile.php';

    //etc.

    ?>[/code]

    I prefer to use realpath() to get the absolute path (also to verify the path exists) before including however.
  9. Yes they do.

    register_globals is now set to Off by default and will be removed completely from php6 onwards.

    It is also bad practice to rely upon register_globals.

    also, even if you are relying on register_globals, are they even defined in the $_GET, $_POST, $_COOKIE, $_SERVER or $_FILES superglobal arrays?
  10. include does not work in that way.

    include is just like copying and pasting the code into your script manually.

    a.php:[code]<?php

    echo $a;

    ?>[/code]

    b.php:
    [code]<?php

    $a = 'Hello World!';

    include 'a.php';

    ?>[/code]

    output:
    [code]Hello World![/code]
  11. you'll need to either change your document root directive in httpd.conf and php.ini or change all the files.. choice is yours.

    and re: include syntax:
    [code]<?php include_once '<file>'; ?>[/code] is the correct syntax as mentioned in the php manual. It's a construct, not a function.[/code]
  12. use checkboxes like so:

    [code]<?php

    if (empty($_POST['checkbox']) {

    ?>
    <form action="" method="post">
      <input type="checkbox" name="checkbox[]" value="check1" />
      <input type="checkbox" name="checkbox[]" value="check2" />
      <input type="checkbox" name="checkbox[]" value="check3" />
      <input type="checkbox" name="checkbox[]" value="check4" />
      <input type="checkbox" name="checkbox[]" value="check5" />
      <input type="submit" value="Submit" />
    </form>
    <?php

    } else {

        foreach ($_POST['checkbox'] as $box) {
            echo "<p>Check box: {$box} was checked!</p>\n";
        }

    }

    ?>[/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.