<?php
echo "PHP Script (test)";
$fileName = "updatelist.txt";
$names = file($fileName);
$numOfNames = count($names);
echo $numOfNames;
for ( $i=0; $i<$numOfNames; $i++ )
{
echo "test of loop";
echo $names[$i];
}
fclose($read);
?>
<form name="hitlist" action="updatelist.php" method="post">
<input type="text" name="hitname" />
<input type="submit" name="add" value="Add to List" />
</form>
🔒 Locked
🤖 Godot
[web] Troubles with PHP
Advertisement
Original Post
I have started programming with PHP, and have had a problem with this bit of code: As you can see, it is a PHP script and a form in a CSS div (I included the part about the form and CSS in case they have to do with the problem). Basically, none of the text shows up when the script is run, even the "echo" which is at the very beginning of the script, no matter what. This makes be believe that the script is not executing at all. I don't think it is a problem with the server, however, because the PHP script associtated with the form works perfectly. Any ideas as to what is causing this?
Have you tried executing it from the command line? Have you checked the server error logs?
It's not my server, so I don't really think I have the option of doing that ('course I could just set up a server on my comp in order to check this kind of thing, but...). Anyway, the one I'm using will tell me of any error-errors (in other scripts when I miss a semi-colon or put an extra character somewhere, for example), so I don't think there are any of that kind of errors. Don't know much about servers though, I could be wrong.
Does the section of script run on its own without he rest of the HTML present?
Quote:You can just download the PHP binaries from their site and run it from the command-line. No tricky setup necessary. It's a good idea, though, because it will let you know if you attempt to do bad things that would normally not be reported by the web module. Most web hosts will disable error reporting to avoid possible security risks, and if you don't have access to the web server logs, you are out of luck.
Original post by NewbJ
It's not my server, so I don't really think I have the option of doing that ('course I could just set up a server on my comp in order to check this kind of thing, but...).
Like some people suggested doing in the last serious sql injection in phpbb. Some people were lazy and had people using their prehacked boards just disable the warning messages. :-/
I released a patch for the one I work on :).
I might test the script out later and see if it does anything, but it looks fine right now without running it.
I released a patch for the one I work on :).
I might test the script out later and see if it does anything, but it looks fine right now without running it.
Ok, I've made a few modifications to the script syntax (I found a few errors when I looked more closely) and took it out of the context of the HTML document (put it into a .php file). It worked. When it's in the HTML document, however, it doesn't work. Any ideas on what's causing this?
If you had the extension on the html document as anything but php, php3, php4, php5, phtml, or any of the other php extensions it won't work.
Quote:
Original post by Edward Ropple
On my own server, I've begun routing all html extensions through PHP as well.
Makes it a lot easier.
yeah, it does, but doesn't it put more strain on the server because it has to parse every requested file (on the server, with the html extension) for php code, right?
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement