Re: [PHP] exist?

2001-03-14 Thread Simon Garner

From: "Kenneth R Zink II" [EMAIL PROTECTED]

 How would I go about checking to see if a file exist from php?
 
 I didn't find anything on php.net when I did a search for exist.
 


if (file_exists("/full/path/to/file.txt"))

http://php.net/manual/en/function.file-exists.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Good Free PHP Editor?

2001-03-12 Thread Simon Garner

From: "Andrew Halliday" [EMAIL PROTECTED]

 Does anyone know of a good PHP enabled editor that fits the following
 criteria:?

 (in order of importance)
 - Is free
 - Runs under Windows
 - Has colors (syntax highlighting)
 - Can edit multiple files (ie multi threaded)
 - Reports line numbers
 - Has good search  replace functionality

 ???

 Ive been using editpad up till now but my code is starting to get so large
 that ill need syntax highlighting soon...

 AndrewH



HomeSite is great. www.allaire.com

- not totally free I'm afraid, but there is an eval version.
- runs under Windows yes
- supports syntax highlighting for lots of languages including HTML, PHP,
Perl, SQL, ASP (VB/JS).
- can edit multiple files yes
- shows line numbers in gutter on left hand side
- supports regular-expression based search  replace across multiple
files/directories
- nice interface.


Cheers

Simon Garner



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] ASP vs PHP

2001-03-12 Thread Simon Garner

From: "Chris Anderson" [EMAIL PROTECTED]

 This is going to sound like heresy, but is there any way to
 use ASP and PHP in the same fle/page? Seperated of course.


What if you put:

!--#include virtual="path/to/file.php"--

in your ASP page?





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Good Free PHP Editor?

2001-03-12 Thread Simon Garner

From: "Boget, Chris" [EMAIL PROTECTED]

  HomeSite is great. www.allaire.com
  - not totally free I'm afraid, but there is an eval version.
  - runs under Windows yes
  - supports syntax highlighting for lots of languages
  including HTML, PHP,
  Perl, SQL, ASP (VB/JS).
  - can edit multiple files yes
  - shows line numbers in gutter on left hand side
  - supports regular-expression based search  replace across multiple
  files/directories
  - nice interface.

 Has the worst memory management of any software I've ever used.
 I have to reboot at lest 10 times a day when I use it.  The support
 forum on their site is filled with complaints on this issue.  Their
response
 to this issue was not to fix the memory leak (or whatever it is) but to
 issue a warning when resources are getting dangerously low to give
 you the opportunity to save all your work before you reboot.  Beyond
 that, their stance is "Well, if you don't like it, return it and we'll
give
 you a refund".
 If this wasn't the only piece of software that handled projects the way
 we needed, we'd have thrown out this piece of garbage software a *long*
 time ago.

 Chris




Running under Win2K I can have HomeSite 4.5.1 open for weeks, working on 10+
files, without any problems whatsoever.

However, I used to run it under Win98 and it would crash 1-2 times per
day...


Regards

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] validating fields

2001-03-08 Thread Simon Garner

From: "W.D." [EMAIL PROTECTED]

 Actually I tried a variation of what you gave me before and it didnt work.
I
 couldnt get yours to validate thanks. heres what I used
 ?php
 if (getenv("REQUEST_METHOD") == "POST")
 {
 if (
 eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $Email)
  eregi("^[a-z0-9]$", $FirstName)
  eregi("^[a-z0-9]$", $LastName)
 )
 {
 echo "thanks";
 }
 else
 {
 echo "error!";
 }
 }
 ?

 This is directly after the form using the registered vars $Email,
 $FirstName, $LastName. So I dunno whats wrong..



Your regular expressions are incorrect.

Try:

if (
eregi("^[a-z0-9\._-]+@[a-z0-9\.-]+\.[a-z]{2,3}$", $Email)
 eregi("^[a-z0-9]+$", $FirstName)
 eregi("^[a-z0-9]+$", $LastName)
)


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] anchor # not working?

2001-03-04 Thread Simon Garner

From: "andrew" [EMAIL PROTECTED]

 hi folks!
 
 I've got a baffling, but probably simple problem (the worst kind)
 
 In my index.php page, I'm dynamically generating links like this:
 http://localhost/news.php#1
 
 
 When I click the link, the url string get's passed in, and looking at the
 source of the news.php page shows:
 
 a href="#1"/a 
 
 about half-way down.. but the page doesn't align with the anchor tag.


Change this to:

a name="1"/a




Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] date

2001-03-04 Thread Simon Garner

From: "Michael Hall" [EMAIL PROTECTED]


 Yes you can. Include a field in your db called 'date' or whatever.

 Generate the date in your script using:

 $today = date("Y-m-d");

 Then simply add the date to the db along with everything else.
 There are lots of ways to format dates, too many to describe here.
 Have a look at the PHP manual.
 Also, if you make the data-type of the date field 'date', your options for
 formatting are more limited. That stuff is all in the MySQL manual.

 Michael


 On Sun, 4 Mar 2001, george wrote:

Can you mark the date when an entry is placed in the db and then get
that
  date to display  when the info is pulled out
 
  TIA
 
  george
 


If you make the field in the database of type "DATETIME" then you can insert
dates and select formatted date values using MySQL's date and time
functions. (I assume you're using a MySQL database.) There is no need to use
PHP's date functions.


Examples:

CREATE TABLE mytable (
...
mydate DATETIME,
...
)

To insert the current date, use NOW() as the date value:

INSERT INTO mytable VALUES (..., NOW(), ...)

To select the date formatted as "Saturday March 5th 2001 12:30 PM":

SELECT
col1,
col2,
DATE_FORMAT(mydate, '%W %M %D %Y %r') AS mydate,
col4
FROM mytable


http://www.mysql.com/doc/D/a/Date_and_time_functions.html


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: IE 5.5,authentication,PHP sessions: IE never stops

2001-03-04 Thread Simon Garner

From: "Ken" [EMAIL PROTECTED]


 Why it's bad is that, if the user clicks "cancel", they are not logged
out.  They have to manually clear the field, THEN OK, then they get prompted
AGAIN, THEN they hit cancel.  That's nuts, and my users aren't going to
understand that.



Why do they need to be able to log out?

If the user doesn't want their password saved (e.g. they're on a public PC)
then they just uncheck the "Save password" box when logging in, and then
they can close the browser and be "logged out".

If they want their password saved then they can check the "Save password"
box and not worry.

It sounds to me like you're trying to implement something that no users are
actually going to need or want...

However, if you want more control over the authentication process I suggest
making your own login form and using cookies, instead of HTTP
authentication. Then you can log users out just by unsetting the cookie(s).


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: IE 5.5,authentication,PHP sessions: IE never stops

2001-03-04 Thread Simon Garner

From: "Ken" [EMAIL PROTECTED]


 Nope - with IE5.5, even with that box NOT checked, the user remains logged
in until either a) the computer is restarted, or b) a new
user-authentication header is sent, AND the user clears out the password
field and hits OK.  Otherwise the user stays logged in, in spite of the HTTP
spec.


Admittedly I'm running IE5.01, but if I close and reopen the browser it will
pop up the authentication dialogue again (with values filled out, if I did
Save Password).

Does this really not happen in 5.5?



 This is how I will wind up going, EXCEPT the users will be required to
click "logout", since merely closing the browser, in IE5.5, does not seem to
clear the user/password from the browser's memory, NOR does it clear any
session cookie.  Again, works fine in other browsers, per spec.


You mean it doesn't clear per-session cookies (expiry=0) either? Cripes...

What Windows version is this under?



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Re: IE 5.5,authentication,PHP sessions: IE never stops

2001-03-04 Thread Simon Garner

From: "Ken" [EMAIL PROTECTED]


 What Windows version is this under?

 Windows 98 and Mac OS 8 or 9.

 - Ken



Is IE set to "Launch browser windows in a separate process" (if that option
still exists in 5.5)? Have a look in Tools  Options  Advanced.

