Jump to content

Jenk

Members
  • Posts

    778
  • Joined

  • Last visited

    Never

Posts posted by Jenk

  1. for pure semantics change your query to:

    [code]<?php

    $result=mysql_query("UPDATE `forum_messages` SET `hits` = `hits` + 1 WHERE `id` ='$id'");

    ?>[/code](also note you were missing a closing apostrophe after $id)

    now check that you don't run the query twice in the process of your application logic.
  2. Depends on your classes constructor.

    (below is PHP5)
    [code]<?php

    class Foo
    {
        protected static $bar;

        public function __construct ($bar)
        {
            self::$bar = $bar;
        }
    }
    ?>[/code]

    That will set the static property of the class to $bar - thus every object that utilises that static property will receive the same value.

    [code]<?php

    class Foo
    {
        protected $bar;

        public function __construct ($bar)
        {
            $this->bar = $bar;
        }
    }

    ?>[/code]

    That will set the property of the object to $bar, thus only that instance of the object will maintain the value.
  3. [code]<?php
    session_start();

    $_SESSION['variable'] = 'foobar';

    ?>[/code]

    That's all you need to start a session and to assign a session variable, php does the rest for you.

    Just remember to have session_start(); at the top of every page before _any_ output is produced, and the session data, if still valid, will be accessible via $_SESSION superglobal.
×
×
  • 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.