veedeoo 474 Junior Poster Featured Poster

Double check your file extension.. or double check if your server supports short tags..My reasoning behind the short tags may not be allowed in your server is that, the only php codes showing on your screen shots are the part of your codes below the short tags.

veedeoo 474 Junior Poster Featured Poster

Hi Diafol,

For the fullscreen, the colorbox event assignment to element example7 ( as defined on my demo) it was set to

        $(".example7").colorbox({width:"75%", height:"75%", iframe:true});

I just changed the % values for both width and height to 100%. :) pretty neat huh?

We can also load jwplayer on the colorbox just by referring to the player.swf and the youtube video id, but I got an email from google 6 weeks ago telling me that I cannot distribute anything that loads youtube videos on different player. I guess its fine for me to show demos in the google API community but cannot distribute.

veedeoo 474 Junior Poster Featured Poster

Hi,

When you run this script, is your computer connected to the Internet? If so, then we need to test your script outside the class. I am not sure if that class is even functional. Lets make a simple function that will load external xml file via cURL.

here we go...

        function loadThisXmlFile($url){

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)');  
        curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,10);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
        curl_setopt($ch, CURLOPT_AUTOREFERER, true);
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        ## store data as an output
        $output = curl_exec($ch);
        curl_close($ch); 
        ## load stored data 
        $xml = @simplexml_load_string($output);
        ## return output as an xml file
        return $xml; 

        }

to use the above function for testing do it like this..

    ## change the url to your own xml target
    print_r( loadThisXmlFile('http://feeds.bbci.co.uk/news/england/london/rss.xml'));

If all is well, then there should be some data showing on the page.

Let me know what you are getting after running the simple function I have provided above, so that we can move on to the next step..

veedeoo 474 Junior Poster Featured Poster

I am pretty sure this is what the book is talking about.(Basic constructs). Not the same constructor, I thought it would be..

It should be called control structures..

veedeoo 474 Junior Poster Featured Poster

check if your colorbox.css and jquery.colorbox.js exists. to use colorbox for youtube videos the href format should be like this

    <a class='youtube' href="http://www.youtube.com/v/Vo_0UXRY_rY" >

Here is a demo, please feel free to look at the source code. Please DO NOT make a direct link on my js and css files. That is all I am asking..

To add title on the colorbox, you will have to add title attribute to the link, like this

<a class='youtube' href="http://www.youtube.com/v/Vo_0UXRY_rY" title="This is Title">
veedeoo 474 Junior Poster Featured Poster

Let me add something, because I just noticed you are using mysqli, so the php.ini file settings for the mysqli should be something like this

    ;this is the entire site using mysql 3 for three seconds time out in seconds. If you have other applications running on the native mysql, then increase this to the number of seconds you want before timing out. -1 is no timeout at all.

    mysql.connect_timeout = 3

    ; by the way this -> ; is how you comment on the php.ini file

    ;for the mysqli settings,
    mysqli.max_persistent = -1
    ; Maximum number of persistent links.  -1 means no limit.
    ; http://php.net/mysqli.max-persistent
    mysqli.max_persistent = -1

    ; Allow accessing, from PHP's perspective, local files with LOAD DATA statements
    ; http://php.net/mysqli.allow_local_infile
    mysqli.allow_local_infile = On

    ; Allow or prevent persistent links.
    ; http://php.net/mysqli.allow-persistent
    mysqli.allow_persistent = On

    ; Maximum number of links.  -1 means no limit.
    ; http://php.net/mysqli.max-links
    mysqli.max_links = -1

    ; If mysqlnd is used: Number of cache slots for the internal result set cache
    ; http://php.net/mysqli.cache_size
    mysqli.cache_size = 2000

If you want to make sure that the short tags is allowed on your server change this value

    ;short_open_tag = Off

to this

    short_open_tag = on

If you want to write your php codes with ASP opening and closing style, for example these

    <?php

    echo "hello";

    ?>

Can be written also as and the php handler will parse this..

    <% …
veedeoo 474 Junior Poster Featured Poster

You may want to check the values assigned to max_input_time, max_input_vars, memory_limit, post_max_size , max_execution_time. You can either change the values of these items in WHM panel under domain management or account management. However, if you would like an independent changes for each domains hosted in your VPS server, you can changed them by adding a new php.ini file in the root of the domain executing the script in question.

Before we can change anything, we need to know the Server API of your server and the Loaded Configuration File (php.ini). Create a new document and save as info.php, paste codes below unto this document

<?php

phpinfo();

?>

