veedeoo 474 Junior Poster Featured Poster

Dude, you need to read the instruction properly.

First run the test.html page on your localhost. Then once you got it working, do the mysql version.

Let say you will be running or testing the script on your localhost/rating,

  1. unzipped the downloaded zip file.
  2. inside the unzipped file, locate 5_stars_rating_script.zip
  3. Unzipped 5_stars_rating_script.zip

On your localhost root directory create a directory called rating

  1. open the rating directory and move these directories (ratingfiles,ratingtxt,and test.html), from the unzipped 5_stars_rating_script directory.

  2. load the rating/ratingfiles/rating.js on your text editor

find line 41 and look for this code

star_sp.style.background = 'url("ratingfiles/star2.png")';

change it to

star_sp.style.background = 'url("http://localhost/ratingfiles/star2.png")';

now, scroll down the page around line 105 and look for this code

 cerere_http.open("POST", '/ratingfiles/ratings.php', true);

change it to this

cerere_http.open("POST", 'http://localhost/rating/ratingfiles/ratings.php', true);

Lastly, load the test.html file on the editor and find this line

- Here can be an image, img1.jpg

replace the string above with your test image

 <img id="yourImage" src="yourImage.jpg" />

save all of your changes and direct your browser to localhost/rating/test.html

You should be viewing something like the screenshot below

02824e6d20b311400e6401733636ca11

veedeoo 474 Junior Poster Featured Poster

hi,

Try reading One and two.

Modify codes presented on two

echo 'wide image<br/>';
$k = 0;
//$area = 0;
$x = 0;
$y = 0;
$largest_image;
for ($i = 0; $i <= sizeof ($a_img); $i++) {
    if(@$a_img[$i]) {
        if(@getimagesize (@$imgdir.$a_img[$i])) {
                list($width, $height, $type, $attr) = getimagesize(@$imgdir.$a_img[$i]);
            // calculate current image area
            $latest_area = $width; //$width * $height;
            // if current image area is greater than previous
            //if($latest_area > $area) {
            if($latest_area > $x){
                //$area = $latest_area;
                $x = $area = $latest_area;
                $largest_image = $a_img[$i];
                //echo $largest_image.'<br/>';
                $k++;
            }
        }
    }
}



print_r($imgdir.$a_img[$k]);

$imgdir.$a_img[$k] gives you the widest image in the directory. To find the tallest modify the codes for $y.

veedeoo 474 Junior Poster Featured Poster

how about this?

veedeoo 474 Junior Poster Featured Poster

this error

Notice: Undefined variable: location in C:\xampp\htdocs\free-prowebsite\site_pro\administrator\upload.php on line 269

is coming from this block..

 // insert into mysql database and show success message
mysql_query("INSERT INTO `image_upload` (`id`, `image`, `thumbnail`, `thumbnail2`, `thumbnail3`, `location` ) VALUES (NULL, '". $image ."', 'thumb-". $image ."', 'thumb2-". $image ."', 'thumb3-". $image ."','". $location ."')");
}

so, you just have to define the $location.

veedeoo 474 Junior Poster Featured Poster

In my humble opinion, I think you are pretty normal, unless you are having dreams about these stuffs like I always have :)(: .

veedeoo 474 Junior Poster Featured Poster

you need to rewrite your array to something like below to associate every fruit to each color.

<?php

    echo '<b> Fruits </b> <br/>';

             $fruits = array('lemon'=>'#FFFF00','orange'=>'#FFA500', 'apple'=>'#FF0000');

    ksort($fruits);

    foreach($fruits as $k => $v){

        echo '<p style="color:'. $v .';">'. $k .'</p>';

        }
veedeoo 474 Junior Poster Featured Poster

You will need to define the variable $location.

veedeoo 474 Junior Poster Featured Poster

Why write too many identical upload processors for the slide group, if simple functions can be written to handle all three?

veedeoo 474 Junior Poster Featured Poster

also, can you try creating a new page and tell me what is on it?

<?php 

    phpinfo(); 


 ?>
veedeoo 474 Junior Poster Featured Poster

the script above should return something like this on the browser

ba5cdc00487a0f6a2438956c7767298e

let us try this. Since there is not error showing up on your side, we create one for the sake of finding what is the situtation of the PHP parser and just maybe php.ini file.

create a new page and name it tester.php. Paste the following codes

<?php


    echo $this_error;

    print_r(error_get_last());

?>

direct your browser to this page and see if there is something on the page. The purpose of the test is to provide an undefined variable to purposely create an error for the error_get_last() function to catch.

veedeoo 474 Junior Poster Featured Poster

Hello Shakib, welcome.( yes, I am the first :)).

