[FX.php List] This is doing my head in...

Roger Price rp272 at cam.ac.uk
Sun Nov 25 06:58:54 MST 2007


Steve

> case 'changePassword':

Shouldn't this have some action specified such as 'do something; break;'

Roger

----- Original Message ----- 
  From: Steve Winter 
  To: 'FX.php Discussion List' 
  Sent: Thursday, November 22, 2007 2:30 PM
  Subject: [FX.php List] This is doing my head in...


  Hi all,

   

  I’ve got a block of code;

   

    $listQuery = new FX($serverIP, $serverPort, $dataSourceType);

    $listQuery->SetDBUserPass($webUN, $webPW);

    $listQuery->SetDBData($databaseName, 'webTutors', 'all');

    $listQuery->AddSortParam('tutorNameFirst', 'ascend');    

    $listQuery->AddSortParam('tutorNameLast', 'ascend');

    switch($_REQUEST['action']) {

      case 'changePassword':

      case 'changeMyDetails':

                $listQuery->AddDBParam('tutorID', $_SESSION['session']['tutorID']);

                $listData = $listQuery->FMFind();

      break;

      default:

                $listData = $listQuery->FMFindAll();

      break; }

   

  When the page is called via a ‘get’ this code runs perfectly and returns the records.

   

  I then lay them out in a table, allow the user to make changes, and post them all back in a series of arrays to the database, which then modifies the records using this code;

   

  $fieldsToSave = array('tutorNameTitle','tutorNameFirst','tutorNameLast','tutorFormClass','tutorEmail','tutorAccessName','tutorAccessPassword','tutorIsAdministrator');

   

  if($_SERVER['REQUEST_METHOD'] == 'POST') {

    switch($_REQUEST['action']) {

      case 'deleteStaff': 

                $listUpdateQuery = new FX($serverIP, $serverPort, $dataSourceType);

                $listUpdateQuery->SetDBUserPass($webUN, $webPW);

                $listUpdateQuery->SetDBData($databaseName, 'webTutors');

                $listUpdateQuery->AddDBParam('-recid', $_REQUEST['recID']);               

                $listUpdateData = $listUpdateQuery->FMDelete();

                if($listUpdateData['errorCode'] == 0) $messages[] = 'mItem deleted successfully.';

                else $messages[] = 'eThe item could not be deleted.';

              break;

      case 'editStaff':

                $sucess = 0; $counter=0;

                for($j=0; $j<count($_REQUEST['tutorNameLast']); $j++) { 

                            $listUpdateQuery = new FX($serverIP, $serverPort, $dataSourceType);

                            $listUpdateQuery->SetDBUserPass($webUN, $webPW);

                            $listUpdateQuery->SetDBData($databaseName, 'webTutors');

                            foreach($fieldsToSave as $field) 

                              $listUpdateQuery->AddDBParam($field, $_REQUEST[$field][$j]);

                            if($_REQUEST['recID'][$j] != '') {

                                      $listUpdateQuery->AddDBParam('-recid', $_REQUEST['recID'][$j]);                        

                                      $listUpdateData = $listUpdateQuery->FMEdit(); }

                            else

                                      $listUpdateData = $listUpdateQuery->FMNew();

                            $counter++;

                            if($listUpdateData['errorCode'] == 0) $sucess++; echo $j.'<br />'; } 

                if($sucess == $counter) $messages[] = 'm'.$sucess.' of '.$counter.' items updated sucessfully.';

                else $messages[] = 'e'.$sucess.' of '.$counter.' items updated were updated. Please verify your data and try again.'; 

              break;

    }

  }

   

  And then the same piece of code at the top of the page gets called again, to re-create my table of data.

   

  When it’s run via the get the first time the page loads, all is good.. I get the page I would expect with no problems...

   

  When it gets called the second time round I get a series of errors generated;

  Warning: urlencode() expects parameter 1 to be string, array given in D:\server\websites\msClients\3square\conduct\assets\fx\FX.php on line 1425

   

  I’ve turned DEBUG on, the same request is generated by the code block both times, and clicking on it gives exactly the results I would expect.

   

  If I refresh the page, so I’m using a GET, then all works fine...

   

  What the...?? any clues...??

   

  Cheers

  Frustrated Steve

   

   



  No virus found in this outgoing message.
  Checked by AVG Free Edition.
  Version: 7.5.503 / Virus Database: 269.16.3/1144 - Release Date: 21/11/2007 4:28 p.m.




------------------------------------------------------------------------------


  _______________________________________________
  FX.php_List mailing list
  FX.php_List at mail.iviking.org
  http://www.iviking.org/mailman/listinfo/fx.php_list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.iviking.org/pipermail/fx.php_list/attachments/20071125/20d8cc07/attachment-0001.html


More information about the FX.php_List mailing list