Perhaps if that is not checked, closing the window does not count as exiting
the browser?




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] stumped on mailing a complete page

2001-03-03 Thread Simon Garner

From: "Brett" [EMAIL PROTECTED]

 This question may have been asked a million times, but I have had no luck
 searching for a difinitive answer.

 I want to send a confirmation email upon receiving an order, and would
like
 to send the page that I display on the browser to the user.

 I can not figure out how to send a page, like the links that let you mail
a
 page to a friend on some sites.  Any help would be much appreciated.

 Thanks,
 Brett


If you want to email them the same page that you sent to the browser, you
can do this using output buffering. In your confirmation page:


?php
ob_start(); // turn on output buffering
echo "html";
?

Thanks for your order!

?php
echo "/html";

// now mail the page
$mailto = "[EMAIL PROTECTED]";
$mailsubject = "Thanks for your order";
$mailbody = ob_get_contents();
$mailheaders = "From: [EMAIL PROTECTED]\nContent-Type: text/html";

mail($mailto, $mailsubject, $mailbody, $mailheaders);

// and output the page to the browser
ob_end_flush();
?


But not all mail clients can read HTML email, so it is a good idea to
provide a plain text version of the email as well. You can put both versions
of the mail in the one message using MIME. Try changing the above code
slightly, as follows:


?php
...

$mailbody = END
This is a multi-part message in MIME format.

--=_NextPart_
Content-Type: text/plain

(Here goes the plain-text version of the email.)
Dear Customer,

Thanks for your order.

--=_NextPart_
Content-Type: text/html

END;
$mailbody .= ob_get_contents(); // inserts the HTML version
$mailbody .= "\n\n--=_NextPart_";

$mailheaders = "From: [EMAIL PROTECTED]\n"
. "MIME-Version: 1.0\n"
. "Content-Type: multipart/alternative;\n"
. " boundary=\"=_NextPart_\"";

mail($mailto, $mailsubject, $mailbody, $mailheaders);

...
?


Have a flick through:
http://www.php.net/manual/en/ref.outcontrol.php
http://www.php.net/manual/en/function.mail.php



Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] quote problem

2001-03-02 Thread Simon Garner

From: [EMAIL PROTECTED]

 Unfortunatly thats not an option since some dumb founded people will be
using
 the script and they dont understand that concept...

 any other suggestions?

 - Peter


Okay, a heredoc may be better then:

?php
$title = END
titleblah "blah" blah/title
END;
echo $title;
?

The syntax in your original e-mail was not quite right - heredocs should
work fine with quotes.

http://www.php.net/manual/language.types.string.php


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Munging hidden/form variables

2001-03-01 Thread Simon Garner

From: "Chris" [EMAIL PROTECTED]

 Would it not be possible to have both the form page and the script page
that
 handles the form be generated o the fly with random filenames?

 The form page would point to the random generated script page, and the
 script page could delete itself after it is proccessed. You would also
want
 a cron to delete any files in case they never bothered to submit the form.

 Can anyone see a problem with this?





That is not going to solve the problem, because a cracker can just copy and
paste the random filename of the script page into their form page.

Bogus form data is a problem for everyone working with html forms. You're
trying to find an esoteric solution to the problem, while overlooking the
obvious: just check if the data is valid.


Regards

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Munging hidden/form variables

2001-03-01 Thread Simon Garner

From: "Boget, Chris" [EMAIL PROTECTED]

 I'm already doing this.  However, if I have a hidden variable containing
 a value of the current user I'm working with, that value can be changed
 to something else and it would pass the test.  However, I need to find a
 way to determine if something like that has happened.  That's where my
 description of what I was thinking of doing came from.

 Chris



Does the user have a password? You need to check if the password matches as
well.


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Munging hidden/form variables

2001-03-01 Thread Simon Garner

From: "Chris" [EMAIL PROTECTED]

 Not really,
 because the script filename is deleted and changed all the time, it
doesn't
 matter if they paste the name into the form, since the file will no longer
 exist.



It has to exist long enough for your form to post to it, which is long
enough for their form to post to it as well.


 Yes, but that's not going to do me any good because it is
 valid for one user to act on behalf of another (as a broker,
 if you will).  So the currently logged in user might not be
 the one who's ID is in the hidden field...


So how do you verify that the logged in user is allowed to act on behalf of
the other ID? You just have to keep reverifying that the client is allowed
to do what they're doing.

It's a chore I know - security usually is :(


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] validating fields

2001-03-01 Thread Simon Garner

From: "W.D." [EMAIL PROTECTED]

 I dont know how to do this, but Ive tried several things with no success.
I
 need to validate several form fields and here is the script I'm working
 with...

 ?php if($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST")
 {
 (eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $Email))?
 header("Location: http://www.site.com/thanks.php"):
 header("Location: http://www.site.com/error.php");
 }
 ;?

 I need to check at least two more fields, possibly 3 but I keep getting
 errors when trying to loop through a bunch of if statements. The above
works
 fine but I need to check eregi() against more strings from fields which
then
 redirects as shown above. Anyone?



?php
if (getenv("REQUEST_METHOD") == "POST")
{
if (
eregi("pattern1", $field1)
 eregi("pattern2", $field2)
 eregi("pattern3", $field3)
)
{
echo "thanks";
}
else
{
echo "error!";
}
}
?


Or if you want better error reporting:


?php
if (getenv("REQUEST_METHOD") == "POST")
{
$errors = array();

if (!eregi("pattern1", $field1))
{
$errors[] = "field1 is not right";
}
if (!eregi("pattern2", $field2))
{
$errors[] = "field2 is not right";
}
if (!eregi("pattern3", $field3))
{
$errors[] = "field3 is not right";
}

if (count($errors)  0)
{
echo "Sorry, " . count($errors) . " errors occurred, please try
again.\nul";
foreach ($errors as $err)
{
echo "li$err\n";
}
echo "/ul";
}
}
?


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Loss of connection handle object

2001-03-01 Thread Simon Garner

From: "Andrew Halliday" [EMAIL PROTECTED]

 Okay - Im writing an object to wrap a database.
 The key problem is this:
 - it declares a connection var as an object property
 - the open() function opens the connection to the database and stores
 the handle in $this-connection
 - the executeQuery() method complains about not having a valid handle,
 because by then, somehow, $this-connection==null!!!

 Any ideas?-i swear its just something stupid ive missed ...

 HELP!

 Thanx in advance,
 AndrewH

 -
 The code following this returns the following to the browser:
 -
 The connection in open() is :Resource id #1
 The connection in executeQuery() is :''

 Warning: Supplied argument is not a valid PostgreSQL link resource in
 /var/wwwroot/php/PostgreSQLDataSource.php on line 67


 -



What happens if you do:

?php
$db = new PostgreSQLDataSource("host", "port", "user", "pass", "db");
$db-open();

echo $db-connection;
?


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Declaring SERVER-WIDE Variables

2001-03-01 Thread Simon Garner

Hi Michael,

I've never used it myself, but this may be of some use:

http://www.php.net/manual/en/ref.shmop.php

If I understand it correctly, this lets you write a string into an area of
memory which can be accessed from any process - i.e. another httpd process.

If you wanted to save an array you would need to serialize() it first.


Cheers

Simon Garner


From: "Michael David" [EMAIL PROTECTED]

 Greetings, fellow PHP hackers!

 The current project I'm working on is porting software written in Tango to
 PHP4.  Because these programs heavily rely on information held in
(off-site)
 databases, the tango programs were written to have a set of array
variables
 declared from SQL queries, which then any user hitting the site would have
 access to.

 Ie...

 User 1 hits the webapge.. the server realizes this is the first user and
 populates the arrays with data from the source database.  The page is able
 to use these arrays.

 User 2 hits the webpage.. the server already has the arrays packed with
 data, and user 2 is able to hit the pages quickly, due to no queries being
 made.  All users are this way.

 Some events would require that these arrays be re-hashed such as when a
