Changining Language code not working in Firefox

I have a new problem with this issue. It seems that this function will not work at all in Firefox.

I have been trough everything and cannot see what the problem is. It is a simple PHP session that works fine in Other browsers, but once again, Firefox has to be difficult and seems to ignore it all together.

When the link for on of the languages is clicked, the page refreshes and all the data is stripped from the page...

You can see here ( www.elite-si.com ) what I mean. try it in IE and Chrome first and all works fine, but Firefox chokes on it.

Below is the code for starting the session and the language links.  I have also added an example of the code for the database table selection.

<?php session_start();

if(isset($_GET['lang']))
{
  $_SESSION['language'] = $_GET['lang'];  
}

if(isset($_SESSION['language']))
{
 $language = $_SESSION['language'];
    
}else
{
  //sets the default language to english
  
 $_SESSION['language'] = 'en';
  $language = $_SESSION['language'];
    
}
?>

__________________________________________


<a href="<?php echo $_SERVER['PHP_SELF'] ?>?lang=en">English</a> | <a href="<?php echo $_SERVER['PHP_SELF'] ?>?lang=vn">Ti¿ng Vi¿t</a>

Open in new window

mysql_select_db($database_elitedb, $elitedb);
$query_rsScrubvac = sprintf("SELECT * FROM equipment WHERE cat = %s AND lang = '$language'", GetSQLValueString($colname_rsScrubvac, "text"));
$rsScrubvac = mysql_query($query_rsScrubvac, $elitedb) or die(mysql_error());
$row_rsScrubvac = mysql_fetch_assoc($rsScrubvac);
$totalRows_rsScrubvac = mysql_num_rows($rsScrubvac);

mysql_select_db($database_elitedb, $elitedb);
$query_rsPage = "SELECT * FROM pages WHERE page = 'home' AND lang = '$language'";
$rsPage = mysql_query($query_rsPage, $elitedb) or die(mysql_error());
$row_rsPage = mysql_fetch_assoc($rsPage);
$totalRows_rsPage = mysql_num_rows($rsPage);

Open in new window

LVL 5
SaigonJeffAsked:
Who is Participating?
 
ropennerConnect With a Mentor Commented:
I think the category information is lost after clicking on a new language link.  My understanding of how it works is that when you click on the language link it runs the script anew and if there is no 'cat' variable sent in then $colname_rsScrubvac = NULL because of these three lines (57-60)

if (isset($_GET['cat'])) {
  $colname_rsScrubvac = $_GET['cat'];
}


If you add somewhere at the top some storage in the session for the currently selected catalogue item then it will not get lost, but rather be stored in the _SESSION  variable.  You will need to use the _SESSION variable  then, rather than the _GET variable to determine the category.

Printing out the query string on line 61 would confirm this.

So line 57 you may want to use this or something like it:
________________
if ($_GET['cat']) {
    $_SESSION['cat'] = $_GET['cat'];
} elseif ($_SESSION['cat']) {
    $colname_rsScrubvac = $_SESSION['cat'];
}
0
 
ropennerCommented:
firefox 3.616 in linux looks like it works properly... the language changes on the page when you click the language buttons.

Perhaps post a picture of your before and after.

There is no difference from Chrome to firefox from my perspective.
0
 
SaigonJeffAuthor Commented:
Sure... I have added both images...

the 'before' pic is the default language...
Before

the 'after' pic is what I get when I select Vietnamese or try to go back to English
After
Am am using Firefox 3.6.6

0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
ropennerCommented:
Chrome 10.0.648 and firefox 3.6.16 both look like your after picture.

You currently have not shown us other SESSION variables like which page you have selected (necessary) so that would be helpful next.

You need to show us code and the lines around it that look like:

$SESSION['current page'] = _REQUEST['vacuum cleaners'];
OR
$SESSION['current page'] = filter_input(INPUT_GET, "user_page_selection");

It appears that the state is being lost somewhere that could be stored in the SESSION variable.


0
 
SaigonJeffAuthor Commented:
Sorry for the delay in replying... I was called away on urgent matter for a few days.

Actually, the only scripting I am using is the Default language session, and the language switching links... Below is the complete code for the vacuums listings page.

<?php require_once('Connections/elitedb.php'); ?>
<?php require('savepath.php'); ?>
<?php session_start();

if(isset($_GET['lang']))
{
  $_SESSION['language'] = $_GET['lang'];  
}

if(isset($_SESSION['language']))
{
 $language = $_SESSION['language'];
    
}else
{
  //sets the default language to english
  
 $_SESSION['language'] = 'en';
  $language = $_SESSION['language'];
    
}

?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_rsScrubvac = "-1";
if (isset($_GET['cat'])) {
  $colname_rsScrubvac = $_GET['cat'];
}
mysql_select_db($database_elitedb, $elitedb);
$query_rsScrubvac = sprintf("SELECT * FROM equipment WHERE cat = %s AND lang = '$language'", GetSQLValueString($colname_rsScrubvac, "text"));
$rsScrubvac = mysql_query($query_rsScrubvac, $elitedb) or die(mysql_error());
$row_rsScrubvac = mysql_fetch_assoc($rsScrubvac);
$totalRows_rsScrubvac = mysql_num_rows($rsScrubvac);

mysql_select_db($database_elitedb, $elitedb);
$query_rsPage = "SELECT * FROM pages WHERE page = 'home' AND lang = '$language'";
$rsPage = mysql_query($query_rsPage, $elitedb) or die(mysql_error());
$row_rsPage = mysql_fetch_assoc($rsPage);
$totalRows_rsPage = mysql_num_rows($rsPage);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Elite  Total Hygiene Solution - Welcome</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<script src="Scripts/swfobject_modified.js" type="text/javascript"></script>
</head>

<body>
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="181" bgcolor="#C8ECC8"><img src="layout/logo.png" width="181" height="170" /></td>
        <td width="619" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="30" align="right" background="layout/headbarBG.png"><?php include('incl-lang.php'); ?></td>
          </tr>
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="41%" bgcolor="#DBF8DC"><object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="251" height="188">
                  <param name="movie" value="slideshow.swf" />
                  <param name="quality" value="high" />
                  <param name="wmode" value="opaque" />
                  <param name="swfversion" value="6.0.65.0" />
                  <!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
                  <param name="expressinstall" value="Scripts/expressInstall.swf" />
                  <!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
                  <!--[if !IE]>-->
                  <object type="application/x-shockwave-flash" data="slideshow.swf" width="251" height="188">
                    <!--<![endif]-->
                    <param name="quality" value="high" />
                    <param name="wmode" value="opaque" />
                    <param name="swfversion" value="6.0.65.0" />
                    <param name="expressinstall" value="Scripts/expressInstall.swf" />
                    <!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
                    <div>
                      <h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
                      <p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
                    </div>
                    <!--[if !IE]>-->
                  </object>
                  <!--<![endif]-->
                </object></td>
                <td width="59%" bgcolor="#DBF8DC"><table width="100%" border="0" cellspacing="0" cellpadding="8">
                  <tr>
                    <td class="headtext"><?php echo nl2br($row_rsPage['content']); ?></td>
                  </tr>
                </table></td>
              </tr>
            </table></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><?php include('menu.php'); ?></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="61%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="5">
              <tr>
                <td height="46" class="pagetitle"><?php echo $row_rsScrubvac['cat']; ?></td>
                </tr>
              <tr>
                <td height="46"><table width="241" >
                  <tr>
                    <?php
