Missing data

I have a php/html form that is filled from a sql database via php. Used to change data in a record.
The edit boxes in the html section will not accept the full text.
I get $Variable correctly holding info from database and in the html section I wish to display that information in a input box ready to be modified and subsequently updated

<input type=“text” id=“Editbox” name=“variable” value=<?php Echo $variable;?>>

if the data is “This is data” I get “This” displayed only
if the data is “Thisisdata” the whole lot is displayed. I guess it has something to do with seperate words or spaces in the data that prevents it being displayed as a whole.

I feel that the <?php Echo $variable;?> statement even though the variable contents is correct it is not being displayed fully in the browser.

You need to put the value of your text box in quotes:

<input type=“text” id=“Editbox” name=“variable” value=“<?php echo $variable; ?>”>

Thanks heaps , I would not have thought of that. I even tried str_replace to insert nbs’s.

I just fired up Wamp and tested it. Next Problem, there always is a next :slight_smile:

I could not find that by searching but there you go.

Most grateful

You made a basic html error - and we have all probably done exactly the same at one time or another (I know I have, several times).

If you had looked at the page’s html source code, you would have spotted it yourself, guaranteed.

So, another little debug/error chasing trick to store away in your brain somewhere: check the source code.

If you use Firefox, get Firebug. It has an Inspect Element function that will take you to the source code of the object you click on so you don’t have to search for it.

And I, too, have done this tons of times.

@Cute Tink doesn’t that show you a version of what the DOM understands the source to be? I don’t use FF tools myself.

Given the OPs case

$variable = "This is data";
<input type="text" id="Editbox" name="variable" value=<?php echo $variable;?>>

would the “inspect element” (or DOM inspector as I understand it to be) show:
It does not try to clean it up:
<input type=“text” id=“Editbox” name=“variable” value=This is data>
OR b)
it makes an attempt to clean it up
<input type=“text” id=“Editbox” name=“variable” value=“This” is data>
OR c)
it really does clean it up
<input type=“text” id=“Editbox” name=“variable” value=“This is data”>

Given that as html of course it just shows This and then gives up?


Fixed code sample above, and I just checked in Chrome Dom inspector I get b) above - so yes you do get a clue as to what is happening but it also gives you false message - it tampers with the data.

With a simple textbox like this:

<input type=“text” name=“name” value=This is text />

Inspect element gives me this:

<input type=“text” text=“” is=“” value=“This” name=“name”>

It does alter the data indeed, but that might give a hint that something is not right. If not, it doesn’t alter the actual source code if you view source, so maybe when the poster is more used to looking for the errors it would be a good tool. I find it invaluable at this point, since my pages often go on longer than I want to scroll.

From the above post you are assuming I have great html knowledge, I get by thanks to the help I get. I have just spent 3 months learning or I should say stumbling with php. I honestly did not have a clue and yes that knowledge is now stored. I use Keynote for my projects. This is a hobby with me and as I am a member of the local art society I have the task of setting up a web site for them. Great fun. I am using a script I found and building around it.
Untitled Page I am not totally useless although at 68 I am sure there are 16 year olds that will dance rings around me.
:slight_smile: I still have a single board Clive Sinclair ZX80 that started my programming days I love technology but hate the modern music bite me I am an oldie.
I use Chrome and it has a inspect element I will investigate, thanks again for the heads up.

One thing to remember is that with HTML, any attribute (name, value, etc.) of an element should be in quotes always, i.e. name=“name”, value=“value” and so on.

Where I made the mistake was of not realizing that also applies to an inserted php variable. Will not forget anymore. I am the accumulated result of 1000’s of answers to sometimes rather lame questions.

I am grinding through code at the moment to separate references to deleted images in a database compared to the active ones. It is lots of fun but when that fun turns to frustration I will let you play with my code as well.

Reason I am modifying a classified script by “Matterdaddy” (Yes strange name) When a posting is deleted the image reference remains. I will use an automated script to run on load of a page to do clean up and maintenance, statistics etc.

There was a time I could not even spell progriming now I are one :slight_smile:

Thanks again. If I need help you are on my radar.


From the above post you are assuming I have great html knowledge

HTML is not that difficult to learn, the minutiae of which DTD to use, xhtml, strict and so on, yes, that can be tricky, but a basic knowledge of html (especially if you want your html output to be ‘valid’ against a known DTD) is a fundamental requirement for using PHP to create websites.

As already stated by at least two of us, we all overlook this from time to time, and busy ourselves desperately hunting around our PHP/Mysql code and data looking for our error.

As a sanity check sometimes, check your html source - and as pointed out “inspect element” in a DOM inspector is a really, really easy to use tool to do similar without having to wade through your entire html source.

This is especially true when you move to outputting Javascript into your html stream, but that is another story …

As with programing either Java, C ,basic, php even Autohotkey, now for me the end does justify the means. To justify that, if one statement does not work I use another as in if I want to use a hot key within a VB program I turn to Autohotkey it is easier to accomplish with less code.

For html I use the blue Voda web builder and I created a program to convert the output to a html page I can use.

It is the rare occasions that I have a problem that I ask for help. I really do wish to find out solutions myself but I am a realist and will not spend more time on a problem than necessary.

I have programed real time computer based high speed production testers in Dos C. That goes back some years now. I was told by a teller at a bank that the oldies do not know about computers. Think! who invented them.

I have not involved myself much in the higher use of html as quite honestly I have never needed it. I sell software and my site albeit quite amaturish works well and pays for itself.
visit Universal Ink Monitor

It is a hobby with me, one of many, there is never enough time. Did I say I also brew my own beer, recommended for any programmer, oils the brain.
I do keep my keg in a back fridge so I get exercise in getting a draft. I am an Aussie and beer is one of the main food groups

If you are wondering “TeeTwo” is the name of our Tibetan Terrier