veedeoo 474 Junior Poster Featured Poster

I don't mean this personally, but the class above will eat the server resources like a hog.

It is a class of too many methods. One probable solution I can think of is to break this class into multiple classes. There is a design pattern called Abstract Factory/Factory Method patterns which I think can work greatly on this type of application. Most importantly, if you are aiming for cache system.

The implementation of Abstract Factory/Factory Method patterns is kinda like this. ( Mr. LDA above thought me how to this, so any corrections are greatly appreciated). It appears to me that the class above is responsible for providing video contents coming from the external sites.

We can make a video factory class like this

class VideoFactory
{
    private $ytube_content;
    private $imgur_content;
    private $dmotion_content;
    private $flickr_content;

    public function __construct(YouTube $ytube_content, Imgur $imgur_content, DailyMotion $dmotion_content, Flickr $flickr_content)
    {
        $this->ytube_content = $ytube_content;
        $this->imgur_content = $imgur_content;
        $this->dmotion_content = $dmotion_content;
        $this->flickr_content = $flickr_content;

     }

     /*
     * get the youtube data
     */

     public function get_youtube()
     {
         return clone $this->ytube_content;
      }

      /*
      * get imgur data
      */
      public function get_imgur()
      {
          return clone $this->imgur_content;

       }

       /*
       * get dailymotion data
       */
       public function get_dailymotion()
       {
           return clone $this->dmotion_content;

        }

        /*
        * get flickr data
        */
        public function get_flickr()
        {
            return clone $this->flickr_content;

        }


} 

the video classes as broken down

class YouTube
{

    public function __construct()
    {
    }

    public function set_video()
    {

        //return all youtube video data

     }