user
 updates, inserts or changes the value of an item in the database.  These
 changes.

 When this update happens, the changes would be made to the server-wide
 variables, so ANY user on the machine (independant of sessions) would have
 the fresh data when it next pulls from the arrays.

 

 Ideally, this would be like settings HTTP_SERVER_VARS[school_array] to
 contain the data, where every page would have $school_array there without
 any additional work, and a refresh being a small function that creates the
 arrays needed and sticks them into HTTP_SERVER_VARS[array_name].  (Along
the
 lines of PHP_SELF, but not dynamic in that sense.)

 Some of this could be handled with sessions, but my concern is that
carrying
 ALL of this data with each user is a waste of resources, and will require
 more database calls than needed.

 If anyone has ANY ideas, PLEASE share them! :)

 Regards,

 Michael


 ---
 Michael David
 The Miller Group
 Web-based software for Schools
 http://www.miller-group.net


 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Dumb newbie graphics question

2001-03-01 Thread Simon Garner

From: "darthzeth" [EMAIL PROTECTED]

 like i said, im a newbie... how do i run phpinfo() ? my almost exclusive
 experience is with FTPing html pages and a few PHP scripts to the server,
 other than that, i dont know much. is there any FAQ you can point me to
with
 answer to absolute newbie questions like these?



Create a new file called test.php and in it put:

?php
phpinfo();
?

FTP it to your web server and then look at it in your browser. It should
tell you a whole lot of stuff about how PHP has been configured on your
server.


Regards

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] what is wrong with this sniplet?

2001-02-28 Thread Simon Garner


From: Jacky [mailto:[EMAIL PROTECTED]]
 
 
  people,
  I tried to write out email using sniplet below, the email will write out
 the
  hyper link so that reciever can click on the link to go to the page.
What
  happen is that the reciever recieve the actual link instead of the hyper
  link I made, so I wonder what did I do wrong. I have mad sure that the
 email
  software I used to test can read html format ( I use outlook express).
 
$mailTo  =   "[EMAIL PROTECTED]";
$mailSubject = "test";
$mailBody= "Dear sir, \n\n";
$mailBody= "Below is the link you can click on, \n\n";
$mailBody   .= "htmlbodyPlease Click a
  href=\"www.php.net\"Here/a/body/html to view the request
details";
$mailHeaders = "From: [EMAIL PROTECTED]\n";
mail($mailTo, $mailSubject, $mailBody, $mailHeaders);
 



You need to tell the mail reader that the message is HTML, using a
Content-Type header. Plus your message is not well-formed HTML anyway
(message should be an HTML document, not HTML inside plain text). Try this:


?php
$mailTo  =   "[EMAIL PROTECTED]";
$mailSubject = "test";
$mailBody= "htmlbodyDear sir, \n\n";
$mailBody   .= "Below is the link you can click on, \n\n";
$mailBody   .= "Please Click a
href=\"http://www.php.net\"Here/a to view the request
details/body/html";
$mailHeaders  = "From: mailto:[EMAIL PROTECTED]\n";
$mailHeaders .= "Content-Type: text/html\n";
mail($mailTo, $mailSubject, $mailBody, $mailHeaders);
?


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Getting form name

2001-02-28 Thread Simon Garner

From: "Matt Williams" [EMAIL PROTECTED]

 Hi

 Is there a way I can get the name of the form that has been posted?

 Looking at the form vars I don't see a name var or such in there.

 TIA

 M@


The NAME attribute of the FORM element is intended for scripting purposes
only.

But you should be able to achieve the desired effect with a hidden INPUT
element:


form name="someform" method="POST"
input type="hidden" name="formname" value="someform"
/form



Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] multiple databases

2001-02-28 Thread Simon Garner

From: "Michael Hall" [EMAIL PROTECTED]

 I'd like to run this past anyone who'd care to comment before I get too
 far down the track I'm considering taking with a PHP web portal site.

 Is it a wise idea to have a PHP web application running on multiple
 databases? Everything I've done to date has run off one database, no
 matter how large it got. With the current small portal site, the idea is
 to break a monolithic database up into around 10 smaller databases, each
 of which should be able to be backed up to a floppy. Not all databases are
 called on each page, but up to 6 or so could be.

 What are the performance implications (slower, obviously, but 10 times
 slower?). Performance beyond what the human mind can perceive is not
 relevant to me.

 Should I use mysql_connect or mysql_pconnect for each db connection ?

 Should I be careful to use mysql_close with each connection?

 Any advice appreciated.

 Mick



Do you mean 10 different database servers, or 10 databases on the one
server?

As far as I know, separate databases on the one server give the same
performance as separate tables in one database.

With separate database servers you will run into new problems such as:

-) additional connection overhead for each server, if you need to access
more than one server in a page
-) can't combine data from servers, e.g. can't JOIN tables

Persistent connections may or may not help. Using persistent connections
could negate the connection time overhead, but you get a memory overhead
instead - if you have 40 connections open, there's got to be 40 mysqld
processes (threads?) running too.


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] multiple databases

2001-02-28 Thread Simon Garner

From: "Michael Hall" [EMAIL PROTECTED]


  Do you mean 10 different database servers, or 10 databases on the one
  server?

 10 databases on the one server.

  As far as I know, separate databases on the one server give the same
  performance as separate tables in one database.

 Music to my ears.


Well, I'm pretty sure on that, but don't quote me ;-)

If you think about it though, each table is just a set of files in a
directory with the name of the database. It should not be any slower to
access a table in one directory compared to a table in another directory
(unless you split those directories onto separate physical disks or
somesuch - but you could do the same thing using symlinks and one database).

As for implementation in your script, you do not need to reconnect to access
a different database; just do mysql_select_db("dbname") to switch between
the databases. Or use mysql_db_query("dbname", "query").

However, there is probably no point in using 10 different databases - save
yourself some complication and just use one.



  With separate database servers you will run into new problems such as:
  -) can't combine data from servers, e.g. can't JOIN tables

 OK ... I didn't realise I could join tables across seperate databases.
 Anywhere where joins are necessary, I'm using the one database.

 Thanks

 Mick



Indeed you can:

7.19 SELECT Syntax
"You can refer to a column as col_name, tbl_name.col_name, or
db_name.tbl_name.col_name."

http://www.mysql.com/doc/S/E/SELECT.html


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] optimal way of counting votes in online poll

2001-02-28 Thread Simon Garner

From: "Vikram Vaswani" [EMAIL PROTECTED]

 Hi all!

 I have a question as to the optimal method of counting and storing votes
in
 an online poll.

 Once a user answers the poll by clicking on one of three options, I am
 performing a query on a table which holds values for each option.
Currently I
 - query the table to get the current count
 - increment the count by 1
 - UPDATE the table with the new value

 I wonder: what happens if two users submit the answer simulatneously, and
 the answer is the same. Will only of those votes register? Or will the SQL
 somehow be "queued" so that both are counted?


And so you should wonder :)

You have created a race condition - if the table is updated between your
SELECT and your UPDATE, then your UPDATE will be using incorrect values.

The solution is very simple - instead of querying the current value and
incrementing it in PHP, let MySQL do the work:

UPDATE polls SET votecount=votecount+1 WHERE pollid=$poll

There are all sorts of manipulations you can do to the data during queries,
and they're all usually much better than trying to do the same thing in your
application.

http://www.mysql.com/doc/F/u/Functions.html


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] regex frustration

2001-02-28 Thread Simon Garner

From: "Jerry Lake" [EMAIL PROTECTED]

 I've tried and tried to no avail, can someone assist
 I need to select the first space in a line like the following
 Nelson Bob and Mary, 123 Street st., Ashton, 555-1212
 
 I need to replace the space between Nelson and Bob with
 a comma so I can separate the first and last names in my DB
 ^\D*\s will select the first name and the space, but I just
 need the space. any ideas?
 



