News:

The Toadfish Monastery is at https://solvussolutions.co.uk/toadfishmonastery

Why not pay us a visit? All returning Siblings will be given a warm welcome.

Main Menu

Basic php html total idocy banging head against brickwall question

Started by Griffin NoName, April 13, 2008, 02:15:38 AM

Previous topic - Next topic

Griffin NoName

Forgotten where this sort of stuff is supposed to go.

Some other Admin move it to another board - wherever.

I am quietly going mad.

I have been trying to write the simplest of simple thing and it simply wont work.

I think I may have alzheimers or perhaps something more subtle where the contents of my head get knotted when copying from window to window.

I have googled the entire internet and followed every variant method of doing the simple thing and none of it ever works.

SOMEONE help me before I kill myself.

Here's the problem, well it's not a problem, it's so simple it cant be a problem.

display something that is known on the screen.

there - that does sound simple doesn't it?

for one reason or another I can't.

it is known in php and I need to display it using html via a program.htrml type file

program.html
~~~~~~~~~
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
bla
bla
bla
<?php
$thisstupidthing = "Hallo World" ;
?>
bla
bla
</head>
<form>
<input type="text" name="halloworld" value="<?php echo $thisstupidthing; ?>" >
</form>
</html>

"value" doesn't work

ie. what is displaye is   <?php echo $thisstupidthing; ?>     and not    Hallo World


neither does  value=?thisstupidthing;


or value="$thisstupidthing";

neither does any other more complex form of prgramming I can come up with


(obviously the php is not really as simple as thisstupidthing=halloworld but that is what I have been reduced to.).

I don't dare put this problem on any support bulletin boards. You should see the answers one gets !!  Not nice I can tell you.

And I've read them all.

And even the ones that include answers as well as inuslts don't solve my problem.

I've tried everything every single person on the internet has ever advised trying.

:headbang: :headbang: :headbang: :headbang: :headbang: :headbang: :headbang: :headbang:

Please don't laugh at me when you tell me the answer.

Where is the smilie for committing suicide by programming?
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


Bob in a quantum-state-of-faith

So, you're basically wanting an input box, to display a default value?

Looks like you're using a variable? 

And you want the return value of the input box to be put back into the variable?

Does not HTML code have a default value setting? 

(been years, I don't remember exactly.)

But sometimes explaining it to someone has helped me in the past, with programming issues.

And, no, I'm NOT laughing!  I've done the same sorts of things, myself.

Sometimes, the real journey can only be taken by making a mistake.

my webpage-- alas, Cox deleted it--dead link... oh well ::)

Bob in a quantum-state-of-faith


You used:
<input type="text" name="halloworld" value="<?php echo $thisstupidthing?>" >

Try this:


<input type="richtext" name="wordpadeditor">
<b>This <i>is</i> so cool man</b>
<table><tbody><tr><td>....</td></tr></tbody></table>
Finally, this is a REAL browser
</input>


Note the opening and closing of the INPUT TAG.

This permits other tags to exist between the beginning and end of the Input box.

Does this help in any way?
Sometimes, the real journey can only be taken by making a mistake.

my webpage-- alas, Cox deleted it--dead link... oh well ::)

Griffin NoName

Sorry, don't see how the example relates to the problem - yes your first post was right, I think, yes I want to display the variable already showing in the input box, but the html doesn't seem to recognize it as a variable... it treats it as text. How would you put the variable into your example?

It should display the content of thisstupidthing and therefore display     Hallo World

By the way, I have checked stuff like php order is EGPCS and server global variables are ON which are soome of the more utterly obscure reasons for this type of problem.

I have very little hair left now.

I am eating myself from the outside inwards aaaaaaaaaaar!


edit
ah like you mean putting the <?php as separate tagging - yes I see now - I'll see if it makes any difference
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


Griffin NoName

Um no actually I still don't see - ignore my edit - the value bit can't go seperately - so I don't see how to use your example ???
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


Bob in a quantum-state-of-faith


Assume:
<?php
$thisstupidthing 
"Hallo World" ;
?>



You used:
<input type="text" name="halloworld" value="<?php echo $thisstupidthing?>" >

What about:

<input type="richtext" name="wordpadeditor">

value=
<?php
 
echo $thisstupidthing
?>


</input>


Note that I left out the quotes around the PHP code segment, you already declared it as STRING, so they shouldn't be needed?
Sometimes, the real journey can only be taken by making a mistake.

my webpage-- alas, Cox deleted it--dead link... oh well ::)

Griffin NoName

Doesn't like the value on a separate line - it "prints" value .... on the screen !!

I have discovered the problem is not just to do with the <input> tag.

The html does not recognise the variable as a variable in other types of tags either.

This is so basic - it is really odd.
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


Bob in a quantum-state-of-faith

