[thelist] PHP includes/comparing string values

Andrew Forsberg andrew at thepander.co.nz
Mon Mar 4 04:12:00 CST 2002


>I've set 666 permission on the .inc file and both files live in the same
>directory. What seems to be happening when I run index.php is that the
>include file gets overwritten with nothing (EVEN IF I CHANGE IT'S VALUE
>TO NOT EQUAL $checkval) AND index.php never includes thefile.inc no
>matter what. I'm half way to insane here! Thanks for reading.

Hi,

That would be because $content is NULL. NULL won't be equal to your
$checkval string, or not equal to it. Try separating the code to do
with reading the file from the rest, and make sure that works
properly first.

The filemode used with fopen(), "w" is write only, so fread() isn't
going to return any value... except NULL. Try using "r+" instead --
that opens the file for reading and writing, and puts the pointer at
the start of the document. Once the file is read you'll need to do a
little more fiddling in order to write over the top of it again, but
the docs should help, otherwise just shout out here! :)

Here are the fopen() docs:
http://www.php.net/manual/en/function.fopen.php

Cheers
Andrew
--



More information about the thelist mailing list