# Solved: PHP Not displaying anything



## Firestone (Dec 24, 2006)

I have 2 php pages, one contains an html form, and another that queries an sql database, and gets the user's age. If I directly enter the name ("WHERE Name = 'Tyler'"), it works just fine, but if I use a variable, it doesn't display anything... here's the code for the first page:

```
<html>
<body>
<form action = "base3.php" method = "post">
First Name:<center><input type = "text" id = "name" /></center>
<br />
<br />
<center><input type = "submit" value = "Check Age" /></center>
</form>
</body>
</html>
```
And the code for the second page:


```
<?php
$name = $_POST['name'];
$con = mysql_connect("xxx", "xxx", "xxx");
if (!$con) {die("<b>Error!:</b> Could not connect to database.");}
mysql_select_db("uinfo");
$result = mysql_query("SELECT * FROM User WHERE Name = '".$name."'");

while ($row = mysql_fetch_array($result))
{
echo $row['Name'] . "'s age is: " . $row['Age'];
echo "<br />";
}
?>
```
Please help!


----------



## deepdiver01 (Dec 23, 2004)

HI Firestone.

Thats better.

BTW. You might want to change the password on the database just in case.

Sorry I haven't got an answer to your question though.

Deep


----------



## brendandonhu (Jul 8, 2002)

Your form field has no "name" attribute set, and user input should be run through mysql_real_escape_string() before using it.


----------



## Firestone (Dec 24, 2006)

That was the problem! I thought the XHTML standard was to use id instead of name. Why wouldn't that work the same? Oh well, the script works now and thats what I care about. Thanks.


----------



## brendandonhu (Jul 8, 2002)

[tsg=yourewelcome]yourewelcome[/tsg]


----------



## namenotfound (Apr 30, 2005)

Firestone said:


> That was the problem! I thought the XHTML standard was to use id instead of name. Why wouldn't that work the same? Oh well, the script works now and thats what I care about. Thanks.


The "name" attribute is allowed in , , , <a>,

I'm pretty sure that's all of them.


----------



## brendandonhu (Jul 8, 2002)

XHTML deprecated name in .


----------



## namenotfound (Apr 30, 2005)

brendandonhu said:


> XHTML deprecated name in .


Yes but it's still valid in Transitional and Frameset doctypes.


----------



## brendandonhu (Jul 8, 2002)

Then , , , , , , <img>, and should be in the list as well as they're also allowed in transitional 

Strict keeps name for everything except a, applet, form, frame, iframe, img, and map.


----------



## namenotfound (Apr 30, 2005)

brendandonhu said:


> Strict keeps name for everything except a, applet, form, frame, iframe, img, and map.


"name" in <a> *IS* valid in strict.


----------



## brendandonhu (Jul 8, 2002)

From the w3c:


> Finally, note that XHTML 1.0 has deprecated the name attribute of the a, applet, form, frame, iframe, img, and map elements, and it will be removed from XHTML in subsequent versions.


----------



## namenotfound (Apr 30, 2005)

W3.org uses the name attribute with the <a> tag on their site and it validates STRICT. Plus I asked them about it once and they said that yes the <a> tag allows the name attribute with Strict. Deprecated or not, the point I was making was that you more or less said that Strict doesn't allow name in <a> but it does.

This screen shot is from w3schools.com and it shows that the name attribute is valid under Strict.


----------



## brendandonhu (Jul 8, 2002)

Their DTD isn't always the same as the standard. This is going pretty offtopic so you can just use whatever you like, but the W3C still says it's deprecated 


> Note that in XHTML 1.0, the name attribute of these elements is formally deprecated, and will be removed in a subsequent version of XHTML.





> Finally, note that XHTML 1.0 has deprecated the name attribute of the a, applet, form, frame, iframe, img, and map elements, and it will be removed from XHTML in subsequent versions.


W3Schools gives the same list here: http://www.w3schools.com/xhtml/xhtml_syntax.asp