veedeoo 474 Junior Poster Featured Poster

try adding this just below the curl initialization

curl_setopt($ch, CURLOPT_PORT, '25565');

to test if the cURL is using the port 25565, try running this

 print_r(useCurl('http://portquiz.net/'));

If you need to know, what was the original port the cURL was using on outbound connection, remove

 curl_setopt($ch, CURLOPT_PORT, '25565');

and run this

 print_r(useCurl('http://portquiz.net/'));
veedeoo 474 Junior Poster Featured Poster

this one works for me using your url and the cURL function above

$url = urldecode('http://82.145.61.242:25565/api/2/call?json=%5B%7B%22name%22%3A%22server.bukkit.version%22%2C%22key%22%3A%22a7584a0f6f1aa22d843ce0d46f88a2101ddae9285127f103092dee4904f9be35%22%2C%22username%22%3A%22ZonkedCompanion%22%2C%22arguments%22%3A%5B%5D%2C%22tag%22%3A%22sampleTag%22%7D%5D%22 ');

print_r(json_decode(useCurl($url), true));

the above returns

Array ( [0] => Array ( [result] => success [success] => 1.7.2 [source] => version [tag] => sampleTag [is_success] => 1 ) ) Array ( [0] => Array ( [result] => success [success] => 1.7.2-R0.3 [source] => server.bukkit.version [tag] => sampleTag [is_success] => 1 ) ) 

Just a side note:

(...he says pulling his hair out having wasted 7hours on this simple task already!)

If I will be pulling my hair for a simple task like this, I will be looking for a new job. Something that will inspire me on a daily basis and not stress me to death. Just my thoughts.

veedeoo 474 Junior Poster Featured Poster

another option beside allow_url_fopen is to use cURL.

Here is a simple funtion for utilization of cURL

function useCurl($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);
    $output = curl_exec($ch);
    curl_close($ch); 

    return($output);
    unset($output);
}

to test the function above, let us use the jsontest.com's as the url

 print_r(json_decode(useCurl('http://ip.jsontest.com/ '), true));

that should output something like this

Array ( [0] => Array ( [result] => success [success] => 1.7.2 [source] => version [tag] => sampleTag [is_success] => 1 ) ) Array ( [ip] => 2605:e000:1213:40e3:c490:f413:c3f9:c617 ) 
veedeoo 474 Junior Poster Featured Poster

Hi,

This works

$json = '[{"result":"success","success":"1.7.2","source":"version","tag":"sampleTag","is_success":true}]';