$rsScrubvac_endRow = 0;
$rsScrubvac_columns = 3; // number of columns
$rsScrubvac_hloopRow1 = 0; // first row flag
do {
    if($rsScrubvac_endRow == 0  && $rsScrubvac_hloopRow1++ != 0) echo "<tr>";
   ?>
                    <td><table width="235" border="0" cellpadding="3" cellspacing="0">
                      <tr>
                        <td><table width="240" border="0" cellpadding="0" cellspacing="0" class="contactborder">
                          <tr>
                            <td width="20" align="center" valign="top" bgcolor="#8CC63F"><img src="images/equipment/thumbs/<?php echo $row_rsScrubvac['img']; ?>" width="60" height="100" vspace="5" /><br />
                              <a href="equip-vac-details.php?ID=<?php echo $row_rsScrubvac['ID']; ?>"><?php echo $row_rsScrubvac['link']; ?></a></td>
                            <td width="1" valign="top" bgcolor="#339900"><img src="layout/spcr.gif" width="1" height="130" /></td>
                            <td width="230" valign="top" bgcolor="#D2E8D3"><table width="100%" border="0" cellpadding="3" cellspacing="0">
                              <tr>
                                <td bgcolor="#019834" class="productname"><?php echo $row_rsScrubvac['name']; ?></td>
                              </tr>
                              <tr>
                                <td><?php echo nl2br($row_rsScrubvac['add']); ?></td>
                              </tr>
                            </table></td>
                          </tr>
                        </table></td>
                      </tr>
                    </table></td>
                    <?php  $rsScrubvac_endRow++;
if($rsScrubvac_endRow >= $rsScrubvac_columns) {
  ?>
                  </tr>
                  <?php
 $rsScrubvac_endRow = 0;
  }
} while ($row_rsScrubvac = mysql_fetch_assoc($rsScrubvac));
if($rsScrubvac_endRow != 0) {
while ($rsScrubvac_endRow < $rsScrubvac_columns) {
    echo("<td>&nbsp;</td>");
    $rsScrubvac_endRow++;
}
echo("</tr>");
}?>
                </table></td>
              </tr>
              <tr>
                <td height="46"><a href="javascript:history.go(-1);"><img src="layout/back.png" name="back" width="78" height="30" hspace="10" vspace="5" border="0" id="back" onmouseover="MM_swapImage('back','','layout/back-over.png',1)" onmouseout="MM_swapImgRestore()" /></a></td>
              </tr>
              </table></td>
            </tr>
          <tr>
            <td valign="top"></td>
            </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="100" align="center" valign="top" bgcolor="#8CC63F"><p><br />
        <a href="index.php" class="link_text">Home</a> | <a href="about.php" class="link_text">About Elite</a> | <a href="contact.php" class="link_text">Contact Us</a></p>
      <p class="copyright">©copyright 2010, Elite Total Hygiene Solution. All Rights Reserved</p>
      <p class="copyright">Site Design: <a href="http://www.glassdragondesign.com" target="_blank" class="link_text">Glass Dragon Design Company Ltd</a>.</p></td>
  </tr>
</table>
<script type="text/javascript">
<!--
swfobject.registerObject("FlashID");
//-->
</script>
</body>
</html>
<?php
mysql_free_result($rsPage);

mysql_free_result($rsScrubvac);
?>

Open in new window

0
 
SaigonJeffAuthor Commented:
I apologize for the delay once again. I will try the last suggestion and will post the results, but I was wondering if the problem might be in the MySQL Select syntax.

I have highlighted the suspect portion in bold...

mysql_select_db($database_elitedb, $elitedb);
$query_rsScrubvac = sprintf("SELECT * FROM equipment WHERE cat = %s AND lang = '$language'", GetSQLValueString($colname_rsScrubvac, "text"));
$rsScrubvac = mysql_query($query_rsScrubvac, $elitedb) or die(mysql_error());
$row_rsScrubvac = mysql_fetch_assoc($rsScrubvac);
$totalRows_rsScrubvac = mysql_num_rows($rsScrubvac);
0
 
ropennerCommented:
sql is fine, but if you print it out

print "<B>$query_rsScrubvac</B><BR><BR>";

you will be able to confirm my previous comment that you are giving it a null value for
   cat= AND ....

which results in an SQL error.  This error is due to no value for $colname_rsScrubvac as described above.
0
 
SaigonJeffAuthor Commented:
Again, I apologize for the long delay.

I have tried your suggestions, but to no avail... Perhaps I am going about it the wrong way, but I do think that I am on the right track.  I will therefor accept you answer as a partial solution, and will post any further progress later on.

Thanks for your help.
0
 
SaigonJeffAuthor Commented:
Thanks for pointing me in the right direction.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.