Upload the info.php to your server. Direct your browser to this page. Look for the values of Server API and the loaded configuration file. Once we know the location of the loaded configuration file, we can change the values as required by your script.

  1. You can either access this via black box or terminal just by typing (terminal only)

    sudo -s
    ## type in your password
    ## then type gedit or whatever is the installed editor on your server
    cd location of your loaded configuration file
    v /location of your loaded configuration file/ 
    

Or, if you have a windows desktop, then you will need a free SSH program called Putty. Open putty, and log on to your remote server.. I believe we can do this on putty

    cd /directory of your loaded configuration file normally it is etc/ …
veedeoo 474 Junior Poster Featured Poster

Hi,

On your vps account, what do you have? WHM panel ? or something else?

What is your setting value for

    mysql.max_persistent 

You can read more of the most common settings here. Anything where it says php_ini system under changeable column can be adjusted or changed on your servers loaded configuration file. loaded configuration file can be found by running

phpinfo();   
veedeoo 474 Junior Poster Featured Poster

hi,

can you echo this in the same directory as your script and one in the image directory. Whatever comes up, that is your working directory and the image directory .

    basename(__DIR__) 
veedeoo 474 Junior Poster Featured Poster

Hi,

The answer to your question can be found in codex..although the tutorial is about integrating wordpress with your site, you can easily create a new page where the tv shows are embedded, and then create a link on wordpress to your tv show page.

I once wrote a tutorial on wordpress integration, but it was 3 years ago. I don't know much of the changes in codex since then.

UPDATE:

You can also search the plugins library for something similar to what you are trying achieved.

veedeoo 474 Junior Poster Featured Poster

Hi,

Can you please show us your upload processor script. How does the script filter the extensions? for example

    list(, , $thisImagetype, ) = getimagesize($_FILES['image']['tmp_name']);

if ($thisImatetype == 3){
    $type="png"; 
}elseif ($thisImagetype == 2){
    $type="jpeg";
}elseif ($thisImagetype == 1){
    $type="gif";
}
veedeoo 474 Junior Poster Featured Poster

Hi,

Thanks for the kind message. Yes, try it. The above cURL script should be functional. I was using it for a long long time, including remote age verification, paypal authentication and some other things.

As an alternative, you can also do API ajax response if it is available from the remote site as what pritaeas suggested. If API or rss feeds is available, it should be the right choice than using cURL.

veedeoo 474 Junior Poster Featured Poster

@Mitch,

It could be just a url stuff and nothing serious. If you could output the other data off from the same file, maybe it is just the directory reference mishaps. Did you try

    ../images/

On your image's src?

Back to the case of smarty's iteration function.. I totally agree with all of you. I have no problem digesting whatever is posted here. Except for the odd implementation on the constructor.

For the template, LastMitch implemented the section loop instead of the foreach loop. So, it is pretty much capable of what the foreach can do.

    {section name=tbl loop=$book->title}

I preferred using dot notation though as much as possible, but it just only me :).

LastMitch commented: Yes, it was the URL all along +9
veedeoo 474 Junior Poster Featured Poster

WARNING! It is not my intension to promote any unauthorized content parsing. By using the script I have provided below, you are responsible for any copyright violations and damages it may caused.

Knowledge is Power, but it can also destroy many things, if the probable consequencies are not evaluated, before hand.

Remote Server form structures
Let say, the remote site have a form structure like this

<form action="remoteProcess.php" method="post">
<input type="text" name="first_name">
<input type="text" name="last_name">
<input type="text" name="roll_number">
<input type="submit" name="submit" value="submit">
</form>

Assuming that the remoteProcess.php" will return "records not available" on all faults, and return something if roll_number is valid one.

On your Server

This simple cURL implementation can parse the remote response to your site.

## first you need to process your own form in your site.
if(isset($_POST['submit'])&&(!empty($_POST['fname'])) && (!empty($_POST['sname'])) && (!empty($_POST['roll_number']))){

## You must add more form filtering before sending it to the remote site.
## if all is well, prepare your data for remote trasmission using cURL

## define remote form processor script
$location = 'http://remoteSite.com/remoteProcessor.php';
## define your user agent
$userAgent = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)';

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_VERBOSE, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $location );

$post_array = array(
    "first_name"=>preg_replace('/[^a-zA-Z0-9 ]/s', ' ', $_POST['fname']),
    "last_name"=>preg_replace('/[^a-zA-Z0-9 ]/s', ' ', $_POST['sname']),
    "roll_number" => $_POST['roll_number'],
    "submit" => "submit"
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array); 

## grab the response from the remote form processor
$response = curl_exec($ch);

## …
veedeoo 474 Junior Poster Featured Poster