?php
$str = "Nelson Bob and Mary, 123 Street st., Ashton, 555-1212";
$str = ereg_replace("^([^ ]+) (.+)", "\\1, \\2", $str);
?

Or alternatively:

?php
$str = "Nelson Bob and Mary, 123 Street st., Ashton, 555-1212";
$str_bits = explode(" ", $str);
$str_bits[0] .= ",";
$str = implode(" ", $str_bits);
?


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] parse error on line after last one???

2001-02-27 Thread Simon Garner

From: "Jaxon" [EMAIL PROTECTED]

 Hi all,

 Can anyone tell me why Im getting an unhelpful error when
 trying to pull up a file?

 The index.php Im calling is including a functions file 
functions.inc.php

 Im getting a parse error on line 144  but functions.inc.php only
 has 143 lines...!

 does this actually mean anything, or is it just poor error reporting??



I think this usually means you have opened a block (e.g. an if statement),
and forgotten to close it.


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Full mailbox

2001-02-27 Thread Simon Garner


Can some moderator please do something about this guy - every post to the
list gets an autoresponse:


-

Your message with subject [Re: [PHP] parse error on line after last one???]
was not delivered to the
following recipient: [kia01].  This recipient's mailbox is full.

Sua mensagem com assunto [Re: [PHP] parse error on line after last one???]
nao foi entregue ao seguinte
destinatario: [kia01].  A caixa-postal deste destinatario esta' cheia.
by srv8-sao.sao.terra.com.br (8.9.3/8.9.3) with ESMTP id UAA27560
for [EMAIL PROTECTED]; Tue, 27 Feb 2001 20:28:56 -0300
Received: (from mail@localhost)
by srv3-tl1.tl1.terra.com.br (8.9.3/8.9.3) id UAA12938
for [EMAIL PROTECTED]; Tue, 27 Feb 2001 20:28:55 -0300
Received: from toye.php.net (va.php.net [198.186.203.51])
by srv3-tl1.tl1.terra.com.br (8.9.3/8.9.3) with SMTP id UAA12926
for [EMAIL PROTECTED]; Tue, 27 Feb 2001 20:28:54 -0300
Received: (qmail 8791 invoked by uid 1013); 27 Feb 2001 23:25:22 -
Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm
Precedence: bulk
list-help: mailto:[EMAIL PROTECTED]
list-unsubscribe: mailto:[EMAIL PROTECTED]
list-post: mailto:[EMAIL PROTECTED]
Delivered-To: mailing list [EMAIL PROTECTED]
Received: (qmail 8648 invoked from network); 27 Feb 2001 23:25:20 -
Message-ID: 004901c0a114$f09af980$[EMAIL PROTECTED]
From: "Simon Garner" [EMAIL PROTECTED]
To: "Jaxon" [EMAIL PROTECTED], [EMAIL PROTECTED]
References: [EMAIL PROTECTED]
Date: Wed, 28 Feb 2001 12:27:08 +1300
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.50.4133.2400
X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4133.2400
Subject: Re: [PHP] parse error on line after last one???




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] very off the topic questions here but hope someone can help out

2001-02-27 Thread Simon Garner

From: "Jacky@lilst" [EMAIL PROTECTED]

 This is very off the topic question, people. But I just wanna see if
 anyone has this experience and can tell me the procedure. I need
 to change the registrant company of several domains we own to
 the new company name. I only know that I need to do that at
 networksolution but don't have any idea about how and the process,
 any guide?

 Jack
 [EMAIL PROTECTED]


RTFM: http://www.networksolutions.com





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to PHP process a .phtml file, or capture the output from within PHP?

2001-02-27 Thread Simon Garner

From: "Andy Jones" [EMAIL PROTECTED]

 Hi

 I'd normally start this mail with some background of what I'm doing,
 but to save everyone time, I'll start with the questions, and then
 in case anyone has alternative suggestions or workarounds, I'll
 fill in the what I'm doing and why...

 Within PHP script, is it possible to

  1.  capture the results of the PHP engine's processing of
  the current .phtml/.php file?
  ie. what the server will sent back to the browser.

  2.  manually feed a (possibly different) .phtml/.php file into
  the PHP parser and obtain the results of the processing?




Yes this is possible, in a way. I have done it before, for a simple caching
mechanism.

Try this:


?php
ob_start(); // turn on output buffering
echo "html";
?

Some bpage text/b!

?php
echo "/html";

// now save the buffer to a file
$fp = fopen("/usr/local/apache/htdocs/file.html", "w")
or die("eek");
fwrite($fp, ob_get_contents());
fclose($fp);

// and output the buffer to the browser
ob_end_flush();
?


And have a flick through:
http://www.php.net/manual/en/ref.outcontrol.php


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Converting code to a function

2001-02-27 Thread Simon Garner

Clayton,

The problem is that some of your variables, e.g. $HOSTNAME, $DB_USER, etc.,
are not global variables, and so are not accessible from inside the
function.

I recommend making those settings define()s instead of variables, but if you
keep them as variables then you just need to add:


?php
function viewdoc ($docid)
{
global $HOSTNAME, $DB_USER, ...;
...
}
?


But to do them as constants instead, do:

?php
define("HOSTNAME", "myhost.net");
define("DB_USER", "myuser");
define("DB_PASS", "jksajfeioe");

function viewdoc ($docid)
{
...
$dbh = mysql_connect(HOSTNAME, DB_USER, DB_PASS);
    ...
}
?


Hope this helps.


Cheers

Simon Garner


- Original Message -
From: "Clayton Dukes" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, February 28, 2001 3:51 PM
Subject: [PHP] Converting code to a function


Hi everyone :-)

I need help, how can I convert the following code into a function so that I
can just place it in a global include file and call it using
viewdoc($docid); whenever necessary?

