October 16th, 1999, 04:44 PM
I currently run a Perl banner exchange but I am looking to convert it to PHP3 and MySQL. My only problem is all the members have code which points to a .cgi file.
How can I get it so that just this one CGI file will be checked by the PHP parser? Either that or somehow get the CGI file to check a MySQL database, or PHP3 file.
Also how can I get all .html files checked?
I am running on a servers with about 2 hundred websites on it.
October 18th, 1999, 12:36 AM
This might be a strange thought, but how about a simple workaround: Make a DIRECTORY with the same name as the .cgi file that the code points to. Then use an index.php3 file of that directory for your PHP code. You will have to make sure that Apache's (or whatever webserver) configuration file makes an index out of .php3 files, and your users will never know the difference:
You're gonna love working with PHP with MySQL.
October 18th, 1999, 12:47 AM
To get all .html files checked by the PHP parser, you simply need to edit httpd.conf (again I am assuming Apache) and add .html to the PHP3 configuration area:
AddType application/x-httpd-php3 .php3 .phtml (you would add .html)
I would recommend you think carefully about doing this, though, because it makes PHP parse *every* web page on your site, whether its got PHP code or not, which will put a big load on your processor. And if this is a global configuration file, then PHP will have to parse every page on all 200 sites. I don't know an easy answer to this one.
October 18th, 1999, 04:01 PM
That thing about having it as a directory index is a good idea, I currently use lots of .htaccess files to make sure the correct file is shown for the index, I just hope the extension won't confuse it. I recently updated the code and used exactly this trick so that I could use what ever technology I wanted.
I doubt I will be able to get the .html files through the parser because I don't run the server. I read somewhere that search engines don't always index .php3 files, and I was going to make it so that .htm was pure html and .html would be php3 files.
October 18th, 1999, 04:37 PM
Maybe I'm missing part of the problem but wouldn't a simple redirect statement in Apache's httpd.conf file do the trick? This is what I did when I replaced a .cgi with a .php3 and it worked perfectly.
October 18th, 1999, 11:17 PM
You are so correct sir... a simple redirect, the obvious solution. But you've got to admit my idea was kinda fun, and it might have its uses.
Lemming -- find out if your server can parse server-side includes in regular .html files (instead of only .shtml files) then you can call your .php3 scripts INTO your .html files and the search engines will be none the wiser.
October 19th, 1999, 01:02 PM
OK, so have can get round my original problem either way, but I now have a new problem - I want to read and write text files using PHP3. This is only temporary, and I know how to access MySQL using perl, but that needs my hosting company to upgrade something, and they are not that fast at responding to requests like this.
So, can you access (existing) text files using PHP3?
October 19th, 1999, 01:29 PM
Yes you can, check out the file system functions in the manual:
October 19th, 1999, 03:19 PM
Thanks. I had looked for the same on devshed but I was sure I couldn't find anything (even if it was right under my nose). Anyway, they have dead links, and so do devshed, but I had the old manual pages bookmarked. Now I should hopefully be able to get this working :-)
October 19th, 1999, 04:28 PM
OK, those could do with being alot cleared. For instance when you are told that the code for an arrar is
it isn't too helpful. Might be OK if you know the language, but if you know the language you don't need it.
Anyway, can anybody see the problem in this code:
$lemnet = file(string german.txt);
the german.txt file exists and is in the same directory as the php file.
October 19th, 1999, 06:58 PM
Remove "string" from
$lemnet = file(string german.txt);
so it looks like this
$lemnet = file(german.txt);
October 20th, 1999, 05:38 AM
October 20th, 1999, 07:17 AM
In the manual where you see something like:
it is saying that function_name takes a string as an argument and returns an integer, so you'd write it like this:
$some_integer_variable=function_name('some string constant');
October 23rd, 1999, 09:25 AM
Rod K: Thanks, that helped a bit.
My problem now is that I can't find anyway to get a value from an array. I have tried $name, @name, $name(0) and many others, bot nothing seems to work and I can't find any mention of it in the manual (despite an entire section for arrays).
October 25th, 1999, 07:36 AM
Well, that's really not enough information to solve your problem. Arrays are referred to with brackets, i.e. $name so that is correct. When you say it doesn't work do you mean you are getting an error, you don't get the value you expect, what?
print $name; // prints "Hillary"
print $name; // prints "Bill"
print $name[jerk]; // prints "Bill"