This might be the code responsible for creating the salt.

    // Create a random salt
  $random_salt = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
 // Create salted password (Careful not to over season)
 $password = hash('sha512', $password.$random_salt);
veedeoo 474 Junior Poster Featured Poster

Here is a simple example of joins. I could have written this in shorthand form, but I will do it in long haul to make my points a lot clearer.

Say, we have a table called students, and on this table we have id, name, username, password, email, course_num, and status columns.

+-----+------+----------+----------+-------+------------+----------+
+ id  + name + username + password + email + course_num + status   +
+-----+------+----------+----------+-------+------------+----------+
+ 100 + name + user     + pass     + @home + 300        + enrolled +
+-----+------+----------+----------+-------+------------+----------+

Another table called courses is also in the same database, and it also have the following columns course_id, course_name, instructor,term, year. course_id is not auto incremented.

+------------+-------------+-----------+------+-------+---------------------------------------------+
+ course_id  + course_name + instuctor + term + year  +               bio                           +
+------------+-------------+-----------+------+-------+---------------------------------------------+
+ 300        + physics     + veedeoo   + fall + 2012  + The youngest professor ever walked on earth +
+------------+-------------+-----------+------+-------+---------------------------------------------+

!NOTICE? the only columns that have common value between these two tables are the course_num and course_id.

Scenario 1: The student log in ( of course another page does the validation), we will show this student of the classes he or she is enrolled. Including the course name, course id, the term and the year of enrollment.

The mysql database query: For even more clarification, I will write the main Key of the query in uppercase. I hope other readers will not take that against me.

   $this_query = "id, name, course_num, status, course_id, course_name, instructor, term, year";
   ## Notice the above …
LastMitch commented: Well Explain! +7
veedeoo 474 Junior Poster Featured Poster

Hi,

Do you mean from other server to your server?, or from server to your computer?

veedeoo 474 Junior Poster Featured Poster

Hi,

try chaging this

<select>

to this

    <select name="package">

So, when you do this

    $package = $_POST['package'];

The value of the selected item from the option is posted.

veedeoo 474 Junior Poster Featured Poster

Try using partition editor, it is really good. I highly recommend the live cd version .

Warning! be careful with this tool.

On your question about the boot menu , run your pc and then select linux mint. Open your terminal and type

    sudo gedit /boot/grub/grub.cfg

This should brought up your text editor. Copy the text from the editor, close the editor. Post what's on the editor here here..

UPDATE

Here is a good tutorial on mint.

veedeoo 474 Junior Poster Featured Poster

cereal is precisely correct. If you know the package name, you can also type

apt-get install [package-name]

For example, if I want to install an nginx server on my ubuntu, I would type this on my terminal

    sudo -s
    // system will ask for password
    // I must provide the password

    sudo apt-get install nginx

Please ignore the [ and ] just type the package name of what you are trying install.

sami.un.96 commented: sa +0
veedeoo 474 Junior Poster Featured Poster

Do as suggested above, and then make sure to have a copy of PHP objects, Patterns,and Practice by Matt Zandstra. This book have a really good example of the design pattern concept. If you read the book, you can take a look at his smarty sample of implementation, but it is not the ultimate guide. There are available template engines out there that can be more comfortable for you to use. I was going to recommend the first book I have when I was 16, but I don't have it in front of me right now, sadly I can't even remember the title and the author. It is the one that have a waffle griddle on the cover.

In addition, while you are venturing into the OOP side, make sure to take the templating engine with it. By doing this, the view aspect of your application will be completely isolated from the application's logic.

Read more about the singleton pattern. The reason we need singleton pattern in PHP because as you master the OOP concepts, you will realize that , you need to write more classes for different aspects of your application. As your application classes increases in number, you will need to have a form of control or at least knowing which of those classes are intantiated ( at the least). By using Singleton Pattern, you can ( at least) control how the classes are instantiated. For example, if an instance of class One is present, then singleton will …

veedeoo 474 Junior Poster Featured Poster

Hi Diafol,

Yes, all of them have a really bad documentations. I am really fascinated by what this little template engine TBS could do. I experimented on it for a few weeks, and it is not that hard to get familiarized with how they do things.

I also experimented with the contents coming from the database, and I don't have to do any loops at all.

What is so interesting about this template engine is that it has its own hook ( some people call it binding capability) to mysql, mysqli and I think it can do PDO also.

