php-windows Digest 12 Oct 2003 23:06:55 -0000 Issue 1953
Topics (messages 21760 through 21765):
Re: I can't make a 'read_tag.php' file
21760 by: Bas
21761 by: Bas
Fast template engines
21762 by: Donatas
PHP uninstall/reinstall
21763 by: Benjamin Howarth
21764 by: Shadow
Re: Subject: selecting and updating fields
21765 by: Neil Smth
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[EMAIL PROTECTED]
----------------------------------------------------------------------
--- Begin Message ---
The output of the function is:
Length = 160
Of Tag = 14
Of Str = 115
Of End = 31
TagData:
I am myself!! This is a test!!! Welcome!!! Closing!!! I am myself!! This is
a test!!! Welcome!!!
"Bas" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I have found that this script doesn't work:
>
> read_tag.php
>
> ---
> <?php
>
> function readTag($filename, $tagtype, $debug = 0) {
> $filedata = file_get_contents($filename);
> $tagrealname = "<bttag=";
> $tagrealname .= $tagtype;
> $tagrealname .= ">";
>
> $tagdata = stristr($filedata, $tagrealname);
> $posofend = strpos($tagdata, "</bttag>");
> $length = strlen($tagdata);
> $lengthoftag = strlen($tagrealname);
> $lengthofend = strlen("</bttag>");
> $lengthofstr = $length - $posofend - $lengthoftag;
> $returndata = substr($tagdata, $lengthoftag, $lengthofstr);
> if ($debug == 1) {
> echo "<br>Length = " . $length;
> echo "<br>Of Tag = " . $lengthoftag;
> echo "<br>Of Str = " . $lengthofstr;
> echo "<br>Of End = " . $posofend;
> echo "<br>TagData:<br>" . $tagdata;
> }
> return $returndata;
> }
> ?>
>
> <HTML>
> <BODY>
> <h1>Test readTag-functie</h1>
> <?php echo readTag("test.tag", "bassie", 1); ?>
> </body>
> </html>
>
> ---
> And with this, it needs the file 'test.tag'
> ---
> <bttag=bassie>
> I am myself!!
> </bttag>
> <bttag=test>
> This is a test!!!
> </bttag>
> <bttag=welcome>
> Welcome!!!
> </bttag>
> <bttag=close>
> Closing!!!
> </bttag>
> ---
> The first parameter of the readTag function is the filename of the tag
file.
> The second is the tag to search for an the third is the debug mode.
>
> The error is that if i load this, the readTag function returns everything
> except for the Closing!!!
>
> What's wrong?
--- End Message ---
--- Begin Message ---
And the HTML output is:
<HTML>
<BODY>
<h1>Test readTag-functie</h1>
<br>Length = 160<br>Of Tag = 14<br>Of Str = 115<br>Of End =
31<br>TagData:<br><bttag=bassie>
I am myself!!
</bttag>
<bttag=test>
This is a test!!!
</bttag>
<bttag=welcome>
Welcome!!!
</bttag>
<bttag=close>
Closing!!!
</bttag>
I am myself!!
</bttag>
<bttag=test>
This is a test!!!
</bttag>
<bttag=welcome>
Welcome!!!
</bttag>
<bttag</body>
</html>
"Bas" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> The output of the function is:
>
>
> Length = 160
> Of Tag = 14
> Of Str = 115
> Of End = 31
> TagData:
> I am myself!! This is a test!!! Welcome!!! Closing!!! I am myself!! This
is
> a test!!! Welcome!!!
> "Bas" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > I have found that this script doesn't work:
> >
> > read_tag.php
> >
> > ---
> > <?php
> >
> > function readTag($filename, $tagtype, $debug = 0) {
> > $filedata = file_get_contents($filename);
> > $tagrealname = "<bttag=";
> > $tagrealname .= $tagtype;
> > $tagrealname .= ">";
> >
> > $tagdata = stristr($filedata, $tagrealname);
> > $posofend = strpos($tagdata, "</bttag>");
> > $length = strlen($tagdata);
> > $lengthoftag = strlen($tagrealname);
> > $lengthofend = strlen("</bttag>");
> > $lengthofstr = $length - $posofend - $lengthoftag;
> > $returndata = substr($tagdata, $lengthoftag, $lengthofstr);
> > if ($debug == 1) {
> > echo "<br>Length = " . $length;
> > echo "<br>Of Tag = " . $lengthoftag;
> > echo "<br>Of Str = " . $lengthofstr;
> > echo "<br>Of End = " . $posofend;
> > echo "<br>TagData:<br>" . $tagdata;
> > }
> > return $returndata;
> > }
> > ?>
> >
> > <HTML>
> > <BODY>
> > <h1>Test readTag-functie</h1>
> > <?php echo readTag("test.tag", "bassie", 1); ?>
> > </body>
> > </html>
> >
> > ---
> > And with this, it needs the file 'test.tag'
> > ---
> > <bttag=bassie>
> > I am myself!!
> > </bttag>
> > <bttag=test>
> > This is a test!!!
> > </bttag>
> > <bttag=welcome>
> > Welcome!!!
> > </bttag>
> > <bttag=close>
> > Closing!!!
> > </bttag>
> > ---
> > The first parameter of the readTag function is the filename of the tag
> file.
> > The second is the tag to search for an the third is the debug mode.
> >
> > The error is that if i load this, the readTag function returns
everything
> > except for the Closing!!!
> >
> > What's wrong?
--- End Message ---
--- Begin Message ---
Can someone recommend me some really fast template engine? I am making
my own template class and I would like to test it's speed against some
best template engines out there. So far mine is way faster than Yapter
(about 8 times) and just a little bit faster than Smarty (about 1.2 times).
Donny
PS. tests were made by doing some big loops to make a table so it
doesn't cover all aspects, only the main one.
--- End Message ---
--- Begin Message ---
Hi all, am a newbie to PHP so please spell your answers to my questions out
in words of one syllable or less...
I recently had PHP 4.2.1 installed on Windows 98 SE, then it suddenly
stopped working for some reason - I don't know why or how, but I kept
getting SErver 500 errors. Having tried to remove all traces of PHP from the
Windows OS and tried to install the latest version (4.3.3), both with the
ZIP manual installation and the EXE self-install program, I still get
problems. Can anyone please please help, cause I really need PHP on my PC to
finish development of my local dramatics society's website and the
intermediary between me and the Society will puncture my jugular if I can't
get it working within the next week.
Ben Howarth
P.S. Am running PWS/IIS 3
--- End Message ---
--- Begin Message ---
I don't remember much about IIS 3/4 but here are the instruction for
installing under
windows......http://www.php.net/manual/en/install.windows.php
Shadow
--- End Message ---
--- Begin Message ---
Why are you trying to do the job of the DBMS in script ? Try instead :
$query="SELECT nrviews FROM url WHERE url=".$url;
$result=mysql_query($query);
if (mysql_num_rows($result)==0) {
$query="UPDATE url SET nrviews=nrviews+1 WHERE url='$url'";
} else {
$query="INSERT INTO url (url,nrviews) VALUES ('$url',1);
}
mysql_query($query);
This gets the one or zero rows which conatin the unique URL, and does a
second query which either updates the existing row by one hit, or inserts a
new row with a value of 1 hit.
Cheers - Neil Smith.
At 17:39 12/10/2003 +0000, you wrote:
From: Claudiu Bandac <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Date: Sun, 12 Oct 2003 20:39:56 -0700
Message-ID: <[EMAIL PROTECTED]>
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
Subject: selecting and updating fields
Hi !
I've got a form that passes a variable to a script.
The script connects to a database and I need to check if a field
containing that variable already exists in the table, and if it does, to
select the "nr_of_views" field, increment it, and update the table and if
it doesn't, to create a new field with that variable and set nr_of_views to 1
the table in my database that looks like this :
url nrviews
www.google.com 1
www.yahoo.com 3
And I've tried something like this:
$query = mysql_query("select * from url") or die (mysql_error());
while ($row = mysql_fetch_row($query))
{
if ($url === $row["url"])
{
$nrviews = $row["nrviews"];
$nrviews++
mysql_query("update url set nrviews='$nrviews' where
url='$url'") or
die (mysql_error());
}
else
{
$nrviews=1;
mysql_query("insert into url (url,
nrviews) values ('$url','$nrviews')") or
die (mysql_error());
}
}
AND STILL DOESN'T WORK !!!
When I get a variable that is not in the database, the whole thing goes
crazy ! (it inserts lots of fields with that variable and nrviews=1
Please HELP !
Thank You !
--- End Message ---