[FX.php List] Memories....MORE

Jonathan Schwartz jschwartz at exit445.com
Thu May 13 07:45:18 MDT 2010


It is instantiated via the "require" that appears 
on the first line of the function 
(log_prefs.php).  However, that must not be good 
enough for iterations 2+. When I moved the 
require to the master script, the error 
dissapeared and the script now works in 
iterations 2+.

So far so good.

The only problem...memory usage actually went UP slightly, not down.

This is a small script/function, though.

I will try and apply this lesson to the bigger 
scripst to get the memory savings desired.

J


At 8:05 AM -0500 5/13/10, Dale Bengston wrote:
>Do you need to instantiate $log first?
>
>On May 13, 2010, at 7:36 AM, Jonathan Schwartz wrote:
>
>>Interesting.
>>
>>I was able to get the function to run, but only once per page.  Otherwise:
>>
>>Fatal error: Call to a member function 
>>newAddCommand() on a non-object 
>>inC:\Inetpub\wwwroot\SSL\functions.inc.php on 
>>line 12
>>
>>where line 12 = $log_add = $log->newAddCommand('web');
>>
>>I'm sure the answer is obvious...but not to me. ;-)
>>
>>Jonathan
>>
>>
>>At 12:12 PM +0200 5/13/10, Gjermund Gusland Thorsen wrote:
>>
>>>function? you want to turn the query into a function?
>>>
>>>function LogMyStuff( $arrayOfVariables, $_SESSION ){
>>>                         require_once('Connections/log_prefs.php');
>>>                         require_once('FileMaker.php');
>>>                         $log_add = $log->newAddCommand('web');
>>>                         $log_add_fields = array(
>>>                         'DB'=>'ABCD',
>>>                         'IP'=> $IP,
>>>                         'Browser'=> $AGENT,
>>>                         'hostname'=> $_SESSION['hostname'],
>>>                         'sessionid'=> $sessionid,
>>>                         'Location'=> $_SERVER['PHP_SELF'],
>>>                         'Step'=>$arrayOfVariables['Step'],
>>>                         'Detail'=> $arrayOfVariables[' Detail,
>>>                         'Name'=> $arrayOfVariables[' Name,
>>>                         'ZipCode'=>$arrayOfVariables[' Zip,
>>>                         'Route'=>$arrayOfVariables[' Route,
>>>                         'Message'=>$arrayOfVariables[' Message,
>>>                         'mode'=>$_SESSION['loginmode'],
>>>                         'type'=>$_SESSION['type'],
>>>                         'elapsed'=>$arrayOfVariables[' timeelapsed,
>>>                         'CustID'=>$_SESSION['Customer_ID_Number'],
>>>                         'Rep'=>$_SESSION['LastName'],
>>>                         'users'=>$_SESSION['OnlineUsers'],
>>>                         'Region'=>$_SESSION['Region'],
>>>                         'referer'=>$arrayOfVariables[' referer,
>>>                         'CustTempRecID'=>$TempRecID
>>>                         );
>>>
>>>                         foreach($log_add_fields as $key=>$value)
>>>                         {
>>>                         $log_add->setField($key,$value);
>>>                         }
>>>                         $log_add_results= $log_add->execute();
>>>
>>>                         if(FileMaker::isError($log_add_results))
>>>                         {
>>>                                 $error_code = $log_add_results->code;
>>>                                 exit;
>>>                         }else{
>>>                                 $log_row =
>>>  current($log_add_results->getRecords());
>>>                         }
>>>
>>>
>>>};
>>>
>>>or maybe
>>>
>>>change it to something like:
>>>
>>>function LogMyStuff( $_POST, $_GET, $_SESSION ){
>>>                         require_once('Connections/log_prefs.php');
>>>                         require_once('FileMaker.php');
>>>                         $log_add = $log->newAddCommand('web');
>>>                         $log_add_fields = array(
>>>                         'DB'=>'ABCD',
>>>                         'IP'=> $IP,
>>>                         'Browser'=> $AGENT,
>>>                         'hostname'=> $_SESSION['hostname'],
>>>                         'sessionid'=> $sessionid,
>>>                         'Location'=> $_SERVER['PHP_SELF'],
>>>                         'Step'=>$_POST['Step'],
>>>                         'Detail'=> $_POST[' Detail,
>>>                         'Name'=> $_POST[' Name,
>>>                         'ZipCode'=>$_POST[' Zip,
>>>                         'Route'=>$_POST[' Route,
>>>                         'Message'=>$_POST[' Message,
>>>                         'mode'=>$_SESSION['loginmode'],
>>>                         'type'=>$_SESSION['type'],
>>>                         'elapsed'=>$_POST[' timeelapsed,
>>>                         'CustID'=>$_SESSION['Customer_ID_Number'],
>>>                         'Rep'=>$_SESSION['LastName'],
>>>                         'users'=>$_SESSION['OnlineUsers'],
>>>                         'Region'=>$_SESSION['Region'],
>>>                         'referer'=>$_POST[' referer,
>>>                         'CustTempRecID'=>$TempRecID
>>>
>>>                         );
>>>
>>>                         foreach($log_add_fields as $key=>$value)
>>>                         {
>>>                         $log_add->setField($key,$value);
>>>                         }
>>>                         $log_add_results= $log_add->execute();
>>>
>>>                         if(FileMaker::isError($log_add_results))
>>>                         {
>>>                                 $error_code = $log_add_results->code;
>>>                                 exit;
>>>                         }else{
>>>                                 $log_row =
>>>  current($log_add_results->getRecords());
>>>                         }
>>>
>>>
>>>};
>>>
>>>compliments of the array-cowboys
>>>
>>>ggt
>>>
>>>
>>>
>>>2010/5/12 Jonathan Schwartz 
>>><<mailto:jschwartz at exit445.com>jschwartz at exit445.com>:
>>>>  OK. How about a gentle push in the right direction? It's a big jump from
>>>>  example code to doing creating a function 
>>>>for an entire query, using a dozen
>>>>  or so variables.
>>>>
>>>>  Here is my log.php query "add" code using the API.  Do I need to define
>>>>  every variable in the function definition? What about the first two lines
>>>>  that contain includes?
>>>>
>>>>
>>>>  Existing Log Code:
>>>>                         require_once('Connections/log_prefs.php');
>>>>                         require_once('FileMaker.php');
>>>>                         $log_add = $log->newAddCommand('web');
>>>>                         $log_add_fields = array(
>>>>                         'DB'=>'ABCD',
>>>>                         'IP'=> $IP,
>>>>                         'Browser'=> $AGENT,
>>>>                         'hostname'=> $_SESSION['hostname'],
>>>>                         'sessionid'=> $sessionid,
>>>>                         'Location'=> $_SERVER['PHP_SELF'],
>>>>                         'Step'=>$Step,
>>>>                         'Detail'=> $Detail,
>>>>                         'Name'=> $Name,
>>>>                         'ZipCode'=>$Zip,
>>>>                         'Route'=>$Route,
>>>>                         'Message'=>$Message,
>>>>                         'mode'=>$_SESSION['loginmode'],
>>>>                         'type'=>$_SESSION['type'],
>>>>                         'elapsed'=>$timeelapsed,
>>>>                         'CustID'=>$_SESSION['Customer_ID_Number'],
>>>>                         'Rep'=>$_SESSION['LastName'],
>>>>                         'users'=>$_SESSION['OnlineUsers'],
>>>>                         'Region'=>$_SESSION['Region'],
>>>>                         'referer'=>$referer,
>>>>                         'CustTempRecID'=>$TempRecID
>>>>                         );
>>>>
>>>>                         foreach($log_add_fields as $key=>$value)
>>>>                         {
>>>>                         $log_add->setField($key,$value);
>>>>                         }
>>>>                         $log_add_results= $log_add->execute();
>>>>
>>>>                         if(FileMaker::isError($log_add_results))
>>>>                         {
>>>>                                 $error_code = $log_add_results->code;
>>>>                                 exit;
>>>>                         }else{
>>>>                                 $log_row =
>>>>  current($log_add_results->getRecords());
>>>>                         }
>>>>
>>>>
>>>>  Thanks for the help.
>>>>
>>>>  Jonathan
>>>>
>>>>
>>>>  --
>>>>  Jonathan Schwartz
>>>>  Exit 445 Group
>>>> <mailto:jonathan at exit445.com>jonathan at exit445.com
>>>> <http://www.exit445.com>http://www.exit445.com
>>>>  415-370-5011
>>>>  _______________________________________________
>>>>  FX.php_List mailing list
>>>> <mailto:FX.php_List at mail.iviking.org>FX.php_List at mail.iviking.org
>>>> <http://www.iviking.org/mailman/listinfo/fx.php_list>http://www.iviking.org/mailman/listinfo/fx.php_list
>>>  >
>>>_______________________________________________
>>>FX.php_List mailing list
>>><mailto:FX.php_List at mail.iviking.org>FX.php_List at mail.iviking.org
>>><http://www.iviking.org/mailman/listinfo/fx.php_list>http://www.iviking.org/mailman/listinfo/fx.php_list
>>>
>>
>>
>>--
>>Jonathan Schwartz
>>Exit 445 Group
>><mailto:jonathan at exit445.com>jonathan at exit445.com
>><http://www.exit445.com>http://www.exit445.com
>>415-370-5011
>>_______________________________________________
>>FX.php_List mailing list
>><mailto:FX.php_List at mail.iviking.org>FX.php_List at mail.iviking.org
>><http://www.iviking.org/mailman/listinfo/fx.php_list>http://www.iviking.org/mailman/listinfo/fx.php_list
>>
>
>
>_______________________________________________
>FX.php_List mailing list
>FX.php_List at mail.iviking.org
>http://www.iviking.org/mailman/listinfo/fx.php_list


-- 
Jonathan Schwartz
Exit 445 Group
jonathan at exit445.com
http://www.exit445.com
415-370-5011
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20100513/0d229129/attachment-0001.html


More information about the FX.php_List mailing list