For example, if we are to fetch some contents from database, the TBS php code can be as minimum as this... this is on the php file side. I love writing them in simple function for easy implementation later on.

    ## function db_connect

    function db_connect($db_host, $db_user, $db_password, $db_database){

    # connect to our databse Use the example below.
    $this_connection = mysql_connect($db_host, $db_user, $db_password);
    mysql_select_db($db_database,$this_connection);

    ## we need some simple boolean response
    $sql_ok = ( isset($this_connection) && is_resource($this_connection) ) ? 1 : 0;

    if ($sql_ok==0) $this_connection = 'clear'; 
    ## this makes the block to be cleared instead of merged with an SQL query.

    ## connection is valid we return it for other fucntion to use
    return $this_connection;
    }

    ## we can directly assign the results to our template using the block function or merge block function
    $query = "select title, description, id from content";

    $Veedeoo->MergeBlock('blk2', db_connect( 'localhost', 'username', 'password', 'password'), $query);
diafol commented: Thanks for the heads up. +14
veedeoo 474 Junior Poster Featured Poster

The content can be from array and database.. if the content is in the form of array as in database, then the proper approach can be something like this.

$this_content_is_array = array(
            'title'=>$title,
            'metaDesc'=>$metaDesc,
            'metaKeywords'=>$metaKeywords,
            'mainContent'=>$mainContent,
            'rightContent'=>$rightContent,
            'footerContent'=>$footerContent
            ); 

The instance of TBS can be something like this

    $veedoo->MergeBlock('blk1',$this_content_is_array);

And the template code will be almost the same as the simple implementation above, but we will be using block function like this

    {{blk1.mainContent}}
    {{blk1.rightContent}}
veedeoo 474 Junior Poster Featured Poster

Hello Everyone,

I got bored reading PHP questions. So, this is probably the best time to add another article here at daniweb.com. If someone ever stumbled upon by boring blog (mini-tutorial), I talked about how light and simple is the tinybutstrong templating engine. However, I began to wonder why not too many people are using it.

Months ago, I went to their site and read their implementation and I finally answer my own question. The reason most people would ignore the validity or the existence of tinybutstrong is that, until now they are using the tables instead of div on their example of implementation. So, I guess it is safe to say that developers and designers these days does not have anything to do with tables, UNLESS, it is deem necessary :).

Why is TinyButStrong, a good template engine?
I am confident it has potentials. However, it is and can be powerful as any BIG template engines available out there .. can be considered somewhere just below twig and smarty. What makes it good is that it has one 1 Php class with 6 methods and 5 properties. This one file makes it a templating engines runner up :).

How do we use TinyButStrong?
Please read tutorials below..

First Step: Download the tinyButStrong here. Unzipped this file and move the tbs_class.php to your working directory.

Second Step: In your working directory (server of course), create a new dirctory called 'templates'.
Thirs Step: Copy and paste …

LastMitch commented: Thanks for sharing! +7
veedeoo 474 Junior Poster Featured Poster

hi,

what others meant by echo your query is something like this.

    <?php
        $title = 'this title';
        $position = 'this position';
        $cate = 'this cate';
            $qry="Insert into postjob (jobtitle,positions,category)
            VALUES('".$title."','".$position."','".$cate."')";
            //printf mysql_query($qry) or die(mysql_error());

            echo $qry;

Isolate the codes where you are having problems with. On the codes above... disable the database connection first, and make sure to replace the $title, position, and cate with the actual values from the form on post.

try removing the quote on postjob first, before echoing your query. I just don't like how the single quoute is formatted. Sometimes they do create an error like that.

     $qry="Insert into postjob (jobtitle,positions,category)
        VALUES('".$_POST['title']."','".$_POST['position']."','".$_POST['cate']."')";
        mysql_query($qry) or die (mysql_error());
veedeoo 474 Junior Poster Featured Poster

What are you trying to do with the loaded file? Edit it like in the wordpress theme editor?

veedeoo 474 Junior Poster Featured Poster

Hi,

think of it as
localhost/ root account
localhost/domainOne/ session is only effective here and nowhere else
localhost/domainTwo/ the same thing here, session cannot be validated above this directory and below this directory

while sessions stablished, in these directories are valid in directory domainOne

localhost/domainOne/directoryone/
localhost/domainOne/directorytwo/
and the list goes on....

So, session from directory domainOne cannot be valid in domainTwo directory. It works like a VPS hosting with multiple domains in it.. sessions are processed only specific to its own working directory, space, or domain.

veedeoo 474 Junior Poster Featured Poster

you need to process the file first and then read... something like this, but you need to check if the form has been submitted..

    ## define target directory for you the uploaded file
    $file_directory = 'someDirectory';

    if(isset($_POST['submit']) && ($_FILES["file"]["error"] > 0)){

    ## move the uploaded file to your specified location, if there is no problem on submit
     move_uploaded_file($_FILES["file"]["tmp_name"], $file_directory .'/'. $_FILES["file"]["name"]);

     }
     else{

     echo 'No file uploaded at this time';

     }

     ## to read the file
     ## double check and make sure the file exist in file_directory, before opening it

     if (file_exists($file_directory .'/' . $_FILES["file"]["name"])) {
       ## put your text file reader function Here..
  }
