Jump to content

shaunie

Members
  • Posts

    52
  • Joined

  • Last visited

Posts posted by shaunie

  1. I have set the parameters in config.yml as this but it's not logging me out after 10 seconds...

     

    framework:

        session:

            cookie_lifetime: 10

            gc_maxlifetime: 10

            gc_probability: 1

            gc_divisor: 1

  2. Thank you for your reply, 

     

    the problem seems to be the after after field3

    foreach ($result->products->product as $field => $value ) {
      file_put_contents( '/vardump.txt' , $field . ' = ' . $value , FILE_APPEND );
    }
    produces:
    field1 = 123
    field2 = 
    field3 = 
    

    but I need field20 value...

     
    So I get the error
    Catchable fatal error: Object of class stdClass could not be converted to string in ...
  3. Hi,

     

    I am trying to get the values of field1 and field20 from the following unserialized output:



    stdClass::__set_state(array(
      'id' => 'xxx',
      'products' => 
      stdClass::__set_state(array(
        'product' => 
        stdClass::__set_state(array(              
          'field1' => '123',
          'field2' => '',
          'field3' => 
          stdClass::__set_state(array(
          )),      
          #various other fields        
          'field20' => '456',    
        )),
      )),
    ))


     

    I have tried this code but it doesn't seem to be working, can someone tell me what I am doing wrong here please?

     



    $result = unserialize($api->getResponseSerialized());                                
    foreach ($result->products->product as $product) {
      $product->field1; //doesnt work!!!                                      
    }


     

  4. Hi guys,

     

    I am setting up a training package based around the Symfony framework. If you have any suggestions on what you think should be included I would love to hear them.

     

    Also if you would like to be included on the mailing list when its ready please just drop me a DM :)

  5. Thanks guys, unfortunately the above code doesn't work, which leads me to believe there is a permissions issue. I have even commented out the lines:

     

    //unlink($csvfile);
    //rename($tempfile,$csvfile);
     
    and the temp file is not present in that directory...
  6. Thank you, I have updated it so the file is closed for reading and then opened for writing, but it's still not editing the file...

    if(isset($_POST)){
    	$row = 1;	
    	if (($handle = fopen("customers.csv", "r")) !== FALSE) {
    	    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    	        $num = count($data);
    	        $row++;
    	        for ($c=0; $c < $num; $c++) {
    	            // Customer ID exists so edit the record
    	        	if($data[0] == $_POST['customerId']){
    	            	$data[1] = $_POST['name'];
    	            	$data[2] = $_POST['email'];	            
    	            }
    	       		
    	        }	        
    	    }
    	    fclose($handle);
    	}
    	if (($handle = fopen("customers.csv", "w")) !== FALSE) {
    		fputcsv($handle, $data);
    	}
    }
    
  7. Thanks 

     

    I've got this so far but for some reason I am unable to open the file for reading and writing at the same time?

     

    if(isset($_POST)){
    $row = 1;
    if (($handle = fopen("customers.csv", "r+")) !== FALSE) {
       while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
           $num = count($data);
           $row++;
           for ($c=0; $c < $num; $c++) {
            echo '$data[0] = ' . $data[0];
               if($data[0] == $_POST['customerId']){
                echo 'true';
                $data[1] = $_POST['name'];
                $data[2] = $_POST['email'];
               }
           
           }
           fputcsv($handle, $data);
       }
       fclose($handle);
    }
    }

     

  8. Thanks for your reply, I have managed to convert the date columns (after a lot of hassle!):

    SUBSTRING(CONVERT(VARCHAR(20), Event.ReportedDateTime, 113), 4,  AS [DateReported],

    My main issue the IF statements which I have attempted to rewrite as

     

    CASE Event.Status
      WHEN 'OPEN' THEN 'OPEN'
      WHEN 'CLOSED' THEN 'CLOSED'
      ELSE 'CANCELLED'
    END
    

    also I keep getting errors for not grouping some of the columns:

    is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause
  9. Hi,

     

    I'm not sure if this is the best place to ask but I have a query I have written in MySQL, and I need to convert it to MSSQL, does anyone have experience of this?

    SELECT DATE_FORMAT(DateReported, '%b %Y') AS DateReported, DATE_FORMAT(DateCompleted, '%b %Y') AS DateCompleted, LocationName,
            IF(status = 'open', 1, 0) AS open,
            IF(status = 'closed', 1, 0) AS closed,
            IF(status = 'cancelled', 1, 0) AS cancelled
        FROM event
        GROUP BY DATE_FORMAT(DateReported, '%b %Y'), LocationName
        ORDER BY FIELD(DATE_FORMAT(DateReported, '%M'), 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
    
  10. Thank you for your reply but the actual data table does not have open and closed fields. Just an entry for each event with a date, location and status field. How can I query the data when it is structured like this? I think maybe it should query the same table twice as I need to COUNT each open and closed event, but I am not sure how to do this?

  11. Hi,

     

    I have created a table to get a Google Chart working, which works on aggregated data:

     

    CREATE TABLE `chart_data` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `month` varchar(50) NOT NULL,
      `location` varchar(50) NOT NULL,
      `open` int(7) NOT NULL,
      `closed` int(7) NOT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `id` (`id`)
    );
     
    With the following data examples:
     
    INSERT INTO `chart_data` VALUES 
    (1,'January','Paris',308,500),
    (2,'February','Paris',257,420),
    (3,'March','Paris',375,235),
    (4,'April','Paris',123,387),
    (5,'May','Paris',308,500),
    (6,'June','Paris',257,420),
    (7,'July','Paris',375,235),
    (8,'August','Paris',123,387),
    (9,'September','Paris',308,500),
    (10,'October','Paris',257,420),
    (11,'November','Paris',375,235),
    (12,'December','Paris',123,387),
    (13,'January','',108,100),
    (14,'February','New York',257,420),
    (15,'March','New York',675,235),
    (16,'April','New York',623,317),
    (17,'May','New York',108,100),
    (18,'June','New York',157,220),
    (19,'July','New York',475,435),
    (20,'August','New York',523,387),
    (21,'September','New York',108,100),
    (22,'October','New York',157,220),
    (23,'November','New York',575,435),
    (24,'December','Paris',323,487);
     
    However the actual data table that I need to move it to doesn't have aggregated figures for open and closed events, just an entry for each event with a date, location and a status field. How can I query this table to populate the array in the same way?
     
    Here is my PHP code:
     
    <?php
    
    mysql_connect('localhost','root','');
    mysql_select_db('chart');
    
    $sqlquery1="SELECT month, location, open, closed FROM chart_data)";
    
    $sqlresult1=mysql_query($sqlquery1);
    
    $table=array();
    $table['cols']=array(
            array('label'=>'Month', type=>'string'),
    	array('label'=>'Location', type=>'string'),
            array('label'=>'Open', type=>'number'),
            array('label'=>'Closed', type=>'number'),
    );
    $rows=array();
    
    while($r=mysql_fetch_assoc($sqlresult1)){
            $temp=array();
            $temp[]=array('v' => $r['month']);
            $temp[]=array('v' => $r['location']);
            $temp[]=array('v' =>(int) $r['open']);
            $temp[]=array('v' =>(int) $r['closed']);
    
            $rows[]=array('c' => $temp);
    }
    
    $table['rows']=$rows;
    
    $jsonTable = json_encode($table);
    //this print statement just for testing
    print $jsonTable;
    
    ?>
    

    Thank you for your advice

     

  12. Hi,

     

    I am creating a system that invoices for events. An event will be of a type of service which will have a cost related to it. I had been planning to store all transactions (payments, invoices, refunds, charges etc) in a transactions table. However invoices are different to all other transactions as they will have invoice line items (made up of events). Should I create a separate invoices table or have an invoice id for each event in the event table?

     

    I wanted to keep all transactions in one table as I felt this made sense and would be easier for calculating customer balances.

  13. Hi,

     

    I am designing a system that stores transactions and invoices. It is a calendar system and bills will be generated from calendar events for their clients.

     

    I have attached a screen shot from MySQL Workbench. My question is whether anyone thinks this can be optimised. In particular I am wondering if an invoice should be a type of transaction?

     

    I appreciate your comments and feedback...

    post-106615-0-40754100-1360428629_thumb.jpg

  14. Hi,

     

    I have a string that will have zero or more letters followed by one or more numbers. For example

     

    aa1

    a1

    a12

    b12

    34

     

    How can I split the sting so that I get just the letter part or the number part?

     

    So letters would return:

     

    aa

    a

    a

    b

    null

     

    and numbers would return:

     

    1

    1

    12

    12

    34

  15. Hi,

     

    Thanks for your reply, my problem is that the form has 2 buttons, one to add a new row and one to save the changes. The save changes button is necessary to ensure that the other parts of the form have been saved . I would like to be able to add a new row without calling the onbeforeunload() function and instead using the onsubmit() function to validate, however I believe onbeforeunload() should be used in all other cases. Is this possible?

  16. Hi,

     

    I have been asked to modify a form to ensure that fields have been completed. The problem is the user is still able to click on the 'leave page' button. This actually redirects to the existing page when the add new button is pressed so the user can still get away with entering blank entries. Can anyone tell me how I can get around this please? Here is my form:

     

    
    </style>
    </head>
    <SCRIPT LANGUAGE="Javascript1.2" TYPE="text/javascript">
    <!--
    isSaved = false;
    
    function unloadMess(){
    mess = "Please make sure that you have saved all changes before leaving the page."
    if(!isSaved) return mess;
    }
    
    function allSaved(){
    var x=document.forms["input_style"].addcfrcode;
    if (x==null || x==""){
    alert("Code must be selected");
    return false;
    } else {
    isSaved = true;
    }
    }
    
    
    //-->
    </SCRIPT>
    
    <body onbeforeunload="return unloadMess()" >
    
    <form method=post enctype="multipart/form-data" id="input_style" name="input_style">
    
    <div><input id="save_btn" type=submit name=update onclick="allSaved()" value="Save Changes"></div>
    
    <p align="right"><b>Budget Company X</b></p>
    
    <div style="width:100%; height:500px">
    
    <table cellSpacing=1 cellPadding=5 width="100%" border=1>
    
    <tr>
    
    <td class=info align=left colspan=11><bExpenditure</b></td>
    
    </tr>
    
    <tr>
    
    <td class=info align=left><b>Code</b></td>
    
    <td class=info align=left><b>Cost</b></td>
    
    <td class=info align=left></td>
    
    <td class=info align=left><b>Description</b></td>
    
    <td class=info align=left></td>
    
    <td class=info align=left><b>Actual<br />Aug-2012/Aug-2012</b></td>
    
    <td class=info><b>Budget<br />Sep-2012/Aug-2013</b></td>
    
    <td class=info><b>Budget<br />Sep-2013/Aug-2014</b></td>
    
    <td class=info><b>Budget<br />Sep-2014/Aug-2015</b></td>
    
    <td class=info align=left><b>Comment</b></td>
    
    </tr>
    
    <tr>
    
    <td class=back align=left>
    
    <select name=addcfrcode>
    
    <option value="" selected></option>
    
    <option value="1">Code 1</option>
    
    <option value="2">Code 2</option>
    
    <option value="3">Code 3</option>
    
    </select>
    
    </td>
    
    <td class=back align=left>
    
    <select name=addchartgroup>
    
    <option value="" selected></option>
    
    <option value="26">Cost A</option>
    
    <option value="27">Cost B</option>
    
    <option value="28">Cost C</option>
    
    </select>
    
    </td>
    
    <td class=info align=left></td>
    
    <td class=back align=left>
    
    <input type=text name=add_desc size=20>
    
    </td>
    
    <td class=info align=left></td>
    
    <td class=back style="text-align: right;">
    
    <input type=text size=10 name="addbudget1" value="">
    
    </td>
    
    <td class="back yearone">
    
    <input class="yearone" type=text size=10 name="addbudget2" value="">
    
    </td>
    
    <td class="back yeartwo">
    
    <input class="yeartwo" type=text size=10 name="addbudget3" value="">
    
    </td>
    
    <td class="back yearthree">
    
    <input class="yearthree" type=text size=10 name="addbudget4" value="">
    
    </td>
    
    <td class=back align=left>
    
    <textarea class="comment" type=text name=comment size=20 value=></textarea>
    
    </td>
    
    <input type=hidden name=addbudgetid value=>
    
    </tr>
    
    <tr>
    
    <td class=back colspan=12>
    
    <input type=submit name=insert onclick="allSaved()" value="Add New">
    
    </td>
    
    </tr>
    
    </table>
    

×
×
  • 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.