lorenzoDAlipio 24 Junior Poster in Training

Honestly, you've developed a bad coding habit already. I am not trying to be negative here, but the way I see it, you will have a hard time correcting them. Also, I second the moderator's comments above in regards to your excessive used of static methods. The way I see it, you are not using a framework.

If your only reason to use static method and properties is due to the namespacing, then you must find a way of creating a general config page.

So instead of doing this

class Filter
{
    protected static $do;
    /* or */
    public static $do;

}

why not put $do in the bootstrap file or in the config file..

If you are using static to mimic a Framework, then frameworks uses static methods to serve immediate response to user's requests. However, there are underlying processes behind those static methods.

for example if you see

ParseController::getController();

On the view side, the above appears to be static. However, the getController() method can be returning an instantiated object + method setting a controller.

so, it can be something like this

class ParseController
{
    public $controller;

    public function __construct()
    {

    }

    public function setController()
    {
        return $this->controller;
    }

    public static function getController()
    {
        $object = new ParseController;

        return $object->setController();
    }


}

Things can be very tricky ...

lorenzoDAlipio 24 Junior Poster in Training

I thought this

$HTTP_SESSION_VARS

has been deprecated 100 years ago? I might be wrong.

pixelsoul commented: It is indeed +9
lorenzoDAlipio 24 Junior Poster in Training

ASP.net is a development framework which allows you to use either C sharp or VB.NET language. There is also a new release called ASP.net 5 that supports angularJS, GruntJs, and node.js. Visual Basic and web forms are somewhat excluded in the features.

lorenzoDAlipio 24 Junior Poster in Training

try including your connection.php after you include the header.php. Include it above all, when header.php is also needing the connection.

In your case the $connection is a variable, and one of the Dont's in developers code of ethics is to avoid using variable in global scope. The reason is that if connection is a function or a method of an object, that object or the class will not know what is being modified by other methods and functions calling the connection.

In other words, this is nothing different than using an static method of a class. The class itself have no knowledge on how the static method is implemented.

example in procedural

$connection = ''; define your mySQLI connection here.

if the mysqli connection is successful, then connection is now a variable that holds a persistent database connection. Making it a global variable creates a problem when debugging which is your case at this very moment.

The least advice I can probably give you is for you to modify your connection and wrap it inside a function. Making it accessable ONLY when the function is called.

Basic example

function dbConnect($db_host, $db_user, $db_pass, $db_name)
{
   $db = mysqli_connect($db_host,$db_user, $db_pass,$db_name);

    /* check if there is a connection error */
    if (mysqli_connect_errno())
      {
      /* you may want to remove the error reporting in production server */
      echo "Failed to connect to Database: " . mysqli_connect_error();
      /* in production server, you need to replace the above with */

      //return false;

      }

      return($db);

  } …
lorenzoDAlipio 24 Junior Poster in Training

this will also work as an alternative to str_replace

$string = trim($string,'(())');
lorenzoDAlipio 24 Junior Poster in Training

okay, I double checked here and I was wrong, affected_rows can be use either update, insert, and select queries.

so if you defined $conn like this

$conn = new mysqli("localhost", "my_user", "my_password", "your_database_name");

you can replace the

$result->num_rows

with ( as suggested by Diafol above)...

$conn->affected_rows;

you should be able to evaluate

<?php if($conn->affected_rows > 0){ ?>

    message sent.

<?php

}

?>
lorenzoDAlipio 24 Junior Poster in Training
$result->num_rows

is a method for select query, while

$conn->affected_rows;

is for the affected rows after executing an insert query. That's what I think. I might be wrong ????

lorenzoDAlipio 24 Junior Poster in Training

you can try creating functions that will sequentially handle the steps.

example,

function firstStep()
{
    /* create database here */

    /* if database has been created */

    /* return true; */

 }

 function secondStep()
 {
     /* insert dummy data */

 }

check if ready for the second step..

if(firstStep()){

    /* do second function */
    secondStep();
 }

you can also do 1 - 2

if(firstStep() && secondStep()){

    echo 'Success';

}

Another good alternative is chaining methods, if you know how to code in Object oriented..

