Page 1 of 1

PHP newbie

Posted: Thu Oct 23, 2008 1:24 am
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?

Re: PHP newbie

Posted: Thu Oct 23, 2008 1:32 am
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.

Re: PHP newbie

Posted: Thu Oct 23, 2008 1:51 am
by s10jam
That seems to do the trick. Thank you.

Re: PHP newbie

Posted: Mon Oct 27, 2008 10:16 pm
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>
 

Re: PHP newbie

Posted: Mon Oct 27, 2008 10:56 pm
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.

Re: PHP newbie

Posted: Mon Oct 27, 2008 11:07 pm
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:

Re: PHP newbie

Posted: Tue Oct 28, 2008 12:59 am
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 :)

Re: PHP newbie

Posted: Tue Oct 28, 2008 1:25 am
by requinix
scottayy wrote:

Code: Select all

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