Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





How To Use Htmlspecialchars With Foreign Language?


I am building a website which uses other charset, not the standard ASCII code. (A foreign language website). It allows users to fill up a form.

Normally we would use htmlspecialchars to prevent potential harmful codes. But doing so will make my website not displaying the text correctly. Anyone has a solution to this?




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Htmlspecialchars?
I am storing some common html tags like the bold tag and a href tag in a database. I am having no problems there. However I am using this code to extract the first 150 characters out of the Database.

$txtNewsDetails = preg_replace('/(?<=^.{150}).+$/s', '...', $txtNewsDetails);

And that works great as well. However, say the last character of the 150 characters is text in between the href tag. The href tag does not get closed off and the script does not work properly. I'm seeking suggestions on how to display 150 characters of long text stored in a database as well as make sure the all html characters get closed off at the same time as the extraction.

View Replies !   View Related
Htmlspecialchars
I'm using WAMP, XAMPP is set up (localhost). Say we use this example:

<?php
$new = htmlspecialchars("<a href='test'>Test</a>");
echo $new;
?>

for some reason, the code outputs: <a href='test'>Test</a>

I looked on php.net, and tried their example; still didn't work. Has anyone had this problem? Anyone any ideas?

View Replies !   View Related
Htmlspecialchars()
I'm trying to execute this code it's straight out of the PHP manual:

$new = htmlspecialchars("<a href='test'>Test</a>", ENT_QUOTES);
echo $new;

This outputs:

<a href='test'>Test</a>

View Replies !   View Related
Htmlspecialchars Like Magic_quotes?
I've got magic_quotes turned on in my php configuration so that I don't have to addslashes or anything like that to my form inputs. I still have to use htmlspecialchars() to get rid of any html tags tho - anyone know if there is a setting in php.ini that would do this automatically like magic_quotes? Magic_html - that would truly be magic.

View Replies !   View Related
Htmlspecialchars And Htmlentities
what's the difference between these two functions and when each should be used. PS: I read the manual but I'm still not sure.

View Replies !   View Related
Htmlspecialchars() Won't Convert
I can't get htmlspecialchars() to do it's conversion - eg it won't convert -&- to -& amp;-
Does anyone know what could be happening? Code:

View Replies !   View Related
Htmlspecialchars() Problem
Running php 4.3.6 on winxp machine
I have following code:
-----------------------------------------------------------------------
Restaurants <select size=&#391;' name='restaurants'>
<?
while ( $row = mysql_fetch_array($restaurant)){
$opt = "<option value = '" . $row["title"] . "'>" .
$row["title"]
. "</option>";
$opt = htmlspecialchars($opt, ENT_QUOTES);
echo "$opt";
}
echo"</select>";

echo "$opt";
------------------------------------------------------------------

View Replies !   View Related
And MySql - Use Htmlspecialchars()
I have a bit of a problem with MySQL and PHP working together. More
specifically when i use htmlspecialchars() to encode my text then load
it into the database, it is interpreting the special characters and
decoding them.

Is there any way that I can perserve this coding and make sure it says
in my database?

Example:

Here is what is entered -- t%20t
Here is what is showing in the database now -- t t
here is what I would like to see -- t%20t

View Replies !   View Related
Slipslashes Or Htmlspecialchars??
I wrote a script to update my news article. However, when I go to edit the title and news, if a ' exist, then the update fails. I know from previous work, that either slipslashes or htmlspecialchars should do the trick, I am just not sure which one, or where to put them.

Would anyone be able to point me in the right direction of where I should include these statements... or if you have an alternative fix, please post.

Keep in mind that I can update articles once the article Title or News body doesn't contain a ' inside of the content. Once a ' exist, then it crashes the script and nothing updates. Code:

View Replies !   View Related
Html_entity_decode() And Htmlspecialchars() For XML
Using the conversion to char sets described for these functions, is it possible to get a whole string into some charset?

I'm trying to figure out a way to take invalid character sets from idiot users, and translate the string so that in the end I have a string that won't cause my XML to test invalid. Code:

View Replies !   View Related
Htmlspecialchars() Or Htmlentities()
I have been wanting to display my PHP sources for stuff I make to help people but using htmlspecialchars() and htmlentities() it only does so much convertion to HTML. The variables still echo the result or nothing, when infact I obviously want it to simple echo $variable_name Lol. Please help. The code I am trying ton convert is the simple random token generation code.

<?php

for($length=9,$ra='strlen($ra)<$length;$ra.=chr(!mt_rand(0,2)?mt_rand(48,57):(!mt_rand(0,1)?mt_rand(65,90):mt_rand(97,122)))); echo $ra;

?>

View Replies !   View Related
Reverse The Htmlspecialchars
Now before any of you get ahead of yourselfs... I do not have PHP 5 thus this has to be a PHP 4 answer.

I encode a chunk of html using htmlspecialchars then split it and break it apart. After that I get out put (in browser) like: .....

View Replies !   View Related
Htmlspecialchars To Whole Array ?
The following is a while loop returning data from an Oracle db: Code:

View Replies !   View Related
Htmlspecialchars() And Htmlentities()
I have another question - I have a lot of information in a mysql database which I want to display allowing HTML coding for basic formating. htmlspecialchars() and htmlentities() both make the HTML tags appear instead of formatting the text. Is there a function that will keep the taglines intact but replace pound symbols (£) etc. with the appropriate HTML equivalent?

View Replies !   View Related
Htmlspecialchars - Character Set
$new = htmlspecialchars("<a href=", ENT_QUOTES, 'ISO-8859-15');
echo $new;

displays:

<a href

Instead of :

&lt; a href

I added the character set since this is a computer in Europe. The PHP is the Win32 5.1.2.

View Replies !   View Related
Htmlspecialchars() Valid XML
It is listed in the XML section of the manual, rather than the section that deals with
strings. I feel strongly that it should be cross-listed.

View Replies !   View Related
Htmlspecialchars And Htmlspecialchars_decode
If I use htmlspecialchars on a user text input before storing into a database, then when showing the data in an output use htmlspecialchars_decode before displaying, would that allow potentially harmful code to be run? (ie is it only a good way to store the data not display it?)

View Replies !   View Related
Using Htmlspecialchars() On The Variable
When I try to send the contents of a textarea from a form to my database I get errors if the textarea contained certain characters - for example, ' or ". The errors appear in my SQL syntax only when those characters are entered, so I need to escape them somehow. How should I format the variable containing the text so that this error doesn't occur?

By the way, I am already using htmlspecialchars() on the variable in question. Am I going to have to use regular expressions

View Replies !   View Related
Reverse Htmlspecialchars
I am pulling information from a database whose input had htmlspecialchars used on it. Is there a way to convert the specialchars into their actual signs so that &lt;b&gt; actually becomes <b> and therefore displayed the text as bold.

View Replies !   View Related
How To Use Htmlspecialchars In The Form
how to use the htmlspecialchars function in the form below:

<form action="formtest1.php?c=1" method=POST>
<b>Find Results with:
These words: <input type="text" length=40 name="keywords">
input type="submit" value="Search">
</form>

View Replies !   View Related
Htmlspecialchars/real Escape
I'm creating a BBCode parser, and everything's working but one thing; I need code tags, but I will need to real_escape/htmlspecialchars the post to make sure it isn't malicious. The only problem is if I real_escape with code tags that contain php, the php will be removed. If I specialchars the post with php, I can't have syntax highlighting (or, not easily). How do I get round this?

View Replies !   View Related
Htmlspecialchars - Mailing System
i have a mailing system with a textarea where people can typ there message and then send the email. Everything works well,except for when you typ for example :

you're great
because then the mail will sent this :
you're great !

could anybody help me?

View Replies !   View Related
Select Option And Htmlspecialchars
I'm trying to create a dropdown option that when selected goes to the url specified, I would also like specific data posted based on the selection Code:

View Replies !   View Related
Foreign Key ID
I am trying to understand how to do the following: I have a form that enters a person's contact information when they attend a meeting (name, address, phone number, etc.). What I need is for the person's ID number (auto incremented) to be duplicated in my attendance table as a foreign key with the current date. How do I do this? How I get the person_ID to enter in both the people table and the attendance table? Below is how my tables are set up: Code:

PEOPLE - person_ID, name, address
DATE - date_ID, date
ATTENDANCE - person_ID (fk), date_ID (fk)

View Replies !   View Related
Htmlspecialchars Makes Stuff Safe?
Do you think using the htmlspecialchars function makes user input safe for the mysql database? If not, what other exploits are there? Do I really need to add more to make my user input secure?

View Replies !   View Related
HTML Entities / Htmlspecialchars With Dollar
I am trying to preform a regex to make sure that valid input is entered, but htmlentities and htmlspcialchars don't seem to translate the dollar sign ($) into it's corresponding HTML code (&# 36; ) (spaces added due to board translation of HTML code)

$_POST['webCurrency'] = "& #36;"; // posted from form with value & # 36; without spaces
$currency = htmlspecialchars(trim($_POST['webCurrency']));
&nbsp;&nbsp;&nbsp;&nbsp;echo 'CURRENCY -> '.$currency; //outputs $
$currency = htmlentities(trim($_POST['webCurrency']));
&nbsp;&nbsp;&nbsp;&nbsp;echo 'CURRENCY -> '.$currency; //outputs $

View Replies !   View Related
Htmlspecialchars And Me. Question About Safety And Flexibility.
I have a site where I let users input text into my mysql database. I run their inputs through mysql_real_escape_string before I enter it into the DB and on the output I run it through htmlspecialchars.

My question is: How can I add the ability for users to add things such as hyperlinks or images when all the <> brackets and such are converted to their entity counterpart?

I don't want them to actually be able to input HTML, or scripts, but I would like to give them the freedom to insert hyperlinks and images, that will parse correctly on the viewing page.


View Replies !   View Related
Mysql Foreign Key
I am using phpmyadmin for database creation. I want to create a foreign key reference.. how can i create?

View Replies !   View Related
Trying To Fix Some Foreign Characters
I seem to have had a small problem with my mysql database a while back (i think when i switched from windows to linux) Anyway it seems to have replaced all my 'é' with 'é' (it also shows as '&#65533;')i was trying to do an ereg_replace on them like:

//username input = 'Andr&#65533;'
$username = $row['username'];

$pattern = '/é/';
$replacement = '/é/';
$fixedNames = eregi_replace($pattern, $replacement, $username);

This however seems to do absolutely nothing. Does anyone have any ideas how i might go about sorting this problem?

View Replies !   View Related
Foreign Keys
Normally, my tables have a primary key, and usually it's an auto-incrementing integer - unless, occasionally, it's an alpha string like a UserName or something. then, I may have a "dependent" table with a foreign key field which references the primary key of the "parent" table. Now, I know it's possible to have a primary key made up of multiple columns - I call that a compound primary key myself. I do that occasionally.

However, is it possible to have a "compound foreign key" ? I.e. a foreign key of two columns, which refers to the two columns for the primary key? I realize you can do that by just creating the tables that way, of course, but can you set referential integrity on that? And how would you do that?

View Replies !   View Related
Foreign Languages
I'm trying to load in a text file using fgets into a database table. The text file contains a dictionary of terms in the form:

<englishword> <spanishword>

Problem is that the spanish words contain characters that are spanish specific, and when I read them in, they are converted into '?'. I don't want this.


View Replies !   View Related
Foreign Characters
I'm hoping to do some work with foreign characters on my database, but I need to learn a little bit more about what is happening first. In the database, character sets are being saved to represent single foreign characters. For example, something like Ä« would be in the database, but would show up in the browser as è. What is this called? And is there any listing out there that displays which sets turn into which foreign characters?

View Replies !   View Related
Populate A Foreign Key In One DB
I have a table called attendees that has attendeeID as a primary key. Then I have a table called relationships that has groupID as its primary key and attendeeID as a foreign key (from the attendees table). Both tables get populated from fields in a single HTML form and both of the primary keys are auto-incremented.

What I need to do is populate both tables at once when the submit button is clicked and insert whatever auto-incremented value attendeeID was given in the attendees table into the attendeeID field in relationships.

View Replies !   View Related
Create Foreign Key
How can I create foreign key in table which using MYISAM storage engine in xampp?

View Replies !   View Related
Primary And Foreign Key..
I am in the process of trying to create a db. There are about 13 tables, some with as little as 2 fields in it.

My question/problem is right now all have an ID field as primary. I am going to rename the ID to be repsentative of the table but don't get the primary and foreigh key deal.

I want to make sure when I load data for record one, it all does to record one. This is a sports memrobalia db and accuracy is key.

View Replies !   View Related
Foreign Key Issues
I have two tables: Code:

CREATE TABLE `images` (
`id` int(255) NOT NULL auto_increment,
`uid` int(255) NOT NULL default &#390;',
`dirid` int(255) NOT NULL default &#390;',
`name` varchar(32) NOT NULL default '',
`size` int(255) NOT NULL default &#390;',
`uploaded` int(20) NOT NULL default &#390;',
`views` int(255) NOT NULL default &#390;',
`approvedby` int(255) NOT NULL default &#390;',
`premium` tinyint(1) NOT NULL default &#390;',
`comment` text NOT NULL,
PRIMARY KEY (`id`),
KEY `uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
....

View Replies !   View Related
Foreign Dates
I'm using the date function to echo out days of the week, which is extremely simple to do. But I'm working on a multi-language site where the user can choose their preffered language. I've sorted that part. The only thing I'm wondering about is, can I use the date() function to output foreign dates. so instead of echoing: Quotemonday, tuesday, wednesdayit will echo something like: Quotelundi, mardi, mercredifor a french viewer. I suppose I could link it in with an array od days for each language, but it would simpler if ther was perhaps a foreign date() function of some sort.

View Replies !   View Related
Stripslashes(htmlspecialchars($myrow[1])) To Display A Record
I am using stripslashes(htmlspecialchars($myrow[1])) to display a record from the database. When I enter data in the form in the backend, I want to put <b>text</b> but this actually turns out as <b>text</b> on the webpage instead of bolding the word text.
How do I make it so I can enter HTML in the backend textarea form fields?

View Replies !   View Related
Loop Through A Result Array And Apply => Htmlspecialchars
I think that this could be easy, but my brain cramps up part way and I can't seem to get it right (I'm in the middle of a marathon coding/programming session).

I have a result set:
$query = "SELECT * FROM mytable WHERE code = 'topsecret!'";
$result = mysql_query($query);

Now I want to loop thru the resulting $row's and apply the htmlspecialchars() function. My brain cramps right about at the point where I start to build the foreach. Can someone walk me through this?

while ($row = mysql_fetch_array($result)) {
foreach ($row as $key => $val) {
CRAMP!
}

View Replies !   View Related
Rmoving Foreign Characters
I need help removing foreign or international characters for form data before storing in a database. What I'm doing is making a username from the persons lastname, firstname inital and middlename inital and have some international users but don't want to allow special characters.

View Replies !   View Related
Foreign Characters To Entities
$trans = get_html_translation_table(HTML_ENTITIES);
$test = "ŽŽˆˆ&#65533;&#65533;";;
$test = strtr($test, $trans);
echo $test;

using this i get back the same foreign characters when what i want are the entities?

View Replies !   View Related
ActiveRecord And Foreign Keys
I am having trouble wrapping my mind around the ActiveRecord pattern and
foreign keys.

I understand that for each table, there should be a class, and each row
is is effectively an instance.

But, my problem arises when I look at foreign keys and advanced
relationships. For basic foreign keys, I can just automatically
reference to the object. Example:

Table: invoice
id, notes

Table: items
id, cost, invoice_id

When working with an instance with items, I can easily load a new object
called "invoice."

But, what if I am already working with invoice, and I want to load
items? I can't think of any way to abstractly relate the two.

Also, what if I want to two things that are both a "has many"
relationship? For example, if I take users that can have multiple
qualities, I would need three tables: one for users, one for the
qualities, and one to link.

Table: users
id, username

Table: link
id, user_id, quality_id

table: qualities
id, quality_name

View Replies !   View Related
Mysql: Get Foreign Keys
there is a function to get the foreign keys of a table?

i have this function to get all table infos:
$fields = mysql_list_fields($V['db']['name'],$table) or die
(mysql_error());
$columnsCount= mysql_num_fields($fields) or die (mysql_error());
for ($i = 0; $i < $columnsCount; $i++) {

$columns[$i]['name']=mysql_field_name($fields, $i) ;
$columns[$i]['length']=mysql_field_len($fields, $i) ;
$columns[$i]['type']=mysql_field_type($fields, $i) ;
$columns[$i]['flags']=mysql_field_flags($fields, $i);
}

but i need alo to know info about foreign keys.

View Replies !   View Related
Displaying Username From Foreign Key
I have created a php page (using mysql dbase) so people can leave comments on a comic (yeah, I like comics! :p). I've figured out how to display these comments, and that works how I'd like. The thing is, when a user leaves a comment, it collects the comment, rating, date, title and memberid. All these things are stored in the membersreview table.

The problem comes when trying to output the member name with the appropriate comment. The membername is stored in the member table, with the memberid (stored in the membersreview table) acting as a foreign key.

My long winded question is, how do I output the relevant membername rather than just the memberid (which is just a number)? Here's the code I have that is working so far: Code:

View Replies !   View Related
Parsing Foreign Characters In Xml
I have an xml file that contains characters like &eacute; for example:

<entry>
<term>Acher&eacute;</term>
<use>Atcher&eacute;</use>
</entry>

What I am trying to do is get the xml file to be parsed by php and then turn the data into a viewable webpage.

I think that the &eacute; somehow needs to be an &#233 ( or é with a semicolon on the end ) etc....

When creating the parser I am using...

$xml_parser = xml_parser_create('UTF-8');

and if I use html_entity_decode on the string before parsing it, it says: "XML error: not well-formed (invalid token) at line 101"

If I do not use the html_entity_decode or set the parser to UTF-8 the characters are turned in question marks as the documentation states that If PHP encounters characters in the parsed XML document that can not be represented in the chosen target encoding, the problem characters will be "demoted". Currently, this means that such characters are replaced by a question mark. (http://nz.php.net/xml )

Any Ideas?

View Replies !   View Related
Adding Field WITH Foreign Key
how do you add a field to a table and add the index and constraint all at the same time?Here is what I tried:

ALTER TABLE `finan_invoices` ADD `Contacts_ID` INT( 9 ) UNSIGNED,
ADD INDEX ( `Contacts_ID` ),
ADD CONSTRAINT FOREIGN KEY(`Contacts_ID`) REFERENCES addr_contacts(ID) ON DELETE RESTRICT ON UPDATE CASCADE;

and it gives me error #1005 - Can't create table './cpm052/#sql-60e_f588.frm' (errno: 150)

Is my syntax off or is there some other problem here?

View Replies !   View Related
# FOREIGN KEY In Xampp Phpmyadmin
How does one add a #FOREIGN KEY in a table while using xampp phpmyadmin .

View Replies !   View Related
Searching Foreign Characters
i've a little search engine set up to query a database. however, i have some entries in my db with foreign characters.

what can i do to make these foreign characters searchable with regular english characters?
for example, someone searches "fur elise" and the query will find "für elise".

View Replies !   View Related
Create Foreign Keys
I know they're not real foreign key constraints, however, for schema and consistency in architecture I'm required to "create" them anyway. What's the syntax? I honestly, truly, don't know. This is what I got from the MySQL Manual: Quote:

ALTER TABLE applicants CREATE INDEX fk_referral_id ON applicants (referral_id);

That is, of course, wrong, but I have absolutely no clue what's the right way to do it. Sorry so stupid, I just don't know.

View Replies !   View Related
Learning To Use Foreign Keys.
I'm having trouble learning to use foreign keys. Does anyone know of a good tutorial they could point me to?

View Replies !   View Related
Put The Value Of One Field In The First INSERT Into The Second As A Foreign Key
I am developing what could be likened to a very simple php/mysql forum solution for a client. I have come to an instance where I need to do two INSERT queries on my MySQL database to put data into two tables. However i need to put the value of one field in the first INSERT into the second as a foreign key sorta thing.

The field i need the value for is an auto incrementing field. Is it possible to return the value of the auto incremented field after and INSERT query so that i can then use this value and insert it into the second table. I think I could probably do this by doing a SELECT query in between to find the max value of that column and then use that but I can't see this being the most efficient method.

View Replies !   View Related
Defining Foreign Keys
Can't find a button for it. How do you set foreign keys in MySQLCC?

View Replies !   View Related

Copyright © 2005-08 www.BigResource.com, All rights reserved