> In order to ensure that XHTML 1.0 documents are well-structured XML documents, XHTML 1.0 documents MUST use the id attribute when defining fragment identifiers on the elements listed above.


EDIT:


> W3.org uses the name attribute with the <a> tag on their site and it validates STRICT.


Someone asked them about that on their mailing list and they said that it was a mistake and would be fixed: http://lists.w3.org/Archives/Public/www-html-editor/2003JanMar/0014.html


----------



## namenotfound (Apr 30, 2005)

http://lists.w3.org/Archives/Public/www-html/2006Dec/0028.html



> in XHTML 1.0 Strict it's still perfectly ok in
> situations like these.





> I'm guessing they did this for backwards compatibility with browsers
> (and some assistive technologies) that still don't play ball with
> linking to fragment identifiers. Although the shape="rect" seems a bit
> useless to me.


So for the LAST TIME, it is ok to use the name attribute in <a> under XHTML 1.0 Strict.

If it was a "mistake" from 2003 (you linked to something from 2003) then why is it still allowed? Don't link to things so old.

Also, we weren't even talking about ID so why even bring it up?

I'm right about this, just like I was right about that CSS issue a few months ago that you wouldn't drop either.


----------



## brendandonhu (Jul 8, 2002)

> So for the LAST TIME, it is ok to use the name attribute in <a> under XHTML 1.0 Strict.


I didn't say it's not "ok", I said it's deprecated. Which it is, anyone can see that from the W3C site. Also, if you read the next post in the mailing list after the one you quoted, you can see they're disagreeing about the same thing we are: http://lists.w3.org/Archives/Public/www-html/2006Dec/0031.html



> I'm right about this, just like I was right about that CSS issue a few months ago that you wouldn't drop either.


When you said the site that's now in your signature wasn't yours, and edited Wikipedia to match your point? Bringing up threads from months ago isn't helping the thread starter any, you can PM or email me if you want to talk about something off-topic from months ago.


----------



## namenotfound (Apr 30, 2005)

brendandonhu said:


> I didn't say it's not "ok", I said it's deprecated. Which it is, anyone can see that from the W3C site. Also, if you read the next post in the mailing list after the one you quoted, you can see they're disagreeing about the same thing we are: http://lists.w3.org/Archives/Public/www-html/2006Dec/0031.html





brendandonhu said:


> *Strict keeps name for everything except* a, applet, form, frame, iframe, img, and map.


That's the same thing as saying "name is allowed in all except for the following in Strict"

So you did say, in your own way, that name in <a> is not allowed in Strict. And later when I tried saying "deprecated or not, it's still allowed" you once again tried to tell me it wasn't.

Now stop trying to twist thing around so you make it seem like you're "absolutely right" like you always do.


----------



## brendandonhu (Jul 8, 2002)

> So you did say, in your own way, that name in <a> is not allowed in Strict.


I didn't say that. Feel free to use an actual quote, instead of making something up and saying that I "said it in my own way."


----------



## namenotfound (Apr 30, 2005)

Umm.... THAT was the exact quote. "Strict keeps name for everything except"

If you can't see how it's the same as saying "all except for the following are allowed" then you must have failed English class in highschool.


----------



## brendandonhu (Jul 8, 2002)

namenotfound said:


> Umm.... THAT was the exact quote. "Strict keeps name for everything except"


And that's true...strict keeps everything except the ones I listed. It deprecates the ones in the list. I'm going to stop repeating myself though, since anyone interested in the answer should understand it by now


----------



## JohnWill (Oct 19, 2002)

namenotfound, if you have nothing to contribute to the topic of the thread, please refrain from posting.


----------



## namenotfound (Apr 30, 2005)

JohnWill said:


> namenotfound, if you have nothing to contribute to the topic of the thread, please refrain from posting.


I contributed this

http://forums.techguy.org/web-development/545275-php-not-displaying-anything.html#post4460151

As you can see it was helpful in the fact that it points out that "name" is valid in <a>

If other members then decided to challenge me on this issue, it's not my fault.


----------