Okay, the syntax is likely not the HTML, then, but in the PHP code itself.

It may be that a tag is missing at the very top of your page, specifying that it contains PHP code?

I remember, back when I was coding a mixed HTML and BASIC pages, that you had to specify what was BASIC, what it was, what was on the server-side and what was on the user-side of the page.

For some reason, your browser is not parsing the PHP segment properly...but then, you figured that out already, yes?  :)
Sometimes, the real journey can only be taken by making a mistake.

my webpage-- alas, Cox deleted it--dead link... oh well ::)

Bob in a quantum-state-of-faith

#8
Okay, I think I found the problem.

PHP uses {} as delimiters, not <>

Try this:
[code]
{?php
$thisstupidthing = "Hallo World" ;
?}
bla
bla
</head>
<form>
<input type="text" name="halloworld" value="{?php echo $thisstupidthing; ?}" >


Okay, that's not right, but the following from here may prove useful:

<?php
$beer 
'Heineken';
echo 
"$beer's taste is great"// works; "'" is an invalid character for variable names
echo "He drank some $beers";   // won't work; 's' is a valid character for variable names
echo "He drank some ${beer}s"// works
echo "He drank some {$beer}s"// works
?>


So, your example would parse out to:

<input type="text" name="halloworld" value="<?php echo {$thisstupidthing}; ?>" >
[/code]
Sometimes, the real journey can only be taken by making a mistake.

my webpage-- alas, Cox deleted it--dead link... oh well ::)

Griffin NoName

I think your previous guess is probably more likely right.

I've been mucking around with the php, moving it about, and checking all the php server settings.

Also, stuff like checking it is being used like in other files that do work etc.

But.... hmmm, of course I may have missed something.

I've just done some more tests on the php bit and I don't think it is being parsed at all !!

======

Re your second post, the <?php ?> is standard in html files.

It ought to work inside <?php ?> tags with or without {} - and indeed I had already tested {} with no results.

============

<sigh>
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


Bob in a quantum-state-of-faith

#10
Did you see my final modified code?

The original <> codes, but some {} included in the usage of the variable.


Here:
<input type="text" name="halloworld" value="<?php echo {$thisstupidthing}; ?>" >

Notice the {} around the use of the variable $thisstupidthing.
Sometimes, the real journey can only be taken by making a mistake.

my webpage-- alas, Cox deleted it--dead link... oh well ::)

Griffin NoName

Yes I did. Thanks ! Ordinary brackets don't work either.

It displays <?php

It really does seem that your first bet is right.

As far as I can tell the php is not setting the variable at all, so whatever I do in the html fails.

I cannot see why the php doesn't set the variable.

wits end.
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


Griffin NoName


Ok

restating the question so as to be clear after all that above

example as in first post

problem

php does not seem to set the variable thisstupidthing to contain   Hallo World

therefore whatever I do in html    using  the variable  thisstupidthing   Hallo World never gets displayed

why wont php set the variable?
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


Bob in a quantum-state-of-faith

Try this:


<?php
$beer 
'Heineken';
?>



Note the single-quotes
Sometimes, the real journey can only be taken by making a mistake.

my webpage-- alas, Cox deleted it--dead link... oh well ::)

Griffin NoName

Nope. No difference.

I've tried javascript now, instead of php, to set the variable.

No dice.

And of course, I've tried displaying the content of $thisstupdthing within the "scripts". There's nothing in it.

I'm beginning to think it must be when the code executes.

Except that doesn't explain how setting it and displaying it on the next code line within the same script fails.

Everything I've ever read says this should work. ie. you put the script in the <head> section. then the html in the <body>.

And in any case I'ver tried putting the scripts in other places.

Beyond wits end.
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


Bob in a quantum-state-of-faith

I'm sorry-- I'm at a loss, as I never actually coded in php before.  I used vba scripts, back in '02.

All I can say is review PHP syntax.

This seems to be straightforward: http://www.php.net/manual/en/language.types.string.php
Sometimes, the real journey can only be taken by making a mistake.

my webpage-- alas, Cox deleted it--dead link... oh well ::)

Griffin NoName


Yup, tried all that.

It really does seem that the php (or javascript) is just not working.

The simplest set variable --- echo/print/document.write - produces nothing on screen let alone the later html displaying it.

It seems bizarre.
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


beagle

I'm an ASP.NET rather than php person, so you may want to disregard this:

Isn't it just that you've called it program.html instead of program.php, so Apache/IIS doesn't know from the file extension it is supposed to invoke the php engine on it?

The angels have the phone box




Griffin NoName

Possibly although from what I've read it appears to be that it doesn't actually matter what the file extension is. And certainly the javascript ought to work even if the php doesn't.

In any case, I am stuck with the html extension - it's not "created" by me, its' part of a package and it's the file one is told to "alter for such stuff.

