PHP - Php Gettext Doesn't Translate Correct: Only One Character Shown
I'm trying to translate a website using PHP gettext. However, it doesn't work. I added Italian translations, but I only see one character instead of the translation. The single character is not the first character in the string. I add this to every page:
Code: [Select] putenv('LC_ALL=it_IT'); setlocale(LC_ALL, 'it_IT'); bindtextdomain('messages', './locale'); textdomain('messages'); I define every string using: $string = _('string'); In my locale folder I have the following folder structu it_IT > LC_MESSAGES > messages.mo/messages.po. I've tried a lot of things, but I can't get it to work. What am I doing wrong? Can anyone help me? Similar TutorialsHi, I have looked through the forum for a fix for this but I was unable to find one. Basically the code I have provided below is not giving me the correct output in other words changing the text to German. I am using an "Ubuntu" environment with Apache2 and php5 installed. I have checked that php-gettext is installed. I have also attached my .mo file (I have added the .txt extension to upload here) local.php <?php $locale = false; if (isSet($_GET["locale"])){ $locale = $_GET["locale"]; setcookie("locale", $locale, time()+60*60*24*30, "/");// save a cookie } if (!$locale && isSet($_COOKIE["locale"])){ $locale = $_COOKIE["locale"]; } putenv("LC_ALL=$locale");//needed on some systems putenv("LANGUAGE=$locale");//needed on some systems setlocale(LC_ALL, $locale); bindtextdomain("messages", $_SERVER["DOCUMENT_ROOT"]."locale"); bind_textdomain_codeset("messages", "UTF-8"); textdomain("messages"); ?> test.php <?php require_once "local.php"; echo $_SERVER["DOCUMENT_ROOT"]."locale"; //for testing ?> <html><head></head> <body> <a href='?locale=en_US'>English</a> | <a href='?locale=es_ES'>Spanish</a> | <a href='?locale=de_DE'>German</a> <br> <?php echo _("Hello World!");?><br> <p><?php echo _("My name is");?> Bob.</p> </body> </html> Hello all, i'm attempting to implement i18n into my project. so I read some tutorials, copied some code and eventually made the following: Code: [Select] /** * applyMultiLingual uses the gettext module from PHP to support multilingual * @param Array $settings */ private static function applyMultiLingual($settings){ /* init global config */ bindtextdomain(self::$project_name,Config::path('i18n')); bind_textdomain_codeset(self::$project_name, 'UTF-8'); textdomain(self::$project_name); if(!array_key_exists('enabled', $settings) || $settings['enabled'] == false){ //initiate default (english) putenv("LC_MESSAGES=en_EN"); setlocale(LC_MESSAGES,'en_EN'); } else{ if(Session::language() === null){ //initiate custom if($settings['default'] == 'auto'){ locale::acceptFromHttp($header); } else{ putenv("LC_MESSAGES=".$settings['default']);setlocale(LC_MESSAGES,$settings['default']); } } else{ putenv("LC_MESSAGES=".Session::language()); setlocale(LC_MESSAGES,Session::language()); } } } The code is (imo) pretty readable, so it sets the textdomain to "project1", and the current language to en_EN. if should search for the translations in DOC_ROOT/i18n/ now, it returns the text between the _(); functions, but I get no translation files in said directory, and I also have no clue how to accomplish this. so what I want to accomplish is this: enable use of function _(), which saves all translations in a folder i18n, and subfolder LOCALE_CODE (ex. DOC_ROOT/i18n/en_EN/messages.po). what am I doing wrong, and how can I fix it? thanks to any who can help, and if more info is needed, ask and you shall receive. Hello folks,
So, trying to create a multilingual website using gettext. Now, just the simplest examples doesn't seem to work for me. I've loaded gettext.so in my php.ini (see http://corbeauperdu.ddns.net/phpinfo.php) and created a PO / MO pair with POEdit. My MO/PO file reads: msgid "" msgstr "" "Project-Id-Version: Prestadesk\n" "POT-Creation-Date: 2020-03-26 21:08+0100\n" "PO-Revision-Date: 2020-03-27 07:59+0100\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: Poedit 2.3\n" "X-Poedit-Basepath: ../../../..\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n" "X-Poedit-SourceCharset: UTF-8\n" "Last-Translator: \n" "Language: fr\n" "X-Poedit-SearchPath-0: .\n" #: templates/prestadesk_dashboard.php:41 #, php-format msgid "Welcome, %s!" msgstr "Bienvenu, %s!" #: templates/prestadesk_dashboard.php:42 msgid "This page will show the dashboard" msgstr "Cette page affichera le tableau de bord" It's located under <DOC_ROOT>/prestadesk/include/locales/fr/LC_MESSAGES/prestadesk.po
And I've got this very simple php test page under <DOC_ROOT>/prestadesk/templates/prestadesk_dashboard.php <?php $lang='fr'; $domain = 'prestadesk'; $codeset = 'UTF-8'; $locales_dir = '../include/locales'; // need to go up on directory from here to get into the include/locales // here we define the global system locale given the found language putenv('LANG='.$lang); // this might be useful for date functions (LC_TIME) or money formatting (LC_MONETARY), for instance setlocale(LC_ALL, $lang); // this will make Gettext look for $locales_dir/<lang>/LC_MESSAGES/prestadesk.mo bindtextdomain($domain, $locales_dir); // indicates in what encoding the file should be read bind_textdomain_codeset($domain, $codeset); // here we indicate the default domain the gettext() calls will respond to textdomain($domain); // test translate echo gettext("This page will show the dashboard"); ?>
Nothing happens. No translation, no errors... I just see the message in English Any ideas for me ? Thanks a bunch! Edited March 27, 2020 by PatRoy Hi, is there any way when using gettext to change the default folder? I mean, gettext read mo files from xx_XX/LC_MESSAGES/domain.mo but isn't friendly... is there any way to change it to another path like langs/xx_XX.mo? Hello again, So, after messing around with gettext, and having found the solution to my previous post (https://forums.phpfreaks.com/topic/310383-gettext-for-multilangual-not-working-for-me/), I've come to the conclusion that I need to use something else than gettext in order to make my site multilingual.
Problem I have with gettext is that I absolutely need to have my desired languages (i.e. fr_FR, nl_NL, etc) installed on my server's system (in my case, a NAS for now). I can see which locales I have on my server with 'locale -a'. I am in no way able to install new locales on my NAS. It's too limited... too much locked down. So, I'm looking for an alternative to gettext. Any suggestions for me perhaps ? Thanks for any advice. Pat
I am using PHP 5.5 on windows 8 and I am trying to localize my website to multiple languages while everything is OK on remote host , the gettext function does not work correctly in my localhost. I have implemented the whole tutorial of http://www.sitepoint...applications-1/ step by step but it seems setlocale(LC_ALL, "en_US") fails and I don't know how to correct or install "en_US" in my system. when I use "en-US" instead of "en_US" the sellocale function does not return FALSE but again the gettext function return the original string.
It's pretty simple to see what I am trying to do here. For some reason all results in the table are the same exact cityName replacing all existing records. The echoed results are correct. I've include a small dump of my table as well. $query = "SELECT cityName FROM sys_city_dev_2"; $resource = mysqli_query($cxn, $query) or die("MySQL error: " . mysqli_error($cxn) . "<hr>\nQuery: $query"); while($result = mysqli_fetch_assoc($resource)) { $nox = $result['cityName']; $toUpper = ucfirst($nox); echo "$toUpper" . "<br />"; $setString = "UPDATE sys_city_dev_2 SET cityName = '" . $toUpper ."' WHERE cityName != ''"; mysqli_query($cxn,$setString); } 100 Records of table dump (pre running my script above): -- -- Table structure for table `sys_city_dev_2_backup` -- CREATE TABLE IF NOT EXISTS `sys_city_dev_2_backup` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Mid` int(11) NOT NULL DEFAULT '0', `cityName` varchar(30) NOT NULL DEFAULT '', `forder` int(4) NOT NULL DEFAULT '0', `disdplay` int(4) NOT NULL DEFAULT '0', `cid` int(11) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=113970 ; -- -- Dumping data for table `sys_city_dev_2_backup` -- INSERT INTO `sys_city_dev_2_backup` (`ID`, `Mid`, `cityName`, `forder`, `disdplay`, `cid`) VALUES (84010, 1, 'dothan', 0, 0, 0), (84011, 1, 'alabaster', 0, 0, 0), (84012, 1, 'birmingham', 0, 0, 0), (84013, 2, 'flagstaff', 0, 0, 0), (84014, 1, 'auburn', 0, 0, 0), (84015, 1, 'florence', 0, 0, 0), (84016, 1, 'gadsden', 0, 0, 0), (84017, 1, 'huntsville', 0, 0, 0), (84018, 1, 'mobile', 0, 0, 0), (84019, 1, 'montgomery', 0, 0, 0), (84020, 1, 'tuscaloosa', 0, 0, 0), (84021, 2, 'mohave valley', 0, 0, 0), (84022, 2, 'phoenix', 0, 0, 0), (84023, 2, 'prescott', 0, 0, 0), (84024, 2, 'sierra vista', 0, 0, 0), (84025, 2, 'tucson', 0, 0, 0), (84026, 2, 'yuma', 0, 0, 0), (84027, 3, 'bakersfield', 0, 0, 0), (84028, 3, 'chico', 0, 0, 0), (84029, 3, 'fresno / madera', 0, 0, 0), (84030, 3, 'gold country', 0, 0, 0), (84031, 3, 'humboldt county', 0, 0, 0), (84032, 3, 'imperial', 0, 0, 0), (84033, 3, 'inland empire', 0, 0, 0), (84034, 3, 'los angeles', 0, 0, 0), (84035, 3, 'alhambra', 0, 0, 0), (84036, 3, 'merced', 0, 0, 0), (84037, 49, 'fayetteville', 0, 0, 0), (84038, 49, 'fort smith', 0, 0, 0), (84039, 49, 'jonesboro', 0, 0, 0), (84040, 49, 'little rock', 0, 0, 0), (84041, 49, 'arkadelphia', 0, 0, 0), (84042, 49, 'texarkana', 0, 0, 0), (84043, 3, 'modesto', 0, 0, 0), (84044, 3, 'alta sierra', 0, 0, 0), (84045, 3, 'alpine', 0, 0, 0), (84046, 3, 'pedley', 0, 0, 0), (84047, 3, 'redding', 0, 0, 0), (84048, 3, 'alondra park', 0, 0, 0), (84049, 3, 'sacramento', 0, 0, 0), (84050, 4, 'canon city', 0, 0, 0), (84051, 3, 'san luis obispo', 0, 0, 0), (84052, 3, 'santa barbara', 0, 0, 0), (84053, 3, 'stockton', 0, 0, 0), (84054, 3, 'aliso viejo', 0, 0, 0), (84055, 3, 'visalia', 0, 0, 0), (84056, 3, 'yuba city', 0, 0, 0), (84057, 4, 'boulder', 0, 0, 0), (84058, 4, 'colorado springs', 0, 0, 0), (84059, 4, 'denver', 0, 0, 0), (84060, 4, 'applewood', 0, 0, 0), (84061, 4, 'pueblo', 0, 0, 0), (84062, 4, 'air force academy', 0, 0, 0), (84063, 5, 'avon', 0, 0, 0), (84064, 5, 'hartford', 0, 0, 0), (84065, 5, 'new haven', 0, 0, 0), (84066, 5, 'ansonia', 0, 0, 0), (84067, 5, 'fairfield', 0, 0, 0), (84068, 7, 'daytona beach', 0, 0, 0), (84069, 7, 'sebastian', 0, 0, 0), (84070, 5, 'wallingford center', 0, 0, 0), (84071, 8, 'belvedere park', 0, 0, 0), (84072, 7, 'sarasota springs', 0, 0, 0), (84073, 7, 'sandalfoot cove', 0, 0, 0), (84074, 7, 'san carlos park', 0, 0, 0), (84075, 7, 'st. augustine', 0, 0, 0), (84076, 7, 'tallahassee', 0, 0, 0), (84077, 7, 'safety harbor', 0, 0, 0), (84078, 7, 'ruskin', 0, 0, 0), (84079, 8, 'athens-clarke county', 0, 0, 0), (84080, 8, 'atlanta', 0, 0, 0), (84081, 8, 'augusta-richmond county', 0, 0, 0), (84082, 8, 'brunswick', 0, 0, 0), (84083, 8, 'columbus', 0, 0, 0), (84084, 8, 'americus', 0, 0, 0), (84085, 8, 'acworth', 0, 0, 0), (84086, 8, 'valdosta', 0, 0, 0), (84087, 10, 'boise', 0, 0, 0), (84088, 10, 'ammon', 0, 0, 0), (84089, 10, 'moscow', 0, 0, 0), (84090, 10, 'blackfoot', 0, 0, 0), (84091, 10, 'twin falls', 0, 0, 0), (84092, 10, 'meridian', 0, 0, 0), (84093, 10, 'jerome', 0, 0, 0), (84094, 10, 'idaho falls', 0, 0, 0), (84095, 11, 'addison', 0, 0, 0), (84096, 10, 'garden city', 0, 0, 0), (84097, 10, 'eagle', 0, 0, 0), (84098, 10, 'chubbuck', 0, 0, 0), (84099, 10, 'caldwell', 0, 0, 0), (84100, 12, 'bloomington', 0, 0, 0), (84101, 12, 'evansville', 0, 0, 0), (84102, 12, 'fort wayne', 0, 0, 0), (84103, 12, 'indianapolis', 0, 0, 0), (84104, 12, 'muncie / anderson', 0, 0, 0), (84105, 12, 'lafayette / west lafayette', 0, 0, 0), (84106, 12, 'south bend / michiana', 0, 0, 0), (84107, 12, 'terre haute', 0, 0, 0), (84108, 12, 'northwest indiana', 0, 0, 0), (84109, 13, 'ames', 0, 0, 0); If I hypoteticly have a website that only contains one word.. eh.. "Hello World". So.. my question is would I be able to translate this into other languages using.. the Google translate API for an example? So basicly I want to do is: Detect what country you're from (probably trought IP), translate the words "Hello World" to whatever language you're in. Is there any translate API's that does this? I don't really care about if it's going to be right spelled etc. I only have single words I want to translate! It would be really awesome! If not.. oh.. ! Ok I am a student and my instructor keeps giving us projects dealing with PHP coding even though only half our class has had a PHP server side scripting class. The project he just gave us I thought would be simple, but I'm still struggling to find online the proper scripting to get my php file to do what I need it to do. Requirements : Create a simple html page that contains a text area with a submit buton - DONE The submit button will call a php page and display the text typed in the text area - DONE Allow users to enter XML script into the text area and when submit button is clicked the php page will display the XML without the XML tags, Example - Text Area Entry Would Look Like - Code: [Select] <fname>James</fname><lname>Mays</lname> Output Would Look Like - James Mays This is the part I'm struggling with, I don't know how to tell the php to not display the XML tags - NOT DONE If this helps here is what code I do have, HTML Page Code: [Select] <!DOCTYPE HTML> <html> <head> </head> <body> <form action="test.php" method="post"> <p>Text Area:</p> <textarea name="xmltags" rows="10" cols="40"></textarea></p> <p><input type="submit" value="Submit"></p> </form> </div> </div> </body> </html>PHP Code Code: [Select] <html> <body> Text Output: <?php echo $_POST["xmltags"]; ?>!<br /> </body> </html> Thank You for any and all help Please translate: $req_user = trim($_GET['user']); if(!$req_user || strlen($req_user) == 0 || !eregi("^([0-9a-z])+$", $req_user) || !$database->usernameTaken($req_user)){ die("Username not registered"); $req_user_info = $database->getUserInfo($req_user); Thanks hi, i looking for a best way to translate a backoffice content. options: A- i can use a separate file each for a lang with all vars. B- use a table with all data both of this solutions have a big time to implement and in all areas that i creat i need add the vars. there is some best solution for this? something that can translate all content like google translator? thanks for your help translate my code please; javascript to php. very very very very thanks. <form> <input type="checkbox" name="myfilter" value="+abst">Amytag1 <input type="checkbox" name="myfilter" value="+mini">Amytag8 <input type="checkbox" name="myfilter" value="+popa">Amytag9 <input type="checkbox" name="myfilter" value="+impr">Amytag13 <input type="checkbox" name="myfilter" value="+green">Amytag15 <input type="checkbox" name="myfilter" value="+gh5">Amytag18 <input type="checkbox" name="myfilter" value="+gh4">Amytag19 <input type="checkbox" name="myfilter" value="+gh3">Amytag34 <input id="search1" placeholder="Word Search..." value=""> <input id="year1" placeholder="Year" value=""> <input id="month1" placeholder="Month" value=""> <input id="day1" placeholder="Day" value=""> <input id="mymenu" value=""> </form> <button onclick="myFunction()" class="Sbutton">search it</button> <script> function myFunction() { var myfilter = document.forms[0]; var txt = ""; var i; for (i = 0; i < myfilter.length; i++) { if (myfilter[i].checked) { txt = txt + myfilter[i].value; } var year = "&year=" + document.getElementById("year1").value; var month = "&month=" + document.getElementById("month1").value; var day = "&day=" + document.getElementById("day1").value; var search = "&s=" + document.getElementById("search1").value; var tag = "/?tag=" + document.getElementById("mymenu").value; } var zzz = "http://test.com/category/art" + txt + tag + year + month + day + search; window.location.assign(zzz) } </script>
and please, not use this way: header("Location: {$target}"); exit; Because it doesn't work on my site (for some reason). p.s: I have a lot of checkbox. Edited May 4, 2020 by ldonopI've signed up for Google's translating service and I'm able to get results, however, it's wrapped around some information. Here's an example: Code: [Select] //Content to translate - Spanish for 'Hello World' $content = urlencode("Hola Mundo"); $translate = file_get_contents("https://www.googleapis.com/language/translate/v2?key=MyKey&q=$content&source=es&target=en"); echo $translate; The code returns { "data": { "translations": [ { "translatedText": "Hello World" } ] } } All I want is the result Hello World I tried using str_replace but it does not work through file_get_contents. The Google Translate does not provide any information on how to do this. Does anyone have any ideas? i have this in a form Code: [Select] <textarea id='textarea' name='tweet' maxlength=140 > <?php if(isset($_SESSION['description'])) { echo $_SESSION['description'];} ?> </textarea> the session variable is just their input and i use that to repopulate the form if the validation script catches an error with their input. The problem is when the user enters carriage returns and then if theirs an error.... this... "blah blah blah" turns into this... "blah blah\r\n\r\nblah" how do i remove that junk? I have a comment form in which the users type thier comment in english.Those pcomments should appear in the native laguage other than english in my website.Is there any php code to do this.i dont have any idea of creating a site other than english. This script is supposed to run in the command line. Like the title says, I need to: Import some columns (input the names with an argument) from a .CSV file Split the column into blocks of 500 lines Translate this pieces Put them back into the original file I already have some code but it is unfinished and not working: <?php //name of the .CSV file $filename = $argv[1]; //name of the column to be translated $header_name = $argv[2]; //open file $file_handle = fopen($filename, "r"); $i=0; $j=0; $counter = 0; $translated = ''; $string = ''; while (!feof($file_handle) ) { $counter++; $line_of_text = fgetcsv($file_handle, 1024); //find the column id that contains the header name. // headers are always on the the first line if ( $counter == 1 ){ while ($line_of_text[$i] != $header_name) $i++; $header_id = $i; } //create the blocks $string .= $line_of_text[$i]; if ($counter % 500 == 0) { $gt = new GoogleTranslateWrapper(); $translated .= $gt->translate($string, "en"); } } //Write the translate column in the same .CSV file fclose($file_handle); ?> Any help in rewriting this to work? Hello all , I am facing a problem when trying to to show image files generated from php code in IE8 . it is working fine on firefox and IE9 . but in IE8 its showing the famous red X instead of the image ; belw is the code: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html dir="RTL" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:v="urn:schemas-microsoft-com:vml" lang="en-us" > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <head> <title>header </title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <?php mb_internal_encoding('UTF-8'); /** * @author IT Department * @copyright 2011 */ INCLUDE ("header.php"); INCLUDE ("connect.php"); if (isset($_GET['id'])) { $ID=$_GET['id']; $sql="select employees.USER_ID, employees.NAME_ARAB, employees.NAME_ENG, employees.TITLE_ARAB, employees.TITLE_ENG, department.DEP_NAME_ENG, department.DEP_NAME_ARAB, location.LOC_DESC_ENG, location.LOC_DESC_ARAB, employees.MOBILE, employees.EMAIL, employees.DEP, employees.LOC FROM employees,location,department WHERE employees.DEP=department.DEP_ID AND employees.LOC=location.LOC_ID and employees.USER_ID=$ID "; //echo $sql; $result=mysql_query($sql,$link); mysql_query("SET NAMES 'utf8'"); ECHO '<html DIR="RTL">'; echo "<table width=100% border='1' cellpadding='8' align='center' bgcolor='white'>"; while ($row = mysql_fetch_array($result, MYSQL_NUM)) { //$row = mysql_fetch_assoc($result); echo"<tr align='center'>"; echo"<td>"; ECHO " الرقم الوظيفي :"; echo"</td>"; echo"<td colspan='2'>"; ECHO "<strong>$row[0]</strong>"; echo"</td>"; echo"<td>"; ECHO " : User ID "; echo"</td>"; echo"<td rowspan='7'>"; ECHO "<img src='IMAGE.php?id=".$row[0]."' width='225' height='300'/>"; //the image echo"</td>"; echo "</tr>"; the php image file is : Code: [Select] <?php INCLUDE ("connect.php"); $ID = "'".$_GET['id']."'"; $sql="SELECT PHOTO FROM employees WHERE USER_ID=$ID"; $result=mysql_query($sql,$link); $row = mysql_fetch_array($result); header("Content-type: image/pjpeg"); print ( $row[0]); ?> Thanks in advance for your help Here is the User profile search form... when i search that all details comes without Employee's Photo.. What's the error ? Code: [Select] </head> <body> <?php $uname = $_POST['uname']; $sql = "SELECT * FROM emp WHERE uname = '$uname'"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { while ($row = mysql_fetch_array($result)) { $fname = $row['fname']; $lname = $row['lname']; $email = $row['email']; $address = $row['address_1']; $address2= $row['address_2']; $address3= $row['address_3']; $image = $row['image']; $gender=$row['gender']; $mobile=$row['tp_mobile']; $land=$row['tp_lnd']; $bod=$row['bod']; } } ?> <div class="main"> <div class="header"> <div class="header_resize"> <div class="logo"><h1></h1></div> <div class="clr"></div> <div class="search"> <form id="form1" name="form1" method="post" action="emp_profile.php"> <span> <input name="uname" type="text" class="keywords" id="textfield" maxlength="50" /> </span> <input name="image" type="image" src="images/search.gif" class="button" /> </form> </div> <div class="menu"> <ul> <!-- <li><a href="index.html" class="active">Home</a></li> <li><a href="services.html">Services</a></li> <li><a href="about.html"> About Us </a></li> <li><a href="contact.html"> Contact Us</a></li> --> </ul> </div> </div> <div class="clr"></div> </div> <div class="clr"></div> <div class="body"> <div class="body_resize"> <form id="" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data" accept-charset='UTF-8'> <div id="container"> <fieldset > <div id="content-container1"> <div id="content-container2"> <div id="section-navigation"> <img align="top" width="175" height="200" src="emp_images/<?php echo $image; ?>"/> <div> <!-- <label>Patient Name : </label> --> <br /> </div> </div> <div id="content" align="justify"> <h2> <label for="fname"> <?php echo $fname; ?></label> <label for="lname"> <?php echo $lname; ?></label> </h2> <p> <label><b>Email:</b></label> <br /> <label for="email"> <?php echo $email; ?></label> </p> <p> <label><b>Employee Address:</b></label> <br /> <label > <?php echo $address; ?></label> </p> <p> <label><b>Employee Address 2:</b></label> <br /> <label > <?php echo $address2; ?></label> <p> <label><b>Employee Address 3:</b></label> <br /> <label > <?php echo $address3; ?></label> <p> <label><b>Gender:</b></label> <br /> <label > <?php echo $gender ?></label> </p> <p> <label><b>Employees Mobile:</b></label> <br /> <label > <?php echo $mobile ?></label> </p> <p> <label><b>Employees Resident Number:</b></label> <br /> <label > <?php echo $land ?></label> </p> <p> <label><b>Date of Birth:</b></label> <br /> <label > <?php echo $bod ?></label> </p> </div> </div> </fieldset> <div class="clr"></div> </div> </div> </form> <div class="footer"> <div class="footer_resize"> <p>© P2011-001</p> </div> <div class="clr"></div> </div> </div> </div> </div> </body> </html> <?php mysql_close($con); ?> hi, i have the code below where it shows the images in connection with a reference. in my img table i only have two rows but the code below keeps showing it 7 times can you please help me? <table width=200> <div id="wrapper"> <!-- Content area --> <div id="content"> <!-- We will be working inside these tags --> <div id="gallery"> <?php $images=mysql_query("SELECT img.id, img.refimage, img.image, img.thumb, users.users_id FROM img, users WHERE img.refimage='$ref' AND users_id='$user_id'"); echo '<table width="40">'; while($row = mysql_fetch_array($images)) { $image=$row['image']; $thumb=$row['thumb']; echo '<div class="image_container">'; echo "<a href='$image' rel='lightbox[roadtrip]'><img src= '$thumb' width='60' height='40' alt='$title'>"; echo '</a></div>'; } ?> </div> <!-- We will be working inside these tags --> </div> </div> </table></td> So. I'm using this code right he <?php $imagepath = "css/images/statspage.jpg"; $image = imagecreatefromjpeg($imagepath); $imgheight = imagesy($image); $color = imagecolorallocate($image, 255, 255, 255); imagestring($image, 5, 70, $imgheight-50, "This is a test", $color); header('Content-Type: image/jpeg'); imagejpeg($image); ?> It works like it should. Now my problem is, is that the image is being displayed at a very low quality! Here's the original image: Here's the image with the code above: RIGHT away you can tell the HUGE difference. I'm not sure what I'm doing wrong. Maybe i need a higher res image? If y'all guys know a different method THAT also achieves the same thing I'm trying to do. Please let me know ASAP! |