diafol commented: +rep for mentioning chaining - a very underused method +15
Gideon_1 commented: Yh, coding in OOP is great, chaining. thumbs up +0
lorenzoDAlipio 24 Junior Poster in Training

It's a matter of preference. However, regardless of what you use, you still have to loop through the result.

There is not much difference between while loop and foreach loop. There is an 8th of advantage if you don't loop inside the logic of your application. What requires the most server resources is the double looping shown by very last example below.

for example, if you are using PDO, you can easily send the data outside the function as output.

example of data is being return

function getData($query)
{
    $db = dbConnect('localhost','user','pass','database_name');
    /* you will have to add error checking here */
    /* you can also do prepared statements here */

    $result = $db->prepare($query);
    $result->execute();

    return($result->fetchAll(PDO::FETCH_ASSOC));

}

or you can simply return( the query method in PDO)

    return($db->query($sql));

you can call the function above and loop through data

$rows = getData( "SELECT user_name FROM users");

    /* deliver the results */

    foreach($rows as $row){
        echo $row['userName'] .'<br />';
    }

the above is more elegant approach, because you can separate your presentation logic from the data handler or business logic.

codes below will have the same result, except the results are looped inside the function. If you replace the codes above with this

$result = $db->query($query);
    while($row = $result->fetch_assoc()) {
    echo 'user : '. $row['userName'] . '<br />'; 
}

If you want to get rid of the echo, you will not be able to take the results out of it, unless, you iterate through the end of …

lorenzoDAlipio 24 Junior Poster in Training

if you are confident with you codes, then just leave it like that and wait for someone to help you maybe they can do better.. :). Just my humble opinion.

lorenzoDAlipio 24 Junior Poster in Training

you should add

return true;

somewhere in your confirm_query() function, preferrably after the die() function and then you can evaluate like this

if(confirm_query($insert_query)){
        /* you won't pass this point if it is false right? */

        /* do whatever you have to do */

}

relying on die() function is a poor choice though. Not saying that you are wrong, but there are other options.

lorenzoDAlipio 24 Junior Poster in Training

I forgot to give you the download link.

Also, I would like to remind you about the security implications of file_get_contents as described in the php security consortium. So, instead of using this function, it is highly recommended to use cURL and then the DOM HTML parser API.

Example of cURL option

function getContents($site_url) {

    /* first off, the curl initialization */
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $site_url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);       

    /* execute the curl */
    $site_data = curl_exec($ch);

    /* anything that you open must be close immediately */
    curl_close($ch);

    return $site_data;

}

assuming you have downloaded the DOM parser above, we can use it like this

include_once('simple_html_dom.php');

$scrape = file_get_html(getContents('some_remote_site.com'));

/* do as my first response example above */

if you don't want to selectively parse the html tags, then parsing is simple as this

echo (getContents('some_remote_site.com'));
lorenzoDAlipio 24 Junior Poster in Training

another option that will give you a total control is php html DOM parser API.

for example,

$scrape = file_get_html('somesite_to_scrape.com');
/* get the css line */

foreach($scrape->find('link.href') as $css_file){
        /* this is the css file location */
        $css_file;

        }

you can also do it with javascript..

lorenzoDAlipio 24 Junior Poster in Training

try,

