cereal 1,524 Nearly a Senior Poster Featured Poster

That's a lot of work, you have to sanitize data, check if the user is sending something else apart from links or if something is appended to the links, if the link format is correct, if the limit is reached, if the headers are ok (considering that headers can be spoofed)... So here it is a scrap just to get links:

<?php

function get_link($data)
{
    preg_match_all('/http(s)?:\/\/(.*)/i', $data, $matches);
    $result = array();
    foreach($matches[0] as $link)
    {
        $result[] = $link;
    }
    return $result;
}

# here place $_POST['links'] or whatever you use in the form
$form = <<<EOF
http://website.tld/image.jpg
http://www.website.tld/image_with_w.jpg
http://www.website.tld/image.png
http://<script>alert('hello');</script>
EOF;

print_r(get_link($form));

?>

I repeat: sanitize data, make sure your script filters malicious scripts, for example here you will get a javascript executed. Try to build your script and if you have doubts or something is not working post your code. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Check for file_get_contents() to get the file from remote, file_put_contents() to save the file:

$file = file_get_contents($url);
file_put_contents('/path/new_name',$file);

You can check links by using parse_url() and pathinfo(), for example to get the basename from a link use:

pathinfo(parse_url($url,PHP_URL_PATH),PATHINFO_BASENAME);

so, if the url is http://www.website.tld/images/this_image.jpg you get this_image.jpg you should also check for the mime, strip comments from the images..

cereal 1,524 Nearly a Senior Poster Featured Poster

You are welcome, bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

What kind? This works for me:

<?php
$xml = <<<XML
<dataroot>
              <content id= "1">
                            <quest><![CDATA[<FONT FACE="Arial">Which of the following is not the measure of a physical quantity?</FONT>]]></quest>
                            <opt1><![CDATA[<FONT FACE="Arial">kilogram</FONT>]]></opt1>
                            <opt2><![CDATA[<FONT FACE="Arial">impulse</FONT>]]></opt2>
                            <opt3><![CDATA[<FONT FACE="Arial">energy</FONT>]]></opt3>
                            <opt4><![CDATA[<FONT FACE="Arial">density</FONT>]]></opt4>
                            <ans><![CDATA[a]]></ans>
                            <ans_desc><![CDATA[<FONT FACE="Arial">kilogram is the name of the fundamental unit of mass</FONT>]]></ans_desc>
              </content>
              <content id= "2">
                            <quest><![CDATA[<FONT FACE="Arial">Which of the following sets can enter into the list of fundamental quantities 
  in any system of units?</FONT>]]></quest>
                            <opt1><![CDATA[<FONT FACE="Arial">length, mass and velocity</FONT>]]></opt1>
                            <opt2><![CDATA[<FONT FACE="Arial">length, time and velocity</FONT>]]></opt2>
                            <opt3><![CDATA[<FONT FACE="Arial">mass, time and velocity</FONT>]]></opt3>
                            <opt4><![CDATA[<FONT FACE="Arial">length, time and mass</FONT>]]></opt4>
                            <ans><![CDATA[d]]></ans>
                            <ans_desc><![CDATA[<FONT FACE="Arial">velocity cannot enter in this set because it itself involves length and time.</FONT>]]></ans_desc>
              </content>
              <content id= "3">
                            <quest><![CDATA[<FONT FACE="Arial">If the unit of force and length are doubled, the unit of energy will be</FONT>]]></quest>
                            <opt1><![CDATA[<FONT FACE="Arial">Œ times</FONT>]]></opt1>
                            <opt2><![CDATA[<FONT FACE="Arial">œ times</FONT>]]></opt2>
                            <opt3><![CDATA[<FONT FACE="Arial">2 times</FONT>]]></opt3>
                            <opt4><![CDATA[<FONT FACE="Arial">4 times</FONT>]]></opt4>
                            <ans><![CDATA[d]]></ans>
                            <ans_desc><![CDATA[<FONT FACE="Arial"><P>Energy = Force <img src="Images/Phys1/XLAD670.gif" WIDTH=12 HEIGHT=13 align="absmiddle"> 
  distance = Force <img src="Images/Phys1/XLAD670.gif" WIDTH=12 HEIGHT=13 align="absmiddle"> 
  length.</P>
<P>When force and length are doubled, the unit of energy will becomes four times 
  that of its initial value.</P>
</FONT>]]></ans_desc>
              </content>
              <content id= "4">
                            <quest><![CDATA[<FONT FACE="Arial">Given that displacement of a particle is given by <img src="Images/Phys1/XLQ680.gif" WIDTH=101 HEIGHT=21 align="absmiddle"> 
  where t denotes the time. The unit of K is</FONT>]]></quest>
                            <opt1><![CDATA[<FONT FACE="Arial">hertz</FONT>]]></opt1>
                            <opt2><![CDATA[<FONT FACE="Arial">metre</FONT>]]></opt2>
                            <opt3><![CDATA[<FONT FACE="Arial">radian</FONT>]]></opt3>
                            <opt4><![CDATA[<FONT FACE="Arial">second</FONT>]]></opt4>
                            <ans><![CDATA[a]]></ans>
                            <ans_desc><![CDATA[<FONT FACE="Arial"><P>Here K is dimensionless. Thus </P>
<P><img src="Images/Phys1/XLAD680.gif" WIDTH=198 HEIGHT=41 align="absmiddle"></P>
</FONT>]]></ans_desc>
              </content>
              <content id= "5">
                            <quest><![CDATA[<FONT FACE="Arial">Dimensions of velocity gradient are same as that of </FONT>]]></quest>
                            <opt1><![CDATA[<FONT FACE="Arial">time period</FONT>]]></opt1>
                            <opt2><![CDATA[<FONT FACE="Arial">frequency</FONT>]]></opt2>
                            <opt3><![CDATA[<FONT FACE="Arial">angular acceleration</FONT>]]></opt3> …