     public function make_cache()
     {
         //you can make a …
SimonIoa commented: thanks veedeoo +2
veedeoo 474 Junior Poster Featured Poster

you need to echo this whole thing

<input type="text" name="ptype" id="ptype" value="<?php $SCYQ64TYPE1 = $ex1["SCYQ64TYPE"]; echo $SCYQ64TYPE = trim($SCYQ64TYPE1) ?>" readonly >

and this one

if($q!='')

should be written like this

if($q!=='')

Alternatively, Gabriel is correct about JQuery option. It is a lot easier to use jquery libraries.

veedeoo 474 Junior Poster Featured Poster

In practice, MVC pattern is not as complicated as my drawing above. They are in fact easy to learn. The secret of learning is to go back to the basic "hello world" program introduced to us when we first met PHP and to follow the progression of PHP during its evolution.

Let us follow the breadcrumb trail of PHP in simplified approach.

Learning the advance OOP and MVC design patterns is somewhat very tricky. Remember the basic "hello world" program introduced to us?

<?php

    echo 'Hello World';

most books will tell us to give ourselves a good pat on the back and then welcome us as a newly anoited PHP programmer. Most books and online tutorials are guilty of excessively anoiting their readers. I honestly believe that this is only for the purpose of boosting the newbie's confidence. However, they were not prepared for the future evolution of PHP.

The first sign of evolution of PHP. "Let there be function" and overnight we learned how to write a function.

<?php

    function sayHello($dialog)
    {

       return ($dialog);

     }

     echo sayHello('Hello World');

Sooner than we can imagine, everyone on the web were talking about how reusable the functions they have created. Wait a minute, someone just claimed that PHP is also an Object oriented language? Huh! you must be kidding me! scream one of the Java coder.

By this time, many PHP programmers stayed with the old method of writing PHP applications, while others move on to the Object Oriented Programming. …

Lorele commented: Absolutely stellar. Hello, Universe. +0
veedeoo 474 Junior Poster Featured Poster

e.g. student management application

You
 YOUR SERVER + Application
    + School = your end-user
        + Students = school's end-user

Take the simple example above. If some delicate information are forcefully taken from the application you wrote e.g. grades, student id, name, email address, class schedule, grades , and anything that are considered private. Who has the ultimate responsibility?

A scenario, a hacker broke into your application and start changing the grades of the students. Who's responsibility is this? Are you prepare to recover from this? How about a back-up for data recovery?

What can you do to protect yourself if such hideous things occurs?
Do you believe in "Code Of Ethics for Programmers and Developers"?

Or should we let the application run without any regards to the school and student's rights of Privacy. Or maybe, we can let the school handle the chaos and let them lie about pretty much everything without accepting responsibility on our end?

What would be the appropriate EULA and TOS for the above?
Maybe you don't need one, don't your think?

veedeoo 474 Junior Poster Featured Poster

First, I honestly believe that you should consult a copyright attorney. There is no way I have the training and any knowledge in giving legal advice in software licensing. Software licensing is one of the most complicated one to understand.

Most developers engaged in enterprise level open sources applications e.g. yours truly and Mr. LDA. Tend to select the license that will cover the things that we fear the most. We have three licensing schemes on the applications that we write DBD(don't be a dick), MIT, and GPL. For all scripts and snippets we published on blogs and forums, we tend to give it DBD and MIT. For our distributable applications we shoot for GPL.

A good example, PHP is lincense under BSD. Why does PHP opted to take the BSD license? The reason is that, you can build any application in PHP secured or not so secured, the front-end user will not be able to file a lawsuts against PHP. In other words, if your PHP written application has been hacked by some obnoxious hacker, your clients will not be able to file a legal actions against the core of your application which is PHP.

Now, when it comes to your propriety license, you can probably have put it out in MIT or BSD.

My reasoning behind having it release in BSD or MIT is that they cannot modify any accessable source codes of your application without notifying you first. MIT allows you to separate …

veedeoo 474 Junior Poster Featured Poster

I hope Mr. LDA don't mind me posting response on this thread.

Do you have composer.json inside your node directory?

veedeoo 474 Junior Poster Featured Poster

for html5, you can probably use object like this..

<body>
<object name="header" type="text/html" data="head.html"></object>
<br />

<object name="footer" type="text/html" data="footer.html"></object>



</body>

I am not sure though, but you can refer to the documentation here.

I am not really sure if we can use two objects ..

Update: yes we can use two. I updated the codes above.

veedeoo 474 Junior Poster Featured Poster

two ways you can do what you wanted.

first, can do it with javascript.
second, add this above your image submit button

<input type="hidden" name="submit" />
veedeoo 474 Junior Poster Featured Poster

here are the screenshots of the server in the virtual box being access by firefox in the host computer

8eaff26fa3d646e0b4b73deb4065653d

Just for the purpose of this discussion, I skinned the ubuntu server with Lubuntu skin and installed the firefox as well so that I can take screenshot of the localhost inside the virtual box.

4acb92ab0acbec42518d90acbc4a4888

I hope you will be able reproduce everything we presented on this thread. I am confident we have already given you enough information on how to set your server andnetwork settings on the virtual server and host computer. What we did not give is the instruction on how to install apache2 on the virtual server. However, I sincerely believe that there is an abundance of tutorials available on the web. If you ever find any problems installing apache, mysql, php on linux, please free to start a new thread.

Good luck....

veedeoo 474 Junior Poster Featured Poster

Per your message, why windows 2008 with WAMP on virtual machine ?
why not linux with LAMPP, if this is going to serve web contents?

besides if you are using VM Virtual Box, it does allow you to install different os's. So, if you really need to have a windows 2008, then install it in different virtual drive, and then install the linux e.g. ubuntu, redhat, fedora, or whatever is more easier for you to work on.

The scenario that I am imagining right now is that

you have windows os as host opereating system ?
you have a virtual box installed in this os?

Here is an example with screenshot just to make points a lot simpler to understand.

Host computer OS: Windows : IP address by way of ipconfig : 1xx.xxx.x.xxx

Guest : Virtual Box with multi-operating system. ifconfig shown on ubuntu terminal : ifconfig 2xx.xxx.x.xxx

let say we have defined our development domain as development.dev which is hosted inside the virtual box by ubuntu server and the windows/system32/etc/hosts has these entries to make sure every http request for development.dev gets forwarded to the ubuntu server in the virtual box 2xx.xxx.x.xxx

the host computer host file entry

2xx.xxx.x.xxx development.dev

The idea is to be able to ping the ubuntu server in the virtual box. All browser request to development.dev will be serve by the apache2 in the ubuntu server inside the virtual box.

Below is the screenshot of a virtual box with ubuntu server

veedeoo 474 Junior Poster Featured Poster

You should run ipconfig on your command prompt whenever this type of error happens. It appears to me that it is an IP related problem. There is a much more reliable DNS service that will auto-update whenever your IP address changes. The free service is provided by freedns.afraid.org. They also provide auto-ip update through curl, wget, and direct url. I can't find the link but they also have a bat file that can run in the background and send any changes on your IP address for the domain names registered under your account.

I have suggested Uniform Server, because I honestly believe that this is more stable than any WAMP appliance ever created. Most WAMPP and XAMPP releases will not pass the suggested standards of live hosting. They solely designed for development with intra-network access.

I have no involvement with uniform server, but I think they cover many security vulnerabilities in running Apache, mysql, php in windows environment.

Some great options available in uniform server
can run a portable without relying so much on your windows resources
create a virtual host in an instant.
change the server configuration file from development to production server
error reporting can be disabled.
accessibility report internal and eternal (from the iternet).
IP checking.
Cron jobs
and many more.

Please take a look at the screenshot provided below running from USB drive and serving my client's development website. Yes, this tiny server can be access …

veedeoo 474 Junior Poster Featured Poster

Here is a simple derivative of the linked thread above.

I want to let you know that this is also a hybrid ( PHP and Javascript). I don't normally use server side time in displaying user time zone related content, but we need a reliable time reference.

our simple function.. save as cases.php

<?php

    function get_cases()
    {
        ## define current server time
        $time = time();

        ## define time beginning e.g. january of this year
        $beg_time = strtotime('2014-01-01 00:00:00');

        ## calculate elapsed time since beg_time
        $elapsed_time = round($time - $beg_time);


        ## return everything as array 

        return array( 

            'time'=> $time, 
            'case_today' => round(($time - (strtotime("00:00"))) / 1.7), 
            'beg_time' => $beg_time, 
            'elapsed_time' => round($time - $beg_time), 
            'ytd_cases' => round($elapsed_time / 1.7)

            );
    }


    $res = get_cases();

    ## test if we can access array output
    //echo $res['beg_time'].'<br/>';
    //echo $res['time'].'<br/>';

 ?>

The page that will display your incrementation. Save as counter.php

<?php
    require_once('cases.php');

?>


<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript">

        function getCurrentTime(){

            return <?php echo $res['time'];?>;

        }
        var timeSinceEpoch = getCurrentTime(); 

        //document.write(timeSinceEpoch);

        var heartFailure = <?php echo $res['ytd_cases'];?> ; // this is the total cases since beginning
        var caseToday = <?php echo $res['case_today'];?>;

        function casesAsOfToday(){

            caseToday++;
            document.getElementById('cases_today').innerHTML = 'Cases today ' + caseToday;

        }

        function countFailure() {

            heartFailure++;
            document.getElementById('heart_failure').innerHTML = 'Year to date cases: ' + heartFailure;
        }
        setInterval('countFailure()', 1700);
        setInterval('casesAsOfToday()',1700);

    </script>

</head>

<body>

    <div id="heart_failure"></div>
    <br/>

    <div id="cases_today"></div>


</body>
</html>

that's pretty much it. You can style the integer count by adding CSS. So, this

<div id="heart_failure"></div>

can have class attribute

veedeoo 474 Junior Poster Featured Poster

Here the screenshot to make points much clearer.

c0237142daa6bdf4519d09a30fbed2aa

The PHP extensions on the left are compiled with VC11 for the PHP version 5.6.3, while on the right side are compiled with VC9. Noticed the difference? The different files (e.g eaccelerator, apc, and many other important extension for PHP's functionalities), you can find more information about those extensions here.

One problem that you maybe facing here is to find extension that are in your current PHP versions compiled with VC11.

You just need to experiment and see if it will work. Hoping, that VC9 compiled extensions are no different than the VC11 extensions as far as functionality is concern.

If you are brave enough, try compiling your own PHP flavor using this guide. The guide requires VC12 and Some PHP extensions like ffmpeg, mp4box requires MingGW

veedeoo 474 Junior Poster Featured Poster

@D,

Luckily, I always keep screenshots on my thumb drive and desktop. Here we go Mr. L.D.A

yes it is a win executable or msi. The application is pretty lightweight. We experimented using a CSS framework like bootstrap.

We used the tideSDK with Titanium SDK. Unlike PHP-GTK, we have more success in developing with tideSDK.

below is the screenshot of a bootsrap framework working as front-end

274c117a456347408e5c34e452f35c67

the screenshot at runtime

ff1163a87aec3fc4f935daf07ec878ba

the executed desktop app using the simple Daniweb API codes as shown

$feed = file_get_contents('https://www.daniweb.com/rss/pull/solved');
$articles = new SimpleXMLElement($feed);

foreach ($articles->channel->item as $article) {
echo '<a href="' . $article->link . '">' . $article->title . '</a><br />';
}

the result

6e983e02f804e5c6a826a741a71f32f9

screenshot of the link destination of the app, once clicked. Screenshot showing the application browsing this thread.

1f0d93124e6661bdf0974de1da981cd0

screenshot of the win32 files

ea8b86b1d6278b5d720ba90eed92d671

The SDK is pretty easy to work on. In fact, they also have an android SDK and other mobile SDKs.

Example of coding in procedural

<script type="text/php">

    function set_array()
    {

       return (array('php','javascript','ruby','python'));

     }

 </script>

we can pass the output of the PHP function above onto the javascript function

<script>

    function jsFunction() {
        var index;
        var text = "<ul>";

        var codes = (show_array());
        for (index = 0; index < codes.length; index++) {
            text += "<li>" + codes[index] + "</li>";
        }
        text += "</ul>";
        document.getElementById("codes").innerHTML = text;
    }

</script>

we deliver …

veedeoo 474 Junior Poster Featured Poster

the error says it all mysql_real_escape_string() . page number is not a string, it is an integer.

So, your validation should focus on is_numeric and FILTER_SANITIZE_NUMBER_INT. Make sure to remove ., +, - before evaluating which page should be deliver to your user.

veedeoo 474 Junior Poster Featured Poster

I think you have arrived to the right place. About your opening question, I am not sure what will work for you and what will not. However, when I was a lot younger than today, I wanted to learn MVC pretty bad. In fact, I was losing some pretty good sleep just by thinking about it.

One day, it just came to me and I fully understand the concept. It was an awakening to me... the attached image below is the representation of my understanding about the MVC design pattern implemented as framework.

a54990cf45de9481bf5db0f2d9242c9f

Lorele commented: I think I noticed this image and extended response late, perhaps due to editing, but it was helpful! +0
veedeoo 474 Junior Poster Featured Poster

In addition, you need to check if $_GET['d1'] is set, before assigning to variable $d1. Otherwise, the parser will assume it is set. You can wrap it up like this

if(isset($_GET['d1']) && isset($_GET['d2])){

          ## rest of codes here

   }
veedeoo 474 Junior Poster Featured Poster

I don't think session_start() is needed in the constructor.

If you do this after logging out

print_r($this->session->all_userdata());

do you still get something ?

You can try modifying this code

 'password' => $this->input ->post('password '),
 'logged' => 1

to this

 'password' => $this->input ->post('password'),
 'logged' => TRUE

another question I have, why do you have to store password in session. Is the member id number is not enough?

veedeoo 474 Junior Poster Featured Poster

I am currently testing the CodeIgniter 3.x, or you can view flavors option here.

I will be bribing my mentor and my friend to write a tutorial focusing on modularization (similar to HMVC) of codeIgniter which can truly demonstrate the great potential of CI3.

Modularization can make codeIgniter to handle many applications running in just ONE framework, while maintaining the separation of concerns. So, app1 can have template engine different than app2. App1 and App2 can have their own libraries and helpers and own preferred template engine. Applications can share common libraries, helpers, config file if necessary, and own triad directories (controllers, models and views).

veedeoo 474 Junior Poster Featured Poster

I totally agree with cereal. That should work. The script from github was written by PHil Sturgeon. The same Phil who wrote the Pyro CMS build on top of CI and CI core contributor.

veedeoo 474 Junior Poster Featured Poster

Not sure, but you can experiment with this will give you the size of the window onload and on resize state.

The jquery part to send it to the controller is as simple as this.

Add a method for the controller

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

Class MyController extends CI_Controller
{

    public function __construct()
    {
        parent::__construct();

     }


     public function get_window()
     {

         if (isset($_POST)){

             ## filter and assigned to session
          }   

     }

Change this part of the script on second linked script above

this

url: 'text.php',

to this

url: 'MyController/get_window',

if you think you need to use routing, please feel free to do so.

If you want the jquery to update the session, make sure to add onchange event or something. So, that when the user manually change the window size, the script get updatated.

veedeoo 474 Junior Poster Featured Poster

how about using jquery to get the browser information and then submit the collected information via ajax to the controller method and then assign them to session.

veedeoo 474 Junior Poster Featured Poster

that is pretty nested. Try using switch statement.You can refactor the $tbl_code==976 to 983 as one query using PHP range function e.g. range(976,983).

range will give you an array. So, it would be nice if you can create a simple function to find out if the $tbl_code is in array to trigger the query.

veedeoo 474 Junior Poster Featured Poster

The purpose of my example is to realize the core principle of MVC design Patterns which is no other than the "Separation of Concerns". All PHP MVC and HMVC frameworks follow this core principle.

In a personal level, I have nothing against the author of the tutorial that you are following. However, things that are meant to be confined in the controller and in the model should not be found in the view files.

Codes below are wrong

    <div id="footermainPan">
    <div id="footerPan">
    <?=$this->Mediatutorialmenu->menu_bottom()?>
    <?
    $site_details = $this->Mediatutorialheader->site_details();
    $structure_core = $this->Mediatutorialheader->structure_core();
    //
    $powered = $structure_core['name'].' '.$structure_core['ver'].' build '.$structure_core['build'].' - '.$structure_core['coding'];
    ?>
    <p class="copyright"><?=$this->Mediatutorialheader->copyRight($structure_core['year'])?></p>
    <p class="powered">Powered by <?=$powered?> </p>
    </div>
    </div>

Even if the view carries an instance of the model, there is no way we can pass those data effeciently. Since the model if pretty mal-formed, expect to have an error in teh core/model.

**The reasons?: ** There must be an intance of this model, We want to take advantage of the protection provided by the helpers and libraries and most of these things must be called or instantiated in the Controller.

 Mediatutorialheader

For another chance, please allow me itimized the weakness of the source codes. If we are to follow the basic principles of MVC, then models/mediatutorialheader.php class must be instantiated by the controller/s. It does not matter how many controllers, as long as the data from the model passes the controller, so that the burden of concern on the model ends when any method returns …

veedeoo 474 Junior Poster Featured Poster

You are doing fine I think. On the other hand, 443 is normally the default Virtual SSL host as defined in httpd-ssl.conf

<VirtualHost _default_:443>

the same port number is use by default in global SSL port to listen to. common in all apache..

#################### Global SSL ##########################
 Listen 443 https

So, if we run this on a page located in the public ssl directory,

if($_SERVER['SERVER_PORT'] !==443){
  echo " We are NOT using SSL";
}

it can provide additional confirmation in checking if using SSL.

if (!isset($_SERVER['HTTPS']) OR empty($_SERVER['HTTPS']) OR ($_SERVER['SERVER_PORT'] !==443)){

     // We are NOT using SSL

}     

that will give us the tertiary check point.

veedeoo 474 Junior Poster Featured Poster

I am just guessing here and I hope someone can look at your code thoroughly

I suspect while loop is running to infinite cycle.

$done = 0;

while($done < 1){
        for($c2 = 0; $c2 < count($open_nodes); $c2++){

        }

  }

It will continue to run who knows until when. While codes below will immediately terminate when $done evaluates to true or assume the value of <1.

$done = 0;

while($done < 1){

    for($c2 = 0; $c2 < count($open_nodes); $c2++){

    }

    $done++;

}

not tested proofs ( just don't have the time actually run it, but I am assuming example below will demonstrate infinite loop.

Example 1 : This will slow down your server, because while loop will never break and will be forced to run over and over again, until the CTRL + C is hit.

$x = 0;

while($x < 1){

    for($y = 1; $y<=3; $y++){

        echo 'Y: '. $y.'<br/>';

    }

    echo '<b>X:</b> '. $x.'<br/>';


}

Example 2: This will terminate or break right away, as soon as $x evaluates to true or have incremented to 1. What is so cool about example 2 is that the output of $y would appear as if it is on top of $x and not inside of it.

$x = 0;

while($x < 1){

    for($y = 1; $y<=3; $y++){

        echo 'Y: '. $y.'<br/>';

    }

    echo '<b>X:</b> '. $x.'<br/>';

    $x++;

}

Example 2 will only loop 3 times while $x is less than 1 .

Y: 1
Y: 2
Y: …
veedeoo 474 Junior Poster Featured Poster

as already been suggested, stay away from using those short tags.

I hate adding more confusion to a broken source codes, so I have decided to write a pretty simple quidelines on the basics of CI. You can either do it like this or follow the tutorials available online.

Before anything else, decide which helpers and libraries will be needed by the controller. If the helpers and libraries are needed throughout the application, then include them in the application/config/autoload.php, else include them in the constructor or inside the method if the requirement of such helpers and libraries is isolated ONLY to such method.

1. Write the controller class

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');


class Myapp extends CI_Controller 
{

    public function __construct()
    {

        parent::__construct();

    }

    /*
    * I am loading the Myapp_model class in the method 
    * index() and not in the contructor
    */

    public function index()
    {

        /*
        * this load the application/models/Myapp_model.php.
        * once the model class is loaded, it is automatically instantiated and this is the reason I don't want it loaded in the constructor. 
        */

        $this->load->model('Myapp_model');

        ## we prepare the output as an array

        $data['content'] = array($this->Myapp_model->set_index(), $this->Myapp_model->another_content());

        /*
        * this will load the application/views/Myapp_view.php
        * we assign the data array to the view file 
        */
        $this->load->view('Myapp_view', $data);

    }

}

/* End of file Myapp.php */
/* Location: ./application/controllers/Myapp.php */

3.** Create the model class for the controller**

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Myapp_model extends …
mattster commented: Great advice, clearly a lot of effort gone into that +6
veedeoo 474 Junior Poster Featured Poster

run this. Values of the array are the most commonly used in CMS application.

<?php 

 $server_min = array(
                        'max_execution_time' => 1000, 
                        'max_input_time' => 1000, 
                        'upload_max_filesize' => '200M',
                        'post_max_size' => '200M'

                        );


     function get_php_ini_settings($server_min = array())
     {

         $res = '';
foreach($server_min as $setting => $value){
                    $res .= "$setting  : ".ini_get( $setting )."  ";
                    $res .= ini_get( $setting ) < $value ? '(<font color="red">we recommend '.$value.'</font>)': '<font color="red"> OK </font>';
                    $res .= '<br/>';


            }

            $res .= '<font color="red"><b>!Important Notice!</font></b><br/>You can optionally correct the values of the items in red. To do this, you need to make the adjustments in your php.ini file located at. <font color="red"><b>'. php_ini_loaded_file().'</font></b>';
            return $res;
     }


     echo get_php_ini_settings($server_min);

anything that has red font on it, you need to change the value in php.ini. the location has already been given to you by the script.

restart your apache and you should be able to upload upon php.ini file update.

veedeoo 474 Junior Poster Featured Poster

and the new home for codeIgniter is (drumbeat please... and another drumbeat) ...The British Columbia Institute of Technology (BCIT) in Vancouver, Canada.

Please read the official announcement from ellislab here.

IMHO, the decision made by the EllisLab is in the best interest of CodeIgniter. Although, I am not sure how far this framework can evolved in the future, I am standing by on what type of license the BCIT will have on their CodeIgniter release.

I am hoping that BCIT will remove the PHP 4 fallback and focus on the implementation of the PHP 5 standards. This could have been done by many fine coders long time ago, but due to licensing restrictions, no one even bothered to take the first step. The version 2.2.0 was an execllent move, but still the PHP 5 coding standards are partially implemented.

veedeoo 474 Junior Poster Featured Poster

here is another really quick and dirty MySQLI connector using foreach loop .

<?php

$con =mysqli_connect($dbhost,$dbuser,$dbpass,$dbname);

## Check connection
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }

    $sql='SELECT * FROM search WHERE function LIKE "%'.$search_string.'%" OR name LIKE "%'.$search_string.'%"';

    $result=mysqli_query($con,$sql);

    ## Fetch all all the result array
    $result_array = mysqli_fetch_all($result,MYSQLI_ASSOC);

    ## Free result_array set
    mysqli_free_result($result_array);

    mysqli_close($con);

    foreach($result_array as $v){

        echo $v['function'].'<br/>';
    }
veedeoo 474 Junior Poster Featured Poster

I really don't to be reiterating the common knoweledge at all times, but I think this one is one of those exemptions.

Codes below are bad

// Connection
global $tutorial_db;
$tutorial_db = new mysqli();
$tutorial_db->connect($dbhost, $dbuser, $dbpass, $dbname);
$tutorial_db->set_charset("utf8");
// Check Connection
if ($tutorial_db->connect_errno) {
printf("Connect failed: %s\n", $tutorial_db->connect_error);
exit();
}

We can instantiate the MySQLI object in one declaration like this

$tutorial_db = new mysqli($dbhost, $dbuser, $dbpass, $dbname);

we catch error if there is one

    if ($tutorial_db->connect_errno) {
        printf("Connect failed: %s\n", $tutorial_db->connect_error());
        exit();
      }

I still don't understand the unecessary while loop followed by foreach loop. However if that is what you want, change this block of codes

 // Do Search
    $result = $tutorial_db->query($query);
    while($results = $result->fetch_array()) {
    $result_array[] = $results;
    }

with this

 $result_array[] = array(); //or like this $result_array = array();
 $result = $tutorial_db->query($query);
    while($results = $result->fetch_assoc()) {
    $result_array[] = $results;
    }

Alternatively, you can eliminate the entire foreach loop and just do it like this

$result = $tutorial_db->query($query);

if($result->num_rows > 0) {
    while($result_array = $result->fetch_assoc()) {

    /*
    * add items from foreach loop here as shown on your code
    */

    echo $result_array['function']; //this is a test

    }
}

else {

echo 'Sorry your request does not exist';

}
veedeoo 474 Junior Poster Featured Poster

Here is how you can start in 10 minutes or less. (Windows)

1 - 3 minutes : download and install your flavor.

4 - 5 minutes : open command prompt assuming your installation is on windows and on c drive. cd to the nodejs directory

C:\>cd nodejs

hit enter and then type

 C:\nodejs>node
 >

let's exit for a moment by pressing ctrl + c twice to go back to nodejs directory.

6 - 10 minutes : create a new file test.js in C:\nodejs\test.js. Copy and paste codes below and save your changes.

console.log("Welcome to my first NodeJs Program");

go back to your terminal and type

C:\nodejs>node test.js

hit enter and you should get something like this

C:\nodejs>node test.js
Welcome to my first NodeJs Program

In addition to cereal's recommendation read this great tutorial. Read the Doing Something Useful - HTTP Server paragraph.

Once you have immersed with the syntax, try reading Doing Something Useful - Express it is about the express framework. Make sure to always follow these simple protocols and you won't get lost.

Practice and read Pro Node.Js for Developers from Appress written by Colin J Ihrig, Andy Ihrig.

cereal commented: good suggestions! +13
veedeoo 474 Junior Poster Featured Poster

That's pretty cool Diafol.

For people who have php version 5.3.7, they can use password_compat .

Before forgetting the purpose of my response, I think it would nice if you can add password_needs_rehash.

The same is true for the people who maybe using password_compat. When the PHP version is upgraded to 5.5, then the password_compat needs to call the password_needs_rehash method.

thank you for reading you guys :) :)

diafol commented: nice ideas +15
veedeoo 474 Junior Poster Featured Poster

You can use ffmpeg PHP, but make sure you have ffmpeg installed on your server. Not until then, I won't be able to give you my response. Yes, it can be done in PHP.

If you want to go ahead, search for ffmpeg concatenation option.

RikTelner commented: Cool. Was unaware of that. +2
veedeoo 474 Junior Poster Featured Poster

You can make the PHP QR code as joomla extension. To be able to do this, you need to follow simple rules as shown here. Pick which example is the closest to your intended application.

veedeoo 474 Junior Poster Featured Poster

Your first attempt was fine for me.

Why is it fine for me?
The $cron_id has nothing to do and it is not part of the query. So, whatever the value of the cron_id, it will not affect nor change the delete query. It may change the frequency of executing the query, but it has no controll on what to delete.

The query that will definitely require a bind_param is something like the scenario on my example below.

For example, we have a user interface that allow user to select and delete their personal files.

Based on the requirement of the interface, there will be user input involvment here. Let say the user click on the link below

<a href="delete.php?id=102"/> delete this item </a>

the delete.php can be coded like this

<?php

    if(isset($_GET)&&(filter_var($_GET['id'],FILTER_VALIDATE_INT))){

        $file_id =  filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT);

        ## the bind parameter
        $stmt = $mysqli->prepare("DELETE FROM user_files WHERE file_id = ?");
        $stmt->bind_param('x', $file_id);
        $stmt->execute();
        $stmt->close();

      }
veedeoo 474 Junior Poster Featured Poster

You cannot just do this

 <?php
    if(isset($_POST['filed'])){
    rename($_POST['file']);
    }
?>

and expect for the magical moments to occur. The reason I have provided you with the link above is for you to use them as reference and to learn more about them.

the rename function syntax is like this

rename("directory_where_file_is_located/name_of_the_file_to_be_rename.ext", "directory_where_the_renamed_file_is_to_saved/new_name_of_the_file.ext");
veedeoo 474 Junior Poster Featured Poster

ok, use your good command in html and css. Create an html document something like this

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <link rel='stylesheet' type='text/css' href='style.css'/>
    </head>

    <body>

        <div>Make this disapper on click using jquery</div> 

    </body>
</html>

create the style.css and make the <div> with blue background; widht: 400px; and height: 400px;

Write a jquery function to make the div fadeout on click. I want you to make the fadeout slow.

veedeoo 474 Junior Poster Featured Poster

I look for all of the above and these as my own personal rules (some are maybe redundant)

  1. Ask for help rather than demanding for help.

  2. Asking us to write the codes for you is a big NO! and another NO!. We can provide one if we feel like writing one for you.

  3. Trim those newbie pride of yours. "I am a seasond developer and I know what is going on." kind of statements will not get fast response. The reason is simple. If you truly know what is going on, then what in the world you are needing help. Where I'm coming from, when we assumed the title of a PHP developer, we are it and the buck stops right in front of us. We solve our own misery by intensive research. Plus, you might intimidate new developers who might know the best anwser to your question.

  4. Be thankful and be respectful to volunteers. Sometimes, a little dub of grease can get volunteers inspired and may give you more than what you asked for. If this your case, considered it one of your luckiest day.

  5. Do not post codes that are not relevant to the problem. Some members will post the entire application source codes.

  6. Do not ask questions about your school project 5 days before the deadline. Waisting the entire semester until 5 days before it ends does not make sense to me. You need to try a little harder. It is your grade and not ours.

  7. If …

mattster commented: Well said. +5
matrixdevuk commented: Agreed 100%. +2
veedeoo 474 Junior Poster Featured Poster

In my opinion, you should create a database design flow similar to what diafol have given above and from the design flow, you create the tentative database table.

The next step is visualization of your design. Once you are satified, create the actual database and add test values. The next step is query testing. The tools that I am currently using in testing proposed database is called "MysQL Workbench" which offfers database visualization, editing, query optimization, data modeling and many other cool stuffs.

A tentative database table can be something like below. A design flow is something like Diafol gave us.

exam table

exam id ( this will be an auto-incremented value)
class id
exam id
exam time
exam duration
exam type ( pre-lim, med-term, finals)
instructor assigned (use instructor id)

class table

class id (auto-incremented)
class description
class section
class instructor id
class term (winter ? spring ? summer ? fall)
class passing grade ( in percent)

instructors table

instructor id (auto)
instructor name
instructor last
instructor dept
instructor total hours
instructor total class
assigned exams ( the number of assigned exams to monitor)

instructors time table

 asignment id (auto)
 instructor id ( derived from the instructor table)
 instructory total assignments ( how many exams this instructor must give)

 time of assignment begin (time when the instructor must be in the class room)
 time of assignment end ( time when the exam will end)
 total time needed for this assignment( the sum of …
veedeoo 474 Junior Poster Featured Poster

add the extension to

$imagetype = array( 'bmp', 'gif', 'jpg', 'jpe', 'png');
$file_type = array('txt','html');

PHP file should not be allowed to be upload in your server due to security reason.

find what is the extension of the upload and then check if it is an image or a file. If image use the image validation on your script, if it is a file validate the file accordingly.

veedeoo 474 Junior Poster Featured Poster

I am new to yii and php and i want to deleveop a database design for school exam time table and maintain the time table for school management. How can I procced the same?

If you are new to PHP and PHP MVC framework like yii, I don't see any reason for you to be developing any application in this type of framework environment.

Please don't take my statement personally. I am just trying to be honest and trying to save you from gargantuan headaches.

veedeoo 474 Junior Poster Featured Poster

The purpose of this class is to be able to create an html form with ease. This is inspired by the form helper in CodeIgniter. This can easily adapt to bootstrap or any css and jquery where id is required.

To use this class, we need to include the class provided below.

require_once('FormHelper.php');

## we create an instance of the class
$form_create = new FormHelper();

we can also dynamically create <select>, by defining the option items as an array

$select_array = array('php','java','html','javascript','python','perl','jquery');

generate the form

echo $form_create->form_option('post', 'processor.php', 'myform', 'coolform');
echo $form_create->form_label('Name', 'name');
echo $form_create->form_input('text', 'name', '', 'input_class', 'type your name here');
echo '<br/>';
echo $form_create->form_label('Select Language','lang');
echo $form_create->form_select($select_array,'language');
echo '<br/>';
echo $form_create->form_submit('submit', 'Submit', 'submit_button', 'submit');
echo $form_create->form_close();

the above should give us this output

<form method="post" action="processor.php" id="myform" class="coolform">
<label class="name" id="">Name</label>
<input type="text" name="name" value="" class="input_class" placeholder="type your name here"/>
<br/>
<label class="lang" id="">Select Language</label>

<select name="language">
<option value="php">Php</option>
<option value="java">Java</option>
<option value="html">Html</option>
<option value="javascript">Javascript</option>
<option value="python">Python</option>
<option value="perl">Perl</option>
<option value="jquery">Jquery</option>
</select>
<br/>
<input type="submit" name="submit" value="Submit" class="submit_button" id="submit"/>
</form>

How to handle the parameters in methods?
Let's take this method as an example

form_input($type, $name, $value = null, $class = null, $placeholder = null)

$type and $name are mandatory, while $value, $class, and $placeholders are not even required. However, if we want to add placeholder, we cannot just put our placeholder parameter after the $name parameter, instead we need to place an empty values for the $value and $class.

 echo …
diafol commented: nice work +15
veedeoo 474 Junior Poster Featured Poster

I like the way how one ask his question. He reminded me of the Bicentennial Man my favorite movie when I was a kid.

To answer one's question, one should find the extension of the file and then based on the file extension one should execute a function to do whatever one's wishes.

veedeoo 474 Junior Poster Featured Poster

Will this be good?

How about this? It is two years old, but I think it should work with minimal upgrades.

veedeoo 474 Junior Poster Featured Poster

Really, are people unable to do even a copy and paste now? Wow.

We can pretty much see what will be the PHP developers of the future.

veedeoo 474 Junior Poster Featured Poster

You can simply do a simple test.

Check for the upload directory permission

<?php

    echo substr(sprintf('%o', fileperms('/images/news/')), -4);

check for the file upload settings on your php.ini file can also be done this way

echo 'Maximum File Upload allowed: '. (ini_get('upload_max_filesize')) .'<br/>';
echo 'Post Max Size Setting: '. (ini_get('post_max_size')) .'<br/>';
echo 'Server Memory Setting:'. (ini_get('memory_limit')) .'<br/>';

You combine those codes above will pretty much give you the answers.

veedeoo 474 Junior Poster Featured Poster

you can add it on your plugin or theme function. I don't have any time to actually check for my answer. However, I did this long time ago and this is how much I can recall.

Warning! *Please check the wordpress codex for validity of my wordpress syntax and make sure they are not deprecated. I did this long time ago and I haven't check on their updated documentation.
*
For example, if I have a plugin called veedeoo_plug and I want to register the PHP session for this plugin in wordpress global space, then I would code it something like this.

function my_session(){

     if(!session_id()){

         session_start();
     }
}

## we need to hook the above function with the wordpress.

add_action('init','my_session');

After adding the codes above, check if there are any errors. If no errors you can assign the session as you would assign them on regular php

$_SESSION['your_session'] = 'foo_bar';

for the add_action reference, please read here.

mattster commented: nice work! +4
veedeoo 474 Junior Poster Featured Poster

another thoughts..

you can also count the PROCESSLIST to find out if you are on the max connection allowed , then let the next connection to sleep, check on wake up and then sleep if there is not available slot, else let the processes to continue. 150 is a lot of connections already, but I have seen people have it set to more than 4000.

The safest and most elegant ways of doing this is probably increasing the max_connections value to some desired number, but reasonably fair to the database server to handle.

veedeoo 474 Junior Poster Featured Poster

Honestly, I think you should have not accepted the project without knowing the core requirements.

I am not insinuating here that you won't learn the frameworks, but if you haven't seen these frameworks before, I couldn't help myself not to think that you are indeed in a big trouble from the moment you took the project.

for codeIgniter, read it here.
for YII, read it here.

Make sure to read both of the links I have provided. If by any chance, it gives you a really bad after taste, make sure to return the project and be honest to your client. That is only my humble opinion.