Character Count
i need to know how to count the number of characters in a variable. E.g.
$a = "hello";
i want something to tell me how many letters are in $a.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Fopen Has Character Count
I'm using fopen and a textbox with text files. I'm getting a character count on the last line which I don't want. Is there something simple I don't know about? Or do I need to write a function to strip off the last few characters? example: http://www.wxsystems.com/catalog/cat7440cs.php3
Character Live Count
Is there a way to do a count as you type... so like this: Remaining characters left: 255. Then as you type a letter it'll go down to 254 but it has to be live and not refresh the page in anyway..the once it gets to 0 left itll put up a pop up message saying "you have reached max characters allowed" ?
The Character '
well i've made a form and when i type something with an ' in it like "it's" then i get an error like this: You have an error in your SQL syntax near 's a shiny day at line 2 the colum type is text.
Character Â
The character  shows up multiple times on my parsed strings. I tried to get rid of it with the following code without success. Is that character represented by anything else? Thanks $bad_chars = array(chr(194), 'Â'); str_replace($bad_chars, '', $parsed_string)
Help On Character Encoding
I have a string in windows-1256 character set. But i would like to change from this chracter set to utf-8. (actually it is for to display arabic text). I am using in my whole site utf-8. Any help highly appreciated.
Trouble With '>' Character
I'm trying to get the '>' in a string into a variable but it doesn't display and everything in front it of disappears. I've tried using '' to escape it but this has no effect. What a m I missing?
Mac Character Translation
I've got a problem with special Apple-Macintosh characters, and I want to translate them to the corresponding PC characters. I found the recode function on php.net, but although php version 4.2.1 is running on the server, the recode funktion does not work. Maybe the whole recode program is not compiled on the server or whatever. In an older post to this subject I found the suggestion to simply do an preg_replace for the Mac characters, what was also my first idea. THE PROBLEM is, that I don't know, how the Mac characters look like and (believe me, I searched quite a long time) I cannot find any list with the mac characters.
Character Conversion
building a site with a backend controlpanel that's made in flash and writes all info thru php scripts to the mysql database... Problem is that i get alot of funky character instead of the known special characters... Since i didn't immediately found how to fix this i wrote a function that goes pretty much like this:
Extracting First Character
I was wondering how would I extract the first letter or number of a string. Like if the string was "Goat Chesse" only extract the "G".
Using The $ Character In Query
Does anyone know a successful way to use the dollar sign character within a query and not generate an error? Here's what I'm trying to do... I have a query that successfully counts the number of records within a query as well as totalizes the dollar amount. What I'd like to do is show a dollar sign ahead of the 'amount' total when it queries back to the screen in my html document. Is there something I can use to null the normal relationship PHP has with the $ character where again, I can use it for text purposes?
Character Set Problem
I have a php app that works great on the development machine(s), but fails on the production server! Two problems. A comment field is entered including the £ symbol - the single character for sterling. The database should store that as £. The display as normal and a field content should also display it as £....
Character Conversion
I'd like to convert this kind of character : #48; into a human readable character : 0 I can't find the function that does this in the doc, so I used str_replace...
Unexpected Character
I am recieving the following error on one of my scripts... Warning: Unexpected character in input: '' (ASCII=92) state=1 in /home/penguinp/www/www/aphistory/admin/addbooster.php on line 16 Parse error: parse error in /home/penguinp/www/www/aphistory/admin/addbooster.php on line 16 here are lines 15-17... for ($i = 1; $i <= $noq; $i++) { fputs($pob,"<? $q$i = "" . ${"q".$i} . "";?>"); }
How To Get Rid Of Control M Character
I'm using PHP code to develop a www interface to let users edit text files stored on a Solaris UX server. Users are using Windows based WWW browser access this web site. Once they have selected the file they want to edit, it's presented in a text window (form) so thay can modify the file. The submit button passes the contents of the field to a variable and it is saved to disc. From the WWW interface everything seems OK, but when I look to the file, each line has a "^M" (control-M) at the end. This makes the files bigger and it can cause problem in a near future because these files have to be processed by shell scripts to populate a mySQL DB. Someone has seen that before and what was the solution.
GD And Chinese Character
I've been around trying to find a solution to write chinese characters on an image (png or jpg) with the GD support in PHP4 (and TTF support)...but still looking for!
Escape Character & And #
Does anyone know the escape character for & and # like in : Update GDO_INFO_ER set V_COMMENTAIRE='B&A' where V_USERMODIFICATION='bilal123' or Update GDO_INFO_ER set V_COMMENTAIRE='B#A' where V_USERMODIFICATION='bilal123' I would like to insert & and # literally in the table.
Everything After ' Character Is Not Displayed
I have been getting strange behaviour when using ' in by textboxes. eg inputting the following this is some test text ' and so is this is saved to the mysql database ok as this is some test text /' and so is this (with add slashes) or this is some test text ' and so is this (without add slashes) mysql field is VARCHAR(255) but when I retreive the data and display in textboxes on my web page, text area type (below) is ok <textarea class='BodyText' style='WIDTH: 85%' name="textarea"><?php echo $opta; ?></textarea> but input type (below) cuts everything off after the ' character. However this does not happen with other characters such as " or / <input type='text' class='BodyText' style='WIDTH: 85%' name='test' value='<?php echo $opta; ?>'> can anyone explain this behaviour and have a solution so that text with any ' characters in it is fully displayed?
Replace Character (UTF-8)
I apologize in advance if a similar question was already posted, but I didn't find it. Here is my problem: I would like to replace all the special characters ' ¾' with another special character 'ž' in a string (retreived by an SQL). After that I would like to update the field with the corrected string. The table and the field are correctly set to UTF-8. Is there a way? I have tried with the usage of functions such as 'str_replace', 'utf8_decode', 'utf8_encode' but without sucess.
Php And Character Sets
does anyone know if php supports any other character sets, particularly korean? i am having issues with php when trying to use korean with it. i'd appreciate someone's response regarding this matter.
Match Any Character But
Can I use any reg exp(mainly for mod rewrite) where I can match any character but a fixed list? I need to match a string that does not contain any /'s but I don't want to have to use a character search string. (I don't see any need to have to hardcode it) that is, .. matches any single charactr and (.*) matches any string what I want to do is use something like % that means ..%/ which means match any character but /. Of course it would need to be valid and I know I can't make up semantics for the reg ex. My point is is that, is that I don't want to have to use [a-z0-9-%&^$#@!etc...] to mean . but not /. Surely there is a way to exclude a few characters from . without having to increase the complexity of the expression 1000 fold? If you don't get that, then a simple example would be that I have an arbitrary string and I want to match only if that string does not contain an a. Sure I can so something like [bcdefghijklmnopqrstuv1234567890!@#$%^&*()_+]['/.,<>?:"{}+-=~`..........................] but surely reg exp has an easier way??? (again, this is specifically for mod rewrite)
PHP And Character Sets
I recently moved my site to a different server which seems to use UTF-8 instead of the normal ISO-8859-1 character encoding. Since my scripts and my data all use the old encoding, I would like to switch the server back to ISO. I know I can change the default_charset variable in the php.ini, but as far as I know that would only change the character set for output. What I need is a way to change the data in $_POST and $_GET to use ISO-8859-1 as well.
Getting Right Character-set From MySQL
I have created MySQL database on XP SP2 machine in cp1250 character-set, and loaded some data in the same character-set. When I read table using EMS MySQL Managet 3 Lite, I get croatian characters displayed correctly, but when I show this data in php page, I get '?' instead of croatian characters. I put <meta http-equiv="Content-Type" content="text/html;charset=windows-1250"> at the HEAD section of the page, and all text is displayed correcty, except those fetched from MySQL database.
PHP Character Classes
i'm quite new to php but i can do some of the basics like: initial and response pages and entering data into MySQL database, the problem is i got stuck when i was about to validate the form entries, i want to do it using ereg and eregi but i'm having a hard time looking for an in-depth reference for character classes and their brief descriptions and how to use them.
Echoing An '&' Character?
I'm trying to figure out how to include an '&' character in a php echo. I'm not looking for the html & a m p ; special character, but the actual character, since i'm trying to do this: Code: echo "<A HREF"/download.php?type=wallpaper&file=$filename">Download</A>"; instead it returns a link such as this: Code: /download.php?type=wallpaperfile=wallpaper.zip
Character Problem...
I have (for sofar) a small problem: I have a site, with mySQL-backend, and an online admin system. The site is in three languages: 1 of them is German. My poblem concerns the 'ß' (without quotes), and probably more characters. When an admin enters it in a textfield, and then writes it into the DB, i use mysql_real_escape_string() to prevent any mistakes. When an admin wants to edit the record with the 'ß' in it, it's displayed just right in the textfield, but when someone views it through a regular page, they see & # 9 4 6 ; (without spaces...). To display DB-contents in a page, i use htmlentities(stripslashes($string)). Where is the flaw?
Character Sets
Here I am writing my first php / mysql site, almost ready, and now this... charactersets.... The encoding that I use on my webpage is: <META HTTP-EQUIV="content-type" CONTENT="text/html; charset=UTF-8"> When people enter new data I use $newvalue = htmlentities($_POST["newvalue"], ENT_QUOTES) I then SQL this into my table and next I display the value e.g. <DIV CLASS="content">'.$newvalue.'</DIV> All of this works fine, BUT, funny characters that may have been entered through the form (e.g. Word-Style quotation marks, e-accent-grave, etc..) are taking on a whole new life. I put in an e with an accent and it changed into a chinese character. I tried to run $link = mysql_connect($host, $username, $password); $charset = mysql_character_set_name($link); printf ("character set is %s ", $charset); but that only gave me an error. I searched on google, but many of the notes are in other languages.... ;-) Does anyone have any hints in English?
Character Set Conversions
I have a PHP routine which parses my incoming emails and extracts certain key data from the body text. This works fine normally, but occasionally an email may contain the name and address of somebody in Europe, and when this happens the character set of the email changes from "us-ascii" to "ISO 8859-1" and this confuses my parsing code, because I get characters like =E4 and =E5 for some of the accented european characters in people's name or address, and where there would normally be a row of "equals" characters which is used as a separator line in the email, I get =3D=3D=3D etc. The data is being saved into a mySQL database, so I want the name and address to look correct when it is printed (ie the =E4 should be printed as the correct accented european character). I've looked into the various PHP functions to unencode strings etc, as my ideal plan would be to convert the incoming text strings before my parser examines them, but I'm confused about which function to use.
In The Opinion Of PHP, What Is A Character?
then log into their accounts and bring up an HTML form and copy and paste the essay and hit submit. Or perhaps they do this using WordPerfect. Or perhaps they use MacWrite. I output everything from my site as UTF-8. I'd like to check the input for characters that are not UTF-8 and then turn the bad ones to an ASCII question mark. I could loop through a string as if it was an array and test each character, but what does PHP think a character is? Does PHP understand what a multi-byte character is? Would this work? // the $string is a form input, possibly containing characters // written in any of the world's word processors $finalString = ""; for ($i=0; $i < strlen($string); $i++) { $char = $string[$i]; $encoding = mb_detect_encoding($char); if ($encoding != "UTF-8") { $char = "?"; } $finalString .= $char; } They offer this on www.php.net, in the comments, but, again, I'm not sure it would work on individual characters, and I'm about reading Regx. =========================== Much simpler UTF-8-ness checker using a regular expression created by the W3C: <?php // Returns true if $string is valid UTF-8 and false otherwise. function is_utf8($string) { // From http://w3.org/International/questio...orms-utf-8.html return preg_match('%^(?: [x09x0Ax0Dx20-x7E] # ASCII | [xC2-xDF][x80-xBF] # non-overlong 2-byte | xE0[xA0-xBF][x80-xBF] # excluding overlongs | [xE1-xECxEExEF][x80-xBF]{2} # straight 3-byte | xED[x80-x9F][x80-xBF] # excluding surrogates | xF0[x90-xBF][x80-xBF]{2} # planes 1-3 | [xF1-xF3][x80-xBF]{3} # planes 4-15 | xF4[x80-x8F][x80-xBF]{2} # plane 16 )*$%xs', $string); } // function is_utf8 ?>
PHP And Character Sets
I recently moved my site to a different server which seems to use UTF-8 instead of the normal ISO-8859-1 character encoding. Since my scripts and my data all use the old encoding, I would like to switch the server back to ISO. I know I can change the default_charset variable in the php.ini, but as far as I know that would only change the character set for output. What I need is a way to change the data in $_POST and $_GET to use ISO-8859-1 as well.
Character Encoding In PHP & GD2?
I have been working on a dynamic image in GD2 which acts as a chatbox in a forum signature. It all seems to be working pretty well, but I have come across a bug (of sorts): if the user were to enter characters such as '¬_¬' the result in the image is shown as 'Ž_Ž'. Is there any way that, using PHP, I can change this so that is actually understands the characters and would print '¬_¬'.?
Return Utf-8 Character Value?
I need to get the numeric value of a utf-8 character. Is there a way to do that with php? I have had no luck thus far.
Character Replacement
I am trying to get a DESCRIPTION for my RSS feed but there are too many special characters in the description for it to display properly. Is there any code that will replace everything?? I have tried:::: htmlentities() addslashes() htmlspecialchars() The problem is there are way too many special characters in my description to just replace each one of them... And not one of the above will do the job.... Stuff like:: ¼ — ö and a lot more.... I would just replace the ones I find as I go.. but that won't stop future descriptions from having more characters that I did not account for making my RSS feed messed up. Should I combine them all...?? htmlentities(htmlspecialchars(DESCRIPTION)); Or something like that...
Get Last Character In String?
I need a quick effective way to get the last character in a string. Maybe a character count of the string and then somehow getting the last character... Yeah, i don't know. It's probably really simple but i don't know my PHP functions well.
Escape Character
I dont know why the browser doesn't present the php string with some escape character like , .... For example: the string "Name Address" should be printed out like Name Address instead it prints out "Name Address".I tried other ones and do not work. Anyone know why?
Return Character
I'm collecting user input from a <textarea> element, saving it in a database, and displaying it later. How do I preserve line returns that the user types so that they'll display later?
Character Replacement
I have a users table which includes username, password, and permission level. In the admin screen of the website I would like to display a table of all the users, but don't want to display the passwords on that table ... instead I'd like to just display *s for each character. So if the password was "fish", the table cell would read ****, if the password was phish, the table cell would read *****, etc. I already know about the strlen() function which can tell me the length of the password string, but what do I use to tell php to "say" * once for each character in the string?
Special Character
I am storing data by a form and save it to the mysql database and displaying it. But ', " this type of special characters how to display?
Replace Character
I would like all '_' in a string to be replaced with a space, how do I do this? Basically the variable is $row_featured['address2'] and there are values such as 'rhos_on_sea' assigned to it, and when I echo it I want to echo it as 'rhos on sea' instead.
Character Encoding
I'm working on a site for my brothers friend and it has a commentary system. The commentaries get added by calling a Javascript which updates the current page and then call a PHP script to store the comment in a mySQL database. My problem is at if the user uses any kind of special chars like the danish chars: æ, ø and å then the PHP script will just die on them. It will store the message until the chars and then stop. I've tried running an escape () in the javascript on the txt i'm sending, and i've tried using CONVERT ('string' USING utf8) in the SQL query. The entire site is encoded in UTF-8, and so is the database but the user might type in ISO-8859-1 (?). Somewhere else on the site i have a fileupload, here the page calls the upload script directly and it has no problems storing special chars in the database, so i'm thinking the problem might be a combination of the Javascript and PHP. I'm hoping someone has an idea to what might be wrong. Code:
Count()
I am getting an error message if I add another field in the Select statement beside Count().
Count Down
I want to display a countdown timer. For this i used frames, the top frame contains the time and the bottom frame contains the questions, the top frame refreshes (autorefresh every second), After reaching the target time, a new page has to be loaded (redirect to a new page, which contains the message test time is over). How to do this? The below code is not redirecting to the timeover page frame.php ....
How To Count Age?
How can I count the difference between two dates? ( I can't change them into Unix format using mktime(), because in my database are also people born before 1970). Are there any alternative functions?
Count & Max
I need to count the rows in a mysql table and to find the max value of a column. I am selecting count and max with mysql queries, but fail getting the results from my php code. For counting the rows I also tried mysql_fetch_array and then counting the rows in the array, but it didn't work either. Does someone know how to retreive the results of count() and max()?
PHP COUNT( )
the code pasted below works perfectly... however if i attempt to change the select to COUNT(id) and also change the echo line down below, I get errors ... Any ideas about how to modify the code for it to perform the count() function properly? Code:
Count Down
I want to display countdown timer in H:m:s format. for this i am using frames, top frame contains the timer, (autorefresh and the time is updated), in the bellow frame, test qustions are there. On reaching the target time, i want to redirect the whole page to a new page or (which contains the message the time is over). How to do this? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859- 1"> </head> <frameset rows="80,*" frameborder="NO" border="0" framespacing="0"> <frame src="head.php" name="topFrame" scrolling="NO" noresize > <frame src="body.php" name="mainFrame"> </frameset> <noframes><body> </body></noframes> </html> ?> ...........
Count
how to count the same data in field?
How To Count Max In SQL?
Maybe this isn't the most apropriate place to ask mysql related question, but I think it is close enought to most php users and I always got find answers on this group. well, I need to count how meny rows have some maximum number. here is exact situation (striped down table) (pictID, jpeg name, #of votes) pict1, name1.jpg, 4 pict2, name2.jpg, 22 pict3, name3.jpg, 5 .... pict7, name7.jpg, 8 pict8, name8.jpg, 22 pict9, name9.jpg, 9 so, I need query (or set of querys) which will give me back rows 2 and 8 (I know, rows 1 and 7, but for easyer description, please let forget for moment that first is 0) I know what to do if I have only one picture with maximum votes: SELECT * FROM picts ORDER BY votes DESC LIMIT 1 (maybe not the best solution, but is working). now, I wanted to count how meny rows have MAX of votes, but I was unable to do that with my knowlage... SELECT max(votes)... and than $TotalMax=mysql_num_rows($result); in any combination (list), (while(list(too(much...) only failures... at the end I wanted to do SELECT with LIMIT so I can drow only those wining pictures: $query1 = "THAT one I don't KNOW"; $result1 = mysql_query ($query1) or die ("Query failed..."); list($new_limit) = mysql_num_rows($result1); //and now: $query2 = "SELECT * FROM picts ORDER BY votes DESC LIMIT $new_limit"; $result2 = mysql_query ($query2) or die ("Query failed..."); list($pict_data1,$pict_data2,$pict_data3) = mysql_fetch_array($result2); can anyone help me with that 1st query? or anyone have easyer solution? oh yes, I can not tell how meny pictures will have maximum number of votes. so far (in 4 years of manual handling of my site) there vere only 3 moments with 2 pictures sharing wining position, never more... normaly just one.
|