[HELP] Is there something wrong with this PHP code?
#1

Right. So I'm pretty much a noob when it comes to PHP. I've only just decided to be assed to learn it, and so I started with the basic "copying and typing it out and trial and error". Obviously, I had errors, I looked back at the TKAdmin PHP code to see how the creator defined 'FORUMURL' and though "Well. PHP isn't as hard as I thought" and decided to copy it.

Now, it's a little... Noobish, and some of you would probably laugh at the way I did it.. But, heres the code.

Код:
<?php
if(!defined ('FORUMURL'))
{
  define('FORUMURL', 'http://www.siliconrp.net63.net');
}

echo "<h1>Hello World!</h1>";
if(defined("FORUMURL")) echo "<li><a href='FORUMURL'>Forums</a></li>"; else echo "<p>&nbsp;</p>";


?>
Now, (I'm using WeBuilder), and in 'preview' mode it outputs "Not Found".

Any help appreciated, and +rep given.
Reply
#2

Is it displaying HTTP 404 error?
I'm not familiar with WeBuilder but try accessing it over your browser over address "http://localhost/scriptname.php".
Script itself seems fine although there are easier ways to do it.
Reply
#3

Quote:
Originally Posted by JiHost
Посмотреть сообщение
Is it displaying HTTP 404 error?
I'm not familiar with WeBuilder but try accessing it over your browser over address "http://localhost/scriptname.php".
Script itself seems fine although there are easier ways to do it.
Its runs off PHP.exe so Apache is not needed via XAMPP
Reply
#4

It should be this:

PHP код:
<?php
if(!defined ('FORUMURL'))
{
  
define('FORUMURL''http://www.siliconrp.net63.net');
}
echo 
"<h1>Hello World!</h1>";
if(
defined("FORUMURL")) echo "<li><a href=".FORUMURL.">Forums</a></li>"; else echo "<p>&nbsp;</p>";
?>
You cannot display defines inside quotes.
Reply
#5

Quote:
Originally Posted by Pinguinn
Посмотреть сообщение
It should be this:

PHP код:
<?php
if(!defined ('FORUMURL'))
{
  
define('FORUMURL''http://www.siliconrp.net63.net');
}
echo 
"<h1>Hello World!</h1>";
if(
defined("FORUMURL")) echo "<li><a href=".FORUMURL.">Forums</a></li>"; else echo "<p>&nbsp;</p>";
?>
You cannot display defines inside quotes.
Ah. Thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)