public function add_email()
{
    /* set errors var as array */
   $errors = array();

   $this->load->library('form_validation');

   $this->form_validation->set_rules('name', 'Name', 'trim|required');
   $this->form_validation->set_rules('email', 'Email Address', 'trim|required|xss_clean');

   /* check if any of the validations fails */
   if ($this->form_validation->run() == false) {
       /* take all of the validation errors as errors */
        $errors['errors'] = $this->form_validation->set_err();

        /* assign the data to your view file */
        $this->load->view('NAME_OF_YOUR_VIEW_FILE', $errors);

    }

on you view file, you can show the errors by adding these next to the form elements.

 <!-- error for name -->
 <?php echo (isset($errors['name']) ? $errors['name'] : ''); ?>

 <!-- error for email -->
 <?php echo(isset($errors['email']) ? $errors['email'] : ''); ?>

Try avoiding the use of PHP echo shorthand. Not all php.ini file have this enabled by default. Besides, in enterprise working environment, they would not allow it. It is nice to develope a good habit earlier than correcting a bad habit that has been going on for years.

Although CI would never twist your arms to have a model, it is always nice to completely follow the M-V-C patterns when writing an application. By doing this, you will not have any difficulties in transitioning between different frameworks.

A good way to remember the M-V-C pattern is to put all data processor in the model and grab the processed data in the controller and then passed it to the view..

good luck..

lorenzoDAlipio 24 Junior Poster in Training

I don't have the chance to test my script above, but for any reason it failed to run, please let us know. I don't visit daniweb everyday, but I do visit at least once a week.

lorenzoDAlipio 24 Junior Poster in Training

Hi,

Just to give you a simple example. By the way there are many terminologies used to describe what you want to accomplished. On a lower level, it can be called simple router and simple dispatcher. Some will call this as front controller which is a pattern that implements a router class and a dispatcher class. As the application gets bigger, this simple concept has grown to become the foundation of a simple framework, where the requests are translated into some meaningful object/objectAction/parameter1/parameter2/ combination.

Assuming that your development server is set to have .htaccess. This can be set on your apache2/conf/httpd.conf file.

Create directories and files needed

+demo
    +blue
        blue.php
    +red
        red.php
    .htaccess
    index.php
    error.php

load the .htaccess file on your source code editor e.g. notepad++, or plain text editor. Add these codes and then save.

<IfModule mod_rewrite.c>

    RewriteEngine on
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule .* index.php/$0 [PT,L] 
    #RewriteRule ^(.*)$ /index.php/$1 [L]

</IfModule>

The directives above tells the apache to direct all requests to index.php. So, you don't need to do localhost/index.php?q=blue, but instead you do like this localhost/blue/.

next, load the index.php and add these codes.

function getBaseUrl()
{

    if (isset($_SERVER['HTTP_HOST'])){
            $base_url = (empty($_SERVER['HTTPS']) OR strtolower($_SERVER['HTTPS']) === 'off') ? 'http' : 'https';

            $base_url .= '://'. $_SERVER['HTTP_HOST'];
            $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);

   }else{
            $base_url = 'http://localhost/';
        }

    return($base_url);
}

/* call the function above */
$base_url =  getBaseUrl();

/* parse the base url */
$parsed_url = parse_url($base_url);