cereal 1,524 Nearly a Senior Poster Featured Poster

Load data into a variable, like $xml and use SimpleXML:

$data = new SimpleXMLElement($xml,LIBXML_NOCDATA);
$array = json_decode(json_encode($data),true);
print_r($array);

json_encode/decode will remove the SimpleXML obj.

cereal 1,524 Nearly a Senior Poster Featured Poster

If I understood you can also replace previous $random_id array_rand() and implode() with:

$random_id = shuffle($id); # or you can use array_rand($id,1);
$sql1 = "SELECT * FROM table WHERE id = '$random_id[0]'";

and if you want one single result from the query then add limit 1 at the end, bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

you're welcome!

cereal 1,524 Nearly a Senior Poster Featured Poster

It's seems fine to me.
In php.ini there is a directive that permits to disable GET, check for variables_order in: http://php.net/manual/en/ini.core.php if G is not present then you have to edit the configuration and reload the server. Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

If I understood the problem this should work:

RewriteRule ^(includes|and|other|directories) - [L]

place it right after RewriteEngine On the rules won't be applied in those directories. Bye! :D

diafol commented: cracking - thanks +14
cereal 1,524 Nearly a Senior Poster Featured Poster

This string is 65 characters long, if you use var_dump(explode(':',$string)); you will see two strings of 32 characters each, so probably these are two md5 hashes, and you can't decrypt an hash, you can only try to find a collision, i.e. a string that creates the same hash. In order to create an hash you can use sha1() or md5(), as suggested before by the others.

md5: http://php.net/manual/en/function.md5.php

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

Try with urlencode():

`redirect(urlencode('abc.php?satisfaction=5&surname=trfhtrd&given_name=tryhtr'));`

a part from that: redirect() is the CI function or is custom? If custom then post the code, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Put also the host in the url, so this:

/folder1/folder2/image.png

becomes:

http://mywebsite.tld/folder1/folder2/image.png

and it should work. Othersiwe you could display the images inside Google/Yahoo/... servers. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Thank you for suggestion, I will work on that!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!

Minimize HTTP requests. One of the suggestion I always read is to combine files, so I made a little Class that merges files on the fly, the supported formats are CSS and Javascript. With little efforts, I think, it can work fine also with JSON and CSV.

Usage is simple:

  • create a file that will serve data and in which the class is included
  • set config variables: method, path and type
  • use a link in this format: /merge/?css&first.css&second.css&third.css

Basically:

<?php

$list = $_SERVER['QUERY_STRING'];
$config['path']['css']  = '/css/';
$config['path']['js']   = '/js/';

include 'merger.class.php';

try
{
    $z = new Merger($list,$config);
    $exp = 60*60*24;
    header("Cache-Control: private");
    header("Cache-Control: maxage=".$exp);
    header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$exp) . ' GMT');
    header('Accept-Ranges: bytes');
    header('Content-Type:' . $z->output_mime());
    header('Content-Length: '. $z->output_sizes());
    echo $z->output_data();
}

catch(Exception $e)
{

    echo $e->getMessage();
    exit();

}

?>

And in the file:

<link rel="stylesheet" href="/merge/?css&a.css&b.css&d.css" type="text/css" media="all" charset="utf-8" />
<script type="text/javascript" src="/merge/?js&jquery-1.7.2.min.js&include.js"></script>

Method and Path are setted in the script and passed as array in the second argument:

$config['method'] = 'get';
$config['path']['css'] = '/css/';

$z = new Merger($list, $config);

get is the default value for method, so it can be omitted, the alternative is cli. Type is setted in the link as first argument:

/merge/?css

this will select the path and the mimes to match, after the first argument append all the files that you want to merge:

/merge/?css&alfa.css&beta.css&gamma.css&...
/merge/?js&javascript_framework.js&calc.js&form.js&...

the string can be served as encoded through urlencode/rawurlencode or not. The class will check for …

cereal 1,524 Nearly a Senior Poster Featured Poster

In addition, check for beanstalkd, you can delay jobs and let them run at specific time: https://github.com/kr/beanstalkd/blob/master/doc/protocol.txt

Check for the job lifecycle which explains how to deal with delays.

cereal 1,524 Nearly a Senior Poster Featured Poster

no problem, that happens.. bye ;D

cereal 1,524 Nearly a Senior Poster Featured Poster

The only problem I see is at line 126 where $zon is not defined, it should be $zone. A part from that I can't see anything wrong. The $zone is always based on a form input? Maybe the script doesn't get the right value from the form..

cereal 1,524 Nearly a Senior Poster Featured Poster

Can you explain better?

The conditional statements are fine, I see just a difference in the last one where the first 3 variables are not grouped as the previous conditions, but that should not change the behaviour.

Also, I tested the conditions with:

$origin = 'NAIA 1';
$vehicle = 'Van'; # switching with 'Innova' and 'Small Car'
$zone = 'Paranaque 2';
$destination = 'BACLARAN';
$rate = 0;

and it works, the only problem I can think happens if the input is in lower case, for example if $destination is baclaran instead of BACLARAN then the conditions are not satisfied.

cereal 1,524 Nearly a Senior Poster Featured Poster

Check previous code that you don't posted. Maybe there is a conditional statement in the mail block code, which includes $variable.

cereal 1,524 Nearly a Senior Poster Featured Poster

Not tested, but try:

$words = explode(',', implode('.,', $string));

this gives you an array again, if you want just a string then use just implode('.', $string).

Edit___
Or:

foreach($words as $value) { $doopnamen .= substr($value, 0, 1).'.'; }

so, if $string:

$string = 'alfa beta';

from the loop you get a.b. It was this you needed? Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi,
I can't help you much on this, so while waiting for better assistance, check the source of that page, you will see that they use few javascript functions to do the converting process. Maybe from there you can find what is going wrong.

cereal 1,524 Nearly a Senior Poster Featured Poster

PHP can run also in command line: http://php.net/manual/en/features.commandline.php
But, if you install PHP 5.4.0 you get also a webserver, just run:

php -S localhost:8000

from the directory with the files to test and you can browse them. Said this, with every programming language you can open a socket and serve data. If there is a problem with restrictions, why not setup a firewall in the working station and block the ports?

cereal 1,524 Nearly a Senior Poster Featured Poster

You're welcome, bye ;D

cereal 1,524 Nearly a Senior Poster Featured Poster

I removed the iframe and added the <div id="result"></div> since with javascript you need this and not the iframe. So try this:

<html>
<head>
    <title>search</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
           $('#forma_kerkimit').submit(function(e) {
                e.preventDefault();
                $.ajax({
                  type: "GET",
                  url: "http://localhost/phptest/search.php",
                  data: $('#forma_kerkimit').serialize(),
                  timeout: 30000,
                  cache: false,
                  error: function(){
                        $("#result").hide().html('server not responding');
                    },
                  success: function( msg ) {
                        $("#result").html(msg);
                  }
                });
            });
        });
    </script>
</head>
<body>
<!-- change this with your form -->
<form method="GET" action="http://localhost/phptest/search.php" id="forma_kerkimit">
    <table style="width:100%; /">
<tbody>
<tr>
      <td><label name= "programi_lb">Emri i programit</label></td>
      <td><label name="ckli_lb">Cikli i studimit</label></td>
      <td><label name="ial_lb">IAL</label></td>
</tr>
<tr>
     <td>
         <input style="width:100%" type="text" class="inputtext" name="programi" id="programi" tabindex="1" />
    </td>
    <td>
          <select style="width:100%" name="cikli_studimit" tabindex="2">
          <option></option>
          <option>Bachelor</option>
          <option>Diplomë 2 vjeçare</option>
          <option>Master profesional</option>
          <option>Master shkencor</option>
          <option>Doktoraturë</option>
          </select>
    </td>
      <td>
          <select name="ial" style="width:100%" tabindex="3">
          <option></option>
          <option>SHLUP "New York University - Tirana"</option>
          <option>SHLUP "Luarasi"</option>
          <option>Universiteti Katolik "Zoja e Këshillit të Mirë"</option>
          <option>Akademia e Filmit dhe Multimedias "Marubi"</option>
          <option>SHLUP "Universiteti "Marin Barleti""</option>
          <option>SHLUP "Universiteti Kristal"</option>
          <option>SHLUP "Justiniani I"</option>
          <option>SHLUP "Sevasti dhe Parashqevi Qiriazi"</option>
          <option>Universiteti Europian i Tiranës</option>
          </select>
      </td>
</tr>
<tr>
      <td><label name="lloji_programit_lb">Lloji i programit</label></td>
      <td><label name="koha_studimit_lb">Koha e studimit</label></td>
      <td><label name="gjuha_studimit_lb">Gjuha e studimit</label></td>
</tr>
<tr>
      <td>
          <select style="width:100%" name = "lloji_programit"tabindex="4">
          <option></option>
          <option>Publik</option>
          <option>Jo publik</option>
          </select>
      </td>
      <td>
          <select style="width:100%" name= "koha_studimit" tabindex="5">
          <option></option>
          <option>Full time</option>
          <option>Part time</option>
          </select>
      </td>
      <td>
          <select style="width:100%" name ="gjuha_studimit" tabindex="6">
          <option></option>
          <option>Shqip</option>
          <option>Anglisht</option>
          </select>
      </td>
</tr>
<tr>
<td><label name="akreditimi_lb">Akreditimi</label></td>
      <td><label name="vendodhja_lb">Vendodhja</label></td>
      <td><label name="fusha_studimit_lb">Fusha</label></td>
</tr>
<tr>      
      <td>
          <select name="akreditimi" size="1" style="width:100%" tabindex="7">
            <option></option>
            <option>Nuk ka hyrë në proces</option>
            <option>Në proces …
cereal 1,524 Nearly a Senior Poster Featured Poster

