Jump to content

scottybwoy

Members
  • Posts

    532
  • Joined

  • Last visited

    Never

Everything posted by scottybwoy

  1. Try using the table and 68 together.  ;) Or I found this CSS function that might help using visable or auto may do it http://www.w3schools.com/css/pr_pos_overflow.asp I think visable may just display the right edge over the other element, may look OK if your image is big enough down that side.
  2. Have you tried changing 69 to 68 in your text wrap function?  Or alternatively stick in another <table border="0" cellpadding="0" cellspacing="0" width="486">   <tr> just under your middle row with the $post in and close it after your <td's> I know it's a bit messy but will stop it messing up the cells in the row above.  If anyone knows a better way, I'd like to know also.
  3. I also have a query about this topic. For instance say you have a form in template.html and ths form is for making a Sale.  You have a dropdown list of items that can be sold and the pricing and quantity have to be confirmed by the user.  Below this function, after pressing the confirm button, I'd like an expandable section below it to show all the products being purchased.  How should I create my html template to take this dynamic data from the php sent to it? Thanks
  4. Since trying to get rid of Database abstraction from a tutorial project, that I have used as my basis.  I get this error : PHP Warning: Wrong parameter count for mssql_result() in C:\Inetpub\wwwroot\database\classes\lib.session_handler.php on line 31 PHP Warning: Wrong parameter count for mssql_result() in C:\Inetpub\wwwroot\database\classes\lib.session_handler.php on line 49 PHP Warning: Wrong parameter count for mssql_result() in C:\Inetpub\wwwroot\database\classes\lib.session_handler.php on line 56 Heres the first block of code, as it's the same error for each function I won't post the others. [code] <?php         function sess_read($key) {                 global $DEBUG, $SESS_LIFE; $statement = "SELECT value FROM sessions WHERE sesskey = '$key' AND expiry > " . time();                 $result = mssql_result("SELECT value FROM sessions WHERE sesskey = '$key' AND expiry > " . time()); //this is line 31                 if ($DEBUG) echo "sess_read: $statement <br>result: $result<br>";                 if ($result) { $row = mssql_fetch_assoc($result); return $row['value']; } return false;         } ?> [/code] It looks like a simple error but I don't know what a perameter count is and it looks fine to me. Thanks in advance
  5. Right I have worked out that what was entered was wrong as the mssql_query returns a TRUE or FALSE value, and have now swapped it for mssql_result and have edited it as follows : [code] <?php         function sess_read($key) {                 global $DEBUG, $SESS_LIFE; $statement = "SELECT value FROM sessions WHERE sesskey = '$key' AND expiry > " . time();                 $result = mssql_result("SELECT value FROM sessions WHERE sesskey = '$key' AND expiry > " . time());                 if ($DEBUG) echo "sess_read: $statement <br>result: $result<br>";                 if ($result) { $row = mssql_fetch_assoc($result); return $row['value']; } return false;         } ?> [/code] Now will this match the code supplied in the two boxes above and miss out the abstraction layer?
  6. OK Beginning to understand that objects are a bit like arrays.  I thaught that I was getting an  array with the value from my sessions table where that particular user was logged in.  Then passing it to the query function, (which I thaught did the DB Abstraction bit) and returned the result back to sess_read, which then went off to get the row that value is found in and return that value or return FALSE. Can anybody confirm if that is correct from the bits of code posted and tell me if Thorpe's version is the same as the code I posted directly below his, but without the abstraction bit? Many Thanks, I think I'm beggining to get somewhere on this problem.
  7. Thanks Thorpe for your time, but I think I have been going about it wrong then, this was the original sess_read function that I changed to the one in the first msg : [code] <?php function sess_read($key) {                 global $dbi, $DEBUG, $SESS_LIFE;                 $statement = "SELECT value FROM sessions WHERE " .                       "sesskey = '$key' AND expiry > " . time();                 $result = $dbi->query($statement);                 if ($DEBUG) echo "sess_read: $statement <br>result: $result<br>";                 $row = $result->fetchRow();                 if ($row) {                   return $row->value;                 }                 return false;         } ?> [/code] Which passes the $statement to function query() in a file called class.DBI.php and works like so : [code] <?php       function query($statement)       {         $result =  $this->dbh->query($statement);         if (DB::isError($result))         {             $this->setError($result->getMessage());             return null;         } else {             return $result;         }       } ?> [/code] So does that mean that result was an object and what I had edited just brought back a true of false? I thaught that this file was just being scanned to see if there was a session already open before moving on to the login page, could you see from what I have posted if it is doing more than that. Thanks in Advance
  8. I mean that within my lib.session_handler.php it had code within function sess_read() listed above that used PEAR, however I swapped it like so above to not use PEAR, now I'm left with that error and the extra stuff I don't know what it does.  Please help am fairly new to php and this is doing my head in.  Thanks
  9. Yeah, I changed that bit already, but then it sticks the result into fetchRow which is integrated into PEAR's DB.php, which is why I posted the functions.  See these Entries : DB_FETCHMODE_DEFAULT DB_FETCHMODE_OBJECT DB_FETCHMODE_ASSOC What are they all about?  And I want rid of that error, but don't really understand it.  Thanks
  10. Also can you heve one template that is the main template that will always be there and have different templates fill the middle bit, or must you use frames?
  11. Hi all, Having a problem with this function : [code] <?php         function sess_read($key) {                 global $DEBUG, $SESS_LIFE;                 $result = mssql_query("SELECT value FROM sessions WHERE sesskey = '$key' AND expiry > " . time());                 if ($DEBUG) echo "sess_read: $statement <br>result: $result<br>";                 $row = $result->fetchRow();                 if ($row) {                   return $row->value;                 }                 return false;         } ?> [/code] It returns this Error : PHP Fatal error: Call to a member function fetchRow() on a non-object in C:\Inetpub\wwwroot\database\classes\lib.session_handler.php on line 33 Now the fetchRow() function it is on about lies in the PEAR DB Class which is shown below : [code] <?php     /**     * Fetch and return a row of data (it uses driver->fetchInto for that)     * @param int $fetchmode  format of fetched row     * @param int $rownum    the row number to fetch     *     * @return  array a row of data, NULL on no more rows or PEAR_Error on error     */     function fetchRow($fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null)     {         if ($fetchmode === DB_FETCHMODE_DEFAULT) {             $fetchmode = $this->dbh->fetchmode;         }         if ($fetchmode === DB_FETCHMODE_OBJECT) {             $fetchmode = DB_FETCHMODE_ASSOC;             $object_class = $this->dbh->fetchmode_object_class;         }         if ($this->dbh->limit_from !== null) {             if ($this->row_counter === null) {                 $this->row_counter = $this->dbh->limit_from;                 // For Interbase                 if ($this->dbh->features['limit'] == false) {                     $i = 0;                     while ($i++ < $this->dbh->limit_from) {                         $this->dbh->fetchInto($this->result, $arr, $fetchmode);                     }                 }             }             if ($this->row_counter >= (                     $this->dbh->limit_from + $this->dbh->limit_count))             {                 return null;             }             if ($this->dbh->features['limit'] == 'emulate') {                 $rownum = $this->row_counter;             }             $this->row_counter++;         }         $res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum);         if ($res !== DB_OK) {             return $res;         }         if (isset($object_class)) {             // default mode specified in DB_common::fetchmode_object_class property             if ($object_class == 'stdClass') {                 $ret = (object) $arr;             } else {                 $ret =& new $object_class($arr);             }             return $ret;         }         return $arr;     }     /**     * Fetch a row of data into an existing variable.     *     * @param  mixed $arr        reference to data containing the row     * @param  int  $fetchmode  format of fetched row     * @param  int  $rownum    the row number to fetch     *     * @return  mixed  DB_OK on success, NULL on no more rows or     *                a DB_Error object on error     */     function fetchInto(&$arr, $fetchmode = DB_FETCHMODE_DEFAULT, $rownum=null)     {         if ($fetchmode === DB_FETCHMODE_DEFAULT) {             $fetchmode = $this->dbh->fetchmode;         }         if ($fetchmode === DB_FETCHMODE_OBJECT) {             $fetchmode = DB_FETCHMODE_ASSOC;             $object_class = $this->dbh->fetchmode_object_class;         }         if ($this->dbh->limit_from !== null) {             if ($this->row_counter === null) {                 $this->row_counter = $this->dbh->limit_from;                 // For Interbase                 if ($this->dbh->features['limit'] == false) {                     $i = 0;                     while ($i++ < $this->dbh->limit_from) {                         $this->dbh->fetchInto($this->result, $arr, $fetchmode);                     }                 }             }             if ($this->row_counter >= (                     $this->dbh->limit_from + $this->dbh->limit_count))             {                 return null;             }             if ($this->dbh->features['limit'] == 'emulate') {                 $rownum = $this->row_counter;             }             $this->row_counter++;         }         $res = $this->dbh->fetchInto($this->result, $arr, $fetchmode, $rownum);         if (($res === DB_OK) && isset($object_class)) {             // default mode specified in DB_common::fetchmode_object_class property             if ($object_class == 'stdClass') {                 $arr = (object) $arr;             } else {                 $arr = new $object_class($arr);             }         }         return $res;     } ?> [/code] So two things I ask, is that I don't really understand the error message.  And I'd also like to cut out the middle-man (PEAR), so how could I create the function to just use MsSql. Thanks in advance
  12. This Guy here [url=http://forums.invisionpower.com/lofiversion/index.php/t198295.html]bfarber[/url] knows what I was trying to explain. That way you would only need one file for the top, middle and bottom and call the parts at seperate intervals. In theory one can also have a main bit of template also included that for intance has buttons to view reports, but with them labled like so in the html template: [code] <html> <head> <title>MyTitle</title> <meta.... </head> <body> <!-- START Administrator --> <a href='superReport.php'>superReport</a> <!-- START Accounts --> <a href='accountsReport.php'>accountsReport</a> <!-- START Sales --> <a href='salesReport.php'>salesReport</a> <!-- END Sales --> <!-- END Accounts --> <!-- END Administrator --> </body> </html> [/code] Now in your php file have this : [code] <?php function whoReport() if { userType => 3 // 3 = Administrator $this->ipsclass->template['_wrapper'] = str_replace( "<!-- START Administrator -->" , $this->ipsclass->compiled_templates['skin_global']->adminReport(), $this->ipsclass->template['_wrapper']); } else if { userType => 2 // 2 = Accounts $this->ipsclass->template['_wrapper'] = str_replace( "<!-- START Accounts -->" , $this->ipsclass->compiled_templates['skin_global']->accountsReport(), $this->ipsclass->template['_wrapper']); } else { userType => 1 // 1 = Sales $this->ipsclass->template['_wrapper'] = str_replace( "<!-- START Sales -->" , $this->ipsclass->compiled_templates['skin_global']->salesReport(), $this->ipsclass->template['_wrapper']); } ?> [/code] Along those lines, please note that code won't work.  But you can see what I am trying to do now I hope.  But if someone does know how to do this properly can they help me out, thanks.
  13. I have now also noted that when I query the database on it's own I find that there is no session key stored in there at all but when I press refresh, it gives a new key for the column name in the error and also it doesn't seem to have any time value at the end of the session key string. :'([color=red]Can some one please read through and help me find the answers cos it's really starting to bug me.  Many Thanks[/color] :'(
  14. Is this a valid MSSQL Query ? [code] <?php $result = mssql_query("SELECT value FROM sessions WHERE sesskey = $key AND expiry > " . time()); ?> [/code] In my example in the post above, there should be nothing interfering with the query is there? If so why do I get this error, and how is a session key generated?
  15. Not sure if my amendmet above really helped, looking at the way it's processed in PEAR's DB.php so changed it back to in lib.session_handler.php: [code] <?php $DB_URL = "mssql://user:pass@localhost:/sessions"; ?> [/code] Although I think it is passed to the Database Abstraction Class called class.DBI.php so changed the function from the commented block to the uncommented block like so : [code] <?php function connect()       {         // connect to the database         /* $status = $this->dbh = DB::connect($this->db_url);         if (DB::isError($status))         {             $this->connected = FALSE;             $this->error = $status->getMessage();         } else {             $this->connected = TRUE;         }         return $this->connected; */ mssql_connect("localhost", "tecnical", "micro")   or die; "Could not connect to database"; mssql_select_db("sessions") or die; "Could not select database";       } ?> [/code] Only to get this error : PHP Warning: mssql_query() [function.mssql-query]: message: Invalid column name 'pplg3pvool34o0ecl98v0d8101'. (severity 16) in C:\Inetpub\wwwroot\database\classes\lib.session_handler.php on line 31 PHP Warning: mssql_query() [function.mssql-query]: Query failed in C:\Inetpub\wwwroot\database\classes\lib.session_handler.php on line 31 PHP Fatal error: Call to a member function fetchRow() on a non-object in C:\Inetpub\wwwroot\database\classes\lib.session_handler.php on line 34 Which shows it is connecting to the database after what I have done, but looks as though it is using the session key as a column name or has passed some crap through the DB.php What do you think people? Here's the query in lib.session_handler.php : [code] <?php function sess_read($key) {                 global $dbi, $DEBUG, $SESS_LIFE;                 $result = mssql_query("SELECT value FROM sessions WHERE sesskey = $key AND expiry > " . time());                 if ($DEBUG) echo "sess_read: $statement <br>result: $result<br>";                 $row = $result->fetchRow();                 if ($row) {                   return $row->value;                 }                 return false;         } [/code]
  16. I'm new also, but I don't see why you'd want to have it going through the address as it is a massive security risk. Think about it, if someone is reading the address bar, thay can take out the encoded string and de-crypt it then use it to log in to your restricted areas and do what they want, especially using this basic form of encryption.  Google MD5 or better SHA1 for a lesson on encrytion.  Also when there is a function you don't understand, if your using Firefox, add a php search to your bar and just copy and paste it in for a quick reference, it'll make your life and everybody that is helping you. Also refer back to the point made in the begining of this section about using ' and "
  17. Yeah I understand this much, from what I have learned about templates so far, is to have seperate template.html files set up as such : [code] <html> <head> <title>MyTitle</title> <meta.... </head> <body> <!-- START MainBody --> This is the body of that page <!-- END MainBody --> </body> </html> [/code] Then to have your file.php to call the code within the template between the comment blocks, however I don't know how it does it? This way I can say : If userID = foo then display baa else display foobaa Any Pointers?
  18. Is that the same as having seperate .html files and including <!-- Start and End Comment Blocks --> Where you want to insert your php code? I understand that.  What I don't quite get is how the .php file knows when to insert itself into the .html template.  Can anyone point me in the right direction.  Thanks
  19. function fetchRow () Is defined it the PEAR DB Library under DB.php and does this : /**     * Fetch and return a row of data (it uses driver->fetchInto for that)     * @param int $fetchmode  format of fetched row     * @param int $rownum    the row number to fetch     *     * @return  array a row of data, NULL on no more rows or PEAR_Error on error     */ fetchInto does this : /**     * Fetch a row of data into an existing variable.     *     * @param  mixed $arr        reference to data containing the row     * @param  int  $fetchmode  format of fetched row     * @param  int  $rownum    the row number to fetch     *     * @return  mixed  DB_OK on success, NULL on no more rows or     *                a DB_Error object on error     */ These functions can be found ported with the PEAR Framework if anyone wants it. However for this project I don't actually need Database abstraction but I do not know how to go about re-writing what it is trying to do without having to use PEAR.  I know that it will probably be easier to solve this problem, but I feel I would learn more if someone helped me with this. This problem may help to solve this problem swiftly though if anyone can see it? [code] <?php function connect()       {         // connect to the database         $status = $this->dbh = DB::connect($this->db_url);//error lies after dbh expected ';' & '}'         if (DB::isError($status))         {             $this->connected = FALSE;             $this->error = $status->getMessage();         } else {             $this->connected = TRUE;         }         return $this->connected;       } ?> [/code] In addition to this I have noticed in my editor, that function 'connect'() shows in green like 'define' 'stripos' and other built in php functions, although I could not find it in the php manual. Further experimentation I changed this line in lib.session_handler.php [code] $DB_URL = "mssql://user:pass@localhost:/sessions"; //into $DB_URL = 'mssql_connect("localhost", "user", "pass")   or die "Could not connect to database" mssql_select_db("sessions") or die "Could not select database"'; [/code] And now get this error : PHP Fatal error: Call to undefined method DB_Error::query() in C:\Inetpub\wwwroot\database\classes\class.DBI.php on line 83 Within this Function [code]<?php function query($statement)       {         $result =  $this->dbh->query($statement);         if (DB::isError($result))         {             $this->setError($result->getMessage());             return null;         } else {             return $result;         }       } ?>[/code]
  20. Ha HA! Sort of solved.  I have cured my error of the missing ; and all my addresses are finding the files they require.  What had happeded way my concatonated variables setting directory paths were double up because I set them wrong in the first place, sorry for your time. Although I would still like someone to look over the code I have entered above to help me understand where my login script is being called.  Thanks in advance.
  21. So do you open index.html in the browser or index.php?
  22. These parts may also help. In class.PHPApplication.php [code] <?php class PHPApplication {     function PHPApplication($param = null)     {         global $ON, $OFF, $TEMPLATE_DIR;         global $MESSAGES, $DEFAULT_LANGUAGE,               $REL_APP_PATH,               $REL_TEMPLATE_DIR;         // initialize application         $this->app_name = $this->setDefault($param['app_name'], null);         $this->app_version = $this->setDefault($param['app_version'], null);         $this->app_type = $this->setDefault($param['app_type'], null);         $this->app_db_url = $this->setDefault($param['app_db_url'], null);         //$this->debug_mode = $this->setDefault($param['app_debugger'], null);         $this->auto_connect = $this->setDefault($param['app_auto_connect'], TRUE);         $this->auto_chk_session = $this->setDefault($param['app_auto_chk_session'], TRUE);         $this->auto_authorize = $this->setDefault($param['app_auto_authorize'], TRUE);                 $this->session_ok      = $this->setDefault($param['app_auto_authorize'], FALSE);         $this->error = array();         $this->authorized = FALSE;         $this->language        = $DEFAULT_LANGUAGE;         $this->base_url        = sprintf("%s%s", $this->get_server(), $REL_TEMPLATE_DIR);         $this->app_path        = $REL_APP_PATH;         $this->template_dir = $TEMPLATE_DIR;         //$this->messages         = $MESSAGES;         // start session         if (strstr($this->get_type(), 'WEB'))         {             session_start();             $this->user_id          = (! empty($_SESSION["SESSION_USER_ID"]))  ? $_SESSION["SESSION_USER_ID"] : null;             $this->user_name        = (! empty($_SESSION["SESSION_USERNAME"])) ? $_SESSION["SESSION_USERNAME"]: null;;             $this->set_url();             if ($this->auto_chk_session) $this->check_session();             if (! empty($this->app_db_url) && $this->auto_connect && ! $this->connect())             {                 $this->alert('APP_FAILED');             }             if ($this->auto_authorize && ! $this->authorize())             {               $this->alert('UNAUTHORIZED_ACCESS');             }         }     }     function getNAME()     { $domain_user = explode("\\", $_SERVER['LOGON_USER']); $name = $domain_user[1]; list($name, $host) = $name;         return ucwords($name);     }     function check_session()     {         if ($this->session_ok == TRUE)         {             return TRUE;         }         if (!empty($this->user_name))         {             $this->session_ok = TRUE;         } else {             $this->session_ok = FALSE;             $this->reauthenticate();         }         return $this->session_ok;     }     function reauthenticate()     {         global $AUTHENTICATION_URL;                          header("Location: $AUTHENTICATION_URL?url=$this->self_url");                    }     function getBaseURL()     {         return $this->base_url;     } ?> [/code] This is only half of it, (ignore the missing "}'s" )but I think it's the important bit for locating what I want to know. This is in config.inc.php [code] <?php $ROOT_PATH    = $_SERVER['DOCUMENT_ROOT']; $INTRANET_DIR = $ROOT_PATH . '/database'; $SCRIPTS = $ROOT_PATH . $INTRANET_DIR . '/scripts'; $AUTHENTICATION_URL  = $SCRIPTS . '/login/login.php'; ?> [/code] Thanks for looking
  23. Thanks, another question, does this : [code]<?php header("Location: $AUTHENTICATION_URL?url=$this->self_url") ?>[/code] call the Authentication URL into the page that is open?
  24. I still don't understand where login.php comes into this home.php? I have got a bit closer into understanding that it just brings in different templates within the same page, but where does it request them.  home.php is scripted in the above post, here is what I have edited of the first function that I believe calls the login page : [code] <?   function run()       {           if (! $this->authorize($this->getSessionField('SESSION_USERNAME')))           {             $this->alert('UNAUTHORIZED_ACCESS');           }           $this->uid = $this->getUID();           // At this point user is authorized           $this->displayHome();     }       function authorize()       {           return TRUE;       } ?> [/code] And here is the getSession function from class.PHPApplcation.php [code] <? function getSessionField($field, $default = null)     {     return (! empty($_SESSION[$field] )) ? $_SESSION[$field] : $default;     }     ?> [/code] Please refer above for any more info, needing help desperately Thanks in advance
×
×
  • 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.