Jump to content

ksmatthews

Members
  • Posts

    97
  • Joined

  • Last visited

    Never

Posts posted by ksmatthews

  1. Hi All,

     

    I need to update our local Mysql DB server with data from the live server

    on a daily basis ...

     

    The simplest approach is to use the mysqldump utility on the live server to create a dump file and then to import that dump file locally. This can be done using a simple shell script.

     

    I could also go down the road of database replication using master - slave.

    There are many articles on how to best do this ...

     

    Basically we have 2 DB server - the local one needs to be kept in sync with the live one ...

     

    What is the best way to do this ?

     

    regards,

     

    Steven M

  2. Hi All,

     

    I usually use apache virtual domains for all web development.

     

    Today however I have enabled 'user web pages' using the following directive

     

    UserDir public_html

     

    and by enabling mods-available/userdir.conf.

     

    After re-starting apache I can now access web pages in my home dir using for example ...

     

    http://localhost/~steven/test/myfile.html

     

    UNFORTUNATELY I cannot run any php scripts like ...

     

    http://localhost/~stevenm/test/index.php

     

    only the plain non - interpreted text is displayed but running php in my virtual domains works OK.

     

    Why is my PHP not working for localhost ?

     

    regards,

     

    Steven M

     

  3. HI There,

     

    I am using this type of code to self load a submitted form

     

    <form name = "testform" method = "post" action = "<?=$_SERVER['PHP_SELF']?>" onsubmit = "return check_data()" >

     

    Apart from using  $_SERVER['PHP_SELF'] is there another way of determining the current URL within a script ?

     

    regards,

     

    Steven Matthews

  4. I want to create 2 select menus - one static (Menu 1) and the other (Menu 2) populated according to the selection made in Menu 1.

    Data will will be pulled from a CSV file.

     

    Menu 2 will not have any values in it until an option from Menu 1 has been selected. Then, the options available will be limited based on the Item 1 selection.

    PHP must be used to read the CSV file and to capture the data (using arrays)

     

    I met this problem before and my approach then was to call a function using the onChange event for Menu1 ...

     

    <script type = "text/javascript">function update_select(obj){     

      window.location.href="./call_stats_main.php?choice=" + obj.value;}

    </script>

     

    onchange="update_select(this)

     

    This would reload the page passing a parameter to the URL (?choice=)

     

    I could then use $_GET['choice'] to capture the selected value and dynamically populate Menu 2 according to this value.

     

    It is the onchange event that triggers the population of menu 2.

     

    I would like to know IF THERE IS A BETTER WAY, other than using ajax ?

     

    Steven M

     

  5. HI All,

     

    I can no longer run my web apps ! When I try to run them in Firefox I simply get a prompt to download the files …

     

    I installed openvpn last night and ever since I have had this problem …

    I checked the files in /etc/apache2 and they were modified but I cannot figure out how. Certainly php has been turned off somewhere.

     

    Interestingly, I can run php5 as a binary from the command line – php5 is most certainly installed.

     

    More info …

     

    file /etc/apache2/mods-enabled/php5.load reads ...

    LoadModule php5_module /usr/lib/apache2/modules/libphp5.so

     

    I have restarted apache2 but to no avail … help !

     

    What do you advise ?

     

    Steven Matthews :-[

  6. Hi THere,

     

    They say that from a security standpoint, we should not implement root-level commands in a web interface ....

     

    I was involved in the creation of a web based front end for a third party telephony system (*Asterisk) running on linux.

     

    Here are some code snippets ...

     

    if(strstr($ID, 'dhcp'))

    {

    if($ID == 'dhcp_1') // DHCP

    $command = '/usr/bin/sudo /usr/sbin/rcdhcpd start'; // /etc/init.d/dhcpd GENERIC

    else if($ID == 'dhcp_2')

    $command = '/usr/bin/sudo /usr/sbin/rcdhcpd stop';

    else

    $command = '/usr/bin/sudo /usr/sbin/rcdhcpd restart';

     

    // run command

    exec($command);

     

    // run status check

    exec('/usr/bin/sudo /usr/sbin/rcdhcpd status', $output, $return_var);

    }

     

     

    // another snippet

    $command = 'rm -rf ' . $temp_folder;

    exec($command);

     

    // write to socket (authentication)

    if($socket)

    {

    fputs($socket, "Action: Login\r\n");

    fputs($socket, "UserName: " . ASTERISK_UNAME . "\r\n");

    fputs($socket, "Secret: " . ASTERISK_SECRET . "\r\n");

    fputs($socket, "Events: off\r\n\r\n");

     

    // loop through output from Asterisk

    $authentication_flag = false;

    while ($buf = fread($socket, 512))

    {

    if(feof($socket))

    break;

     

    if(strstr($buf, "Response: Success"))

    {

    $authentication_flag = true;

    break;

    }

     

    if(strstr($buf, "END COMMAND"))

    break;

    }

     

    if($authentication_flag == false)

    {

    echo 'No Asterisk !';

    die();

    }

    }

     

    Is this code  poor practice ?

     

    If so, then I would be curious to know how web hosting companies provide web front ends to their linux based web hosts.

    Surely they too must be running root commands using sudo ....

     

    Any ideas ?

     

    regards,

     

    Steven Matthews  :shrug:

  7. Should get this ...

     

    08-07-2010,277,CLICKATELL,CLICKATELL_June_Oct_09,GBP,33179.70,0.00,33179.70,Paid on 10/02/2010

    08-07-2010,182,IPX,IPX_Jul09_23852,EUR,1654.55,0.00,1654.55,Paid on 02/12/2009

    10-06-2010,406,NETM,07091486,EUR,721.17,0.00,721.17,Paid on 24/03/2010

    08-04-2010,342,COMEXME,Comexme_July09 - Dec09,USD,2131.11,0.00,2131.11,Paid on 08/04/2010

     

    But I get this ...

     

    08-07-2010,277,CLICKATELL,CLICKATELL_June_Oct_09,GBP,33179.70,0.00,33179.70,Paid on 10/02/201008-07-2010,182,IPX,IPX_Jul09_23852,EUR,1654.55,0.00,1654.55,Paid on 02/12/200910-06-2010,406,NETM,07091486,EUR,721.17,0.00,721.17,Paid on 24/03/201008-04-2010,342,COMEXME,Comexme_July09 - Dec09,USD,2131.11,0.00,2131.11,Paid on 08/04/2010

     

    WHY ? Is this a CSS issue ?

     

    Steven M

  8. Hi All,

     

    I am having problems writing to the textarea HTML object. Basically I am losing my new line char

    and the text looks awful and unintelligible.

     

    How can I get my new lines appended at the end so that each line is separate.

     

    Here is some code ...

     

    Creating EACH data line:

     

    $arrCsvRow = array(

    $arrTags['DATE_UPLOADED'],

    $arrTags['SCAN_NUMBER'],

    $arrTags['OPERATOR'],

    $arrTags['REFERENCE'],

    $arrTags['CURRENCY'],

    $arrTags['GOODS'],

    $arrTags['VAT'],

    $arrTags['TOTAL'],

    $arrTags['PAID_TITLE']

    );

    $arrCsv[] = implode(',', $arrCsvRow);

     

    etc ....  

     

    Dumping it all at the end ...

     

    $arrTags['CSV_OUTPUT'] = implode("\n", $arrCsv);

     

    Note: $arrTags['CSV_OUTPUT'] is added to  a text area control WITHIN a template

     

    Any advice appreciated,

     

    regards,

     

    ksmatthews

     

     

  9. Hi All,

     

     

    I am running a CLI script written in PHP to execute a remote web service. THe service calls a method 'GetUKLocationByCounty($param)'  which returns XML. I keep getting an error when I pass a string to this method, as required.

     

    Here is part of the code ...

     

    $client = new SoapClient('http://www.webservicex.net    /uklocation.asmx?wsdl', array('trace'    => 1 ));

                             

     

      // call method                 

      $response = $client->GetUKLocationByCounty('Cornwall');

     

      // get last soap response

      echo $client->__getLastResponse();

     

     

    The web service can be found at :

    http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=28

     

    RESULT:

     

    PHP Fatal error:  Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Procedure or function 'GetUKLocationByCounty' expects parameter '@County', which was not supplied.

      at WebServicex.UKLocation.GetUKLocationByCounty(String County)

      --- End of inner exception stack trace --- in /home/steven/public_html/XML-load/soap_test2.php:16

     

    Any ideas ?

     

    regards,

     

    Steven Matthews

  10. Hi All,

     

     

    I am running a CLI script written in PHP to execute a remote web service. The service calls a method 'GetUKLocationByCounty($param)' which returns XML. I keep getting an error when I pass a string to this method, as required.

     

    Here is part of the code ...

     

    $client = new SoapClient('http://www.webservicex.net /uklocation.asmx?wsdl', array('trace'    => 1 ));

                             

     

      // call method                 

      $response = $client->GetUKLocationByCounty('Cornwall');

     

      // get last soap response

      echo $client->__getLastResponse();

     

     

    The web service can be found at :

    http://www.webservicex.net/WCF/ServiceDetails.aspx?SID=28

     

    RESULT:

     

    PHP Fatal error:  Uncaught SoapFault exception: [soap:Server] System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Procedure or function 'GetUKLocationByCounty' expects parameter '@County', which was not supplied.

      at WebServicex.UKLocation.GetUKLocationByCounty(String County)

      --- End of inner exception stack trace --- in /home/steven/public_html/XML-load/soap_test2.php:16

     

    Any ideas ?

     

    regards,

     

    Steven Matthews

     

    :'(

  11. 1. What do you mean by tabs? (tabs in browser? some javascript generated tabs?)

    2. If using javascript are you using  a framework for this? And which one?

     

    HI,

     

    The page itself is divided into tabs (3 sections each with a clickable 'tab' at the top, a CSS feature). I am not referring to browser tabs !

    I am using the jquery framework,

     

    Steven M

  12. HI All,

     

    I have a page with 3 tabs A, B and C. Each tab is a form in its own right. Tab A is the default active tab.

    When I submit tabs B or C I am always returned to tab A. How can I ensure that I return to the tab that

    I submitted from ?

     

    regards,

     

    Steven M

    >:(

  13. Hi There,

     

    I am using ajax to display a simple tabbed form on my main page. This tabbed form uses js (jquery) for tab browsing. Problem is that when displayed using ajax, the js functionality just disappears as if it was never there.

     

    I have tried adding the js files to the top of the tabbed form in the php script that will display it ...

     

    Anyone got any ideas ?

     

    regards,

     

    Steven M

     

  14. Hi There,

     

    My client data gathering front end consists of ten tabs - each tab is a form in its own right.

    The default (highlighted tab) is the first one which happens to be 'Personal details'.

     

    PROBLEM; when I submit another tab form for processing I am always returned to tab1 and not to the submitted tab. How can I get around this issue ?

     

    This may well be a javascript issue ....

     

    THanks,

     

    Steven M

  15. Hi There,

     

    In languages like java and C++ you can create objects on the fly as class variables, like this ...

     

    class myClass

    {

      // Declare class members here

      private class1 myobj;

      private class2 myobj2;

      private class3 myobj3;  // etc

     

      // constructor

      public function myClass(){}

     

      public function fred()

      {

        myobj.function1();

        myobj2.function2();

     

      // etc

      }

    }

     

    Can you do this in PHP 5 without using new and  if so , how ?

     

    regards,

     

    Steven M

     

  16. Hi There,

     

    I am trying to create a page with 2 or more forms using only ONE table. Consider this code ...

     

    <form action="blah.php" method="POST">

      <table>

        <tr>

          <td>Name:</td>

          <td><input type="text" name="name"></td>

        </tr>

     

        <tr>

          <td colspan="2" align="center">

            <input type="submit" name="Submit_btn" id="Submit_btn" value="Send">

          </td>

        </tr>

      </table>

    </form>

     

    How to create another form from within the same table ?

     

    regards,

     

    Steven M

  17. Hi There,

     

    I am using a class that makes a lot of use of a DB object (see code below).

    Currently I instantiate the object within each function which has to be repeated for each function.

    How can I avoid this ? I have tried to instantiate the object OUTSIDE of the class but it is not visible from within the functions ....

     

    // Access Control class

    require_once('class.database.php');

     

    class Access_control

    {

      // Declare class members, PHP 5 style

      private $uname = "";

      private $pword = "";

     

      // constructor

      public function Access_control($uname, $pword)

      {

      $this->uname = $uname;

      $this->pword = $pword;

      }

     

      public function func_1()

      {

      // instantiate DB class object

    $myDB = new mySQLDatabase(DB_NAME, USER_NAME, PASSWORD, CONNECT_SQL_ERROR, URL);

     

    // code here

     

    $myDB->Close_DB();

     

      }

     

      public function func_2()

      {

      // instantiate DB class object

    $myDB = new mySQLDatabase(DB_NAME, USER_NAME, PASSWORD, CONNECT_SQL_ERROR, URL);

     

    // code here

     

    $myDB->Close_DB();

     

      }

     

    // etc

     

    }

     

    Thanks,

     

    Steven M

  18. Hi all,

     

    I need to create some huge forms. When it comes to the backend submission, the SQL insert becomes large

    and cumbersome.

     

    Is there an easier way to insert a large amount of POSTED data without having to explicitely refer to each

    and every form variable by name when creating the SQL insert string ?

     

    I have tried code like this

     

    $values = serialize($_POST);

    $SQL = 'insert into mytable values (' .$values. ')';

     

    but that does not work ...

     

    How can I access each and every form field in $_POST without referring to names ?

     

    regards,

     

    Steven M

     

    :(

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