/* take the path of the above …
lorenzoDAlipio 24 Junior Poster in Training

just to add another hint. Normally, we we add packages from packagist.org through composer. We would look for the class needed to install or setup the package. In the case of Doctrine, the package wanted us to add this on the composer.json file inside the require block.

 "doctrine/orm": "*"

while on the front controller or bootstrap, they want us to have this

require_once "vendor/autoload.php";

use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

the problem here is that we don't even know if the package is properly loaded or installed.

If you want you can experiment by opening

vendor/doctrine/orm/lib/Doctrine/ORM/Tools/Setup.php

find the closing bracket of the method

public static function createConfiguration()
{
}

and then add

public static function testSetup()
{
    echo 'testing setup'.__CLASS__.'<br/>';
}

open your command prompt and then type

composer dump-autoload -o

hit enter;

open your bootstrap, and then call the static test method

setup::testSetup();

good luck...

lorenzoDAlipio 24 Junior Poster in Training

can you post your composer.json? Just want to see how you set up the autoload for PSR-4. For example, I have something like this for the MVC I co-wrote with Veedeoo

"autoload":{
            "psr-4":{
                        "System\\" : "vendor/geeglerapp/system/",
                        "App\\" : "vendor/geeglerapp/app/",
                        "Tbs\\": "vendor/tinybutstrong/"



                    }



}

keep in mind that some packages are 2 directories or more deeper inside the vendor directory.

Did you try typing this on your command prompt

dump-autoload -o

it is "o" and not zero.

Whenever you added or change namespaces on a file, you need to use the dump command.

lorenzoDAlipio 24 Junior Poster in Training

$_REQUEST will also process even if the method is not defined. Such as

<form method="" action="yourprocessor.php">

Malicious request can also be sent to your site, in this manner

yourprocessor.php?name=hello&last=world&code=javascript:;alert(something);

print_r($_REQUEST);

although the javascript will not cut it on today's advance browsers, the use of $_REQUEST is highly discouraged. It was added only for the purpose of pre-development and no way it was intended for lazy form processing.

If you want to improve your application, you may want to consider browsing the packages in packagist.org and learn how to use composer. Composer is a dependency management for PHP.

here is a collection of routers from packagist.org. You can browse them and select the one that you can comfortably implement to your controller, model, and view. If you don't want to install the package via composer, you can get it from github and download as a zip file.

Under any circumstances, you DO NOT do this to create an object of the controller and its method.( Assuming the part of your codes below execute or instantiating something, please don't do it).

 $result = $controller->execute($_REQUEST);

executing something that we don't really know is pretty scary.

Most routers, works like this, regardless if it is the biggest router like the symfony2 router or a simple router like mine. **WARNING! this router contains many static and yes, I am considering going back to school maybe someone can teach me how to code in OOP. **

This how …

lorenzoDAlipio 24 Junior Poster in Training

you can try using

is_uploaded_file('some_file');

to validate if the file was uploaded.

Another alternative way of doing this is to check if the file has been moved or not.

if(move_uploaded_file()){
    //do whatever is needed to done

}

you can also check based on the user's input,

$there_is_file = (!empty($_POST['upload']) ? true : false );

if($there_is_file){

    //process file
}

else{

    //leave it alone on update

}    
lorenzoDAlipio 24 Junior Poster in Training

this should be an easy thing for you to code. Have you look at jquery ajax?

lorenzoDAlipio 24 Junior Poster in Training

plus, you can rewrite this

if($ins>0){ 
    echo "sucess";
}

to something like this

if($ins){ 
    echo "sucess";
}

because anything greater than zero are always presumed to be true.

lorenzoDAlipio 24 Junior Poster in Training

did you try something like this?

 if(pwd.value != rpwd.value)
lorenzoDAlipio 24 Junior Poster in Training

I totally agree with all of the definitions above. On the other hand, frameworks can limit the type of application that you can built. However, there is a framework like CodeIgniter that can be easily bent, molded, and hammered to your requirements.

If you will be distributing an application intended for all types of hosting, then framework may not be your best choice, because framework tend to consume more resources.

Using framework you are in control of your source codes and libraries. Meaning, you will be writing them instead of a download and intall found in CMS. If written properly, framework application are more secure, because you don't have to rely on downloadable plugins similar to the ones found on CMS.

For really serious application, I personally prefer writing it in the framework rather than cutting corners and downloading the readily available CMS with unknown plugins from unknown authors.

Since you are already proficient in using jquery, have you look into possibility of using node.js that can utilize expressjs, sails.js, and Koa frameworks?

Although your question is PHP related, node.js is perfect for big and small web application. Besides, node.js can utilize the simplicity and speed of MongoDB.

lorenzoDAlipio 24 Junior Poster in Training

to help you out guys, here is the complete refactoring reference table for all video getters.

                +--------+
                + thumb  + 
+---------------+--------+
+ youtube       + false  +
+---------------+--------+
+ funnyordie    + false  + 
+---------------+--------+
+ dotsub        + false  +
+---------------+--------+

           +-------+-------+-------+
           + thumb + size  + url   +
+----------+-------+-------+-------+
+ metacafe + false + false + false +
+----------+-------+-------+-------+
+ twitpic  + false + false + false +
+----------+-------+-------+-------+

       +-------+-------+--------+
       + size  + embed + iframe +
+------+-------+-------+--------+
+ blip + false + true  + true   +
+------+-------+-------+--------+

            +-------+--------+
            + embed + iframe +
+-----------+-------+--------+
+ revision  + true  + true   +
+-----------+-------+--------+
+ videojug  + true  + true   +
+-----------+-------+--------+
+ hulu      + true  + true   +
+-----------+-------+--------+


             +--------+
             + iframe +
+------------+--------+
+ slideshare + true   + 
+------------+--------+

                +--------+-------+
                + iframe + url   +
+---------------+--------+-------+
+ soundcloud    +  true  + true  +
+---------------+--------+-------+
+ kickstarter   +  true  + true  +
+---------------+--------+-------+
+ ted           +  true  + true  +
+---------------+--------+-------+

                +--------+
                + url    + 
+---------------+--------+
+ instagram     +  true  +
+---------------+--------+

by Veedeoo's recommendation the tables above are the refactored values against the defined default value..

Also, I would like to agree on the smarty template engine as viable option in creating cached content. At least, if you choose this option, you will have to do it once. If the source code will be needing refactoring in the future, the template will only need minor modification as needed.

lorenzoDAlipio 24 Junior Poster in Training

I totally agree with the above response. Once you declare an abstract method within abstract class, it will impose a mandatory must have method in the child class.

Unlike, in factory pattern a class can also be written in abstract class without abstract method, but methods within the abstract class can return a clone of an instance of a class from different namespaces.

lorenzoDAlipio 24 Junior Poster in Training

If you are really serious about your question and willing to invest a $1.99 for a good used PHP book. Look for the book entitled Programming PHP(second edition) by Rasmus Lerdorf, Kevin Tatroe,Peter MacIntyre. It is currently on sale for $1.99 at barnes&noble.

You can also look for the PHP books published by O'Reilly Media. I highly recommend the coverage of O'Reilly on the arrays.

lorenzoDAlipio 24 Junior Poster in Training

this

$content = file_get_contents("http://www.phpfastcache.com/testing.php");

get the remote page named testing.php from the phpfastcache.com by way of cURL, API or mySQL query.

for example if the testing.php returns

<!doctyp html>
<html>
<head>
</head>
<body>
    <h1>Hello world </h1>
</body> 

then the cache class will make a cache file of the page and generate a new file after 5 seconds as defined by the static method called set.

phpFastCache::set("keyword1",$content,5);

keyword1 is something that you need to define. So, if we call the static method set like this

phpFastCache::set("helloword",$content,5);

the cache file created by the class will be helloworld.

You have mentioned earlier about external urls from youtube,vimeo, dailymotion and so forth. The problem here is that even with the cache file generated, the url remains external. Meaning, the browser viewing the cached or non-cached page will still have to work hard in picking those embedded url.

What I am trying to tell you is that caching your content will not make sense, because the embedded url are external. However, it will only make sense if and only if the url are stored in the database. This will save you some loading time equal to the time that your server will send and return the query results.

If you are generating the url from the database, the resulting data can be represented like this. Let say we have a page called search.php with the following codes..

 //function get_data()
 //{
      $data = array(
                'youtube' => 'some_item_from_youtube',
                'vimeo' => …
lorenzoDAlipio 24 Junior Poster in Training

Guys, allow me to add something important here. CI is backward compatible with PHP4 and therefore if you want to write a PHP5 controller, then the constructor must be define and the parent constructor must be called within the controller class constructor.

e.g.

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

     }

 }

otherwise, this made the method index to act like a constructor

class YourApp
{

    public function index()
    {

    }
} 

and, any methods that are needed by the template can be called within the method index. Otherwise, it must be explicitly define by a route ( if the expected uri is different than the object/method convention).

class YourApp
{
    public function index()
    {
      $this->other_method();

     }

     public function other_method()
     {

         return 'something';
     }    

 } 

the above can also work without a defined route for the second method e.g. localhost/yourapp/other_method/, but this will expose your application to non-routed object/class vulnerabilities common to user profile unauthorized viewing.

The common vulnerability in auto routing in CI can be demonstrated by the codes below

class User
{

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

    public function index()
    {
        // some default stuffs here

    }

    public function get_user($id)
    {
        // $id = some segment //
        //get user credential base on $id

     }

}     

What will happened if someone load this http://localhost/user/get_user/5 ? With few tries, they can pull out something from the application.

though PHP4 backward compatibility is the norm in CI, we CANNOT do this...

class YourApp …
lorenzoDAlipio 24 Junior Poster in Training

I honestly believe that the lastInsertId() is the most error proof for this purpose.

lorenzoDAlipio 24 Junior Poster in Training

@V, dude I like your style :).

lorenzoDAlipio 24 Junior Poster in Training

I think PHP is pretty loose in implementing license compliance. Providing link to your webpage is an excellent way showing your appreciation to the creators and contributors of PHP distribution.

You can also aknowledge them by just including your acknowledgement inside the source code.

for example,

<?php

    /*
    * source codes are written in PHP. For more information about
    * PHP license, please visit http://php.net/license
    */