---START---
if ($docid == "") {
  echo "Fatal Error - DocID not supplied";
  exit;
  }

  $dbh = mysql_connect("$HOSTNAME","$DB_USER","$DB_PASS");
  mysql_select_db("$DATABASE");

  $sth = mysql_query("SELECT docdata FROM documents WHERE docid like
  '$docid'");

  $row = mysql_fetch_array($sth);

  if ($row[0] != "") {
  echo "DocID: $docid\n\n";
echo (wraptext($row[0],72));

  } else {
  echo "Fatal Error - Can't fetch docid";
  }
---END---

I tried to do this:
function viewdoc($docid) {
...PASTE FROM ABOVE...
}

But then I get:

Warning: Supplied argument is not a valid MySQL result resource in
/home/www/websites/gdd/inc/funcs.inc on line 76
Fatal Error - Can't fetch docid

when I call it from a web page using:

viewdoc($docid);


What have I done wrong?



TIA!
Clayton Dukes








 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple String Replace Question

2001-02-25 Thread Simon Garner

From: "Jeff Oien" [EMAIL PROTECTED]

  On 25 Feb 2001 10:34:27 -0800, Jeff Oien [EMAIL PROTECTED] wrote:
  I would like to get rid of \n characters unless there
  are two or more in a row. So for example if there
 
  The Perl-compatible regular expressions support lookahead and look
behind:
 
  $str = 'abcdefabcaadd';
  echo "$str\n";
  $str = preg_replace("/(?!a)a(?!a)/", "-", $str);
  echo "$str\n";
 
  will display this:
  abcdefabcaadd
  -bcdef-bcaadd

 Man, that went right over my head. Is there a description of
 how this works anywhere? Thanks for help in any case.
 Jeff Oien



Or you could just do this:

?php
$str = "abc\ndefg\n\nxyzpqr\njklmno";
$str = ereg_replace("([^\n])\n([^\n])", "\\1 \\2", $str);
echo $str;
?

That should give you:

abc defg\n\nxyzpqr jklmno

Works by replacing any \n with a space, as long as that \n is not next to
another \n.


Cheers

Simon Garner



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Removing HTML codes using regexp

2001-02-25 Thread Simon Garner

From: "Toke Herkild" [EMAIL PROTECTED]

 What if I want to replace all html codes from a string ?
 I've tried using :
 
 $myString = preg_replace('/*/, '', $myString);
 but that deletes all string... ( or everything from first '' ) ...
 
 Toke Herkild...
 
 



Try striptags()

http://php.net/striptags


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple String Replace Question

2001-02-25 Thread Simon Garner

From: "Jeff Oien" [EMAIL PROTECTED]

 That almost works. The two \n in a row are on new lines.
 So it's
 \n
 \n
 intead of \n\n. If that makes any sense.
 Jeff Oien


No, that doesn't make any sense whatsoever :)

A \n *is* a new line. I can only guess you're getting confused because
there's \r's as well as \n's in the string. Try this:


?php
$str = "abc\r\ndefg\r\n\r\nxyzpqr\r\njklmno";
$str = ereg_replace("([^\r\n])\r\n([^\r\n])", "\\1 \\2", $str);
echo $str;
?

Or alternatively:

?php
$str = "abc\r\ndefg\r\n\r\nxyzpqr\r\njklmno";
$str = ereg_replace("\r", "", $str);
$str = ereg_replace("([^\n])\n([^\n])", "\\1 \\2", $str);
echo $str;
?


A CR is a carriage return, a LF is a line feed or newline. \r = CR, \n = LF.
Unix files use only LF (\n) for new lines, whereas MS DOS/Windows uses CRLF
(\r\n) and Mac uses just CR (\r).


Cheers

Simon Garner



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Script not updating

2001-02-25 Thread Simon Garner

From: "Peter Houchin" [EMAIL PROTECTED]


 Could some one please have a look thru my code and tell me why it creates
a new record instead of updating the record?


[snip]


 if ($submit){

  $result = mysql_query("INSERT INTO app
(name,company,address,suburb,state,post,areacode,phone,faxareacode,fax,email
,secret) VALUES
('$name','$company','$address','$suburb','$state','$post','$areacode','$phon
e','$faxareacode','$fax','$email','$secret')");



^^ Here's your culprit. Check your logic. Whenever they push submit it
INSERTs a new record (I think...).


Regards

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Regular expression problems

2001-02-25 Thread Simon Garner

From: "Dan Watt" [EMAIL PROTECTED]

 Im trying to build a user login system, and when there is a new user, I
need
 to validate that they are usign using word characters ([0-9A-Za-z_] or
 \w)... I have TRIED MANY different regular expressions to test this, but
 none work. This seems so simple but I am missing something. I need a
 expression that returs true ONLY if ALL the characters match \w  Any
 help would be appreciated.




?php
$username = "johnny";

if (!eregi("[^A-Z0-9_-]", $username))
{
echo "username OK";
}
else
{
echo "bad username!";
}
?

Assuming you only want letters, numbers, underscores or hyphens. If you
really want \w you would need to use preg instead of ereg, and then you need
PCRE support in PHP. Or you could use ereg's character classes, I think the
pattern would look like: "[^[:alphanum:]]". However you are probably better
off using an explicit set of characters as I have shown, so that it is
obvious what is and is not allowed.


Cheers

Simon Garner



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Regular expression problems

2001-02-25 Thread Simon Garner

From: "Dan Watt" [EMAIL PROTECTED]

 ok, that was my problem Was using ereg... All the places I read about
 how to do regular expressions (book, online...) did NOT clarify that \w
and
 such would need preg.. Thanks!



No prob - yeah, \w is a Perl feature :)

(preg = PCRE = Perl Compatible Regular Expressions)



Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Simple String Replace Question

2001-02-25 Thread Simon Garner

From: "Jeff Oien" [EMAIL PROTECTED]

 Ok now I'm really being a pest. Your code works on your
 example but not on mine. I can't figure out why. But I really
 appreciate the help so far from Chris and Simon so thanks.

 Here is my example and what happens when I use your
 code. I tried it by pasting text into a textarea part of a
 form and also just having it in a plain text file (Windows system).
 (I just tried creating a file on Unix also, same result.)
 Removes the line breaks but also the multiples for paragraphs.
 This isn't very important, more of a curiosity.


I just tried with your text and it reformats it correctly for me...

Here's what I have got:


html
body

form method=post
textarea name="str" cols=50 rows=10/textareabr
input type=submit
/form

hrpre
?php
$str = ereg_replace("([^\r\n])\r\n([^\r\n])", "\\1 \\2", $str);
echo $str;
?
/pre

/body
/html


I pasted your text into the textarea and submitted it:


This is a story
of how the West was won.
Not about the Brady bunch
but how those guys with guns
somehow won.

I don't know who won, but
I do know the West was won.
So the West is number one.

Yay.


And it outputted:


This is a story of how the West was won. Not about the Brady bunch but how
those guys with guns somehow won.

I don\'t know who won, but I do know the West was won. So the West is number
one.

Yay.


(Just need to run it through stripslashes() to fix the don\'t.)

Does this not work for you? Some troubleshooting ideas:

?php
$str = ereg_replace("\r", "CR", $str); // replace CRs with "CR"
$str = ereg_replace("\n", "LF", $str); // replace LFs with "LF"
?

?php
echo urlencode($str);  // may help to highlight any special characters
in the string
?


Hope this helps

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] JavaScript

2001-02-25 Thread Simon Garner

From: "Deependra B. Tandukar" [EMAIL PROTECTED]

 Greetings!

 Is there any equivalent code for (JavaScript) a
 href=JavaScript:history-back(1)Back Button/a in php?

 This works as back button on the menu bar.

 Looking forward to hearing from you.

 regards,
 DT




Yes, but it works differently. If the user typed in the URL of your page
(instead of clicking a link) then you can't go back from PHP, so you need to
be careful. Here's some sample code:


?php
$referer = getenv("HTTP_REFERER");

if ($referer)
{
$url = $referer;
}
else
{
// can't go back... try JS instead
$url = "javascript:history.back()";
}

echo "a href=\"$url\"Back Button/a";
?



Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] $result = $$function

2001-02-24 Thread Simon Garner

From: "Peter Van Dijck" [EMAIL PROTECTED]

 Hi,
 I'd like to do:
 $function = "build_result()";
 $result = $$function;
 but it doesn't seem to work.


Try:

?php
$function = "build_result";
$result = $function();
?


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] checking $more still does not work !

2001-02-24 Thread Simon Garner

From: "Web Admin" [EMAIL PROTECTED]

 Hi Kaab,
 There must be another problem, it should work. Maybe it helps if
 you send your code here. To see how a simple script works, try
 this tiny script named test.php:
 
 form action=test.php
 input type=submit name=more
 /form
 ?php
  if ($more) {print "pSubmit is pressed/p"; };
 ?
 
 If you first load the php page, you don't see anything rather than a 
 submit button. If you press submit, you will see a message.

 Ahmad Anvari



I think you need a value for the submit button:

input type="submit" name="more" value="Click for more"



Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Parsing a string

2001-02-23 Thread Simon Garner

From: "Todd Cary" [EMAIL PROTECTED]

 Thanks all!!

 split() works like a champ!!

 Todd

 --
 Todd Cary
 Ariste Software
 [EMAIL PROTECTED]



If you're just tokenising by a comma, don't use split(), use explode().

split() accepts a regular expression for the separator, whereas explode()
accepts just a normal string. The difference is, split() is slower.



Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] getting what's between td/td

2001-02-22 Thread Simon Garner

 ?php
 $data = "trtdItem3/tdtdItem3 Has Changed/td/tr";

 eregi("trtd([^]+)/trtd([^]+)/td/tr", $data, $regs);

 echo $regs[1];   // "Item3"
 echo $regs[2];   // "Item3 Has Changed"
 ?


Oops sorry, that fourth line should say:

 eregi("trtd([^]+)/trtd([^]+)/td/tr", $data, $regs);



From: "Simon Garner" [EMAIL PROTECTED]

 From: "Tyler Longren" [EMAIL PROTECTED]

  Hello,
 
  I've been reading a LOT on how to solve my problem today, but haven't
been
  able to come up with anything yet.
 
  Here's my problem:
  I have an html file that contains many table rows like this:
 
  trtdItem1/tdtdItem1 Again/td/tr
  trtdItem2/tdtdItem2 Again/td/tr
  trtdItem3/trtdItem3 Again/td/tr
  trtdItem4/trtdItem4 Again/td/tr
 
  And so on.  I want to search this html for a table row that has 'Item3'
in
  the first cell.  And the second cell should contain 'Item3 Again'.  I
know
  that I can do this with something like this:
 
  $file = fopen("http://localhost/html.html", "r");
  $data = fread($file, 1);
  $results = eregi("trtdItem3/trtdItem3 Again/td/tr", $data);
 
 
  However, this won't exactly work for me, because that contents of the
  second cell will change daily, so tomorrow, the third table row could
look
  like this:
 
  trtdItem3/tdtdItem3 Has Changed/td/tr
 
  I was thinking I could use sscanf() to do this, but couldn't get
anything
  to work.  I've tried everything I can think of.
 
  Sorry if the explanation of my problem was hard to understand, I don't
  exactly understand it myself.  Thanks everybody!!!
 
  Regards,
  Tyler Longren
 



 You just need to use a regular expression with eregi:

 ?php
 $data = "trtdItem3/tdtdItem3 Has Changed/td/tr";

 eregi("trtd([^]+)/trtd([^]+)/td/tr", $data, $regs);

 echo $regs[1];   // "Item3"
 echo $regs[2];   // "Item3 Has Changed"
 ?

 A good guide to regular expressions (which are absolutely indispensible if
 you want to do much work with strings) is here:

 http://www.delorie.com/gnu/docs/rx/rx_toc.html


 Cheers

 Simon Garner






-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Generating percentages of numbers

2001-02-22 Thread Simon Garner


 Better (if it works):
 SELECT (hitcount / MAX(hitcount)) * 100 AS percentage FROM sometable


Nope unfortunately that does not work :(

Firstly using MAX() will not work as that finds the largest value in the
group; SUM() would be more appropriate as it finds the total for that column
in the group. But you can't group the data here (you want to select all page
rows from the table) so these grouping functions are not usable.

He will need to do two queries:

?php
$result = mysql_query("SELECT SUM(hitcount) FROM pages");
list($totalhits) = mysql_fetch_row($result);

$result = mysql_query("SELECT (hitcount / $totalhits) * 100 AS
percentage FROM pages");
?

I think...




From: "Christian Reiniger" [EMAIL PROTECTED]

 On Thursday 22 February 2001 00:04, Simon Garner wrote:

  I have a database of numbers:
 
  TOTAL HITS: 1000
  PAGE 1: 500
  PAGE 2: 250
  PAGE 3: 250
 
  How can I query these numbers and display back a percentage number?
  For instance with the numbers above:
 
  PAGE 1: 50%
  PAGE 2: 25%
  PAGE 3: 25%
 
  Or is their a process by which to store numbers for easily getting
  this to work?

 SELECT (hitcount / 1000) * 100 AS percentage FROM sometable


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] String manipulation with ereg_replace

2001-02-22 Thread Simon Garner

From: "Ian LeBlanc" [EMAIL PROTECTED]


 I am working on a site that has over 1000 pages and all the images need to
 be made lower case in the HTML.
 Here is what I have so far. Please someone tell me what I am doing wrong.


 $contents="img src=ThisOneReallyNeedsToBeAllLowercase.gif
 alt=ThisOneReallyNeedsToBeAllLowercase.gif";

 $contents =
EREG_REPLACE("([-_a-zA-Z0-9]+).gif",strtolower("\\0"),$contents);


 Output of $contents needs to equal
 img src=thisonereallyneedstobealllowercase.gif
 alt=thisonereallyneedstobealllowercase.gif





You need to use preg_replace which supports evaluating PHP code for the
replacement. To use preg functions you need to have compiled PHP with PCRE
(Perl Compatible Regular Expression) support.

http://www.php.net/manual/function.preg-replace.php3

This should do the trick (untested!):

?
$contents = "img src=ThisOneReallyNeedsToBeAllLowercase.gif
alt=ThisOneReallyNeedsToBeAllLowercase.gif";

$contents = preg_replace("/([-_a-zA-Z0-9]+)\.gif/e", "strtolower('\\1')
. '.gif'", $contents);
?


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] passing variables in javascript

2001-02-22 Thread Simon Garner

From: "Nicholas W. Miller" [EMAIL PROTECTED]

 I have a text link that is coded to open a PHP file in a popup window:

 a

href="#"onClick="MM_openBrWindow('../email/popup.php?title=B2B+Antitrust:+Op
ening+Moves+in+the+Gameurl=http://www.domain.com/biz/pubs.html#antitrust','
email','width=410,height=435')"Emailthis
 article/a

 For some reason the $url variables cuts off the anchor, so I only get
this:

 $url = http://www.dttgfsi.com/ebiz/pubs_eviews.html

 I have tried escaping it (\#antitrust), but the doesn't work.

 Any suggestions would be appreciated ...

 Nick



You have to encode each part of the query string on the URL correctly:

a href="#" onClick="MM_openBrWindow('../email/popup.php??php
echo "title=" . urlencode("B2B Antitrust: Opening Moves in the Game")
. "url=" .
urlencode("http://www.domain.com/biz/pubs.html#antitrust");
?', 'email','width=410,height=435')"Emailthis/a


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Counter Help

2001-02-22 Thread Simon Garner

From: "Chris Lee" [EMAIL PROTECTED]

 change

 $row[count]

 to

 $row['count']

 it thinks the work [count] is some kind of conastant, it doesnt know you
 mean (string) 'count'



rant

I have noticed a lot of people do not put quotes on their array indexes
(e.g. VBulletin is a prime offender) - imho this is a really bad practice
because your code becomes ambiguous.

Example:

?php
define("foo", "donkey");

$test = array("foo"="orange", "bar"="purple");

echo $test[foo];
?

Now, I think that should print nothing (or an error), because there is no
index matching "donkey" (the value of the constant "foo"). But for some
reason PHP looks for an array index matching the string "foo" as well,
encouraging this kind of sloppy programming.


Regards

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] select name=....

2001-02-22 Thread Simon Garner

From: "Jonathan Sharp" [EMAIL PROTECTED]

 well...i just finished some code for dealing with an option box that has
all
 the states listed...

 select name="state" size="1"
 option value=""Select State/option
 ?
 $ST[] = 'AL'; $ST[] = 'AK'; $ST[] = 'AR'; $ST[] = 'AZ';
 $ST[] = 'CA'; $ST[] = 'CO'; $ST[] = 'CT'; $ST[] = 'DC';
 $ST[] = 'DE'; $ST[] = 'FL'; $ST[] = 'GA'; $ST[] = 'HI';
 $ST[] = 'IA'; $ST[] = 'ID'; $ST[] = 'IL'; $ST[] = 'IN';
 $ST[] = 'KS'; $ST[] = 'KY'; $ST[] = 'LA'; $ST[] = 'MA';
 $ST[] = 'MD'; $ST[] = 'ME'; $ST[] = 'MI'; $ST[] = 'MN';
 $ST[] = 'MO'; $ST[] = 'MS'; $ST[] = 'MT'; $ST[] = 'NC';
 $ST[] = 'ND'; $ST[] = 'NE'; $ST[] = 'NH'; $ST[] = 'NJ';
 $ST[] = 'NM'; $ST[] = 'NV'; $ST[] = 'NY'; $ST[] = 'OH';
 $ST[] = 'OK'; $ST[] = 'OR'; $ST[] = 'PA'; $ST[] = 'PR';
 $ST[] = 'RI'; $ST[] = 'SC'; $ST[] = 'SD'; $ST[] = 'TN';
 $ST[] = 'TX'; $ST[] = 'UT'; $ST[] = 'VA'; $ST[] = 'VT';
 $ST[] = 'WA'; $ST[] = 'WV'; $ST[] = 'WI'; $ST[] = 'WY';
 for($i = 0; $i  count($ST); $i++)
 {
 echo 'option value="'.$ST[$i].'"';
 if($state == $ST[$i])
 {
 echo ' selected';
 }
 echo ''.$ST[$i]."/option\n";
 }//For
 ?
 /select

 First it creates an array $ST that contains a list of all the states
 (includes PR and DC)
 Next it loops through that array and if $state has the same value as the
 state, it selects it...

 You could probably turn this into a function or something...

 =codeboy




Or better would be:

?php
$states = array('AL', 'AK', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE',
'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA',
'MD',
'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ',
'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'PR', 'RI', 'SC', 'SD',
'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WV', 'WI', 'WY');

foreach ($states as $s)
{
echo "option value=\"$s\"";
if ($state == $s) echo " selected";
echo "$s/option";
}
?


PHP has many syntax features and language constructs which can significantly
improve code performance and manageability -- use them!

Now this code could easily be extended to give each state a descriptive
name, and to create a generic listbox-drawing function which you can then
re-use elsewhere in your program (or as a code snippet which you can use in
other programs in the future!):


?php
function drawListBox ($name, $data, $selectedvalue="")
{
echo "select name=\"$name\"\n";
foreach ($data as $key = $value)
{
echo "option value=\"$key\"";
if ($selectedvalue == $key) echo " selected";
echo "$value/option\n";
}
echo "/select";
}

$states = array(
"AL" = "Alabama",
"AK" = "Arkansas",
"AZ" = "Arizona",
... etc
"WY" = "Wyoming"
);

drawListBox("state", $states, $state);
?


When it comes to programming, in many ways "laziness is a virtue". Instead
of writing the same code 10 times over in subtly different ways, write it
once and make it reusable! Not only does this save you time, it can make
your program less buggy and easier to upgrade.

/lecture :)


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mail prob