veedeoo 474 Junior Poster Featured Poster

Do you have any codes to show? Any design flows? We need an starting point somewhere.

veedeoo 474 Junior Poster Featured Poster

Hi,

copy and save whateverFileNameYouWant.php, upload to your server, and then direct your browser to this file..

<?php

phpinfo();

?>

Look for the following values, and they should have something more than 2MB at least 100MB or higher depending on your application

post_max_size
upload_max_filesize

If those above php.ini settings still on the default value you need to change them.. To change it, you need to ask your host. If you are testing it on WAMPP or XAMPP, look for the loaded configuration file on the page above..

Loaded Configuration File // this should have a value of /php/php.ini depending on your server setttings

If your host does not allow you modify your php.ini file look for the "server API" value of your server". Is it fast CGI? or is it Apache Module?

If it is CGI, FAST CGI, or anything with CGI. create a new file and save it as php.ini. paste codes below to this file

post_max_size = 200M
upload_max_filesize = 200M

Upload this file to the root directory of your server or your domain...CANNOT be in the same level as the public_html file.

If server API says, apache module.. create a new document on your notepad and save it as .htaccess

php_value post_max_size 200M
php_value upload_max_filesize 200M

WARNING! If you have an existing .htaccess file anywhere where the upload script is running, just ADD the above codes to it.

If you are running your script in LAMPPP or XAMPP just edit the php.ini …

veedeoo 474 Junior Poster Featured Poster

Hi,

There is a place called codex, and this is the place where they revealed the ins-and-outs of wordpress from posting your first blog all the way up to migrating wordpress sites.

If you are interested, Click Here.

There is a minor modification allowed inside the admin dashboard, but this one is pretty limited to just a simple modification. Log in to your WP site as admin, click on the dashboard, click on the appearance, and then click on the editor link.

Normally, you will be presented with some php files and css files of your default theme which I believe you can't do much about editing on them, unless you educate yourself at the wordpress codex.

Just a friendly advice, before venturing into editing PHP documents, you must know the basics of PHP.

veedeoo 474 Junior Poster Featured Poster

here is another one... :).

<?php

$string = 'abcd_23$_&';

if(!preg_match('/^[\w-]+$/',$string)){

echo 'oops! not a valid username';

}
else{

echo 'Valid Username'. $string;


}
veedeoo 474 Junior Poster Featured Poster

Here is the extended response proving both of the responses above :) are true.

<?php

function check_bool($value){

return ($value == 1 ? 'yes' : 'no');

}

$value = true; // this can be from database

## let us test the function above.

echo 'This shows a true value : <b>'. check_bool($value) .'</b><br/>';

echo 'This shows a false value : <b>'. check_bool('false') .'</b><br/>';

echo 'This given the value of 1 : <b>'. check_bool(1) .'</b><br/>';

echo 'This has value of 0 : <b>'. check_bool(0) .'</b><br/>';

echo 'This has value of "1" : <b>'. check_bool("1") .'</b><br/>';

echo 'This has value of "0" : <b> '. check_bool("0") .'</b><br/>';

echo 'This has an empty value : <b> '. check_bool(" ") .'</b><br/>';


## another way of utilizing the above function can be something like a comparator seen in c or java not like it, but serves like it ( now, I am confused which one is it really ???) :)

echo (check_bool($value) == 'yes' ?  '<b> Yes is the answer </b>' : 'No Way' );
diafol commented: show off! :) +14
LastMitch commented: Good Job! +7
veedeoo 474 Junior Poster Featured Poster

@lastMitch,

Here is an extremely simple example of inheritance where both the parent and the child has its own constructor.

Looking at the code, the parent does not even know that the child class exist. Only the child knows that the parent class exist.., and yes we don't have to let the parent knows whatever methods is being use by the child.

<?php

class Person{
        ## please pardon my shorthand approach. Normally, variable below are itemized for clarification.
        private $name,$lastName,$age;

        ## in older version of php, var was used instead and the constructor is not included. 
        ## However the first method should be named after the class name as in function Person().

        // var $name,$lastName,$age;
        //public function Person(){  return $name; }


        ## this is the constructor for the class Person 
        public function __construct($name,$lastName,$age){
            $this->name = $name;
            $this->lastName = $lastName;
            $this->age = $age;

        }

        public function get_name(){

        return $this->name;
        }

