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




Double Quotes In Text Input


I accept text, add_slashes, and store it in my MySQL DB. When I display
the text, I normally strip_slashes and also strip_tags. This all works
excepts for a field with double quotes. e.g.

"My Book's Title" is very simple

When I display this field, it is totally blank. What's the solution?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Input, POST And Double Quotes
I am having problems with double quotes inside a post variable. The
code below illustrates this. If the user enters non-quoted text then
the code works OK. If "Hello" is entered then I get $some_text equal
to "Hello". What I want is the actual text that the user entered
and not the processed version.

<?php
if (isset($_POST['some_text']))
$some_text = $_POST['some_text'];
else
$some_text = "";
?>
<html><body>
<form method="POST" action="test.php">
<p>
<?php echo("Old text: " . htmlentities($some_text). "<br>"); ?>
Enter text: <input name="some_text" size="20"><br>
<input type="submit" value="Submit" name="Submit">
</p>
</form>
</body></html>

Escaping Single Quotes, Double Quotes, And Semicolons With STR_REPLACE()
i have this error code unexpected T STRING on this line:

str_replace(addslashes('onmouseover="showImg('name', 'tabla_novedades2', 's_asc.png', 'img1');"'), addslashes('onmouseover="showImg('name', 'tabla_novedades2', 's_desc.png', 'img1');"'), $td_name);

i tried escaping slashes with the addslashes function but obviously this did not work
there is a ";" in the string so i know that is causing the error

I am replacing this string:
'onmouseover="showImg('name', 'tabla_novedades2', 's_asc.png', 'img1');"

with this string:
'onmouseover="showImg('name', 'tabla_novedades2', 's_desc.png', 'img1');"

how do I do this with no errors with the str_replace function??

Stripping Double Quotes And Replacing With Single Quotes
I have a problem I had trouble finding any existing threads on in the forum.

I have tried learning more about str_replace() but have had trouble with implimentation.

Here is what is happening. I am adding text to a variable called $content that looks like this:

Hi everyone. This is text I made up. I think it was Larry that said, "Love is a battlefield". But I think it was Benitar.

Now I want to replace those " " in there with ' ' (single quotes.)

Practical Reason For Single Quotes Vs Double Quotes
I've always wondered why - or even if there's a difference - for using double quotes vs single quotes in php.

My code typically ends up with a mish-mash of both - sometimes I'll use:

$tomorMonth = date('n', $tomorrow); on one line, and then,
$arrMonth = $_POST['arrive_month']; on another line (or lines)

Both seem to work okay - I don't seem to be throwing any errors - but my question here lies in the interest of getting the "best practices" usage straight so I can start implementing single or doubles as appropriate.

So... when SHOULD someone use singles over doubles ... or does it make any difference to php at all?

Single Quotes And Double Quotes Showing As ? On Web Page
I have an issue with quotes showing as question marks on my webpage. I am sure its a UTF-8 related issue, but some of the facts surrounding the issue confuse me. The database is MySQL and stores the text as UTF-8. The PHP script simply takes the data from the database to a string: $desc = $info['description'];

And the text itself, is in a HTML string in the database as:

<P class=MsoNormal style=MARGIN: 0in 0in 0pt>The Golfers will enjoy their favorite sport on the Golf course only 5 min drive from “The Vineyards”.</P>

I am pretty sure that the original source was MS Word, and that the double quotes, in this example, are the special quotes from Word and not the ASCII quotes. When the webpage displays, it displays with the Unicode encoding. So, database is UTF-8, assignment in PHP is simple assignment without any form of stripping, tag removal etc.  And encoding on webpage is Unicode.  So can anyone suggest why they arent being displayed?

In the above example, the latter part of the text shows as ?The Vineyards?
It seems to apply to double quotes for sure, but also to some single quotes, as I have other text that displays as it?s instead of it's.

Double Quotes & Single Quotes
I have a web page with four input boxes. If a user types in text with either single or double quotes the insert fails.

I have looked into solutions and there seems to be some disagreement on the best method.

Some people say turn on magic quotes while others say not to, or use addslashes and stripslashes and again some say not to.

What about an mssql version of mysql_real_escape_string and mysql_escape_string??

What is the correct method? How do I overcome?

Single Quotes, Double Quotes And "undefined Index"
I am trying to write clean code but keep having trouble deciding
when to quote an array index and when not to.

sometimes when I quote an array index inside of double quotes I
get an error about enased whitespace (to my best memory)

AT other times I get an undefined index notice as below:

Notice: Undefined index: last_reminder_id in...

the 2nd line (which wraps to the 3rd in this posting
is the one listed in the error message:

$sql = "SELECT * from notes
where recall_date &#390;' and recall_date <= '$now' and id >
'$_SESSION[last_reminder_id]'";

what is the correct syntax and/or can anyone point me at a
reference that will explain this ?

Using Double Quotes In CSV Files?
I've got a CSV file in which I need to use double quotes and import into MySQL.
However, I've tried using a in front of each quote. I've tried using the HTML code. They doesn't work (and it's not something I want to mess with during data entry).

The HTML code gives a parse error.

Pg_query() And Double Quotes
I'm discovering that my pg_query isn't working because PostgreSQL is
wanting double quotes around my column names and table names. Is there
a way to turn quoted identifiers off?

Double Quotes Appear As ? On Website
I have an Excel file (which is converted to csv by a tool and then
uploaded to a MySQL database) and then php is used to display the
data on the website.

In the Excel file i have text fields which has data containing double
quotes. They end up appearing at ? question mark on the website. Any
idea how to dispaly the quotes

Should i be carefull of any other invisible characters in Excel which
can mess up the data.

Single Or Double Quotes
Is there a difference between using single quotes (') and double quotes (") in php functions?

When To Use Single Or Double Quotes
I am still confused as when to use single or double quotes.

This works:

echo "<td>" . $row[0] . "</td>";

and this does not

echo "<td bgcolor="#FFFFFF"><font face="Arial" size="1">" . $row[0] .
"</font></td>";



Double Quotes Issue
I have a string thats displayed from a database table, and when the database value contains a string in quotes, its not displayed in the output form. So if the value of advtitle is  - this is an advert, as "featured on tv" When displayed it shows - this is an advert, as So its missing the "featured on tv" part. Here is the code:

What Does F Do When Surrounded By Double Quotes?
I just installed php5.2.5 on a server and I am porting over an old script. Every time there is an f surrounded by double quotes in one of the include/require paths, there is a blank space causing the include/require call to fail. What does it do and can I turn that off in the ini somehow?

Removing Double Quotes From A String
i tried eregi_replace(""", "", $string); without success.
can anyone help?

Escape Single/double Quotes....
I haven't found a more efficient way to better escape the quote characters for the javascript right from PHP because I only get "The kid" in the javascript alert message, so I'm wondering if anyone of you know of something better than that...Code:

How To Strip Quotes (single And Double) From A String
I have used a class called clsMetaContent.php, as provided in the book Creating Interactive Websites with PHP and Web Services, by  Eric Rosebrock - who I understand is the lead developer of this site.

While using this class with my application - I find a problem in the assignment of the description for the description part of the meta tag.

The code in the class looks like this:

// Formulate the description for each page.
      if(empty($ptitle)){
         $description = $this->description;
      } else {
         $description = '$ptitle - $this->description";

I have found that my description can contain single and/or double quotes. Which causes a problem with the assignment of the meta tag for the description. What happens is, due to the error in the format of the meta tad description, it outputs the contents of description again on the start of my web page, instead of keeping it within the meta tag assignment.

I think I just need a function to strip out double and single quotes - but have been unable to find any.

Trouble Inserting Single/double Quotes To MySQL
I am having trouble inserting single and double quotes and commas to my mysql db. Is there a php method that I can run to prep variables before hand?

Double Input Of Form Data When Browser Is Refreshed
I have a form page. When submitted it posts to page2.  On page 2, it inserts variable into the database. The queries the database and displays the information. But....

If the viewer refreshes their browser, it now submits the information into the database again.

Not sure how to handle problem. I think that if a session variable passed to page 2 in an if else statemen, it will keep this from happening when refreshed since the session variable is not passed in the refresh. 

Stripping Quotes From Form Input.
Is there a (better,quicker,easier) way of stripping anything other than text, and numbers without using an if statement to catch errors, and have them re-enter the info? I'd rather just strip them all together.

Something like.. if I want to stip out anything other then the alphabet, and 1-9, so I don't have entries that look like this.. Quote: ..%blah''''""""";blah!!!@@@~``

Problem With "escaped Characters" Not All Double Quotes Show Up?
$tdsubclass=<<<bumelum
<td><a href="http://www.ygabel.php/$artnr[$arayartnrcounter]"
="" onmouseout="
function onmouseout(event) {
window.status = "Done";
return true;
}
" onmouseover="
function onmouseover(event) {
window.status = "http://www.fup.dk";
return true;
}
"> <!--target="_Self"-->
bumelum;

When I print this the double quotes after Done" and after dk" are
missing?

I have also tried with escaped characters in double quotes

I Want My Server To "allow" Single And Double Quotes
I'm working on a language learning website where teachers are uploading questions like: What does, "How ya do'n?" mean?

I haven't added anything to my code that restricts what types of punctuation can be uploaded to the database. However, when single or double quotes are inserted along with text, the quotes come back as symbols+text, or parts of the text has been deleted, or backslashes appear before some punctuation. I asked my hosting provider if I could solve this problem with a php.ini dirrective (?)

They got back to me that it might be a character collation issue, and that I could change the default from Latin1 to something else, but I still don't understand how that would solve the problem.. wouldn't the same thing happen with a different character collation?

Finding Double Data In Text File
I am working on this e-mail newsletter subscription thing and I am storing the data in a txt file (mySQL is better, I know but I want it to be compatible with non-mysql systems).

Off course I don't want any e-mail adresses appearing twice in my list (the list looks like this: someone@somewhere.com, blah@bla.com, et cetera). How can I prevent this?

Get Text Info Inside Quotes
Wondering how I can do this. Say I have the following as a string. info="get this text"
how can I turn that into a php variable ie.. $info="get this text";

Submitted Long Text : Php Could Have Problem With Quotes
I've run into this problem a few time but just ignored but I can't ignore it anymore.
On a few of my sites I have a "News" section and I've made a simple admin area for people to type in new stories, etc. They also get stories emailed to them to put up on the site.

But I found that articles with quotes and lots of punctuality and if the article is long, wont submit to the DB. PHP Code:

When To Clean Input Text
I was wondering what people do with text provided by the user in a
form. Some cleaning needs to be done at some stage if you are going to
be putting it in a database or displaying it etc. But when is the time
to do that?

Do you clean it as soon as you get it?
Do you pass around the original text and clean it when you use it?

What about magic slashes? You need to addslashes before using in a db
statement, but you need to strip them when displaying. When do you do
that?

Text Area Input Box With PHP
I have a text area box on one page. PHP sets the information that is inputted into the text area into a variable. When I print this info to the screen via echo, it does't have the line retain the formatting that the user had in the text area. It has no line breaks, it runs everything together.

Input Text Issues
Whenever I receive input from an HTML text field or and HTML text area
with " or ' meaning double or singe quotes into a php variable and
then print or echo it back out to the user in html I get these
characters accompanies by a . Why is this and how can I get rid of it.

$submitform->body=@$_POST['body']; <<<< there are no in the input.

print("body - ".$submitform->body."<br>"); <<<< but here there will
be slashes for all ' or " .

Text Input With Links, Etc..
I hope you can give me a few pointers on this issue.

I'd like visitors to my website to be able to enter text to be viewed on the
site - a bit like a bulletin board or forum. I can do this for regular text
easily by simply populating a 'TEXT' field within my MySQL database and
grabbing it back when rendering the site using PHP. However, I'd also like
visitors to be able to put in URL links or email items that can be clicked.
How would I go about doing this?.I've seen this sort of thing on forums
where words can be selected and a URL applied, but I have no idea how to do
this and how this information (ie. the link and the associated text) would
be stored in the database field(s).
Any ideas?. Are there any PHP examples available for this sort of thing?.

Input SQL Data Through Text Box And Get Nothing?
I want to add SQL command through a textbox in the form using post
method,but when i execute the following file, nothing is added to the
database.
I can add
$sqlol = "update acc_account
set user_name='k'
where accountid=1";
to the database if it was added to the file but when i use $result =
mysql_query($sql); which execute the query, it get nothing. However,
the $sql statement do print out on the screen using print.

<?php
$conn=mysql_connect('localhost', 'shytr8');

if(!$conn)
{print "Error- Could not connect to MYSQL";
exit;}

$er=mysql_select_db("test");

if(!$er){
print "Error- Could not create er";
$query = "CREATE DATABASE test";
mysql_query($query);}

$sql=$_POST[SQLcommand];
$result = mysql_query($sql);
?>

Checking Input Text?
I wondered if this script seemed correct? The user should enter a
userid and password in two text fields, and then pass these values to
the method login_user.

Could I ask, is there any approach to, once the user clicks the submit
button to test the userid and password has been entered, and the text
fields are not empty.

<?php

function login_form(){
?>
<html>
<head>
<title></title>
</head>

<body>

<div align="center">
<form method="post">
<table border="1">
<tr>
<th align="right">E-mail</th>
<td nowrap>
<input name="userid" size="25">
</td>
</tr>
<tr>
<th align="right">Password</th>
<td nowrap>
<input name="password" size="25">
</td>
</tr>
<tr>
<td align="center">
<input type="submit" name="submit" value="Login">
</td>
</tr>
</table>
</form>
<div>
</body>
</html>
<?php
}

login_form();
$user_info = login_user($_POST['userid'], $_POST['password'];
?>

Spaces In <input Text> Boxes.
When I submit a form where a user has typed a space into the input box, then check that value in the action .php file, only the text before the first space is displayed. How can I get all of the text sent?

eg

Code:
<form name="form2" method="post" action="temp.php">
<input type="text" name="name">
<input type="submit" name="Submit" value="Submit">
</form>

Then in temp.php
Code:
echo "Username = $name";

If the user enters "Greg Bennet" into the text field, I get back "Username = Greg".

Wiki Style Text Input
I have a text file called test.txt which is I am trying to get to load
into a webpage. This is simple enough, but I am trying to make it so
that it recognises certain formatting, similar to how wikipedia pages
work.

so, my text file contains ONLY the following:

This is /just/ some test text *to see* if the PHP works
and to /*evaluate*/ what it actually does

The intention is that /just/ will show as italic, *to see* will show as
bold and /*evaluate*/ will show as bold italic.

Creating the text inside the page works fine.

<?php
$s = 'hello. /this/ works *bolding* works. /*Both work*/!'
$search = array ( '@/(.*?)/@si',
'@*(.*?)*@si');
$replace = array ( '<i>1</i>',
'<b>1</b>');
echo preg_replace($search, $replace, $s);
?>

However when I try and read from a text file using

$s = file('./wiki.txt');
$search = array ( '@/(.*?)/@si',
'@*(.*?)*@si');
$replace = array ( '<i>1</i>',
'<b>1</b>');
echo preg_replace($search, $replace, $s);
?>

All that is shown is the single word 'Array'. This confuses me a lot as

<?
$s = file('./test.txt');
print_r($s);
?>

shows that the text is being read into the page
Array ( [0] => This is /just/ some test text *to see* if the PHP works
[1] => and to /*evaluate*/ what it actually does )

How Can I Insert A Deafult Value In An Input Text Box?
for example if I have a box where you should put a date how do I keep
today date inside that box as default?

Simple Looped Text Input
I'm trying to build a website with a simple text input option. After the input, the input is checked and acted upon accordingly. This is followed by a new input line.

For example:
> input: test

"test" is not known to me

> input: _

So far, I've been trying things with the "do-while" loop (see code below), but so far, all I seem to get is a fixed input box and the "respons" being displayed below it. Code:

How Can I Print Out Multiple Text Input Boxes?
How Can I Print Out Multiple Text Input Boxes. The function below prints out three text boxes. The code below is static, cannot accept user input, and therefore cannot be changed. What I need to do is write a function or maybe a class that can accept user input and print or echo a different number of text boxes, depending on the user input.

The name variable for each of the textboxes needs to have a different name. For example, the name for the first text box would be something like "name=textfield1", the second would be "name=textfield2", and so forth. PHP Code:

Returning Text Input Type As Array
I'd like to make all the text inputs in this form to be part of an array. The reasoning is that the form is built dynamically so there are times when there are 4 inputs while other times it's 12. When the form is submitted I need those inputs to be error checked and such.

Updating Text File With Textarea Input
i am creating an admin page for a person to update a page of their website through a web browser. the problem that i am having is the formatting of the inputted data into the textarea box. when it is displayed, all the returns and breaks are removed and the data is all in one line. i have been experimenting with nl2br() but i am not sure where to put it.

Text Input Of Date And Timestamp Fields
I'm working on a PHP frontend for a PostgreSQL db and I'm looking for the
best way to create date or timestamp inputs. Let's take a date in the
format yyyy-mm-dd as an example. This is too error prone, I know my users
will do it wrong

<input type="text" name="fieldname">

Right now I'm thinking about something like this:

<input type="text" size="4" name="y_fieldname">-
<input type="text" size="2" name="m_fieldname">-
<input type="text" size="2" name="d_fieldname">

but this is IMO a very ugly solution, because after the SUBMIT I have to
glue all the parts together before inserting the values into the db.
Something like this:

<input type="text" format="yyyy-mm-dd" name="fieldname">

Displaying Text Fields On User Input
How would I echo a particular amount of text fields depending on how many the user selects from a drop down menu that I have already created. For example say the user selects 4 or whatever other number from a drop down menu how would I echo 4 or whatever the amount of text fields for a user to input text into? An example would be an airline website were you select how many people are travelling and then it echo fields for those people to enter their names.

Tag In Smarty Which Enables Us To Get The Input Type=text
Is there any tag in Smarty which enables us to get the input type=text alongwith the value filled from a variable?

i.e. a tag such as html_text such that I get input type=text alongwith value?

Text Input Box Automatically Escapes Quotation Mark
Text Input Box Automatically Escapes Quotation Mark

The text input box below works fine with text. However, when a single or double quotation mark (i.e. ' or ") is entered the code below outputs an escape mark. For example, if the word DevShed is entered into the text box then executed the code simply outputs the word DevShed. But if the word DevShed is put in quotation marks, like so "DevShed", and executed the code outputs the following: "DevShed".

My question is this: How can I keep the PHP code from automatically escaping quotation marks when the form text input box is executed?

Clearing The Input Text Field After Submiting The Form To A New Page
I have a page with a form with an input text field ... and when a user types his/hers ID ... and submits the form - his/hers page opens in a NEW window .... but the value (ID) that was written in the original window remains.

I want to make sure that the form input field on the original page becomes "invisible" - by refreshing/reloading the original page or just by clearing the input form after submission.

For now I have put in a meta refresh tag in the head of the html file ... but that is not the solution ... becouse I only need a one time refresh/reload of the page ... and this is to happen right after the input text value is being submitted.

Detecting URL's And Html Tags In Text, Input From Form
Is it possible to check text and set a PHP variable if someone inputs links, <h1></h1> ect. and other html tags when filling out your form mail or guestbooks?

$_POST Behavior From Input=submit Vs Input-type=button
I have been trying to solve an annoying behavior with PHP (I think).
Maybe some of you have encountered the same and have some ideas.

I have an html form and I use an <input type="button"> element with
the onClick event that calls a javascript funtion. Once the script's
content has been processed, I execute the form.submit() directive.

I would like to combine the html form and the PHP script into one, and
use action="<?php echo($PHP_SELF) ?>".

When the html form has <input type="button" name="theButton"
value="thisisthetrigger" onclick="doThis(this.form)">but PHP cannot
'read' the value of $_POST["theButton"] after form.submit().

If I substitute the <input type="button"> for <input type="submit">
then PHP reads the value just fine. Some may argue to just use the
latter option, but that will cost me a trip back to the server to
basically do a lot of validation that can be very easily accomplished
on the client side.

Md5 Has For Double Opt-in: Missing Something ?
I have made a script to register contacts in a database with the double
opt-in system.

Anyway, when looking for some examples, I have found the following
script which uses a md5 hash code to append on the confirm url sent by
email to the registering user.I tried it but with no results. Don't you think is it missing anything?How could it work without storing the hash code for the user in andatabase? To confirm a registration I think the script should look if the access key matches the one it already knows, shouldn't it?

Anyway I have no problem to insert into the database the hash code ,
it's just I want to know if I am right to believe the following script
was wrong .

here's the code..

Double Dot Means What ::
I'm still exploring in PHP programming with little knowledge on C ..
the mother of programming language..

Just wonder .. some times we will see some pepole use :: singn in
their code
and what it mean ?

for e.g Get::message ; <-- what the :: means.. is it some conditional
statement
because i saw a lot in Pear stlyle of coding..

OCI - Double Results?
to work with the example for OCI... and the $row returns 2
values, the same twice, but my query only have one... code below.

$query = 'select distinct(something) from a.b'

$stid = oci_parse($connX, $query);
if (!$stid) {
$e = oci_error($connX);
print htmlentities($e['message']);
exit;
}

$r = oci_execute($stid, OCI_DEFAULT);
if (!$r) {
$e = oci_error($stid);
echo htmlentities($e['message']);
exit;
}

print '<table border="1">'
while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS))
{

print '<tr>'
print "<td>".(count($row))."</td>";
foreach ($row as $item) {
print '<td>'.$item.'</td>'
}
print '</tr>'
}
print '</table>'

oci_close($connX);

Double Submit
I have a bank feature, players can add and withdraw money ect ect. What it seems people are doing is quickly when the server is under a load to add their money to it and buy something at the same time. So the money goes in the bank while they get the item they bought as well.

Is there anyway you guys can think of to stop people from submitting 2 forms at the same time?


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