Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: PHP Trouble displaying array

  1. #11
    Join Date
    May 2007
    Location
    San Antonio, TEXAS
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: PHP Trouble displaying array

    Quote Originally Posted by ibuclaw View Post
    Done!

    We have a report button for that sort of request (even though the image for it says - rather confusingly - 'report abuse').
    oh, I thought that just meant to report the post as something that needs to be looked at for closure. Thanks

    A LITTLE UPDATE, I AM STILL WORKING ON GETTING THAT FILE CUT DOWN, IT WILL BE AWHILE BEFORE I POST IT.
    Our only ignorance is our own intelligence
    Linux Is not Windows | Atheros 5007 Wifi Chipset Hardy (8.04LTS) Install|
    Linux user number 479043 | Ubuntu User number is # 24065

  2. #12
    Join Date
    May 2007
    Location
    San Antonio, TEXAS
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: PHP Trouble displaying array

    I just noticed something on line 1186
    Code:
    if (/*$values["values"][$field["name"]] && */file_exists($file_name)) {
    however the "/*$values["values"][$field["name"]] && */" is greyed out (like it is a comment) instead of the colorful reds and greens.

    Could this be my problem, if so how do I fix this?
    Our only ignorance is our own intelligence
    Linux Is not Windows | Atheros 5007 Wifi Chipset Hardy (8.04LTS) Install|
    Linux user number 479043 | Ubuntu User number is # 24065

  3. #13
    Join Date
    May 2007
    Location
    San Antonio, TEXAS
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: PHP Trouble displaying array

    Since no one replied to previous post I am going to guess that it should be like that.

    Anyway I have took out ALL comments, except a few that I am not sure if should be there or not, more like different variables you could choose.
    Took out alot of double spaces, and tried to go through and remove the stuff that is not applied to the problem at hand. Still over a 1000 lines of code. So I wont post that. However I am going to post these two snippets, since it seems to be directly involved. And if there is a fix I can try to apply to all of the ones similar to it.

    /lib/forms.php line 5
    Code:
    $form_months = array (1 => "January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December");


    /lib/forms.php lines 1108 - 1131
    Code:
    case "month":
    
    								if (($field["fields"]["month"]["empty"] == "true"))  {
    
    									$months[0] = "--" ;
    
    								}
    
    
    
    								global $form_months;
    
    
    
    								if (is_array($months))
    
    									$formmonths = array_merge($months, $form_months);
    
    								else
    
    									$formmonths = $form_months;
    
    
    
    								$current_field .= $html->FormSelect(
    
    																		$field["name"]."_month" , 
    
    																		$formmonths, 
    
    																		$this->templates , 
    
    																		"DateSelect", 
    
    																		$month_selected,
    
    																		array() , 
    
    																		array("DISABLED" => ($field["fields"]["month"]["editable"] == "false") ? "DISABLED" : "")
    
    																	);
    
    
    
    								$current_field .= $val["separator"];
    
    							break;
    Now as far as numbers, like those for the dates and years, I cant seem to find a list defined like it was defined for months on line 5. Can those numbers be automated some how, if so how would that code look?

    by the way, there is what appears to be a very big empty space, need to scroll all the way over to see it.
    Our only ignorance is our own intelligence
    Linux Is not Windows | Atheros 5007 Wifi Chipset Hardy (8.04LTS) Install|
    Linux user number 479043 | Ubuntu User number is # 24065

  4. #14
    Join Date
    May 2007
    Location
    San Antonio, TEXAS
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: PHP Trouble displaying array

    Ok, I believe I grabbed the whole source where it is talking about dates. Some reason even talks about time, which I dont have available anyway on the site.
    Still look above to see where it is defined on line 5
    Code:
    case "date":
    
    
    
    				if (is_array($field["fields"])) {
    
    
    
    					echo "<pre style=\"background-color:white\">";
    
    					print_r($field);
    
    					print_r($values["values"]);
    
    
    
    					$html = new CHtml;
    
    
    
    					//do some variables cleaning
    
    					if (is_array($years))
    
    						unset($years);
    
    					if (is_array($days))
    
    						unset($days);
    
    					if (is_array($months))
    
    						unset($months);
    
    
    
    					
    
    
    
    					$date_vals = &$values["values"][$field["name"]];
    
    
    
    					if ($date_vals > 1000) {
    
    
    
    						//setting the previous values
    
    						$year_selected = isset($values["values"][$field["name"] ."_year"]) ? $values["values"][$field["name"] ."_year"] : @date("Y" , $date_vals );
    
    						$month_selected = isset($values["values"][$field["name"] ."_month"]) ? $values["values"][$field["name"] ."_month"] : @date("n" , $date_vals );
    
    						$day_selected = isset($values["values"][$field["name"] ."_day"]) ? $values["values"][$field["name"] ."_day"] : @date("j" , $date_vals );
    
    
    
    						//crap, adding the time values too
    
    						$hour_selected = isset($values["values"][$field["name"] ."_hour"]) ? $values["values"][$field["name"] ."_hour"] : @date("G" , $date_vals );
    
    						$minute_selected = isset($values["values"][$field["name"] ."_minute"]) ? $values["values"][$field["name"] ."_minute"] : @date("i" , $date_vals );
    
    						$second_selected = isset($values["values"][$field["name"] ."_second"]) ? $values["values"][$field["name"] ."_second"] : @date("s" , $date_vals );
    
    						
    
    					} else {
    
    
    
    						$fld = $field["fields"];
    
    
    
    						//setting the default value 						
    
    						$year_selected = $fld["year"]["default"] == "now" ? date("Y") : $fld["year"]["default"];
    
    						$month_selected = $fld["month"]["default"] == "now" ? date("n") : $fld["month"]["default"];
    
    						$day_selected = $fld["day"]["default"] == "now" ? date("j") : $fld["day"]["default"];
    
    
    
    						//crap, adding the time values too
    
    						$hour_selected = $fld["hour"]["default"] == "now" ? date("G") : $fld["hour"]["default"];
    
    						$minute_selected = $fld["minute"]["default"] == "now" ? date("i") : $fld["minute"]["default"];
    
    						$second_selected = $fld["second"]["default"] == "now" ? date("s") : $fld["second"]["default"];						
    
    					}
    
    
    
    					foreach ($field["fields"] as $key => $val) {
    
    						switch ($key) {
    
    							case "year":
    
    								if ($field["fields"]["year"]["empty"] == "true") {
    
    									$years[0] = "--" ;
    
    								}
    
    								
    
    								for ($i = $field["fields"]["year"]["from"] ; $i <= $field["fields"]["year"]["to"] ; $i++ )
    
    									$years[$i] = $i;									
    
    
    
    								$current_field .= $html->FormSelect(
    
    																		$field["name"]."_year" , 
    
    																		$years , 
    
    																		$this->templates , 
    
    																		"DateSelect", 
    
    																		$year_selected , 
    
    																		array() , 
    
    																		array("DISABLED" => ($field["fields"]["year"]["editable"] == "false") ? "DISABLED" : "")									
    
    																	);
    
    
    
    								$current_field .= $val["separator"];
    
    							break;
    
    
    
    							case "day":
    
    								if ($field["fields"]["day"]["empty"] == "true") {
    
    									$days[0] = "--" ;
    
    								}
    
    
    
    								for ($i = 1 ; $i <= 31 ; $i++ )
    
    									$days[$i] = sprintf("%02d",$i);
    
    
    
    								$current_field .= $html->FormSelect(
    
    																		$field["name"]."_day" , 
    
    																		$days , 
    
    																		$this->templates , 
    
    																		"DateSelect", 
    
    																		$day_selected,
    
    																		array() , 
    
    																		array("DISABLED" => ($field["fields"]["day"]["editable"] == "false") ? "DISABLED" : "")
    
    																	);
    
    								$current_field .= $val["separator"];
    
    							break;
    
    
    
    							case "month":
    
    								if (($field["fields"]["month"]["empty"] == "true"))  {
    
    									$months[0] = "--" ;
    
    								}
    
    
    
    								//importing the months from global
    
    								global $form_months;
    
    
    
    								if (is_array($months))
    
    									$formmonths = array_merge($months, $form_months);
    
    								else
    
    									$formmonths = $form_months;
    
    
    
    								//ehcking if the dates must apear like strings or numbers
    
    								$current_field .= $html->FormSelect(
    
    																		$field["name"]."_month" , 
    
    																		$formmonths, 
    
    																		$this->templates , 
    
    																		"DateSelect", 
    
    																		$month_selected,
    
    																		array() , 
    
    																		array("DISABLED" => ($field["fields"]["month"]["editable"] == "false") ? "DISABLED" : "")
    
    																	);
    
    
    
    								$current_field .= $val["separator"];
    
    							break;
    
    
    
    							case "hour":
    
    								for ($i = 0; $i <= 23; $i++ )
    
    									$hours[$i] = sprintf("%02d",$i);;									
    
    
    
    								$current_field .= $html->FormSelect(
    
    																		$field["name"]."_hour" , 
    
    																		$hours , 
    
    																		$this->templates , 
    
    																		"DateSelect", 
    
    																		$hour_selected , 
    
    																		array() , 
    
    																		array("DISABLED" => ($field["fields"]["hour"]["editable"] == "false") ? "DISABLED" : "")									
    
    																	);
    
    
    
    								$current_field .= $val["separator"];
    
    							break;
    
    
    
    							case "minute":
    
    								for ($i = 0; $i <= 59; $i++ )
    
    									$minutes[$i] = sprintf("%02d",$i);;									
    
    
    
    								$current_field .= $html->FormSelect(
    
    																		$field["name"]."_minute" , 
    
    																		$minutes , 
    
    																		$this->templates , 
    
    																		"DateSelect", 
    
    																		$minute_selected , 
    
    																		array() , 
    
    																		array("DISABLED" => ($field["fields"]["minute"]["editable"] == "false") ? "DISABLED" : "")									
    
    																	);
    
    
    
    								$current_field .= $val["separator"];
    
    							break;
    
    
    
    							case "second":
    
    								for ($i = 0; $i <= 59; $i++ )
    
    									$seconds[$i] = sprintf("%02d",$i);;									
    
    
    
    								$current_field .= $html->FormSelect(
    
    																		$field["name"]."_second" , 
    
    																		$seconds , 
    
    																		$this->templates , 
    
    																		"DateSelect", 
    
    																		$second_selected , 
    
    																		array() , 
    
    																		array("DISABLED" => ($field["fields"]["minute"]["editable"] == "false") ? "DISABLED" : "")									
    
    																	);
    
    
    
    								$current_field .= $val["separator"];
    
    							break;
    
    
    
    						}						
    
    					}					
    
    				}				
    
    
    
    				//if the field hs description then i add the valign code
    
    				$current_field_extra = $field["description"] ? $this->templates->blocks["TopAlign"]->output : ""; 
    
    
    
    			break;
    oh, almost forgot, I took out the indexing from line 5, so instead of it starting out like
    $form_months = array (1 => "January"
    it is now starting out like
    $form_months = array ( "January"
    Last edited by k33bz; September 25th, 2010 at 01:32 AM.
    Our only ignorance is our own intelligence
    Linux Is not Windows | Atheros 5007 Wifi Chipset Hardy (8.04LTS) Install|
    Linux user number 479043 | Ubuntu User number is # 24065

  5. #15
    Join Date
    May 2007
    Location
    San Antonio, TEXAS
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: PHP Trouble displaying array

    Ok, not much to update. However I am more than sure what the problem is. This code was written for a version of PHP4 (I am more than sure on this). However I am running the latest PHP5.

    Where can I go that will tell me how to update the code so it will work on PHP5. Not sure how to, or what keywords to search for, to find my answer on this one. I have only came up with one hit http://www.webmaster-talk.com/php-fo...-and-php5.html but I need more references.

    Thanks
    Our only ignorance is our own intelligence
    Linux Is not Windows | Atheros 5007 Wifi Chipset Hardy (8.04LTS) Install|
    Linux user number 479043 | Ubuntu User number is # 24065

  6. #16
    Join Date
    Jul 2006
    Location
    Calgary, Alberta
    Beans
    1,123
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: PHP Trouble displaying array

    Anything written for PHP4 will work in PHP5, that's likely not your problem.

    If you want you can send me all the files you're using or your FTP login and I'll take a few minutes to fix it. Otherwise go to phpfreaks.com and post your problem there. But beware, they won't even look at more than 50 lines of code.
    Quote Originally Posted by Tristam Green View Post
    I can tell you something about a turntable.
    I have two of them.
    And a microphone.
    Where it's at.

  7. #17
    Join Date
    May 2007
    Location
    San Antonio, TEXAS
    Beans
    Hidden!
    Distro
    Ubuntu 10.10 Maverick Meerkat

    Re: PHP Trouble displaying array

    Quote Originally Posted by Maheriano View Post
    Anything written for PHP4 will work in PHP5, that's likely not your problem.

    If you want you can send me all the files you're using or your FTP login and I'll take a few minutes to fix it. Otherwise go to phpfreaks.com and post your problem there. But beware, they won't even look at more than 50 lines of code.
    Sent you a message And ya I know they wont, I have tried that, as well as a few other php forum sites
    Our only ignorance is our own intelligence
    Linux Is not Windows | Atheros 5007 Wifi Chipset Hardy (8.04LTS) Install|
    Linux user number 479043 | Ubuntu User number is # 24065

  8. #18
    Join Date
    Nov 2008
    Location
    Boston MetroWest
    Beans
    16,326

    Re: PHP Trouble displaying array

    Quote Originally Posted by k33bz View Post
    lib/forms.php line 5
    Code:
    $form_months = array (1 => "January" , "February" , "March" , "April" , "May" , "June" , "July" , "August" , "September" , "October" , "November" , "December");
    Entries of the form "x"=>"y" indicate associative arrays. If you just want a numbered list then remove the '1=>' and include only the months. Be aware, though, that PHP numbers from zero like most everything else in the Unix world. So $form_months[0] will equal January, and $form_months[12] will be undefined.

    If the first entry is "", then $form_months[0] will return an empty string, and $form_months[1] will return "January". One convenient trick this permits is to assign the first entry a value like "Select a Month" which will appear by default in the drop-down box.

    Usually I create drop-down boxes from a simple function I wrote. It requires an associative array of "key"=>"value" pairs that are used to populate the select control. The function looks like this:

    Code:
    function make_select($name,$options,$selected[,$extra=""]) {
    
        # make a select box
        # $name = name of the HTML field
        # $options = associative array of key/value pairs to populate select box
        # $selected = a previously selected value or "" if none
        # $extra = optional additional text for styles, etc.
    
        $output="";
        $output.="\n<select name=\"$name\" $extra >\n";
    
        while (list($key,$val) = each($options)) {
             $output.="<option value=\"$key\"";
             if ($key==$selected) {
                $output.=" selected";
             }
             $output.=">".trim($val)."</option>\n";
         }
         $output.="</select>\n";
    
         return $output;
    
    }
    I wrote this some years ago; today I'd use a "foreach ($options as $key=>$val)" construct instead of a while() loop.
    Last edited by SeijiSensei; October 6th, 2010 at 05:09 PM.

  9. #19
    Join Date
    Feb 2011
    Beans
    1

    Re: PHP Trouble displaying array

    You should try to upgrade your version of php to 5+ and modify your class contents
    php4 often use var for variable's declaration but you should be using private, public. Php 4 is kind of based on pseudo-objets so if you want to use php oriented objet to the fullest start by using a version later than 5.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •