php-windows Digest 7 May 2002 00:51:14 -0000 Issue 1131
Topics (messages 13571 through 13580):
Can you use file() and rtrim() together
13571 by: blulagoon
13576 by: Olivier Hubert
Spreading the returned results among multiple pages...
13572 by: R.S. Herhuth
13573 by: Svensson, B.A.T. (HKG)
unexpected $ ???
13574 by: Zac Hillier
Re: Getting Apache 2.0.35 and PHP 4.2 to work on Win2k
13575 by: alphapoet
Download monitor
13577 by: Olivier Hubert
13579 by: Ross Fleming
BCMath functions
13578 by: Peter
Re: Testing...pls ignore
13580 by: Brad Thomas
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 ---
I don't know if this is the right way to go about what I'm trying to do.
In a nutshell, I want to open a simple text file and load the file into
an array with each line represented by one element in the array.
Now $myArray = @file("my_text_file"); achieves 90% of what I want, but I
need to strip out the line feeds at the end of each line that are in the
original file.
rtrim($myString, "/n") would seem to offer this functionality, but I
can't figure out the best way to use it with an array ?
Anyone got this working, or is there another easier way to do it,
perhaps with a variant of file() which doesn't include the linefeeds
that I don't know about.
Looking forwards to your input guys .....
Blu.
--- End Message ---
--- Begin Message ---
I don't know if you pasted the code directly from source, but your problem
might come from the fact that you're using "/n" instead of "\n".
What I recommend would be this:
$myString = @file('text_file');
$myArray = rtrim($myString, "\n");
Note that for the second part, you might have to put \r and then \n (e.g.
"\r\n") or simply no char specified. By default PHP will strip all
whitespaces, tabs and end of line/NULL bytes when you use rtrim without a
second parameter. You might want to give it a try.
Hope this helps,
Olivier Hubert
At 13:23 2002-05-06 +0100, blulagoon wrote:
>I don't know if this is the right way to go about what I'm trying to do.
>
>In a nutshell, I want to open a simple text file and load the file into
>an array with each line represented by one element in the array.
>Now $myArray = @file("my_text_file"); achieves 90% of what I want, but I
>need to strip out the line feeds at the end of each line that are in the
>original file.
>
>rtrim($myString, "/n") would seem to offer this functionality, but I
>can't figure out the best way to use it with an array ?
>
>Anyone got this working, or is there another easier way to do it,
>perhaps with a variant of file() which doesn't include the linefeeds
>that I don't know about.
>
>Looking forwards to your input guys .....
>
>Blu.
>
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
List,
I'm trying to write a script that only returns x number of results from
a query per page. I have all the logic in place that should do the
trick but the one problem I'm having is getting the SQL query to work
for me.
BTW I'm suing Microsoft SQL Server 2000, not My SQL. I know that MySQL
has the LIMIT attribute, but that doesn't work with MSSQL.
The problem I'm having specifically is that I can't bring back say only
rows 10-15 for example.
This is what I'm using (danger code from memory):
...
//the next set of variables are dynamically set in the actual script
$currentPage = 2;
$numOfPages = 5;
$dispPerPage = 5;
$lwr = ($dispPerPage * $currentPage);
$lwr = ($dispPerPage * $currentPage) + $dispPerPage;
for($i = $lwr; $i < $upr; $i++){
$row = mssql_fetch_row($i, $result);
echo "$row[first_name] $row[last_name]";
}
if (($currentPage + 1) < $numOfPages){
$nextPage = $currentPage + 1;
echo "<a href='this_page.php?currentPage=$nextPage'>next page</a>
}
The first page works fine. The next page comes back with an index
related error. I suspect it has to do with this line:
$row = mssql_fetch_row($i, $result);
What mssql command should I be using so that I can control the reults
that I am returning?
Thanks,
Ron
--- End Message ---
--- Begin Message ---
> The first page works fine. The next page comes back with an index
> related error. I suspect it has to do with this line:
> $row = mssql_fetch_row($i, $result);
Please post the error msg.
--- End Message ---
--- Begin Message ---
Hi All,
I'm new to this and have a strange error message - can anyone shed some light?
I have included a file into my main page that uses php to build an area of html and
javascript. I always get this error:
Parse error: parse error, unexpected $ in d:\php-dev\includes\frmBuilder.php on line
161
Line 161 is the end of the file, I have checked back through the code and the code
around the include statement and cannot find any errors in syntax or missing '$'.
Can anyone suggest what 'unexpected $ ' is referring to?
Many thanks,
Zac
--- End Message ---
--- Begin Message ---
The below worked for me on Win2K Professional/Apache2.0.35 and PHP4.2
So, this worked:
LoadModule php4_module C:\php\experimental\apache2filter.dll
(Server started with no problem. and when running phpinfo() output page was
correct)
While this did not:
LoadModule php4_module C:\php\sapi\php4apache.dll
(Server would not start)
"Chris Dion" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
David,
Install PHP 4.2 like you usually would but in your httpd.conf put:
LoadModule php4_module C:\php\experimental\apache2filter.dll
AddType application/x-httpd-php .php
I did a complete uninstall and reinstall of both apache and php when I
upgraded so nothing would be confused.
--Chris
"David" <[EMAIL PROTECTED]> wrote in message
001501c1eb49$e440da80$6700a8c0@WOPR">news:001501c1eb49$e440da80$6700a8c0@WOPR...
> I've been running apache 2 as my server for a while, and have been
> running php as a cgi (I know not the best idea). I saw that 4.2 offered
> experimental support, so I tried upgrading to that. Install.txt only
> includes instructions for 1.3.x, but I tried adjusting it to 2.x I
> couldn't get them to work. I then reverted to 4.1.2, but this had the
> following odd behavior: whenever I have a page request such as
> "file.php?foo=bar" it would never acknowledge it (load the page as
> though foo=bar wasn't there." I haven't had this problem before. I then
> tried running 4.2 as a cgi. It causes a message "The procedure entry
> point php_output_activate could not be located in the dynamic link
> library php4ts.dll" to pop up. Any help with apache 2 and php 4.2 would
> be a great help.
>
> David Tucci
>
>
--- End Message ---
--- Begin Message ---
This is probably a topic for gurus.
I'd like to have some way of knowing, with PHP, when a download is
finished. My site offers several files for download, and I want to make
sure a given user does not download more than one file at a time. I know
there is a way to do this with an Apache module, but I'm using Apache for
Windows and I really don't feel like writing my own module for connection
management.
Users are people with sessions, so I have access to session vars and since
I use a database I also have acces to MySQL tables.
The configuration I use is as follow:
- Apache 1.3.22
- PHP 4.1.1
- MySQL 3.23 something
Again, my goal is to be able to tell when a given user has finished a
download so I can give him permission to start another one. This could be
done in anything, PHP, javascript, Java, I don't really care.
Any help appreciated.
Olivier Hubert
--- End Message ---
--- Begin Message ---
Theories then (completely untested but in my mind should do with a but of
work)...
Keep the downloadable in a folder not accessable to the webserver. Give php
permission to read them.
Now at this point, I don't know enough about sessions to tell you the
syntax, but set a flag saying "downloading" or something, and then open the
file and pass it through to the script. Once it's passed through
completely, reset the flag to say "not_downloading". Obviously outside this
you should have a test to see what the flag is set to in the first place...
Example (download stuff borrowed from the php website
<?
if (flag != "downloading" // from session vars) {
// set flag = "downloading"; (session vars)
// begin download
$completeFilePath=$fileDir.'/'.$fileName;
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');
header("Content-type: application/octet-stream\nContent-Disposition:
inline; filename=\"".$fileName."\"\nContent-length:
".(string)(filesize($completeFilePath)));
$fd=fopen($completeFilePath,'r');
while(!feof($fd)) {
$buffer = fread($fn, 4096);
print $buffer;
}
fclose($fd);
// set flag = "not_downloading"; (session vars)
}
else {
echo "you're already downloading";
}
?>
Like I say, this is completely untested, but with a bit of work I believe
could be persuaded to work. Obviously you'd need some security checks on
the file they are trying to download (seeing as they could feasibly download
any file they liked in this method) and you'd need a time-out on the session
vars (like a timestamp on it) in case the script terminates prematurely and
the flag is never reset.
Have fun, and feel free to ask me to explain anything, it works in my mind
at least!
Ross
-----Original Message-----
From: Olivier Hubert [mailto:[EMAIL PROTECTED]]
Sent: 06 May 2002 18:28
To: [EMAIL PROTECTED]
Subject: [PHP-WIN] Download monitor
This is probably a topic for gurus.
I'd like to have some way of knowing, with PHP, when a download is
finished. My site offers several files for download, and I want to make
sure a given user does not download more than one file at a time. I know
there is a way to do this with an Apache module, but I'm using Apache for
Windows and I really don't feel like writing my own module for connection
management.
Users are people with sessions, so I have access to session vars and since
I use a database I also have acces to MySQL tables.
The configuration I use is as follow:
- Apache 1.3.22
- PHP 4.1.1
- MySQL 3.23 something
Again, my goal is to be able to tell when a given user has finished a
download so I can give him permission to start another one. This could be
done in anything, PHP, javascript, Java, I don't really care.
Any help appreciated.
Olivier Hubert
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--- End Message ---
--- Begin Message ---
How do the BCMath functions work?
I tried using them for some precision iterative processes and they kept
giving me incorrect answers (correct only to about 4 decimal places).
In the end I changed the precision setting in php.ini to 14 and used
standard math functions which gave the same results as my calculator and
Excel.
--- End Message ---
--- Begin Message ---
I am also ignoring this.
BT <..>
http://hellkeeper.hostbet.net/
"Then" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> pls ignore this
--- End Message ---