print_r(json_decode($json, TRUE);

I suspect that the error is coming from the url source..

veedeoo 474 Junior Poster Featured Poster

If you enjoy mathematics, why not major in mathematics and physics.

veedeoo 474 Junior Poster Featured Poster

There are many ways of doing this, and one of the most effective is the double loop (while(inside the class) and foreach(outside)). Return the array from the while loop and iterate them outside, when the class is instantiated..

example

public function gallery_loader(){

    $image_array = array();

    while(..........){
        $item['src'] = $row['src'];
        $item['desc'] = $row['description'];

        $image_array[] = $item;

        }

        return array($image_array, $count);

        } // end of method

The $count above is the actual count of the items or images, you will need that in iterating the image_array.

Example of coding it on the view...

<?php

$object = new YourClass();
$data = $object->gallery_loader();
$images = $data[0];
$count = $data[1];

    $i = 0;
?>
<!-- add your javascript here -->
<script>
var imagesDataArray = [

// loop through the output of the gallery_loader() 

    <?php

        foreach($images as $image){
        ?>
        {

                src: <?php echo $image['src']; ?>,
                description:<?php echo $image['desc']; ?>,

        <?php
            echo ($count === $i ? '}' : '},' ); 

            $i++;

            } // endof foreach loop

            ?>
         // end of your    ImageDataArray
         ];

       // add jquery function below -->

        </script>

That's pretty much it...

veedeoo 474 Junior Poster Featured Poster

@JohnPeter,

Please learn the basic first. Have you ever heard about these responsive frameworks?

bootstrap
960 Grid System
Foundation 5
Yaml:4

I could go on for hours, but it is your turn now and I want you to research for the remaining responsive frameworks. Hint: they are more than 25 responsive frameworks the last time I checked.

veedeoo 474 Junior Poster Featured Poster

Hello Ehsan! welcome.

veedeoo 474 Junior Poster Featured Poster

@gianluzzz,

can you please let the forum members, which MVC framework you are currently using?

veedeoo 474 Junior Poster Featured Poster

I think matlab can interface with C and JAVA languages, but I am not sure. If so, then you can write your PLC in C or JAVA and post your question in C forum or JAVA forum.

veedeoo 474 Junior Poster Featured Poster

Hi Meryl, Welcome.

veedeoo 474 Junior Poster Featured Poster

I guess it would be something like this

base64_decode($pics)

yes?

veedeoo 474 Junior Poster Featured Poster

Good question. Some of the codes I posted here on Daniweb made it to Github and github members were very kind in asking my permission.

veedeoo 474 Junior Poster Featured Poster

Hai and Welcome :).

veedeoo 474 Junior Poster Featured Poster

Hi Widy, welcome.

veedeoo 474 Junior Poster Featured Poster

Hi,

you can generate coupon code by implementing str_shuffle PHP function.

example codes

function get_coupon_code($string_length = 5){

  $coupon_code =  substr(str_shuffle('ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz), 0, $string_length);

  }

  echo get_coupon_code(5);

If you want the coupon to be an image, you can use imagestring function.

veedeoo 474 Junior Poster Featured Poster

From what script is this? Is it from PHP using a PHP/Java bridge, or simply a regular PHP script?

If it is from regular PHP application script, then the IO is the class or object and intValue is the static method of that object.

for example, we can have a class with static method like this

class IO{

    public function __construct(){
    }

    public static function intValue($id){

        return(intval($id));

        }
  }      

The class above can duplicate or allow us to test your code.

echo IO::intValue('50');

it should print out 50 which is an integer. Eventhough, I made it like a string.

My example above is extremely simple that in real world application, the class is not even needed due to int() function that can do the job with less code.

veedeoo 474 Junior Poster Featured Poster

cool fair enough.

One of the many ways of doing this for your purpose is to create a bridge between the existing database and the magento database.

It's been a while since the last time I was playing around with magento. Although I still know the basics construct, I can easily get lost at this time.

As far as creating a bridge, I completely forgot how I did it, it was long long time ago when I was a sophomore in high school. I remember writing a bridge for the SMF (simple machine forum) and the phpBB forum. The bridge was intended to use the existing phpBB database in SMF forum environment. The most challenging part was the authentication of the users.

I am sure the process will be pretty similar.

Here is a good start about multiple database connection in magento.

veedeoo 474 Junior Poster Featured Poster

Hello Venky, welcome to Daniweb.

veedeoo 474 Junior Poster Featured Poster

GET here

POST here

veedeoo 474 Junior Poster Featured Poster

Magento is pretty much follows the same MVC pattern as Zend framework. You will need to have some really good understanding on how MVC pattern works.

veedeoo 474 Junior Poster Featured Poster

Your helper looks good. Just always remember that

$CI =& get_instance();

will call the CI's main controller class by reference. So, all of the native helpers and libraries are available and usable by the function if it is in helper and by the object and methods if it is in the library class.

$CI->load->helper('url');
$CI->load->library('session');
$CI->config->item('base_url');
//and many more

There are some occasions where only few of these native helpers and libraries are needed. I honestly believe that we should only reference the main or original CodeIgniter object as needed and only when necessary.

How about if we only need the database connection? Do we really need to drag the entire CI main controller to our simple helper to make it function to do its work? My take on this is maybe yes or maybe not. However, let us take a look at your helper codes below

 function my_theme_options($var)
        {
        $CI =& get_instance();
        $CI->db->select('value');
        $CI->db->from('themes');
        $CI->db->where('option', $var);
        $query = $CI->db->get();
        foreach ($query->result() as $row) {
        echo $row->value;
        }
        } 

The codes above looks pretty good to me. Can we make it a little conservative in terms of server resources usage? Sure we can, why not?

The codes above or helper function ONLY need the database class, and we can simplify it to something like this.

 function my_theme_options($var)
    {
   $this->load->database();
     ## do all your queries here as you normally would.
    }

The modified codes above will load the database class manually and not by referencing …

veedeoo 474 Junior Poster Featured Poster

Hi Sandy, welcome.

veedeoo 474 Junior Poster Featured Poster

Hi Sophia, welcome to Daniweb.

veedeoo 474 Junior Poster Featured Poster

it is similar to the template engine cache function. The only difference is that in template engine such as smarty, we can define which block of contents should be ignore by the cacheing mechanism.

In codeigniter, it will keep the cached the contents based on the definition of $x as time in minutes.

$this->output->cache($x); // $x is the number of minutes

Warning!
Only use this function outside the form, login form, user's account page, administration page and other contents where login authentication is required.

If you will be using this function, it is helpful to create a purging script or class to give you the option to purge the cached content on demand without manually deleting them.

It is useful in delivering contents that don't change a lot. For example, a front page with content from the database that don't change a lot can use the cache function. It will definitely saves a great deal of server resources by just loading the cache page rather than executing a database fetch queries for the contents.

veedeoo 474 Junior Poster Featured Poster

yes, that is definitely an excellent option. I wrote installer in the past, similar to the wordpress installer. I will look for the script tomorrow.

veedeoo 474 Junior Poster Featured Poster

good catched AndrisP. Spaces indeed.

veedeoo 474 Junior Poster Featured Poster

I suggest to save the old config files and then write a new one. Another way of doing this is to write a new XML file for all of the user's settings and parse it as the config file. Similar to the one found in Symfony2's yaml file.

Or the simplest and yet pretty effective is to use the php function called parse_ini_file() which can parse configuration file. Just make sure that the ini files are not accessible by public.

veedeoo 474 Junior Poster Featured Poster

try testing it on MySQL workbench. From there, you can optimize your query.

veedeoo 474 Junior Poster Featured Poster

Welcome to Daniweb Albert.

veedeoo 474 Junior Poster Featured Poster

welcome :).

veedeoo 474 Junior Poster Featured Poster

pretty much there are few things you can do with .htaccess file. Please read #9 on this article. While you are at it, try reading some topics that are related to your situation.

veedeoo 474 Junior Poster Featured Poster

Hello, welcome to Daniweb.

veedeoo 474 Junior Poster Featured Poster

try

$sql = "CREATE TABLE $uID(".
"Col0 int(10) NOT NULL auto_increment,".
"Col1 varchar(255) NOT NULL,".
"Col2 varchar(255) NOT NULL,".
"Col3 varchar(255) NOT NULL,".
"PRIMARY KEY(Col0)".
")";       
veedeoo 474 Junior Poster Featured Poster

try this

## define constraints
    $height = 600;
    $width = 400;
    $screen = 1600;
    $format = 'png';
    $alt = 'this is alt';
    $url = 'http://daniweb.com';

echo '<img src="http://api.webthumbnail.org?width='.$width.'&height='.$height.'&screen='.$screen.'&format='.$format.'&url='.$url.'" alt="'.$alt.'" />';

If you run the above codes, you will see something like the screenshot below.

deded1796186251fba8de91b8853e87a

veedeoo 474 Junior Poster Featured Poster

if the photos name and file name are stored in the database, you need pagination. We have plenty of pagination scripts and threads here in Daniweb.

if the photos are in the directory and you are reading the contents by way of PHP, then you want the pagination using javascript as shown here. DynamicDrive's example is only for one image. For 25 images, you can modify the demo script to this...

<script type="text/javascript">

var pagecontent=new virtualpaginate({
 piececlass: "virtualpage", //class of container for each piece of content
 piececontainer: "div", //container element type (ie: "div", "p" etc)
 pieces_per_page: 25, //Pieces of content to show per page (1=1 piece, 2=2 pieces etc)
 defaultpage: 0, //Default page selected (0=1st page, 1=2nd page etc). Persistence if enabled overrides this setting.
 wraparound: false,
 persist: false //Remember last viewed page and recall it when user returns within a browser session?
})

pagecontent.buildpagination(["paginatediv"])

</script>

Here is another one.

veedeoo 474 Junior Poster Featured Poster

webthumbnail.org is pretty easy to use.

<?php

    ## define constraints
    $height = 300;
    $width = 400;
    $screen = 1280;
    $format = 'png';
    $alt = 'this is alt';
    $url = 'http://daniweb.com';

echo '<img src="http://api.webthumbnail.org?width='.$width.'&height='.$height.'&screen='.$screen.'&format='.$format.'&url='.$url.'" alt="'.$alt.'" />';
veedeoo 474 Junior Poster Featured Poster

just another maybe :). I am borrowing Diafol's last line of code.

$followers = json_decode($ids, true);

foreach($followers as $follower){

    echo $follower .'<br/>';

    }
veedeoo 474 Junior Poster Featured Poster

what is on your config.php?