How about your html framework e.g. bootstrap vs. foundation?

If you are using bootstrap, another consideration must be given on the use of glyphicon and bootstrap. Glyphicon have a very strict licensing. The majority of developers use font-awesome when distributing application, because of the MIT licence which is an open source friendly.

Bootstrap is license under Apache v2.0 which can be included in GPLv3, but GPLv3 cannot be included in the Apache v2.0. It is like putting a coffee creamer over coffee, but coffee is not allowed to be pour over coffee creamer. However, MIT license can co-exists with Apache v2.0 without precendence. This is the reason why we can install PHP in apache server. Another good example is the case of nginx server with 2-clause BSD-like license, that can serve as a reverse proxy for the apache server, but you cannot make the apache2 to carry out the reverse proxy configuration for the nginx.

As Veedeoo already stated, licensing compliance is the most complicated one to follow because of the thin line separating them.

lorenzoDAlipio 24 Junior Poster in Training

please elaborate. It is hard to speculate .

lorenzoDAlipio 24 Junior Poster in Training

Unlike in PHP, composer.json is run by NPM in node.js.

To be able to use jquery in node.js, you can run a command like this..

cd your_node_directory
npm install jquery

you can also use bower for the same purpose

bower install jquery

I prefer NPM over bower.

To use jquery in node.js, you can easily add it on your app.js or anywhere where it fits. After installing the jquery, you can do something like this.

