Page 1 of 1

Problem with de special html characters

Posted: Thu Oct 19, 2006 6:31 am
by hmsg
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hello ppl.

       I have a form in html for date, and i'm having problems with the March month, because in portuguese march=março, and ç character iskilling me 

       So the problem is , i receveid th month "março" of my form but i need to compare it to a string to see what month is:

Code: Select all

<?php
                $month_array = array("Janeiro"=>01, "Fevereiro"=>02, "Mar&ccedil;o"=>03, "Abril"=>04, "Maio"=>05, "Junho"=>06, "Julho"=>07, "Agosto"=>08, "Setembro"=>09, "Outubro"=>10, "Novembro"=>11, "Dezembro"=>12);

                  
        $partida_year = $_POST['partida_year']; //here i have the year
        $partida_month = $_POST['partida_month']; // here the month name
	$partida_day = $_POST['partida_day'];// here the day of the month

        $partida = $partida_year."-".$month_array [$partida_month]."-".$partida_day; // here i want tohave my date like yyyy-mm-dd - but when the month is "Março" i have problems because of the 'ç'  how can i do this?

              ?>



I will apreciate a help

With the best regards

Hugo Gomes


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Oct 19, 2006 7:07 am
by feyd
How is the form sending this information? It'd be nice to see (the code of) the form being used. Also, in PHP as with many other C based languages, a zero followed by a number is not understood to be decimal but octal.

Your 09 is understood as just zero as nine is outside the bounds of octal.

Posted: Thu Oct 19, 2006 7:29 am
by hmsg
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


This is the code that i use to put in the array the months names that will gonna be shown in the select box of my html

Code: Select all

<?php
         $array_meses = array( 1 => "Janeiro", 2 => "Fevereiro", 3 => "Mar&ccedil;o", 4 => "Abril", 5 => "Maio", 6=> "Junho", 7 => "Julho", 8 => "Agosto", 9 => "Setembro", 10 => "Outubro", 11 => "Novembro", 12 => "Dezembro");

		$fill_array = array("");
		for ($i = 1;$i <= 12;$i++)
		{
			array_push($fill_array, $array_meses[$i]);
		}
		$this->print_pulldown($date_name."_month", $date_month, $_REQUEST[$date_name.'_month'], $fill_array);
?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Oct 19, 2006 7:34 am
by feyd
How is print_pulldown() written?

Posted: Thu Oct 19, 2006 8:53 am
by hmsg
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Code: Select all

<?php
function print_pulldown($pulldown_name, $value_row, $value_chosen, $value_option_array, $value_underlying_array = "", $auto_reload = 0)
	{echo "<select name='".$pulldown_name."'";

		if ($auto_reload == 1) echo " onchange='JavaScript:submit()'";

		echo ">";		
		$i = 0;
		foreach ($value_option_array as $value_option)
		{
			if ($value_underlying_array[$i] == "")
			{
				#blank option (first option is blank)
				echo '<option value="'.$value_underlying_array[$i].'"';
				if (isset($_REQUEST[$pulldown_name]) and $value_chosen == $value_underlying_array[$i])
				{echo 'selected';}
				else
				{
					if ($value_row == $value_underlying_array[$i])
					{
						echo 'selected';
					}
				}
				echo'></option>';
			}
			else
			{
				#non-blank option
				echo '<option value="'.$value_underlying_array[$i].'"';
				if ($value_chosen == $value_underlying_array[$i])
				{
					echo 'selected';
				}
				else
				{
					if ($value_row == $value_underlying_array[$i])
					{
						echo 'selected';
					}
				}
				echo'>'.$value_option.'</option>';
			}	
			$i ++;
		}
		echo "</select>";

	}


?>

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Thu Oct 19, 2006 9:13 am
by feyd
hmsg, please read how to use the highlighting.

Code: Select all

echo '<option value="'.$value_underlying_array[$i].'"';
could be changed to

Code: Select all

echo '<option value="'.$i.'"';
Which would then supply the index to the selected option which is often easier to process then a name.