Wrox Programmer Forums
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 8th, 2004, 09:58 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default Input type

Hi,

I'm building a small website atm with MySQL.
Its all new to me and I have 1000 questions for you.

The 1st batch of questions are:
<input type='text' name='Dataentry1'>\n
This 'text' seams to have a limit on how many characters I can write down.. I want to copy over 100K of data in my field; is there some kind of input 'textbox' I could use?

Before you ask me why I need to import so much text, I will explain since it's my next question:
I want to copy HTML code into that field , save it on my database and recall it later as a variable.

I'm doing a media/news site and the users needs to use tables, colors etc..

So far, PHP doesn't like what I'm doing:
Test.php
<?php
session_start();
?>
<html><head></head><body>
<?php
echo "
<Form action='Test2.php' method='POST'>
<input type='text' name='Dataentry1'>\n
<input type='submit' value='Go to Test2.php'>\n
</form>";
?>
</body>
</html>

Test2.php
<?php
session_start();
?>
<html><head></head><body>
<?php
echo "{$_POST['Dataentry1']}<br>\n";
?>
</body></html>

If I put a simple code in the field it works.. but if I write:
<p>Testing color</p>
PHP transform it to:
<p>Testing color</p><br>
One of the 0 as gone.. so I get green instead of red.. (PHP bug?)

It's all VERY complicated for me atm so any kind of help is appreciated!
 
Old December 8th, 2004, 10:02 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

oups just realised (I've been working on it all night!!) the 0 is there.
It does however change the color from red to green.. ??
 
Old December 8th, 2004, 10:55 AM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Your first question... yes you should use <textarea> like this:

<textarea name='Dataentry1'></textarea>

I believe there is almost no limit to this field.

Your second question... I need an example of this, I've never encountered anything like this. If the zero is still there, it should still be red.

-Snib - http://www.snibworks.com
Where will you be in 100 years?
 
Old December 8th, 2004, 11:53 AM
Authorized User
 
Join Date: Dec 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to peg110
Default

Quote:
quote:Originally posted by Mantis

<p>Testing color</p><br>

One of the 0 as gone.. so I get green instead of red.. (PHP bug?)
You need to show us the COMPLETE php line entry for the above example. What I mean by that is you have presented a line that is almost completely NO php (with the exception of escaping the double quotes.)

For example :
the line you presented as it should be (perhaps) in PHP
echo "<p>Testing color</p><br>";
or
echo '<p>Testing color</p><br>';

the line you presented as it should be (perhaps) in HTML (without PHP)
<p>Testing color</p><br>
or
<p>Testing color</p><br>
or
<p>Testing color</p><br>

While experimenting with this (to make sure MY syntax was right), I found out that YOU are likely using JUST
<p>Testing color</p><br> as PLAIN HTML which indeed does give GREEN text.

The most likely reason is that, generally speaking, html will IGNORE or do a BEST GUESS on things that it doesn't quite understand. Since presenting a color (in html) as \"#FF000\" is NOT standard HTML format, it's best guess was/is apparently GREEN.

Paul Gardner
------------------
PHP-LIVE help
Via Web @ http://www.mnetweb.co.uk/irc
Via IRC Client pgardner.net:6667
room #PHP
 
Old December 8th, 2004, 02:48 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The text area works great :D thks!!

I have 2 files for test purpose:
Test.php:

<?php
session_start();
?>
<html><head></head><body>
<?php
echo "
<Form action='Test2.php' method='POST'>
<textarea name='Dataentry1'></textarea>
<input type='submit' value='Go to Test2.php'>\n
</form>";
?>
</body>
</html>

And Test2.php:

<?php
session_start();
?>
<html><head></head><body>
<?php
echo "{$_POST['Dataentry1']}<br>\n";
?>
</body></html>

If I put a basic HTML code like:
<p align="right"><i>Right side italic</i></p>
<p align="left"><b>Left side Bold</b></p>
<p align="center">[u]Middle underline</u></p>
In the Textarea, the Test2 "should" echo on the screen :
Right side italic ; on the right side of the screen in italic (etc..) however; Test2 doesn't because
Dataentry1=
<p align=\"right\"><i>Right side italic</i></p>
<p align=\"left\"><b>Left side Bold</b></p>
<p align=\"center\">[u]Middle underline</u></p>

Some \ are automaticaly added (I'm guessing by PHP) and are confusing the HTML code..

I have no idea why..(I'm guessing it's some kind of feature to stop PHP getting confused with variables...) ; more to the point.. how do I stop this from happening?
 
Old December 8th, 2004, 03:09 PM
Authorized User
 
Join Date: Dec 2004
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to peg110
Default

I don't (necessarily) think it's PHP per se', but perhaps your editor. Are you using a special editor? (I use VI in linux or NOTEPAD in windows... )

Again, if you are using PLAIN HTML (as appears the case) then you should make sure that you CLOSE the PHP section with the ?>.

ONLY that which is enclosed in the <? ?> sections are processed by the PHP processor. Everything outside of it is processed as plain HTML/Text.

If you are entering the info as you suggest INSIDE the <? ?> then you should ensure that you use something like the echo statement to display it properly.

Paul Gardner
------------------
PHP-LIVE help
Via Web @ http://www.mnetweb.co.uk/irc
Via IRC Client pgardner.net:6667
room #PHP
 
Old December 8th, 2004, 03:32 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm doing something really weird so no one understand me.. all my fault!!

I am not writting the HTML code in the file. I am using Test1.php to input the HTML code into the variable Dataentry1.

Then I use Test2.php to output the HTML on the screen which in theory should work..

However, life been a b.. ; the variable Dataentry1 is somehow 'transform'...

Let's put it in a diffrent percpetive:
lets use this:
<input type='text' name='Dataentry1'>\n

If I enter: "0000" (with the "") in the field, the variable Dataentry1, should be "0000" but actually, somehow the variable is: \"0000\"
2 \ \ were added to my data??
 
Old December 8th, 2004, 06:27 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have trouble shoot the problem and the issue is that whenever you enter " inside an input type='text' the system automaticaly add \ in front of it.

Why? and how do I remove this \ from my variable?
please :)
 
Old December 9th, 2004, 12:56 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If anyone wonder how to remove slashes from PHP variables:
Use the command "stripslashes"
 
Old December 10th, 2004, 05:03 AM
Authorized User
 
Join Date: Oct 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to SiliconFuRy
Default

or use a string replace function(cant remember the exact syntax), to replace "\" with "".

stristri() i _think_ is the one (case-insensitive version)

but stripslashes, same thing :)

Many shoes,

Jamez/SiliconFuRy





Similar Threads
Thread Thread Starter Forum Replies Last Post
Radio type Input. Magen Classic ASP Basics 2 February 22nd, 2007 05:39 PM
input type file darkhalf Javascript 1 October 29th, 2005 02:17 AM
input type="image" tgopal Javascript How-To 1 September 22nd, 2005 05:16 AM
input type="image" tgopal Javascript 1 September 22nd, 2005 05:15 AM
<input type="File"> - Specify File Type and Path gp_mk Classic ASP Basics 2 August 2nd, 2004 03:07 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.