$ = require('jquery');
var yourVar = require('jqueryFunctionHere');

node.js is pretty much the same as PHP, Ruby and Python.

node.js application can also be written in MVC framework similar to Codeigniter in PHP. It can also use template engine like blade similar to the template engine in Laravel.

Node.js should not viewed as the user side javascript and should have its own forum in Daniweb, instead of mixing it up with html/javascript. Node.js is equally powerful just like PHP, RUBY, or Python.

Node.js can use mongodb which can make the landscape of web development a lot different than 7 years ago. I honestly beleive that it is more faster than PHP with lesser vulnerabilities.

lorenzoDAlipio 24 Junior Poster in Training

what is your os? linux or windows?

lorenzoDAlipio 24 Junior Poster in Training

you probably need node.js. It is a server side javascript. Server side javascript can pretty much do what other server side scripting languages can do.

lorenzoDAlipio 24 Junior Poster in Training

whatever happened to your <body> after </head>?

lorenzoDAlipio 24 Junior Poster in Training

We always try to prevent ourselves from sinking into recursive function in PHP. However, if that is what you need, please consider the simple function I wrote to demonstrate how recursion works.

Recursion in PHP is a function or method that calls itself within itself.

Huh!???? I know my definition is a little blurry. For a moment allow me to provide a generic example without logic.

function genericFunction()
{

    return genericFunction();

 }

We can make our simple non-logical function above as template.

Let say we have a paren array as shown below,

$parent = array(
                    'a'=>(array('a_one' => 'a_one value','a_two'=>'a_two value', 'a_three' => 'a_three value')),
                    'b'=>(array('b_one' => 'b_one value','b_two'=>'b_two value', 'b_three' => 'b_three value'))
                    );

and we want a function that will give us the $parent['a'] and $parent['b'] recursively.

Array ( [a_one] => a_one value [a_two] => a_two value [a_three] => a_three value ) 
Array ( [b_one] => b_one value [b_two] => b_two value [b_three] => b_three value )

we can simply write a function that can do or provide us an output like the above.

the function::

function find_child_in_parent($child,$parent = array())
{

    if(is_array($parent)){

        foreach($parent as $p_key => $p_value){

            if($p_key == $child){

                return ( $p_value );
            } // endif

         } //endforeach

         if(is_array($p_value)){

            //recursion here
            $recursion_res = find_child_in_parent($child,$p_value);

            return($recursion_res ? $recursion_res : FALSE);

            }

            return FALSE;





    }

    }

we call the function like this

 $parent = array(
                    'a'=>(array('a_one' => 'a_one value','a_two'=>'a_two value', 'a_three' => 'a_three value')),
                    'b'=>(array('b_one' => 'b_one value','b_two'=>'b_two value', 'b_three' => 'b_three value'))
                    );

     print_r(find_child_in_parent('a',$parent)); …
