PHP newbie

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
s10jam
Forum Newbie
Posts: 4
Joined: Thu Oct 23, 2008 1:19 am

PHP newbie

Post by s10jam »

I thought I had PHP setup correctly. It displays correctly when I browse to a page I wrote here:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<p>This is an HTML line
<p>
<?php
echo "This is a PHP line";
phpinfo();
?>
</body>
</html>

But when I use the one below, or many others like it, the content does not display. The page title does, but the body is blank.

<html>

<head>
<title>DATE</title>
</head>
<? print(Date("l F d, Y")); ?>

<body>
</body>
</html>


Any ideas?
mini4
Forum Newbie
Posts: 4
Joined: Thu Oct 23, 2008 1:17 am

Re: PHP newbie

Post by mini4 »

Thursday October 23, 2008

your code works in my computer.

try to change your php tag to

Code: Select all

<?php print(Date("l F d, Y")); ?>
if this works, you should open short tag in php.ini.
s10jam
Forum Newbie
Posts: 4
Joined: Thu Oct 23, 2008 1:19 am

Re: PHP newbie

Post by s10jam »

That seems to do the trick. Thank you.
s10jam
Forum Newbie
Posts: 4
Joined: Thu Oct 23, 2008 1:19 am

Re: PHP newbie

Post by s10jam »

Now I'm having the same issue with this one. It's from the PHP & MySQL for Dummies book. I get the same thing. Title works, but page is blank.

Code: Select all

 
<html>
<head>
<title>Test MySQL</title>
<body>
<!-- mysql_up.php -->
<?php
$host="localhost";
$user="thatguy";
$password="1234";
 
mysql_connect($host,$user,$password);
$sql="show status";
$result = mysql_quesry($sql);
if ($result == 0)
    echo("<b>Error " . mysql_errno() . ": " . mysql_error() . "</b>");
elseif (mysql_num_rows($result) == 0)
    echo("<b>Query executed successfully!</b>");
else
{
?>
<!-- Table that displays the results -->
<table border="1">
    <tr><td><b>Variable_name</b></td><td><b>Value</b></td></tr>
    <?php
        for ($i = 0; $i < mysql_num_rows($result); $i++) {
            echo("<TR>");
            $row_array = mysql_fetch_row($result);
            for ($j = 0; $j < mysql_num_fields($result); $j++) {
                echo("<TD>" . $row_array[$j] . "</td>");
                }
                echo("</tr>");
        }
    ?>
</table>
<?php } ?>
</body>
</html>
 
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP newbie

Post by requinix »

Code: Select all

$result = mysql_quesry($sql);
Do yourself a favor: go into your php.ini file and turn on the display_errors setting.
s10jam
Forum Newbie
Posts: 4
Joined: Thu Oct 23, 2008 1:19 am

Re: PHP newbie

Post by s10jam »

Aha! Thank you. Found that mysql.so wasn't enabled. That should help me resolve some of these errors myself now in the future. Should have thought of that :oops:
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: PHP newbie

Post by s.dot »

Code: Select all

echo("<b>Query executed successfully!</b>");
You're missing a } after that line.

Glad you figured out how to display errors :)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP newbie

Post by requinix »

scottayy wrote:

Code: Select all

echo("<b>Query executed successfully!</b>");
You're missing a } after that line.
You sure about that? :|
Post Reply