Are you testing this page from inside a server right? If you load the page locally (e.g. file:///index.html) it will not work.

Also, if you post the table structure and an example of the data, I can try to replicate the behave of your script. To get the table structure run the following commands in mysql client and paste results here:

show create table ial_programet;
show create table ial_institucionet;
cereal 1,524 Nearly a Senior Poster Featured Poster

Mine was an example, in your case use $_FILES['fileupload']['tmp_name']; instead:

$img = $_FILES['files']['tmp_name'];
$exif = exif_read_data($img,'IFD0');
echo $exif['Make'];

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Please, post your updated code, it will be easier to find the problem :)

cereal 1,524 Nearly a Senior Poster Featured Poster

This works for me:

<?php
    $img = "img2.jpg";
    $exif = exif_read_data($img,'IFD0');
    echo $exif['Make'];
?>

I think you don't need to do all this:

$image = chunk_split(base64_encode(file_get_contents($_FILES['fileupload']['tmp_name'])));   //store image in $image

at least not for the exif_read_data() function, just provide the name and the correct path of the file.

cereal 1,524 Nearly a Senior Poster Featured Poster

Change your implode() with: implode(',', $array['checkbox']);
or there is another problem?

choconom commented: super helpful post!! +0
riddhi_A commented: helpful. thanks +0
cereal 1,524 Nearly a Senior Poster Featured Poster

@choconom you're welcome

implode(), in this case, is used to separate each value of the array by a comma, so you get a string: 3,8,17 (ref. to previous post) instead of something to loop like array(3,8,17)

if you change $_POST['checkbox[]'] you can get rid of the line $array = array("checkbox" => $_POST['checkbox']); since you have already an array, as already stated by jstfsklh211

bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

The simplest solution is to add an iframe:

<form action="search.php" target="result" method="post">
    <input type="text" name="msg" />
    <input type="submit" name="submit" value="send" />
</form>

<iframe name="result" src="search.php"></iframe>

If you want to use javascript, you can try JQuery, which is a framework and helps you to write code faster, this is an example:

<html>
<head>
    <title>search</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">

        $(document).ready(function(){

           $('#forma_kerkimit').submit(function(e) {
                e.preventDefault();

                $.ajax({
                  type: "GET",
                  url: "/phptest/search.php",
                  data: $('#forma_kerkimit').serialize(),
                  timeout: 30000,
                  cache: false,
                  error: function(){
                        $("#result").hide().html('server not responding');
                    },
                  success: function( msg ) {
                        $("#result").html(msg);
                  }
                });

            });

        });

    </script>
</head>
<body>

<!-- change this with your form -->
<form id="forma_kerkimit" method="get" action="/phptest/search.php">
    <input type="text" id="fname" name="fname" /><br />
    <input type="submit" name="search" id="search" value="search" />
</form>

<!-- display results from query -->
<div id="result"></div>

</body>
</html>

Here the important is that the form tag has the ID value of forma_kerkimit so the ajax request is done. The result div is where the script displays the query result. If your script is already working, just replace the form of this example with yours and it should work.

Bye.

cereal 1,524 Nearly a Senior Poster Featured Poster

In my code replace previous $_POST['checkbox'] with $_POST['checkbox[]']. I just forgot, sorry!

cereal 1,524 Nearly a Senior Poster Featured Poster

You can use:

  • Ajax to display results in your HTML page
  • an iframe
  • otherwise you need to make your page processable by PHP

in this last option you can mantain the .html extension if you need it, but you have to change the configuration file of your server or add a directive in the .htaccess file:

AddType application/x-httpd-php .html

show your code, someone will help you. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello,
If you temporary comment the delete block of code and add an print_r($_POST) you can read in which format you get the data, something like this:

Array
(
    [checkbox] => Array
        (
            [0] => 3
            [1] => 8
            [2] => 17
        )

    [delete] => Delete
)

if you select an element to delete, otherwise you get:

Array
(
    [delete] => Delete
)

so, in the delete block instead of using $count which is related to the query result, you can count() the checkbox array and do a loop or use implode() to run just one query, like this:

if(isset($_POST['delete']))
{
    if(count($_POST['checkbox']) != 0)
    {
        $ids = implode(',', $_POST['checkbox']);
        $result = mysql_query("DELETE FROM r_textbook_info WHERE id IN($ids)") or die(mysql_error());
    }
 }

hope is useful, bye!

choconom commented: this post saved me :) +0
cereal 1,524 Nearly a Senior Poster Featured Poster

From php.net: http://php.net/manual/en/language.operators.logical.php

TRUE if either $a or $b is TRUE, but not both.

so, here's an example:

<?php
$a = true;
$b = true;
$c = false;

echo ($a xor $b) ? 'true':'false'; # output: false because $a and $b are both true
echo ($a xor $c) ? 'true':'false'; # output: true because $a is true, but not $c
?>

the above can be written also like this:

<?php
if($a xor $b) { echo 'true'; } else { echo 'false'; }
?>

ok?

cereal 1,524 Nearly a Senior Poster Featured Poster

Yep, confirmed, now it works fine. Thanks! :D

cereal 1,524 Nearly a Senior Poster Featured Poster

Hello all :)

I'm experiencing a little problem in the post textbox: I can select the text but this is not highlighted, so I don't see where my selection ends. This happens if I select from the keyboard and also with the mouse. It happens with normal text and also with the code. I noticed this problem few hours ago and is happening only on Google Chrome. With Firefox and Opera everything works fine.

I don't know if this is related but I also noticed that Shift + Ins works as method to paste text, before I could use only CTRL + v.

My user-agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.78 Safari/535.11
OS: Ubuntu 12.04

cereal 1,524 Nearly a Senior Poster Featured Poster

You have to use mysql_data_seek($result, $counter); inside the loop, so you can move the internal result pointer: http://www.php.net/manual/en/function.mysql-data-seek.php

here it is an example: http://www.daniweb.com/web-development/php/threads/396784/php-mysql-while-loop#post1702034

Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi, check the updateImg() function, what should happen there?

As side note: if you can, change chmod to 644, the 666 gives write permission to any process on the server.

cereal 1,524 Nearly a Senior Poster Featured Poster

While developing remove the @ above the functions and you will see the error. At line 11 try to set an absolute path, at the moment this is relative to the script, not to the root: $uploadfile = 'images/' . $newsid . '.jpg';

So change it to:

$uploadfile = $_SERVER['DOCUMENT_ROOT'] .'/images/' . $newsid . '.jpg';
cereal 1,524 Nearly a Senior Poster Featured Poster

You can use explode(), basically: explode(';', 'data;goes;here'). An example:

<?php
  $f = file_get_contents('/filepath/data.csv');  
  $f = array_filter(array_map('trim',(explode(';',$f))));
  print_r($f);

  # in addition you can run array_chunk() this will split the array, it can be helpful in loops
  print_r(array_chunk($f,3));
?>

file_get_contents() is used to read data from csv file, array_filter() is used to remove empty entries from the resulting array, array_map is used to use trim() function, so you can remove white spaces at the end of each string.

Once you have the array just run a query to insert data. Hope it's useful. Bye :)

cereal 1,524 Nearly a Senior Poster Featured Poster

It seems your query has an extra opening parenthesis in the WHERE clause:

"SELECT ... FROM articles WHERE (( ... ) OR ( ... ) GROUP BY ..."

So at line 42 remove the first parenthesis. I'm not sure this will fix your problem, if not post the line error, bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

I suggest something simple, easy to remember, so: Sanket Labs, Sanket Software or Sanket Solutions. Then if you are searching for domains .com, the first two are still free.. :)

cereal 1,524 Nearly a Senior Poster Featured Poster

I think it depends on the different players, the first video is served by jwplayer, the second by youtube. Your friends should try to update Flash and Shockwave or just try to open those links with another browser.

cereal 1,524 Nearly a Senior Poster Featured Poster
cereal 1,524 Nearly a Senior Poster Featured Poster

