PHP - Problem With Language In A Php Page Of My Website
I am helping a friend to fix their website and I dont have too much experience with php.
I have noticed a problem with the language on one of the pages http://www.fincalavicaria.com/alameda.php When the page loads the Servicios shows in Spanish, which is correct however, if you click on the Servicios link it changes to the English version in the Spanish vesrion. This should only be available after you have changed the language for the site to english at the top As I dont have too much experience I would be grateful if someone could tell me what would be causing this to happen. It should be something very easy to fix but no matter what I try I can't find the problem. Thank you. Similar TutorialsMy website is multi-language and using mod_rewrite for clean urls. I have a $lang variable that stores the language code. For example: website.com/index.php?lang=en, which turns to website.com/en I use a $_GET["lang"] to get the language and prepare the links to the other pages, for example a link to page1.php would be page1.php?lang=$_GET["lang"]. What I want to know is if this is the right way to do it or there is a better way. According to woorank.com my page shows the following. Language Declared: Missing Detected: en I have used Code: [Select] header('content-type: text/html; charset=utf-8'); but do not know how I declare the language. also how do i specify Language/character encoding how is this done ? When you select language I just got an error message Got an error message that says: This problem can sometimes occur if you are disabled or refused to take accept cookies. I have accepted cookies. My code is: language.php <?php if(!isset($_COOKIE['language'])) { if(!isset($_GET['lang'])) { ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>123</title> <style type="text/css"> <!-- body { background-image: url(images/background.jpg); } .style1 { color: #FFFFFF; font-weight: bold; } --> </style></head> <body> <p><br> <br> <br> <br> <br> </p> <div align="center" style="margin-top:400px;"> <table width="200" border="0"> <tr> <td width="114"><div align="left"><a href="language.php?lang=swe"><img src="http://www.clickbuxer.com/images/swe.jpg" border="0" alt="swedish" /></a></div></td> <td width="1" rowspan="2"> </td> <td rowspan="2"><div align="left"></div></td> <td><a href="language.php?lang=usa"><img src="http://www.clickbuxer.com/images/usa.jpg" border="0" alt="usa" /></a></td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td><div align="center" class="style1">SWE</div></td> <td> </td> <td width="0"><div align="center"></div></td> <td width="110"><div align="center" class="style1">USA</div></td> </tr> </table> </div> <p align="center"> </p> </body> </html> <?php } else { //Add cookie code $language = $_GET['lang']; setcookie("language", $language, time()+3600);//set to expire in 1 hour, 3600=seconds switch($language) { case usa: $redirect = "http://www.clickbuxer.com"; break; case swe: $redirect = "http://www.clickbuxer.com/sv/index.php"; break; default: $redirect = "http://www.clickbuxer.com"; } header("Location: $redirect"); } } else { //If cookie is already set $language = $_COOKIE['language']; switch($language) { case usa: $redirect = "http://www.clickbuxer.com"; break; case swe: $redirect = "http://www.clickbuxer.com/sv/index.php"; break; default: $redirect = "http://www.clickbuxer.com"; } header("Location: $redirect"); } ?> index.php <?php if(!isset($_COOKIE['language'])) { header("Location: http://www.clickbuxer.com/language.php"); } else { $language = $_COOKIE['language']; switch($language) { case usa: $redirect = "http://www.clickbuxer.com"; break; case swe: $redirect = "http://www.clickbuxer.com/sv/index.php"; break; default: $redirect = "http://www.clickbuxer.com"; } header("Location: $redirect"); } ?> Hello masters. I wish to share with you a problem that is killing me in this dais!! I have a website in xhtml, with some php form. This website is made for Japanese customers (all in Japanese) and that's the big trouble. The language encoding of the php form is really killing me. I tried several solutions, but I couldn't sort this problem. So I was wondering if you guis could help me... This is how it should work: customers fill up the form in Japanese. The php script send the deta to my mail address and to the customer one. Simply and plan. No image, just text ... easy. I tested it on my Japanese computer and it works great: I recive the mail, the customer recive the mail and all the field are ok and I can read all the Japanese charachters. The big troubles come out when I try to fill up the form with a Japanese mobile device: Both the customer and me recive a mail with weird characters. something like this: ..????i???.... and so on....damn, I can't understand why. The most weird thing is that it really works great on computer browser. But as this is a website for mobile devices I have no choice but to settle this. Here is part of the code I use for the form: <?php // I set the page encoding to EUC-JP and set the Japanese language mb_language("ja"); mb_internal_encoding("EUC-JP"); // Declare $ $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "orders@mobile-body-ex.com"; $Subject = "Body-ex Cellphone Order"; $Nome = Trim(stripslashes($_POST['Nome'])); $Cognome = Trim(stripslashes($_POST['Cognome'])); $Postal = Trim(stripslashes($_POST['Postal'])); $Address = Trim(stripslashes($_POST['Address'])); $Number = Trim(stripslashes($_POST['Number'])); .... // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=error.xhtml\">"; exit; } // prepare email body text $Body = "モバイルサイトから注文受けました: Angel スリーラウンドペンダント AD-0011 Booking Form;"; $Body .= "名前: "; $Body .= $Nome; $Body .= "\n"; $Body .= "名前(フリガナ): "; $Body .= $Cognome; $Body .= "\n"; $Body .= "郵便番号: "; $Body .= $Postal; $Body .= "\n"; $Body .= "住所: "; ..... // send email $success = mb_send_mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); .....Follow the second mail directed to the customer email address. ps: モバ are Japanese characters... Both the html page with the form and the php page are set to EUC-JP (charset="euc-jp"). What should I do to make this work properly? I repeat that it actually works on the net if you use a computer browser (try to see at http://www.mobile-body-ex.com/ora1.html). But I couldn't find a way to make it works if you fill up the form trough a browser for mobile devices (Japanese). ......please, give me some hint Thank you everybody! Hello everyone For a multilingual website we have to be able to open 1 page in 4 different languages. For example, product 'A' is in Dutch, English, French and German. How can I open the right language file? At the moment I use Code: [Select] http://www.zinncosmetics.nl/shop/product_info.php?products_id=36?language=de but it doesn't work. It allways opens the default Dutch pages. What do I do wrong? I don't have very much php experience (newbie) so please don't make it too difficult for me. Thanks for all help! I just want to add a css cass named "active" to my navigation links when its page opened using php.
In my website the content have broken into its individual components. And those components are separated, organized, and put back together using one index file. (website bootstrap file) Actually I am modularizing this website using php.
My Navigation is something similar to this code -
... <li> <a href="index.php?p=dashboard">Dashboard</a> </li> <li> <a href="index.php?p=page-two">Page Two</a> </li> <li> <a href="index.php?p=page-three">Page Page Three</a> </li> ...This is how my index.php looks like - // Validate what page to show: if (isset($_GET['p'])) { $p = $_GET['p']; } elseif (isset($_POST['p'])) { // Forms $p = $_POST['p']; } else { $p = NULL; } // Determine what page to display: switch ($p) { case 'dashboard': $page = 'dashboard.inc.php'; $page_title = 'Control Panel'; break; case 'page-three': $page = 'page-three.inc.php'; $page_title = 'Page Three'; break; case 'page-two': $page = 'page-two.inc.php'; $page_title = 'Page Two'; break; // Default is to include the main page. default: $page = 'login.inc.php'; $page_title = 'Control Panel Login'; break; } // End of main switch. // Make sure the file exists: if (!file_exists('./modules/' . $page)) { $page = 'login.inc.php'; $page_title = 'Control Panel Login'; } include('./includes/header.html'); include('./modules/' . $page); include('./includes/footer.html');I tried it something like this - case 'dashboard': $page = 'dashboard.inc.php'; $page_title = 'Control Panel'; $class == ($page == $p) ? 'active' : ''; break; And adding this class to my navigation <li> <a class="<?php echo $class;?>">.... </li>But this is not working for me. hope somebody may help me out. Thank you. Edited by thara, 02 January 2015 - 06:00 AM. Hello! I would like to use cURL to login to the website: lockerz.com I have some code, but it doesn't seem to work: <?php // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auth/login'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'email-email=EMAIL@hotmail.com&password-password=PASSWPRD'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); // SET FILE TO DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'http://lockerz.com/auction'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); // CLOSE CURL curl_close ($ch); echo $content; ?> Thank you very much if you can help! Hello, I need help trying to figure out why my form won't write the database it is supposed to - i checked the connection to the database and it works and the user seems to have permission to edit database - the error I get is "Error: User not added to database." from "register.php". Can someone please look over my code and see if the problem is coming from somewhere within?
I created a connection file (connect.php)
<? session_start(); // Replace the variable values below // with your specific database information. $host = "localhost"; $user = "master"; $pass = "hidden"; $db = "user"; // This part sets up the connection to the // database (so you don't need to reopen the connection // again on the same page). $ms = mysql_pconnect($host, $user, $pass); if ( !$ms ) { echo "Error connecting to database.\n"; } // Then you need to make sure the database you want // is selected. mysql_select_db($db); ?>Then there is the php script (register.php): <?php session_start(); // connect.php is a file that contains your // database connection information. This // tutorial assumes a connection is made from // this existing file. require('connect.php'); // If the values are posted, insert them into the database. if (isset($_POST['email']) && isset($_POST['password'])){ $firstname = $_POST['firstname']; $lastname = $_POST['lastname']; $email = $_POST['email']; $password = $_POST['password']; $query = "INSERT INTO `member` (firstname, lastname, email, password) VALUES ('$firstname', '$lastname', '$email' '$password')"; $result = mysql_query($query); if ( !mysql_insert_id() ) { die("Error: User not added to database."); } else { // Redirect to thank you page. Header("Location: surveylanding_no-sidebar.html"); } } ?>Here is the HTML form: <form name="htmlform" method="post" class="form" action="register.php"> <p class="firstname"> <input type="text" name="firstname" id="firstname" /> <label for="firstname">First Name</label> </p> <p class="lastname"> <input type="text" name="lastname" id="lastname" /> <label for="lastname">Last Name</label> </p> <p class="email"> <input type="email" name="email" id="email" /> <label for="email">Email</label> </p> <p class="Password"> <input type="password" name="password" id="password" /> <label for="password">Password</label> </p> <p class="submit"> <input type="submit" value="Register"/> </p> </form> This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=349726.0 I am using wampserver to run my website but i keep getting error when i type in localhost in my address bar Is it the problem with wampserver or the coding? The Error Quote Warning: mssql_connect() [function.mssql-connect]: Unable to connect to server: localhost in C:\wamp\www\libs\dmssql.php on line 35 Cant Connect to mssql [dmssql class] here is the config.php Quote ##### Template Dir ########### $template = 'default'; ##### Server Name $title = 'RoseCP AE'; ###### Your msSQL Info ######## $hostname = "localhost"; $username = "sa"; $password = ""; # databases, that if you changed db names. if not, dont change a thing $seven_ORA = "seven_ORA"; $sho = "SHO"; $sho_log = "SHO_LOG"; $sho_mall = "SHO_MALL"; And here is the dmssql.php Quote ##### Template Dir ########### $template = 'default'; ##### Server Name $title = 'RoseCP AE'; ###### Your msSQL Info ######## $hostname = "localhost"; $username = "sa"; $password = ""; # databases, that if you changed db names. if not, dont change a thing $seven_ORA = "seven_ORA"; $sho = "SHO"; $sho_log = "SHO_LOG"; $sho_mall = "SHO_MALL"; And here is the dmssql.php Quote class dmssql { function dmssql($h,$u,$p,$d) { $this->host = $h; $this->user = $u; $this->pass = $p; $this->db = $d; } function connect() { $this->linkid = mssql_connect($this->host,$this->user,$this->pass) or die("Cant Connect to mssql [dmssql class]"); if ($this->linkid) { if (mssql_select_db($this->db)) { return TRUE; } else { $this->dbclose($this->linkid); echo "Cant Select $this->db [dmssql class]"; return FALSE; } } else { echo "Cant Connect to mssql [dmssql class]"; return FALSE; } } function query($q) { if ($this->connect()) { $q = $this->clean($q); $r = mssql_query($q) or die("FATAL ERROR"); return $r; } } function clean($string) { $new_data = preg_replace("[^A-Za-z0-9@.]", "", $string); return $new_data; } function num_rows($data) { return mssql_num_rows($data); } function qFirstRow($q) { if ($this->connect()) { $ret = mssql_fetch_row($this->query($q)); } return $ret[0]; } function fetch_array($data) { return mssql_fetch_array($data); } function dbclose() { return mssql_close($this->linkid); } } ?> Can you help me Please Guys :X i enbaled php_mssql.dll and i replaced from ;extension php_mssql.dll to extension php_mssql.dll Could you help me guys please X.x HERE IS The full website code im using http://uploading.com/files/get/8de48e5m/ Hi, I have create a small website with a login, over the past month it has been working fine, however today I tried to login and it says incorrect password. So I go into my phpMyAdmin database and change the password with the function type as PASSWORD. I go to login again and it still doesnt work. I did however have a dummy account on the site and that does work, and the only difference I can see is the encryption of the password, the new passwords I create start with the astrix symbol (*) and the old password that works doesnt have that. I can guess im probably using the wrong encryption type, but Iv tried loads of different ones and still nothing. I have however noticed which line of code in my PHP code isnt working for the new Passwords, but I cant see a problem. I have put it below, if anyone knows what the problem is, please, please, please let me know. Code: [Select] if ($pwd === PwdHash($pass,substr($pwd,0,9))) { It fails at this point and goes strait to the else at the bottom of the if statement. Thanks Ben p.s. if you want me to post all the Login code I will happily do so. So I'm working on a website for an airline (not real) and on one of my pages you can request the cost of a flight by putting in the depart and arrival locations, like this: And if they put in a selection that isn't in the database they get this: The problem is that when they load the page initially, instead of just the selection bars and sumbit button showing up, it all does and i get an error like this: When you sumbit it, it all looks like it should, it's just that when they load it things seem to go wrong, any idea how i can fix this? Heres the code i use: Code: [Select] <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <p>Depart: <select name="depart"> <option selected="selected">Bristol</option> <option>Newcastle</option> <option>Manchester</option> <option>Dublin</option> <option>Glasgow</option> </select> Arrive: <select name="arrive"> <option>Bristol</option> <option selected="selected">Newcastle</option> <option>Manchester</option> <option>Dublin</option> <option>Glasgow</option> </select> <input type="submit" /> </p> </form> <?php $depart = $_POST['depart']; $arrive = $_POST['arrive']; $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("test", $con); $result = mysql_query("SELECT price FROM flights WHERE depart = '$depart' AND arrive = '$arrive'"); if ($row = mysql_fetch_assoc($result)) { echo 'This flight shall cost you £'; echo $row["price"]; } else include('includes/price.php'); ?> </div> My if-else statement doesn't seem to be doing it's job Thanks in advance Hi, I have uploaded a website for someone but they are having problems viewing it and are telling me that nothing comes up. Not sure if its a dns problem. The domain was registered 2 days ago. Can a couple of you please check and tell me if this site loads up, it should show an ecommerce website : http://www.cassellmotors.com Many thanks, Scott i created a insert php code which successfully submit to database but i was lost at some point because what i really wanted was a php code that will print on the next page after submission to db At the minute i am using variables in my tpl files in place of plain text so users can change the language the page is shown in. eg. the tpl file would include: $lang->hello; and the replacement would be $lang['hello'] = 'hello'; the php file would include the language class which replaces the variable in the language file with the array value in the relevant language file. but what happens when i have a phrase with a needed variable in the middle? $lang['msgs'] = 'you have '.$msgs.' messages'; i cant have 'you have' and 'messages' as seperate lang variables as phrases are constructed differently in other languages? so how do i accomplish this? hopefully i habe explained this ok. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=321347.0 Hi, I am trying to append a language session like this: Code: [Select] $ATC_itemWeight = floatval("".$row_productos_RS['capacidad_'.$_SESSION['session_idioma'].'']; but I get this error Code: [Select] Parse error: syntax error, unexpected ';' in /usr/home/mysite.com/web/productos_esp.php on line 121 what am I doing wrong? Thanks I got site wirch I like tu turn to multilanguage. Code: [Select] <?=$home_jezik?>This is my variable for language code. So I wonna add it to Code: [Select] <?php echo $redak['novost_naslov_hr']; ?>so that "hr" change to "en" or any other language. I try with this but nothing happens Code: [Select] <?php echo $redak['novost_naslov_.$home_jezik']; ?> |