lorenzoDAlipio 24 Junior Poster in Training

I totally agree with it being bad. Bad if you allow your user to see it. Errors about your script, database, config file, ando other site related settings must be keep private and must be recorded in the log file.

lorenzoDAlipio 24 Junior Poster in Training

you need to create routing directives for it.

$route['movies'] = "movies/cool";

assuming that you have movies.php in your application/controllers/ directory and it is coded something similar to this

class Movies extends CI_Controller
{

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

    public function index()
    {

        // you can do some other options as opposed to just cool method //

    }

    /* 
    * @cool method
    * execute cron job
    */

    public function cool()
    {

        //put your cron here
        // don't forget to run it on the background

        //catch cron-job log here if needed
        //if cron-job is successful return something or return true.

    }


    public function cron_status()
    {

        //this will check if the cron job log file exists
        // check the cron job status 
        // if a success return something 

        //call this method in the index method above, but make sure the reporting is only available to the administrator of the site.
      }

 //end of the class

 }

Another feasible option is to create a cron-job libraries and just load it whenever it is needed.

lorenzoDAlipio 24 Junior Poster in Training

I need to know how many people are interested in learning how to write a desktop application using PHP? If I get enough interest on this topic, then I will write a simple tutorial on how its done.

We (veedeoo and me) were experimenting on Desktop apps utilizing the Daniweb API. I don't have the screenshot for now, but if there are reasonable number of interested party, I can easly provide some.

Please let me know and thanks for reading. You can either response or click on the up vote..

lorenzoDAlipio 24 Junior Poster in Training

It would be nice if we can have server side js e.g. node.js, google polymer and jquery.mobile sections. I honestly believe that node must be treated as a server side scripting like PHP.

lorenzoDAlipio 24 Junior Poster in Training

You need to at least show us something that you have done.

lorenzoDAlipio 24 Junior Poster in Training

I truly admire your ability to write and read your codes in this form. However, I would also like to advice you to at least indent your codes, so that we can at least follow the flow of your script. PHP-FIG suggested PSR-1 and PSR-2.

lorenzoDAlipio 24 Junior Poster in Training

XAMPP is intended for quick web application development and should not be use as a frontend for production environment. Try Uniserver. Uniserver allows you to easily configure the server to either production or development. The apache, PHP, and MySQL configurations are easy to tweak.

I have a client who wanted to host their basic corporate website locally. Since the website is so small, I develop everything inside a 10gb flash drive.

  1. sign-up for free account at freeDNS.afraid.org. Make sure to download their IP address update.
  2. Use the nameserves provided by the freeDNS site. You need to add these nameservers by accessing your domain registrar account panel.

  3. Configure the vhost.conf

  4. create you site's files

  5. wait for your domain to propagate and your good to go.

lorenzoDAlipio 24 Junior Poster in Training

I normally develop PHP apps in windows environment using Uniserver as WAMP server. Before the app release, I would run my application to linux environment to make sure everything works.

Some basic differences between developing PHP application in Windows vs. Linux.

  1. in Linux, we can use nginx as the front server and use apache2 as the backend server, which is by far faster than letting apache2 do the job by itself.

  2. files and directories permission. We have more control in Linux.

lorenzoDAlipio 24 Junior Poster in Training

nice proofs veed. You can also spread those proofs upwards and sideways similar to 4 axis, thus making it not leaving any stone unturned.

lorenzoDAlipio 24 Junior Poster in Training

try to validate between the hash and the something['user_pass']?

user password input --- hash this password Vs. something['user_pass'].

Make sure the password stored in your database used the same hashing mechanism as the validation hashing mechanism.

lorenzoDAlipio 24 Junior Poster in Training

I've noticed on your codes, why are you still using mysql_? I have not seen this for a while. Use either PDO or MySQLI. mysql_ has already been abandoned and the authors have not intension of any future upgrade.

lorenzoDAlipio 24 Junior Poster in Training

I totally agree with the Moderator and the Administrator. Item can be set and it can also be empty.

$test = '';

    if(isset($test)){

        echo 'Test is set and is empty';

        }