@jmichae3 it's not a bug, but there is a different behaviour, just try this:

$a = true;
$b = false;

$c[] = $a and $b;
$c[] = $a && $b;

var_dump($c);

as output you will get:

array(2) {
  [0]=>
  bool(true)
  [1]=>
  bool(false)
}

when you should get always false, this happens because the expression with and is working like this:

($c[] = $a) and $b;

instead of:

$c[] = ($a and $b);

and this is why broj1 wrote about the higher precedence of &&. Bye!

cereal 1,524 Nearly a Senior Poster Featured Poster

This is a known problem, check this comment in the function page: http://www.php.net/manual/en/function.strtotime.php#107331

There is also a note that suggest to use DateTime::sub():

Using this function for mathematical operations is not advisable. It is better to use DateTime::add() and DateTime::sub() in PHP 5.3 and later, or DateTime::modify() in PHP 5.2.

cereal 1,524 Nearly a Senior Poster Featured Poster

To print your array structure remove the string inside print_r(), so just use: print_r($_options); and paste the result here, at least a sample.

About javascript I can't help you much. Just be sure to output an HTML document with unique ID, otherwise document.getElementById() will detect only the first one.

cereal 1,524 Nearly a Senior Poster Featured Poster

Hi!
I tried your script, I had to comment the magento functions because I don't have that, but the loop seems to work. In my attempt I'm using an example $_options array, but I'm not sure about the structure, if the array structure is different, please post an example. Maybe the problem is there.

<?php
# example array structure
$_options = array(
    array(
        'label' => 'label a',
        'value' => 10,
        'option_id' => 23,
        'full_view' => 'label a extended'
        ),
    array(
        'label' => 'label b',
        'value' => 20,
        'option_id' => 24,
        'full_view' => 'label b extended'
        ),
    array(
        'label' => 'label c',
        'value' => 30,
        'option_id' => 25,
        'full_view' => 'label c extended'
        ),
    array(
        'label' => 'label d',
        'value' => 40,
        'option_id' => 26,
        'full_view' => 'label d extended'
        )
    );

    $countforfor=0;

    foreach ($_options as $_option) :

      $countforfor=$countforfor+1; ?>
        <input id="xyys" type="hidden" name="xyys" value="<?php echo($_option['value']);echo ($_option['option_id']);?>" /> 
            <?php if($_option['label'] != 'Corte'): ?>
                <?php $_formatedOptionValue = /*$this->getFormatedOptionValue(*/$_option/*)*/ ?>
                <dt><?php echo /*$this->htmlEscape(*/$_option['label']/*)*/ ?></dt>
                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>><?php echo $_formatedOptionValue['value'] ?>
                    <?php if (isset($_formatedOptionValue['full_view'])): ?>
                    <div class="truncated_full_value">
                        <dl class="item-options">
                            <dt><?php /*echo $this->htmlEscape(*/$_option['label']/*)*/ ?></dt>
                            <dd><?php echo $_formatedOptionValue['full_view'] ?></dd>
                        </dl>
                    </div>
                    <?php endif; ?>
                </dd>
            <?php else: ?>
                <?php $_formatedOptionValue = /*$this->getFormatedOptionValue(*/$_option/*)*/ ?>
                <dt><?php echo /*$this->htmlEscape(*/$_option['label']/*)*/ ?></dt>
                <dd<?php if (isset($_formatedOptionValue['full_view'])): ?> class="truncated"<?php endif; ?>>
                <img id="fotop<?php echo $countforfor; ?>" name="fotop<?php echo $countforfor; ?>" height="100px" width="100px" src=""></img><?php echo Si; ?>
                    <?php if (isset($_formatedOptionValue['full_view'])): ?>
                    <div class="truncated_full_value">
                        <dl class="item-options">
                            <dt><?php /*echo $this->htmlEscape(*/$_option['label']/*)*/ ?></dt>
                            <dd><img id="fotog<?php echo $countforfor; ?>" name="fotog<?php echo $countforfor; ?>" src=""></img><?php …