Jump to content

What is wrong with this code?


jwilh

Recommended Posts

I switched over to yahoo hosting and alot of the php I was using elsewhere now no longer works, if someone could take a look and tell me any problems they see that would be nice!
[code]<?php
echo date("4 November 2006");
echo "<br>";
  $d=date("D");
  if ($d=="Fri")
echo "Have a nice weekend!";
    else
echo "Have a nice day!";
echo "<BR>";
?>

<p style="color:White">
<div ALIGN=CENTER><h3><?php
if (isset($_POST['name'])) echo "
Welcome <B>$_POST[name] !</B>\n";
?></p></div></h3>[/code]
Link to comment
https://forums.phpfreaks.com/topic/26185-what-is-wrong-with-this-code/
Share on other sites

Your Problem lies in...

if (isset($_POST['name'])) echo "
Welcome <B>$_POST[name] !</B>\n";

change that to

[code]
if (isset($_POST['name'])){
echo "
Welcome <B>$_POST[name] !</B>\n";
};
[/code]


You are missing the { } that surround the echo!
you don't need brackets when you only have one statement after your IF

if ($blah)
  echo "yep";
else
  echo "nope";


jwilh, are you getting any errors whatsoever
if not put this line at the top of your script
error_reporting(E_ALL);

and if it's not errors you get
What not working the way you want it to

and the first and only thing I see wrong with your code so far is this
echo date("4 November 2006");

it should be
echo date("d M Y", strtotime("4 November 2006"));

which is pointless cuz you might as well just say
echo "4 November 2006";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.