        public function get_info(){

            ## simple example of using another method of a class within another method within class ??????? :)
            return array($this->name,$this->lastName,self::get_age() );

        }

        public function get_age(){

        return $this->age;

        }
}

## extending the class Person above, child class can inherit all the properties of a parent class

class Info extends Person{

        ## this child class will inherit all the properties of the parent class.
        ## we can create a consructor here for this child class, and at the same time, must invoke the parent's constructor.

        public function __construct($name,$lastName,$age,$job,$hobby,$salary){

                    ## envokes the parent constructor
                    parent::__construct($name,$lastName,$age);

                    ## we only define things that …
veedeoo 474 Junior Poster Featured Poster

I love both of them, depending on application requirements. There is a neglectable performance differences between the two. MySQLI is somewhat faster than the PDO... however like what Pritaeas already mentioned, PDO can function and work in different environment.

One specific reason out of all other reasons, why I would also prefer PDO is that it can take an instance of a class and use it as the parameter on its query, this is called PDO fetch class . This functionality is perfect for applications requiring the implementation of a templating system like the smarty, dwoo, twig, tinybutstrong, and others. Although, it can be use in tinybutstrong environment, I prefer to use the built-in tinybutstrong database interface.

For example, say we have a class called rockStars ( Why some geeks adore rock stars and rock stars wishes to be a geek at some point of their lives?? wow! I can trade places at any time)..

  class RockStars{

  public function get_RockStars($name,$band,$cd){

  return array($name,$band,$cd);

  }
  }

 $thisPDO = $db->prepare("SELECT name, band,cd FROM rockstars");

 $thisPDO->execute();

 ## grab the output array and send it to the template engine or just loop over it

 ## for the template
 $smarty->assign('rockStars', $thisPDO->fetchAll(PDO::FETCH_CLASS, "RockStars"));

 ## you can loop through the result below as you wish
 $this_PDO_result = $thisPDO->fetchAll(PDO::FETCH_CLASS, "RockStars");

That's all I can say on this subject matter... performance wise? MYSQLI got a meniscule upper hand, but PDO supports named_parameters and supports many different database.

veedeoo 474 Junior Poster Featured Poster

on the php side, you can use the php built-in validate filters and sanitize filters..

$sanitized_email = filter_var($email, FILTER_SANITIZE_EMAIL);

     ## validate email by boolean response
     if (!filter_var($sanitized_email, FILTER_VALIDATE_EMAIL)){

       ## email is a valid one 

     }

if you want to explore these amazing filters, you can read more about them here.

veedeoo 474 Junior Poster Featured Poster

hi,

here is a demo I made, you can copy the source code if your want. Make sure the video ids are added as shown in the source code.

You cannot play all of them at the same time, but one at a time on click event. The most important about utilizing jquery is the ability to play video without reloading the page..

veedeoo 474 Junior Poster Featured Poster

I totally agree with jmaat7.. I also have xampp and eclipse on a flashdrive.. I even have the static ffmpeg to work with the ffmpeg-php in my thumb drive.

My portable eclipse is a portable eclipse php version can be downloaded by Clicking Here. I saved about 50MB of space..

It is working pretty well without any issues, but if you will be working on smarty templating system, make sure to ignore the errors and warnings being caught by the eclipse from the template directory. Portable eclipse just don't have the extra module to recognize the smarty syntax. To correct this problem you may want to mock up smartypdt with the eclipse installation as you see it fit.

veedeoo 474 Junior Poster Featured Poster

let me add something, to make it a lot easier for you to grab the array output of a function without relying so much on the integer indexer, we can do it like this also;

<?php

function some_Array($name,$last,$address){
        $arrayItem = array();
        $arrayItem['name'] = $name;
        $arrayItem['last'] = $last;
        $arrayItem['address'] = $address;

        $output_Array[] = $arrayItem;

        return $output_Array;

}

$id = some_Array('poor','boy','north pole');

    foreach($id as $pos_id){

    echo 'Name: '. $pos_id['name'] .' '. $pos_id['last'];
    echo '<br/>';
    echo 'Location: '. $pos_id['address'];

    }
veedeoo 474 Junior Poster Featured Poster

try

$these_items = NewPos($mk_pos,$pos_member,$prev_num,$prev_loc,$type,$under_mem,$sent_id);
## loop through the output
foreach($these_items as $pos_id){

$position = $pos_id[0];
$follow_id = $pos_id[1];

}
veedeoo 474 Junior Poster Featured Poster

@davy_yg

Why are you saying it is difficult to design it on your own? Have you tried it yet? Did you attempt to at least jot down how would your program will flow?

A part of being a coder is to be able to write codes when there is no ready made open source out there. What you want to write is not even that hard... I mean a cup of hot nicely brewed coffee (starbucks), can definitely help out to visualize how the program should react to your user's click..

Please allow me to help you build the basic core foundation of the program you are trying to achieve or make.

First, you will need a page to add the banner links of the sponsors. Make sure the destination domains of these sponsors are saved in your database.

Second, the outgoing link should be forwarded to your outgoing page to track which url or domain is being clicked. This event should executed in split second, and the browser should not be held more than a blink of an eye. In this outgoing page, you will need to update your database by adding 1 to the outbound count as the browser is being redirected to the sponsors domain.

Third, create a function of which it will be able to detect the referring url, you then match this url to your sponsors or link exchange partners to track down how many are bouncing, returning, and coming from external links to your …

veedeoo 474 Junior Poster Featured Poster

Hi,

Using the recommended script above, it can be easily done. It is simple as adding methods in the class.

First, you will need to modify your member's table and add another column. You can name this column as 'privs'.. Upon successful registration, make sure the privs value has been defined. For example, for regular member you can assign a privs value of 001 and 007 for the admin. In fact, you can even add designator for the moderator, contributor and so forth.

Lets assume that we assigned a membership priviliedges as follows admin=007, moderator = 300, regular member = 100.

We can modify the fg_membersite.php by adding the following codes. Add this just right after the closing curly bracket of the method function UserFullName().

###################################################
    ## user privs 
    function UserPrivs()
    {
     $this->userSess = $_SESSION['privs'];
        ## this is for the user privs
        if((isset($_SESSION['privs'])?$_SESSION['privs']:'')&& (isset($_SESSION['name_of_user'])?$_SESSION['name_of_user']:'') ){
         if($this->userSess == 7){
            $this->userType = 700;

        }
        ## moderator
        if($this->userSess == 3){
        $this->userType = 300;

        }
    if($this->userSess == 1){
        $this->userType = 100;

        }

    }
    return $this->userType;
    }

    function ShowUsername(){
        $this->user = $this->UserFullName();
        return $this->user;
    }
    #########################################################################

Scroll down the page and look for the method CheckLoginDB change this method to this

function CheckLoginInDB($username,$password)
    {
        if(!$this->DBLogin())
        {
            $this->HandleError("Database login failed!");
            return false;
        }          
        $username = $this->SanitizeForSQL($username);
        $pwdmd5 = md5($password);
        $qry = "Select name, email,privs from $this->tablename where username='$username' and password='$pwdmd5' and confirmcode='y'";

        $result = mysql_query($qry,$this->connection);

        if(!$result || mysql_num_rows($result) <= 0)
        {
            $this->HandleError("Error logging in. The username or password does not match");
            return false;
        }

        $row …
veedeoo 474 Junior Poster Featured Poster

LastMitch is right on the yii framework, but then again the rest will rely heavily on how much coding experience do you have in OOP.

If you are pretty fluent in OOP concept of writing codes in PHP, then you can attempt to just write your own MVC framework.. trust me it is not that hard, once you have a complete grasp on how the model, controller, view design pattern works.

If you want to practice in mvc pattern.. it is not that I am trying to inject something here that people don't need or not PHP related topic. However, achieving a broad knowledge in writing codes cannot be achieved overnight.. of course, there are many bumps and obstacles in the process. Sometimes, we are even required to take a few steps back just to make one step forward.

My suggestion is to practice first in ASP.net environment (about 1 week), and then move on to the ASP.Net razor C#(variables, logic, and loops) (1 to 2 days), and then move on to the ASP.net MVC. Work on building a simple application and then, once you have the grasp of building an application in ASP.net MVC using C# ( believe me this is not hard and it will give you so much coding techniques experience that you can use in PHP later on).

After that, I truly believe that you can write it your own.. The advantage of writing it your own is that you can decide which plugins you want …

LastMitch commented: You should be tutoring luis_see_me! =) +0
veedeoo 474 Junior Poster Featured Poster

just to add some very important info. on your php function usage, session_register has already been deprecated and removed in php 5.4. So, if you will be writing an application based on this function, it might not work in production server of which the majority now are using php 5.4.x.

you can replace the session_register with something like this,

    $_SESSION['username'] = $username;

In addition, we can also create a session array to simplify the process and it can be coded like this

    $thisSessionArray = array($username, $privs, $item3, $item4);
    ## assign the above array into one session

    $_SESSION['user_credit'] = $thisSessionArray;

    ## or we can shorten  it by coding it like this
     $_SESSION['user_credit'] = array($username, $privs, $item3, $item4);

To use the above approach, we can assign the individual session value into constant, but it is not necessary. The idea of defining them into constant is the ease of implementation accross pages. Although not many developers would agree with me, I found it pretty useful in my projects, especially in the developement of the open source vidiscript years back ( I don't want to sound as if I am pretty old. I will be turning 20 next month, so I guess I am old.).

    ## grab the session values from the session array

    ## for username
    define('USERNAME',$_SESSION['user_credit'][0]);

    ## define the privs
    define('PRIVS', $_SESSION['user_credit'][1]);

You can create a more application friendly user table, and on this table you must have a priviledge column that will accept a numerical …

veedeoo 474 Junior Poster Featured Poster

Hi,

Try adding...

if(isset($_GET['q'])){

## codes for the script response when GET is triggered
$q=$_GET["q"];
}

else{

$q = '';

}

Alternatively, I keep on seeing this type of approach by other developers of which I have not tested or ever tried, but I think it is worth teting for any vulnerability issues and weaknesses..

 if($_GET){

 ## codes here

 }
 else{

 $q = '';

 }

Again the alternative option is just too broad for my consideration. I am just assuming here that this method can fail.

veedeoo 474 Junior Poster Featured Poster

@MB.ShadowFox, LastMitch is correct.

Since Im already typing something in response to your question, why not do it something like this. but this does not happen very often..only when my mood is good (caffeinated).

## protect your script from getting undefined index in php 5 just in case itemnumb.png does not exist.
$thisImage = '' ;

## define the directory where the image is located.. this is needed just in case you will be storing this value in the database.
$imagePath = 'SomeLocationInYourServer/images/' ;


while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['owner'] . "</td>";
## check if the image does exist
if (@file_exists($imagePath.$row['itemnum'].".png")){

## I am not really into mixing PHP and html, but I will do it this time. Maybe a templating crash course could help.

echo '<td> <img src="'.$imagePath.$row['itemnum'] .'.png"/>';
}
## if it does not exist, why not show something else put the td, to prevent the table from behaving oddly.
else{
echo '<td>No Image</td>';


}
 echo "<td>" . $row['count'] . "</td>";
echo '</tr>';
}

echo '</table>';
veedeoo 474 Junior Poster Featured Poster

Will the data from $login will be encrypted? As long as the data are sent and processed by script ( php to php ), I don't see any possibilities for human to hack whatever is sent by the php script to another server.

Paypal API works the same way as this, with the only exemption of implementing the cURL to do the submission of the data and grab the remote response from paypal. So far, I have not heard anyone able to intercept this process. Interception only occurs when there is a browser involved.

Do not allow your user's browser to go in that url, it should be the script sending the data and pick up the response. For example, I wrote a similar script before as shown here. What this script can do is to remotely validate First Name, Last Name, and credit number ( this is a test form only ). The data are being sent out to two different servers. The first server is in Nevada and the Other is in Texas.

API works in the background and in the server side... as long as you keep it this way, your applications will be safe.

veedeoo 474 Junior Poster Featured Poster

Hi,

Try searching from my older posts in daniweb. I wrote at least two functional upload scripts like this, even with the image to BLOB fucntionality.

Just a friendly advice, please make sure to describe the problems first, before posting your PHP code..

andyy121 commented: ok thnx +2
veedeoo 474 Junior Poster Featured Poster

Just to add some simple ensight, the $s don't even matter it is merely a place holder, because it is there waiting for whenever the class is called upon. So, we can replace the $s = new static with

   return new static();

this class will still continue to return the instances of the classes ABC respectively, because of the hierarchy imposed on class B inherit class A and ultimately class C inherits class B.

Let us get out of the OOP conundrum for a just a few seconds, and lets take few steps back. Remember in basic PHP how we write functions? kind of something like this

    function SaySomething(){

        if(isset($_POST['submit']){

        echo 'Form submitted';

        }

        }

What is happening in the simple codes above is just waiting for the right event when form is submitted.. therefore we can place this code anywhere in the page where the processor is located.

    $s = SaySomething();

    ## or just simply use code below and the effect and response will be absulutely the same
    SaySomething();

Pretty much that if ever the SaySomething is going to be triggered by the submit button, 'Form submitted' should be showing on the page, the same is true with the $s in your class.

If the class does not have any child classes, then the class can be written like this

    class A{

        public static $instanceA = NULL;

        private function __construct(){

            ## echo ONLY for the purpose of checking the instance of this …
LastMitch commented: Nicely Explain! +6
veedeoo 474 Junior Poster Featured Poster

It is working, I just came from that page to this page. It might be the server issues with my hosting company, but I cannot complain very often, because I am only paying them $11.00 dollars per year. So, I practically getting what I have paid for ( I guess)..