Of course, I could alter the package to suit, but that means nasty stuff every time an upgrade is issued.

I've already hiked the php that HAS to be done elsewhere into a separate (additional) file which does have a php extension and which is the advised method of passing stuff into the html code via an "include".

Nope, it does not make sense.

My latest thoughts are taking me down the path of passing stuff through the html without involving any screen display - that seems to work because I am not fiddling with "thisstupidthing" but just dumping it to the next program in the chain - which is a php file.

I still believe there must be a way, but I have no more time to waste on it.

I hate it when a computer beats me.
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


beagle

This Javascript way works for me on Vista/IE7


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<html>
<head>
bla
bla
bla
<script type="text/javascript">
var stupidthing="Hello World";
</script>
</head>
<body>
<form>
<input type="text" id="helloworld"></input>
<script type="text/javascript">
document.getElementById("helloworld").value=stupidthing;
</script>
</form>
</body>
</html>


Wouldn't like to guarantee it anywhere else, and it's probably important that the setting Javascript is after the input definition.
The angels have the phone box




Griffin NoName

Yep, I almost had that at one point...... thanks.

I reckon it would work for me too. In fact I reckon all the combinations I tried would have worked for me altogether.

IF somehow all the execute permissions on the program files hadn't been messed around with !!!!!!!!!!!!!!!!

I'd only checked and set them all on Friday............... silly to assume a few hours later they will still all be ok............. obviously I need to check them every few hours......... that should fill up any spare time I have awake.

Whole directory fulls had got their execute permission unset. Presumably early on Saturday.

Thank goodness just now I was running my new solution which used a completely different pair of programs and it was perfectly obvious the file was "missing" - ie. not getting executed at all. It sort of nudged me beyond the this code isn't working mindset into this whole thing isn't working mindset. It wasn't at all obvious from the file with what I thought was a coding problem. And I wasn't looking cos I had checked the permissions Ha Ha Ha bloody Ha.

I am NOT happy with this new HOSTing co. but then I think I have mentioned that before.


Sorry to have wasted everyone's time on top of my own.


:blush:
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


Bob in a quantum-state-of-faith

Quote from: Griffin NoName on April 13, 2008, 08:58:59 PM
Sorry to have wasted everyone's time on top of my own.

:blush:

Wasted?  I wouldn't say that.

A lesson was learned.  I, for one, was intrigued and learned a bit about PHP, of which I knew nothing previously.

Next time, you, knowing what you know NOW will check the permissions/settings first, any time you have a problem.

I wouldn't call that a waste. 

Frustrating as Perdition, :headbang:  but not a waste--just so long as you don't actually :explode:

:mrgreen:
Sometimes, the real journey can only be taken by making a mistake.

my webpage-- alas, Cox deleted it--dead link... oh well ::)

Griffin NoName

Well, next time I'll be paranoid is what you mean.

Because I don't really expect permissions to unset themselves to quite that extent in quite that little time. Like I had checked them. I'd moved on to the next thing to check.

They'd even unset permissions on a system I wasn't working on at all. Which meant that anyone trying to use it wouldn't have been able to. Luckily hardly anyone uses my systems :ROFL:

I guess if they did I'd have to pay more for Hosting !

Um.

Oh dear.

I've just offered to Host a forum for West London ME sufferers. Surprising number of them there are too.

What with this Hosting co. of mine saying they delete any old files they think are too old without warning ..... and the fact that I have also found out that they've disabled half the cpanel functions.... I think I need to find a better hosting co. and pay more....  I heard there's some good hosting being developed in Toadfish land..........

The message you get on all the cpanel options they've disabled is
contact them to get it enabled

When you do, they don't respond.

Eventually - after weeks of repeat requests and no replies - I rang them in the US -

They told me they wouldn't ever be enabling them.... they've stopped supporting them...

I asked them if they got a lot of phone calls like mine....

They said Yes They Did.

I think unsetting permissions may be their way of controlling traffic :mrgreen:

I know, I know, cheap hosting, you get what you pay for.... <sigh>
Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


beagle

Quote from: Bob in a quantum-state-of-faith on April 13, 2008, 09:27:49 PM
A lesson was learned. 

Exactly. In future you'll blame everyone else first, and only admit it might possibly be less than optimal behaviour in your coding as a last resort.
The angels have the phone box




Griffin NoName

Psychic Hotline Host

One approaches the journey's end. But the end is a goal, not a catastrophe. George Sand


Sibling Zono (anon1mat0)

In all fairness, while in development a programmer will look to his own code as faulty first, but once the code is working for him he will blame the environment (everything else) first.
Sibling Zono(trichia Capensis) aka anon1mat0 aka Nicolás.

PPPP: Politicians are Parasitic, Predatory and Perverse.

beagle

The angels have the phone box