2001-02-22 Thread Simon Garner

From: "W.D." [EMAIL PROTECTED]

 so there is no way to pull this variable from an email form field?



Eh? Of course, $from can be set by a form field if you want. Or a database,
or any way you can set a variable. Then pass it to mail(), per my last
message.






  From: "W.D." [EMAIL PROTECTED]
 
   I'm using a remote host, and when I call mail() with all the var's
 pulling
   values from form fields, it still shows as nobody in from header. Is
 this
  a
   server situation? Theyre using php4 support and they claim its that
I'm
  not
   using appropriate variables in the function.
  
  
 
 
  You have to set the From header manually:
 
 
  ?php
  $to = "[EMAIL PROTECTED]";
  $from = "[EMAIL PROTECTED]";
  $subject = "Blah";
  $body = "Lorem ipsum dolor sit amet.";
 
  mail($to, $subject, $body, "From: $from");
  ?
 
 
  http://www.php.net/manual/en/function.mail.php
 
 
  Regards
 
  Simon Garner




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] mail prob

2001-02-22 Thread Simon Garner

From: "W.D." [EMAIL PROTECTED]

 yea I guess that would work better, I dunno tho, I tried setting $from =
 $Email and the blasted server still served it up as nobody in the header.
 But the rest would make more sense. Yes [EMAIL PROTECTED] would need a copy
to
 trigger an autoresponse. I know I probably seem like someone who hasnt
read
 much php, but Ive actually read a couple php4books, the first an easier
 learning and the second PHP 4 Bible. I'm still a newbie tho so bare with
me.



Okay, it sounds like you're forgetting the "From: " prefix in front of
$from.

This prefix is necessary because the mail message you are composing must
come out looking essentially like this (this is what gets given to your SMTP
mail server):



To: [EMAIL PROTECTED]
From: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: Blah

Here is the main body of the message.



Now, PHP's mail() function will automatically insert the To: and Subject:
headers, and the body, from the first three arguments to mail(). But to add
the custom From: and Cc: headers, you have to add them yourself (correctly
formatted as mail headers) using the fourth argument to mail().

Which is how we get to:

mail("[EMAIL PROTECTED]", $subject, $message,
"From: $from\nCc: [EMAIL PROTECTED]");

Making sense? :)





  From: "W.D." [EMAIL PROTECTED]
 
   form method="POST" action="?php print ($PHP_SELF);?"
   First Name: input type=TEXT name="FirstName" size=15p
   Last Name: input type=TEXT name="LastName" size=25p
   E-mail Address: input type=TEXT name="Email" size=25p
   textarea name="Info" rows="5" cols="40" wrap=SOFTAsk a
   Question/textareap
   input type=SUBMIT input type=RESET
   /font
   /form
  
  
   ?php
   $from = $FirstName ." ". $LastName;
   $subject = $Email;
   $message = $Info;
   mail("[EMAIL PROTECTED], [EMAIL PROTECTED], $subject, $message,
$from);
   ?
  
 
 
  See, your syntax is incorrect :P
 
  Try:
 
  ?php
  $from = $Email;
  $subject = $Email;
  $message = "Question from $FirstName $LastName:\n\n$Info";
 
  mail("[EMAIL PROTECTED]", $subject, $message, "From: $from\nCc:
  [EMAIL PROTECTED]");
  ?
 
  I'm assuming you wanted to send a copy to [EMAIL PROTECTED]
 
  Please read the docs for mail(): http://php.net/mail
 
 
  Regards
 
  Simon Garner
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: Re: [PHP] passing variables in javascript

2001-02-22 Thread Simon Garner

From: "Nicholas W. Miller" [EMAIL PROTECTED]

   H ... is there anyway to do this without requiring the page
 with the link to use PHP?
 


Well if the string you're going to urlencode() is always going to be the
same, then just run it through once, grab the encoded version and hard-code
it :)




 
 You have to encode each part of the query string on the URL correctly:
 
 a href="#" onClick="MM_openBrWindow('../email/popup.php??php
  echo "title=" . urlencode("B2B Antitrust: Opening Moves in the
Game")
  . "url=" .
 urlencode("http://www.domain.com/biz/pubs.html#antitrust");
 ?', 'email','width=410,height=435')"Emailthis/a
 
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How to pass variables on php command line ?

2001-02-22 Thread Simon Garner

From: "Leonard Schneider" [EMAIL PROTECTED]

 I use PHP as script to generate HTML pages using the command
 php -q script.php  file.html
 
 I would like to pass some variables to the PHP script so that it
 generates a different HTML file.
 I tried the -d option but it seems it doesn't work.
 Is there any means of doing this ?
 
 
 Leonard Schneider
 


Easiest way is using environment variables.


?php
system("SOME_VAR=blah; php -q script.php  file.html");
?


Then in script.php you can do:

?php
$some_var = getenv("SOME_VAR");
?


Hope this helps,

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] htaccess problems disabling phplib

2001-02-21 Thread Simon Garner

From: "Gfunk" [EMAIL PROTECTED]

Hi, I'm trying to disable phplib, and I have a .htaccess file consisting of
the line

php_value auto_prepend_file none

And now I'm getting a 500 internal server error. Can anybody shed some
light
on what I'm doing wrong?

Cheers,
Gfunk


It sounds like your Apache configuration does not allow the php_value
directive to appear in an .htaccess file. Check your error_log for a
description of the problem.

In httpd.conf (or access.conf) find an applicable Directory block and
check the setting of AllowOverride.

I'm not actually sure what the override setting you need is, but you could
try Options or just All.

http://httpd.apache.org/docs/mod/core.html#allowoverride

Example:

Directory /www/htdocs
AllowOverride All
...
/Directory

Of course, if you're able to edit httpd.conf then you could just put the
php_value directive directly in there. :)


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Newbie passwordcheck-program problem

2001-02-20 Thread Simon Garner

