PHP newbie
Moderator: General Moderators
PHP newbie
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?
<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
Thursday October 23, 2008
your code works in my computer.
try to change your php tag to
if this works, you should open short tag in php.ini.
your code works in my computer.
try to change your php tag to
Code: Select all
<?php print(Date("l F d, Y")); ?>Re: PHP newbie
That seems to do the trick. Thank you.
Re: PHP newbie
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
Code: Select all
$result = mysql_quesry($sql);Re: PHP newbie
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 
Re: PHP newbie
Code: Select all
echo("<b>Query executed successfully!</b>");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.
Re: PHP newbie
You sure about that?scottayy wrote:You're missing a } after that line.Code: Select all
echo("<b>Query executed successfully!</b>");