Hi Ronald,


 Hello there fellow programmer,

 I just started learning PHP (I got version 4 installed with Apache on a
 Win98 machine). At the moment I'm trying to write a little program that
 verifies a user login.
 I know the program is not professional but for me it will do. Only I got
 stuck with the following problem. I have written a class (I'm not very
sure
 if this is the right way to do this) in which I specified a function that
 does the password check.
 Now I like the program to check the password and return me a true or a
false
 which I can read from somewhere else in my program.
 I wrote it like this:

First of all, you don't need a class for this. Unless you expect the program
to get a lot more complicated, you could just use a function.




 html
 head
titlePassword Check/title

 ?PHP class password
 {
  function checkpwd()
  { ?

  FORM ACTION="?php print("$PHP_SELF"); ?" METHOD="POST"
  User name is:BR
  INPUT TYPE="text" NAME="UserName" P

  ?php echo "Give Password:BR" ?

  INPUT TYPE="PASSWORD" NAME="passwd"
  INPUT TYPE="HIDDEN" NAME="GeefInfo" VALUE=1 p
  INPUT TYPE="submit"

  ?PHP if (IsSet($this-GeefInfo)IsSet($this-UserName))
{
 $this-UserName=strtoupper($this-UserName);
  $this-passwd=strtoupper($this-passwd);


$this-GeefInfo and $this-UserName will never be set. You need to change
this to something like:

if (isset($HTTP_POST_VARS["GeefInfo"]) 
isset($HTTP_POST_VARS["UserName"]))





if (IsSet($this-passwd))

Similarly here.

if (isset($HTTP_POST_VARS["passwd"]))


  {
 if ($this-passwd=="MYPASS"  $this-UserName=="RONALD")
 {
  $this- testvar=1;
  exit(1);
 }
 else
 {
  $this- testvar=0;
  exit(0);

I think you might be expecting exit() to do something different to what it
does here. The function exit() will terminate script execution. I suspect
what you wanted was return.

return 1;

else

return 0;




 }

  }

 }
   }
 }?

 /head
 body

 ?php $exec_pwd=new password;
 $vexec_pwd-checkpwd();
 print $exec_pwd; // Where is my output   ?


You won't get any output. $exec_pwd contains an object (an instance of your
"password" class).

If you want to output the return value from checkpwd(), do:

$exec_pwd = new password;
print $exec_pwd-checkpwd();


I think you may be a bit confused about how variables, classes and objects
work in PHP. Have a closer read through the manual. Moreover, if you're just
starting out with PHP then steer clear of objects entirely - you don't need
them!


 ?

 /body
 /html

 If you can and like to help me I will be very pleased.
 Thanks in advance !!!

 Ronald


Hope this helps.


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Re: sending variables

2001-02-20 Thread Simon Garner

From: "Ifrim Sorin" [EMAIL PROTECTED]

 In test1.php you shoul have
 
 ?
 $qry=getenv("QUERY_STRING");
 $rosen=substr($qry,6);
 print("$rosen");
 ?
 
 Sorin Ifrim


wtf? Most certainly do NOT do it like that. That's a ridiculous kludge.

Rosen, when you say "it doesn't work" what do you mean?





 
 Rosen [EMAIL PROTECTED] wrote in message
 96tdvp$oo7$[EMAIL PROTECTED]">news:96tdvp$oo7$[EMAIL PROTECTED]...
  Hi,
  I have two simple php files:
 
  main.php:
  A HREF="test1.php?rosen=11"LIST/A
 
  test1.php:
 
  ?print("$rosen");?
 
 
 
  But this doesn't work !
 
  please HELP !
 
 
 
  Rsen Marinov
 
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] How do I ....

2001-02-20 Thread Simon Garner

From: "Michael Zornek" [EMAIL PROTECTED]

 ok, I'm starting to play with sessions and have a few things I want
 to do, first is recompile --with-trans-sid and I'm pretty sure I know
 how to do that (make clean, then configure, etc.)

 However, I'm thinking of changing a few of the things ? phpinfo() ?
 is giving me like:

 session.use_cookie and/or session.save_path or anything else they list
there.

 My question.. how do you do it?

 Thanks
 Mike



I think you'll find those settings in your php.ini file.



Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] PHP SSI

2001-02-20 Thread Simon Garner

From: "Brandon Orther" [EMAIL PROTECTED]

 Hello,

 I am writing a banner rotation script and want to use Server Side include.
 When I try to include from any server other than the one that php script
is
 on I get an error,

 Error: [an error occurred while processing this directive]

 Any Ideas?


 Thank you,

 
 Brandon Orther
 WebIntellects Design/Development Manager
 [EMAIL PROTECTED]
 800-994-6364
 www.webintellects.com
 



SSI doesn't support opening files over HTTP, so what you're trying to do
will not work.

You either need to have your banner script called from an IMG tag in the
remote file (your script would return image data) - in which case you can't
do HTML banners - or the remote server needs to run PHP and do something
like this where the banner will appear:

?php
readfile("http://your-adserver.dom/banner.php?id=1234");
?


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] php and javascript

2001-02-20 Thread Simon Garner

From: "Carl Natale" [EMAIL PROTECTED]

 I need some help passing a variable to a popup window. The following form
 collects input from the user and stores it in the variable $summary.

 ?
 print "FORM action=\"hint.php\" METHOD=\"post\"";
 $summary = "Hellow universe";
 print "INPUT TYPE=\"hidden\" name=\"summary\" value=\"$summary\" ";
 print "input type=\"submit\" value=\"Try This\"
 onClick=\"window.open('hint.php', 'remote',
 'menubar,scrollbars,resizable,width=350,height=200,left=20,top=20');
 return false;\"";
 print "/form";
 ?


Try:

window.open('hint.php?summary=" . urlencode($summary) . "', )

Realise that the pop-up window is a totally separate document, from the web
server's point of view, hence hint.php cannot magically get the value of
$summary from the form page.





 When you click on the "Try This" button, hint.php opens up in another,
 smaller window just like I wanted. But the variable $summary doesn't show
 up

 ?
 file://hint.php script says this

 file://THIS LINE PRINTS
 print "Here's the hint:BR";
 file://BUT NOT THIS ONE
 print $summary;
 ?

 If I take JavaScript out of the submit coding, the browser window moves
 to hint.php and prints the $summary variable.

 I'm much more comfortable with PHP than JavaScript. How can I deliver the
 text in $summary to a second, smaller window?

 Thank you.




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] % Help

2001-02-20 Thread Simon Garner

From: "Jeff Lacy" [EMAIL PROTECTED]

 Hello Everyone,

 Could someone please explain the whole % thing?  I sort of understand it,
 but not quite.  My goal is to have a table, and have every row alternate
 between 4 colors.  I can alternate sort of alternate between 3, but not
 quite.  I have tried lots of different combinations, but I can't figure it
 out.  Thank you very much!

% is the modulus operator, it tells you the remainder after dividing two
numbers.

For example, 5 % 4 will give you the remainder after 5 / 4, which is 1.

A common use for this is to check if a number is even or odd, by doing
modulus 2. E.g.


?
function even_or_odd($number)
{
if ($number % 2)   // if remainder is not 0
{
return "odd";
}
else// remainder is 0
{
return "even";
}
}

echo even_or_odd(4);   // even
echo even_or_odd(13);  // odd
?


A practical application of that is inside a for-loop you increment a number
and return a different colour value depending on whether it's even or odd,
to give e.g. each row of a table an alternating background colour.

In your case if you want to alternate between four colours, all you need to
do is change to modulus 4 instead of modulus 2, i.e. $number % 4, and then
check if the remainder is 0, 1, 2 or 3.





 Maybe there should be a better link to it in the manual.  The only one I
 could find was at http://www.php.net/manual/en/ref.math.php, but it is far
 from clear (to me at least).


Well, this is a mathematical concept rather than PHP language-specific. :)


Cheers

Simon Garner


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]