RE: [PHP] Formating datevariables...

2002-07-22 Thread John Holmes

> I have a column in a mysql table with a timestamp. The value of this
> column
> is for instance:
> 
> 20020722185242
> 
> How do i change the format on this to "DDMM" (22072002) in php?

SELECT DATE_FORMAT(date_column,'%d%m%Y') AS Formatted_Date FROM
your_table

There's no need to involve PHP at all...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Digit Grouping

2002-07-22 Thread John Holmes

> I've got a small question. Does php provide any function to group a
number
> like 3193576 into 3.193.576  ? Just reads easier when the hits for my
> website are being displayed ... Or if php doesn't have a function for
it
> ..
> anybody any good suggestions on how to do it?

number_format()

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] redirecting after login

2002-07-23 Thread John Holmes

> why don't u do something like
> 
> if (!username)
> { you can not access this page
> }
> else
> {
>  //page content
> }
> 
> ?
> 
> that's a quick fix but might be all you need to do..

Umm...I hope register_globals is off...

www.yourdomain.com/yourpage.php?username=a_bad_user

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: MySQL - PHP combined log

2002-07-23 Thread John Holmes

I guess I missed the part where you wanted to implement something w/o
changing existing scripts. 

There's no easy way to do it right now. You could write a script that'll
run in the background and combine all of the error logs together. You
can turn on error logs for PHP and for MySQL. You'll still have the
problem of identifying which PHP page caused the MySQL error, though...

---John Holmes...

> -Original Message-
> From: PHPCoder [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 23, 2002 2:23 AM
> To: Richard Lynch
> Cc: php-general
> Subject: Re: [PHP] Re: MySQL - PHP combined log
> 
> Thanks, but all these "methods" require modification of the scripts
> already on the server, and it won't ensure any new script being
written
> by a user on my system to comply.
> Are you all saying that there are no logs kept by default of errors
> generated on php/mysql pages at all unless specifically coded?
Wouldn't
> it be possible then in future PHP releases to have a
"set_error_logging"
> directive in the php.ini file that will automatically run a wrapper
> function on all mysql_query() functions to do this kind of thing?
> 
> How are people out there managing the scripts/script errors caused  by
> users on their systems? Or is it a case of "handling the crisis when
it
> happens"?
> You see, as administrator, I need to be able to quickly see who are
> coding in such a way as to leave security holes, or even worse, cause
> the server to crash due to poor coding. There are almost 1000
individual
> php files on my server, and it wouldn't be possible for me to
scrutinize
> all of them to make sure they are OK.
> Are there any admins out there that have policies about scripting
> practices on their systems; ie, checking a script from a user before
it
> is allowed to be uploaded etc?
> 
> Thanks
> 
> 
> Richard Lynch wrote:
> 
> >>Hi, tried this on mysql list, no luck:
> >>
> >>I want to be able to view a single log that contains the following:
> >>
> >>IP of user : page_name (PHP only): time/date: MySQL query ( 'select
*
> >>
> >>from xxx' etc.) : error msg from mysql/php if any
> >
> >>So it's almost a hybrid between apache and mysql with some extra's
> >>
> >>I'm sure you all should see the benifit of this in troubleshooting
and
> >>specially keeping track of who does what when it comes to PHP coding
on
> >>ones server, specially with crappy code that kills the server.
> >>
> >>Is something like this possible, already there?
> >>
> >>PS, Running RedHat 7.0 with PHP4 and mysql 3.23.x
> >>
> >
> >http://php.net/error_log
> >
> >if you can get everybody to use your own function to query the
database.
> >
> >Or, you could use http://php.net/set_error_handler and
> >http://php.net/trigger_error and catch all errors thrown by all PHP
code.
> >
> >Actually, to get the PHP page name and line number, set_error_handler
is
> >probably your best bet.
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] How to store an image into a mysql database using php language?

2002-07-23 Thread John Holmes

There's no reason to store images in a database. It's a waste of time
and it's a slower process than just loading it off the disk. 

If you still want to know how to do it, search the web. This question is
asked every day and there are a couple dozen tutorials out there that'll
tell you exactly how to do it. 

---John Holmes...

> -Original Message-
> From: Rija [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 22, 2002 11:03 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] How to store an image into a mysql database using php
> language?
> 
> I want to store image data into mysql table using BLOB but I don't
know
> how to read it after. To record the image, I doesn't have any problem,
but
> to read the file after and to view the image, I can't do anything the
> variable show only comment like this: memobin24.bin
> 
> So how can I do?
> 
> This was the script.
> 
>  
> Include("connect.inc") ;
> 
> $fp = fopen("image/photo.jpg","r") ;
> 
> if ($fp) {
> 
> $code2 = "" ;
> 
> while (!feof($fp)) {
> 
> $buffer = fgets($fp, 4096);
> 
> $code2 = $code2.$buffer;
> 
> }
> 
> }
> 
> $code2 = addslashes($code2) ;
> 
> $table = 'image' ;
> 
> $instruction = mysql_query("INSERT into $table values ('','fichier
> inage','$code2','') or die("FATAL ERROR") ;
> 
> ?>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: Formating datevariables...

2002-07-23 Thread John Holmes

> Thanx for the help..
> 
> I ended up with this solution ;)
> 
> $dag = substr ( $row['endret_dato'], 7, 2 );
> $mnd = substr ( $row['endret_dato'], 4, 2 );
> $aar = substr ( $row['endret_dato'], 0, 4 );
> 
> date ("dmY", mktime(0,0,0,$mnd,$dag,$aar) )

Did you even read the replies? Why are you going to do a bunch of string
manipulation, mktime, and date calls in PHP when you can just use
DATE_FORMAT() in your query and get exactly what you want without any
additional work by PHP?

Take a little time and Read Chapter 6 of the MySQL manual. It will save
you a ton of work later on...

---John Holmes...


> -R
> 
> "Ragnar" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > I have a column in a mysql table with a timestamp. The value of this
> column
> > is for instance:
> >
> > 20020722185242
> >
> > How do i change the format on this to "DDMM" (22072002) in php?
> >
> > Thanx
> >
> > -R
> >
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Sorting db entries by Year-Month

2002-07-23 Thread John Holmes

Isn't there a MONTH function in PG?

SELECT * FROM your_table WHERE MONTH(NOW()) = MONTH(your_column) ??

Or if PG stores dates in the Unix timestamp format, is the an equivalent
to date() that you can extract the month from the column and compare
them??

---John Holmes...

> -Original Message-
> From: Andre Dubuc [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 23, 2002 7:26 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Sorting db entries by Year-Month
> 
> Apache 1.3.23 + PHP 4.1.2 + PostgreSQl 7.2
> 
> I have a guestbook that I would like to display the current month's
> entries.
> I can display all the entries before the current month, but i can't
seem
> to
> figure out how to extract the currrent month's.
> 
> Although the code below is a db issue, I don't know whether I should
write
> code to extract the info before or after the db connection. Should I:
> 
>   1.  Set up the parameters beforehand in PHP, and then do a
query;
>   2.  Within the query itself (as the code I tried [and didn't
work]
> below);
>   3.  Or, somehow in PHP, after I get all the results [obviously
> without the
>   db WHERE clause].
> 
>  // lots of code
> 
> $db = pg_connect("dbname=rap user=postgres");
> $query = "SELECT * FROM guest WHERE pdate = "{$_SESSION['pdate'] ==
> date('Y-m')";  // pdate is formatted ('Y-m-d')
> 
> // etc, etc. . .
> ?>
> 
> I know this is a simple question -- but my mind's totally blotto after
a
> day's coding.
> 
> Any help, pointers of where to look, or admonitions will be gratefully
> accepted.
> 
> Tia,
> Andre
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Sorting db entries by Year-Month

2002-07-23 Thread John Holmes

> further research indicates that for PG I could trysomething like:
> 
> SELECT EXTRACT(MONTH FROM TIMESTAMP)

I'm sure there is a NOW() or TIME() function in PG that returns the
current date/time. Then you could do this:

SELECT * FROM your_table WHERE EXTRACT(MONTH FROM your_column) =
EXTRACT(MONTH FROM PG_CURRENT_TIME_FUNCTION());

>  $today = getdate();
>  $start = $today['year'] . '-' . $today['mon'] . '-' . '01';
>  $end  =  $today['year'] . '-' . $today['mon'] . '-' . '31';
> 
> "SELECT * FROM guest WHERE pdate BETWEEN {$start} AND {$end}";
> 
> but PG doesn't like my format of $pdate as type date, since the result
for
> $start and $end seems to result in type integer. Sigh.

I think PG uses the unix timestamp format, the number of seconds since
Jan 1, 1970 or something. You could use a combination of date() and
mktime() and maybe even strtotime() to figure the unix timestamp of the
current month's start and end, then use the BETWEEN SQL given above...

---John Holmes...


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: Formating datevariables...

2002-07-23 Thread John Holmes

> Sure using MySQL specific calls is faster but makes you more dependant
> on MySQL and thus makes your application less portable to other
databases.
> 
> Cameron

Of course. It depends on your application. I know I'm only going to use
MySQL for the programs I'm doing now, so I can use this _faster_ method.


I felt weird about saying it was faster before, so I did some
benchmarking to make sure I could back up what I was saying. Using these
two functions:

function sql_method()
{
$query = "SELECT DATE_FORMAT(date_column,'%d%m%Y') FROM benchmark";
$result = mysql_query($query);
while($row = mysql_fetch_row($result))
{
$field = $row[0];
}

return;
}

function php_method()
{
$query = "SELECT date_column+0 FROM benchmark";
$result = mysql_query($query);
while($row = mysql_fetch_row($result))
{
$dag = substr ( $row[0], 6, 2 );
$mnd = substr ( $row[0], 4, 2 );
$aar = substr ( $row[0], 0, 4 );

$field = date ("dmY", mktime(0,0,0,$mnd,$dag,$aar));
}

return;
}

There were 1000 rows in the one column table, the single column being a
random date in the standard MySQL format. Each function was run 10
times.

Results:

SQL/PHP Date Manipulation   total time  average iteration time  
100% SQL Method 18ms0.0175564  
279% PHP Method 49ms0.0489336  

Your results may vary. I used some benchmark class by Sebastian
Bergmann.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] MySQL Backup and Restore

2002-07-23 Thread John Holmes

Second the MySQL Front recommendation. That's one heck of a tool that
makes things really easy.

Otherwise, use mysqldump like Peter recommended.

To dump the databases, use this from the system prompt:

mysqldump -uuser -ppassword database_name > filename.sql

To import, create the database and use this:

mysql -uuser -ppassword database_name < filename.sql

---John Holmes...

> -Original Message-
> From: Peter [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 23, 2002 11:04 PM
> To: kip; [EMAIL PROTECTED]
> Subject: RE: [PHP] MySQL Backup and Restore
> 
> grab ur self a copy of myphpadmin  or use mysqldump or just simply
make a
> copy of the data dir or grab ur self a copy of mysql_front
> 
> > -Original Message-
> > From: kip [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, 24 July 2002 12:58 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] MySQL Backup and Restore
> >
> >
> > Hi,
> >
> > Can you tell me the steps of backup and restore the databases in
Mysql?
> >
> > And can i specific a path for the backup file?
> >
> > Futhermore, i have installed the MySQL in Win2000 but i don't know
how
> to
> > restore the database of MySQL from a Linux server to Win2000 MySQL.
> >
> > Thanks
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Accessing upper directory of public_html directory

2002-07-23 Thread John Holmes

> I bought a web host service from a company named easyspace.com.  I
have
> tried to ask them this question many times but until now there is no
> response from them at all.
>   According to the security issue of placing password in script I
brought
> up
> days ago, some one on this news group suggested me to place such
script in
> directory above %public_html directory.  The problem is I do not know
how
> to
> access such directory.  Is it because the service I bought does not
allow
> me
> to do it? or if it is accessible, how to do it?

Just use include() or require() to "include" the file into your script.
You can provide a full path to the file (above the web root) or use a
relative path according to the file that's doing the including. Say you
using a script in your webroot and you want to include a db.php file
that's in an include/ directory above your web root. You can use:

include("/home/full/path/to/your/dir/include/db.php");

Or

include("../include/db.php");

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Trouble with \

2002-07-24 Thread John Holmes

> > Try this function:
> > http://www.php.net/manual/en/function.stripslashes.php
> 
> Oddly enough, as I told John, I did that as well and it doesn't work.

Are the \ there to escape anything, like ' or " or are they just in
there by themselves..as a delimiter or something. If the \ is by itself,
then stripslashes() won't do anything to it. Maybe you should just try

$newtext = str_replace("\","",$old_text);

Without seeing a sample of your file and some more information, all I
can give is "snooty" answers, evidently. 

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Speeding up PHP or MySQL

2002-07-24 Thread John Holmes

> Is there anyways to speed up MySQL queries?  Or showing the results
> through
> PHP? I have several queries that have about 8 left joins or so.. Yes
very
> huge and when you have lots of people using these functions at once it
> really slows down.. Are there any practices that you can think of that
> would
> speed up any sql queries?  I was thinking of using stored procedures,
but
> after a bit of research I found ou= t that MySQL doesn=B9t have that
yet
> so
> that's a no go :(  Or is there a way of storing common query results?
I
> am
> looking for _anything_ that will speed up showing results to large
> queries..

How about an index on your tables?

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: date

2002-07-24 Thread John Holmes

>   I am not sure it works, since isn't tested, but here we go. It's
pure
> Mysql, and it would be probaly easier, faster, and more readable to do
> with
> PHP mixed. But where's the fun of it? ;-)
> 
> date_field is the name of your date column.
> 
> $sql = "SELECT IF(DAYOFMONTH(date_field) = DAYOFMONTH(CURRENT_DATE),
> 'Today', IF (date_field = DATE_SUB(date_field, INTERVAL 1 DAYS),
> 'Yesterday', date_field)) FROM table"

I don't think you want DAYOFMONTH. Otherwise if today is July 24th, then
a date column with June 24th, or any 24th, will come up as Today.

Something like this will work, though...

SELECT IF(TO_DAYS(CURDATE()) =
TO_DAYS(date_column),'Today',IF(TO_DAYS(CURDATE())-1 =
TO_DAYS(date_column),'Yesterday',date_column)) FROM your_table;

Hope that helps...

---John Holmes...


> Julio Nobrega
> Pode acessar:
> http://www.inerciasensorial.com.br
> 
> 
> "Alexander Ross" <[EMAIL PROTECTED]> escreveu na mensagem
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > I have a column in one of my mysql tables which holds the date &
time
> that
> > the record was inserted.  When I run a query later on I want to
display
> the
> > date, but if the date is today or yesterday I want to display
"today" or
> > "yesterday" instead .. how do i compare to stored date with todays
date?
> > todays date -1?  Thanks
> >
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] datetime field - still a newbie

2002-07-25 Thread John Holmes

> I have a datetime field in one of my mysql tables...when displaying
some
> of
> my records I want to display the date in the aforementioned datetime
> field,
> but if the date is today I want to display "today" instead.  If the
date
> is
> yesterday I want it to display that  so I how do I compare the
date in
> my record to todays date? Thanks

I posted this response earlier...did you get it? Are you looking for a
MySQL solution or a PHP solution??

SELECT IF(TO_DAYS(CURDATE()) =
TO_DAYS(date_column),'Today',IF(TO_DAYS(CURDATE())-1 =
TO_DAYS(date_column),'Yesterday',date_column)) FROM your_table;

If you want a PHP solution, then just select the regular MySQL date
format MMDD and use something like this when looping through your
results.

switch($your_row['Date_Column'])
{
  case date("Ymd"):
echo "Today";
break;
  case date("Ymd",strtotime("-1 day")):
echo "Yesterday";
break;
  default:
echo $your_row['Date_Column'];
}

Untested code, of course...

---John Holmes...




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] preg_match() occurence position

2002-07-25 Thread John Holmes

> Can I get the starting position of my string occurence when using any
> regexps searching functions in PHP ?
> 
> for example:
> $mem='this is a test';
> preg_match('/test/', ...) should return me somehow: 10

Does it have to be a regular expression you are searching for? If not,
you can use strpos().

www.php.net/strpos

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Parse error - new set of eyes?

2002-07-25 Thread John Holmes

> elseif ((!isset($HTTP_SESSION_VARS['clk']) ||
> (!isset($HTTP_SESSION_VARS['holy_cow']) ||
> (!isset($HTTP_SESSION_VARS['ipaddy']) ||
(!isset($HTTP_SESSION_VARS['a']))

Your parenthesis don't match up, if I can count correctly today.

---John Holmes...




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] still on sessions

2002-07-26 Thread John Holmes

> Alright this is my last question. I have closed the session, but can i
> make
> sure it is closed? i want to use something like if the session is
closed
> then print a message session closed.

You don't have to close it; it's automatic. Just treat $_SESSION like
the regular variable it is. Anything you assign to it will be available
on any page you call session_start(). How much easier can it be??

If you really want a message, then on the last line of your file put 

echo "Session Closed";

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] calling user-defined php functions from tag

2002-07-26 Thread John Holmes

> There MUST be some creative way to call a user-defined PHP function
from
> an  tag. Does anyone have any suggestions?

Yeah, I got one. It's kind of crazy, but how about we assume PHP is
server side and anything that happens in the browser is called, well,
let's say client side. Let's, for argument's sake, say that server side
happens first to create the client side code. After the server side part
is done, it's done. It can't affect anything client side unless you
request another page or refresh the page.

>  Click here to start "function joe()". 

click here to run function joe().

Then place the following in function.php file:

>  function joe() {
>   $temp1=10;
>   $temp2=20;
>   $result=$temp1+$temp2;
>   echo "The result of this function is: " . $result;
> }
> ?>


> So, if the user clicks on the link, he'll see:  "The result of this
> function is: 20"

And he will, but it requires a page to be requested...otherwise use
JavaScript. 

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] RE:

2002-07-26 Thread John Holmes

> Hey, thanks for the reply. But I have multiple functions on one page
(and
> I need to keep it that way, because of all the variables I'm passing
> around between them), so I can't just have the link call a new php
file. I
> need it to somehow call a function within the page.

Okay, do you understand, though, that PHP is server side and the browser
is client side. PHP happens first, to generate the HTML code, that's
evaluated in the browser on the client side. Once PHP generates the HTML
code, it can't do anything else. It will take another page refresh or
request to invoke PHP again.

That being said, in your href link, pass an ID saying which function to
call. It can be the name of the function, or a number to relate to it.
Make the action of the page the current page.

Maybe something like this is what you're after??

Run Function
One";
    echo "Run Function
Two";
}
?>

---John Holmes...




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: Date() Problem

2002-07-27 Thread John Holmes

> I store all dates in unix timestamp format.  It's the easiest one to
work
> with, and it's easy to do things like "date + three days", because
it's
> just
> a case of adding the right number of seconds to the current stamp.
> 
> You don't have to split anything, or get substr()'s of anything... and
> since
> date() accepts unix timestamps AND is the easiest way to get date
formats
> (for me), I reckon it's the best way to go.

Well, I've got to butt in on this one and put in a big DISAGREE. Use
whatever is easiest for you, but MySQL provides a very rich assortment
of date and time manipulation functions that are a lot better than PHPs
(without any added classes). 

For example, to get everything from your database that was inserted
three days ago, you'd use:

SELECT * FROM your_table WHERE your_date_column = CURDATE() - INTERVAL 3
DAY;

Now, much of this is MySQL specific, though. I only use MySQL right now,
so it's not an issue, but it can be for some of you. 

Bottom line is use whatever is easiest for you, but realize that there
are a ton of Date and Time functions built into MySQL. Anything you can
do with a PHP function you can do with a MySQL function. You are also
not completely lost if you're storing things as Unixtimstamps. You can
convert from and to unixtimestamps and still make use of all of the
MySQL functions...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Q:What is the easiest way to test my PHP+Html pages?

2002-07-27 Thread John Holmes

Search on Google for PHPTriad or Firepages, or look on hotscripts.com or
sourceforge. There are a couple packages out there that'll install
Apache, PHP, and MySQL automatically for you on Windows. It's nice and
painless. 

Once it's installed, you run a little .bat program to start it all up,
and then call up http://localhost/ to view your pages.

---John Holmes...

> -Original Message-
> From: Marcus Unlimited [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, July 27, 2002 10:05 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Q:What is the easiest way to test my PHP+Html pages?
> 
> Hello,
> 
> Okay,
> 
> Here's what I want to do.
> 
> Simply test my PHP stuff and practice with MySQL.
> 
> I don't want to learn to master Unix or anything at all like that but
> these vague and arcane install instructions are leading me nowhere
> except to frustrations.
> 
> So what is the absolute simplest and easiest path to open my .html
pages
> 
> with some php mysql in em. and see them as they will work on the
web???
> 
> Thank you,
> -Marcus
> 
> 
> 
> --
>

||
> 
> 
> Marcus Unlimited
> http://marcusunlimited.com
> Multimedia Internet Design and Education
>

||
> 
> 
> ---
> Also visit:
> -  http://www.chromaticus.com
> -  http://ampcast.com/chromaticus
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] removing html...

2002-07-27 Thread John Holmes

Use a regular expression. Something like this should work.

eregi("(.*)",$html_text,$matches);

$matches[1] should contain the text you are after.

---John Holmes...

> -Original Message-
> From: JJ Harrison [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, July 27, 2002 9:41 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] removing html...
> 
> Hi,
> 
> I have search around on google/php.net to try and find a way to remove
> , everything above , and everything below it in a html
page.
> 
> eg.
> 
> 
> 
> test
> 
> 
> Blah Blah Blah
> 
> 
> 
> would become: Blah Blah Blah
> 
> I know how to use php to convert html to pure text etc but I don't
know
> how
> to remove the unwanted header and footer HTML.
> 
> I am pretty sure that someone must have done it(HTML file uploads for
> sites
> etc).
> 
> Thanks in advance and good night.
> 
> 
> --
> JJ Harrison
> [EMAIL PROTECTED]
> www.tececo.com
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] removing html...

2002-07-27 Thread John Holmes

Or...

preg_match("/(.*)<\/body>/i",$html_text,$matches);

---John Holmes...

> -Original Message-
> From: JJ Harrison [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, July 27, 2002 9:41 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] removing html...
> 
> Hi,
> 
> I have search around on google/php.net to try and find a way to remove
> , everything above , and everything below it in a html
page.
> 
> eg.
> 
> 
> 
> test
> 
> 
> Blah Blah Blah
> 
> 
> 
> would become: Blah Blah Blah
> 
> I know how to use php to convert html to pure text etc but I don't
know
> how
> to remove the unwanted header and footer HTML.
> 
> I am pretty sure that someone must have done it(HTML file uploads for
> sites
> etc).
> 
> Thanks in advance and good night.
> 
> 
> --
> JJ Harrison
> [EMAIL PROTECTED]
> www.tececo.com
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Q:What is the easiest way to test my PHP+Html pages?

2002-07-27 Thread John Holmes

.bat is a Batch file. All it's going to do is go through and start up
Apache and MySQL for you. Then you can call up your local pages in any
browser you have installed. You can run a .bat file to stop Apache and
MySQL when you are done, too.

It's all explained in the install instructions for the package you
install.

---John Holmes...

> -Original Message-
> From: Marcus Unlimited [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, July 27, 2002 11:17 AM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Q:What is the easiest way to test my PHP+Html
pages?
> 
> Hmm, .bat that is a new one for me, will I still be able to test my
pages
> in regular windows browsers like IE and NN?
> 
> -Marcus
> 
> 
> THANKS
> 
> John Holmes wrote:
> 
> > Search on Google for PHPTriad or Firepages, or look on
hotscripts.com or
> > sourceforge. There are a couple packages out there that'll install
> > Apache, PHP, and MySQL automatically for you on Windows. It's nice
and
> > painless.
> >
> > Once it's installed, you run a little .bat program to start it all
up,
> > and then call up http://localhost/ to view your pages.
> >
> > ---John Holmes...
> >
> > > -Original Message-
> > > From: Marcus Unlimited [mailto:[EMAIL PROTECTED]]
> > > Sent: Saturday, July 27, 2002 10:05 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] Q:What is the easiest way to test my PHP+Html
pages?
> > >
> > > Hello,
> > >
> > > Okay,
> > >
> > > Here's what I want to do.
> > >
> > > Simply test my PHP stuff and practice with MySQL.
> > >
> > > I don't want to learn to master Unix or anything at all like that
but
> > > these vague and arcane install instructions are leading me nowhere
> > > except to frustrations.
> > >
> > > So what is the absolute simplest and easiest path to open my .html
> > pages
> > >
> > > with some php mysql in em. and see them as they will work on the
> > web???
> > >
> > > Thank you,
> > > -Marcus
> > >
> > >
> > >
> > > --
> > >
> >

> > ||
> > > 
> > >
> > > Marcus Unlimited
> > > http://marcusunlimited.com
> > > Multimedia Internet Design and Education
> > >
> >

> > ||
> > > 
> > >
> > > ---
> > > Also visit:
> > > -  http://www.chromaticus.com
> > > -  http://ampcast.com/chromaticus
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> 
> --
>

||
> 
> 
> Marcus Unlimited
> http://marcusunlimited.com
> Multimedia Internet Design and Education
>

||
> 
> 
> ---
> Also visit:
> -  http://www.chromaticus.com
> -  http://ampcast.com/chromaticus
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: How to UPDATE two MySQL Tables

2002-07-27 Thread John Holmes

> You can use REPLACE instead of making two separate queries (UPDATE and
> INSERT) because it checks if it is there, and if it's not, then it
adds
> it;
> otherwise it updates it.  I think that's right ... but the SQL
server's
> SQL
> server is broken! (the irony!)

Just note that REPLACE is MySQL specific. A solution using it may not be
portable to other databases. May or may not matter to you...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Is it possible...

2002-07-27 Thread John Holmes

> Is it possible download php scripts from webpages ? for example i need
> php.net scripts or others :-)  If yes, how ?

Not unless they let you and give you a link to show the source or to
download it. You can't get the source for just any PHP page b/c it's
parsed on the server and only HTML is sent to you.

---John Holmes


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Quotes getting screwed up in form fields

2002-07-27 Thread John Holmes

> If someone enters this into a field...
> 
>New York "City"
> 
> and I need to re-display it in the field (if an error occurred, for
> example), this is what's in the field...
> 
>New York \
> 
> I have another multi-line text field that I used quotes in and this
> doesn't
> happen with that field, even though they are both being treated in the
> same
> manner. What am I missing?

If you look at your source code, you'll see that the entire string is
there. It will look like this:

Value="New York\"City\""

HTML doesn't know that \ is used to escape the " character. It just sees
the string "New York\" and treats the rest as an unknown attribute. 

So, to do it correctly, you should use this:

Value=""

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] removing html...

2002-07-27 Thread John Holmes

> I have search around on google/php.net to try and find a way to remove
> , everything above , and everything below it in a html
page.

FYI on the two methods I suggested:

preg_match("/(.*)<\/body>/i",$html_text,$matches);
eregi("(.*)",$html_text,$matches);

Preg vs. Ereg 
nametotal time  average iteration time  
100%Preg Method 59ms5.906E-005  
339%Ereg Method 200ms   0.00020036  

Each method was called 10,000 times. 

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Stopping Multiple Entries in mySQL DB

2002-07-27 Thread John Holmes

> I just want my Adding Into Database script to check if
> the Name/Country already exists, and if it does, it
> shouldn't be allowed.
> 
> If some with
> Name : Jackson
> Country : USA
> exists in my DB, no one with same name/country should
> be able to add his name/country in the DB.

Have your database handle that, not PHP.

When you create your table, make the combo of Name and Country unique.

CREATE TABLE your_table {
Name VARCHAR(15),
Country VARCHAR(15),
UNIQUE Name_Country (Name, Country)
}

Then you can have "Jackson, USA", "Jackson, UK", "Someone Else, USA",
etc...just not the same combination at all.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] string comparison

2002-07-27 Thread John Holmes

Strcmp() is case sensitive. So use it when you need a case sensitive
comparison.

---John Holmes...

> -Original Message-
> From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, July 27, 2002 12:35 PM
> To: PHP General
> Subject: [PHP] string comparison
> 
> Hello,
> 
> When should i prefer strcmp() above == or !=?
> I have test it out (see code below).
> But a == comparison seems to be faster always.
> First i thought is was cause, if(strcmp($1,$2)!=0),
> needs two comparisons (strcmp and !=). But even
> if($1!=$2) is faster then if(strcmp($1,$2)).
> 
> Thanks,
> 
> Bas Jobsen
> 
>  
> function getmicrotime(){
> list($usec, $sec) = explode(" ",microtime());
> return ((float)$usec + (float)$sec);
> }
> 
> 
> $t1='hello';
> $t2='hello';
> $t3='hallo';
> 
> ?>
> 1000x: $start=getmicrotime();
> for($a=0; $a<10; $a++) if(strcmp($t1,$t3));//nonmatch
> echo getmicrotime()-$start;
> ?>
> 
> 1000x: $start=getmicrotime();
> for($a=0; $a<10; $a++) if($t1!=$t3);//nonmatch
> echo getmicrotime()-$start;
> ?>
> 
> 
> 1000x: $start=getmicrotime();
> for($a=0; $a<10; $a++) if(!strcmp($t1,$t3));//match
> echo getmicrotime()-$start;
> ?>
> 
> 1000x: $start=getmicrotime();
> for($a=0; $a<10; $a++) if($t1==$t3);//match
> echo getmicrotime()-$start;
> ?>
> 
> 
> 1000x: $start=getmicrotime();
> for($a=0; $a<10; $a++) if(strcmp($t1,$t2));//nonmatch
> echo getmicrotime()-$start;
> ?>
> 
> 1000x: $start=getmicrotime();
> for($a=0; $a<10; $a++) if($t1!=$t2);//nonmatch
> echo getmicrotime()-$start;
> ?>
> 
> 
> 1000x: $start=getmicrotime();
> for($a=0; $a<10; $a++) if(!strcmp($t1,$t2));//match
> echo getmicrotime()-$start;
> ?>
> 
> 1000x: $start=getmicrotime();
> for($a=0; $a<10; $a++) if($t1==$t2);//match
> echo getmicrotime()-$start;
> ?>
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Combining Columns in MySQL for PHP

2002-07-27 Thread John Holmes

> SELECT COMBINE(column_1, column_2) As column FROM column_list;
> 
> Would give me the results of column_1 and column_2 simply by going
through
> "column".

Use CONCAT() where you have COMBINE().

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Combining Columns in MySQL for PHP

2002-07-27 Thread John Holmes

You have a bad database design if you need something like what you are
describing. The columns should probably be in another table, with a
second column, a number, saying which column the number is for.

So your second table would look like the result you want to have...

You may be able to do it with a temporary table, though:

INSERT INTO temp (col) SELECT col1 FROM your_table;
INSERT INTO temp (col) SELECT col2 FROM your_table;
SELECT col FROM temp ORDER BY col ASC;

---John Holmes...

> -Original Message-
> From: Chris Earle [mailto:[EMAIL PROTECTED]]
> Sent: Saturday, July 27, 2002 4:08 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Combining Columns in MySQL for PHP
> 
> Thanks for the reply, and I see that I didn't get specific enough (my
> fault!
> sorry).
> 
> Here's what I want to take from:
> 
> +-+--+
> | col_1| col_2 |
> +-+--+
> | 2.0| 6.8|
> +-+--+
> | 4.1| 8.9|
> +-+--+
> 
> I want to do something like SELECT COMBINE(col_1, col_2) as col FROM
> column_list ORDER BY col;
> 
> Which would give me:
> 
> +---+
> | col |
> +---+
> | 2.0 |
> +---+
> | 4.1 |
> +---+
> | 6.8 |
> +---+
> | 8.9 |
> +---+
> 
> CONCAT would only work if I want strings concatenated on the same row.
Is
> there some way I can use JOIN to get what I want?
> 
> "John Holmes" <[EMAIL PROTECTED]> wrote in message
> 000201c235a7$59348560$b402a8c0@mango">news:000201c235a7$59348560$b402a8c0@mango...
> > > SELECT COMBINE(column_1, column_2) As column FROM column_list;
> > >
> > > Would give me the results of column_1 and column_2 simply by going
> > through
> > > "column".
> >
> > Use CONCAT() where you have COMBINE().
> >
> > ---John Holmes...
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Speed issues.

2002-07-28 Thread John Holmes

> I am new to PHP and trying to implement some PHP and MySQL on my
website.
> My
> website has a lot of tables and inside some of those tables, I want to
> display information that is drawn out of the MySQL database using PHP.
I
> was
> wondering what goes faster:
> 
> (A). Building the whole page normally up in HTML, doing the usual

>  and so forth, and then inside the  calling up the PHP in
order to
> display the information. For example:   
> 
> (B). Doing everything in the PHP document, also the 'building' of the
> tables, and then including the PHP script in the main page. For
example
> using printf("  and so forth.

(A) will be faster, generally. Plus it's easier to read and find the PHP
snippets in the HTML, than it is to read an entire page of print/echo
statements. And it'll generally open neatly in a graphical HTML editor,
too.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] php 'mail()' security

2002-07-28 Thread John Holmes

HTTP_REFERRER can be spoofed quite easily with some browsers. 

The best way to handle this is to provide as much of your own data as
possible, and validate anything you do end up using from the user.

For instance, use your own subject, make sure the To: address comes from
you (a file or database, whatever), etc... Make sure anything coming
from the user, that you put into the headers, subject, from, reply-to,
etc... do not have any line breaks. A simple str_replace or something to
remove them, or pop up an error if they are there, will work.

The less user data you can use the better. It gives them less of a
chance to insert extra headers, which is pretty much the only threat. If
there's a possibility of the email not being shown as plain text, then
you'll want to use striptags() like others mentioned. 

---John Holmes...

> -Original Message-
> From: Tech Support [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, July 28, 2002 10:57 AM
> To: Dennis Gearon; Bob Lockie
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] php 'mail()' security
> 
> There is no substitute for good data verification such as strip_tags()
or
> some regular expressions to limit valid input. I also would recomend
> checking the referrer to be sure someone doesn't hijack you form and
try
> to
> modify it and submit it from a remote location. Here is an example:
> 
> if (validReferrer() === false)
>  die("invalid referrer");
> 
> function validReferrer()
> {
>  $_valid_referrers =
> array("www.yoursite.com","www2.yoursite.com","yoursite.com");
>  $referer = str_replace('//', '/', $_SERVER['HTTP_REFERER']);
>  $ref = explode('/', $referer);
>  if ( in_array($ref[1], $_valid_referrers) )
>   return true;
>  else
>   return false;
> }
> 
> Jim Grill
> Support
> Web-1 Hosting
> http://www.web-1hosting.net
> - Original Message -
> From: "Dennis Gearon" <[EMAIL PROTECTED]>
> To: "Bob Lockie" <[EMAIL PROTECTED]>
> Cc: <[EMAIL PROTECTED]>
> Sent: Saturday, July 27, 2002 10:54 PM
> Subject: Re: [PHP] php 'mail()' security
> 
> 
> > What I meant was, how to sanitize the input on the forms so that
> > malicious stuff cannot be put as commands, etc. in the email
address, or
> > body, or 'extra' field of the 'mail()' function in PHP.
> > --
> > -
> > Joy is just a thing (to be).. raised on,
> > Love is just the way to Live and Die,
> > John Denver.
> > -
> > He lost a friend, but kept his Memory (also John Denver),
> > Thank you...John Corones...my friend always.
> > -
> > Look lovingly upon the present,
> > for it holds the only things that are forever true.
> > -
> > Sincerely, Dennis Gearon (Kegley)
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] PHP-MySQL connection problem

2002-07-29 Thread John Holmes

> My server is running on shared server which has support for PHP 4.1.2.
I
> installed mySQL for our shared server. I also installed phpMyAdmin.
Both
> are running properly. But I am facing following problems
> 
> 1) If there is any error in the script - It is not getting displayed -
> screen is becoming blank, so it is becoming very difficult for me to
make
> out any mistake.

Check PHP.ini and make sure display_errors is ON.

> 2) I am trying to send email - but not getting any email. This is the
> script
>  $mailBody = "This is one line \ n This is a second line \n\n this is a
> third line";
> 
> $boolMail = mail ("[EMAIL PROTECTED]", "Test mail", $mailBody);
> print ("Email has been send ");
> ?>
> 
> I am getting print statement but not the mail. Any extra settings are
> required ?

Just the settings in PHP.ini in the mail section. Ensure you are even
using a PHP.ini to begin with, too. If there isn't one, PHP will use its
own defaults. 

Load up a page that has just  in it and in the first
block shown, it'll tell you where PHP thinks it's PHP.ini file is. Edit
that file if it's there. If it's not, then look for a PHP-ini.dist or
PHP-ini.recommended in the files you downloaded and rename it to PHP.ini
and copy it to that location. 

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Resetting ID

2002-07-30 Thread John Holmes

> I have a table, with 4 columns. One of the column is
> ID, a Primary Key, which has Auto_Increment set on it.
> 
> 
> Now i have a lot of rows deleted and a lot of
> duplicate rows that will be deleted, and all sorts of
> stuff happening in the table.. the result is, that the
> IDs have become inconsistent.
> 
> What you get is something like
> 5,6,9,10,25,32,33 .. and so on. With many IDs missing
> etc.
> 
> What i want to do is delete the entire IDs and
> generate them again so that they are in one single
> order like 1,2,3,4,5... .like this.
> 
> And so that any new entry in the table gets the ID
> accordingly. How can i do this?

Who cares if your IDs aren't sequential?? All these IDs are for is to
provide a unique identifier for each row. That's it. If the holes are
causing a problem in your scripts, then you are using this column
incorrectly. My guess is that you'd want to read up on the COUNT() or
LIMIT functions in MySQL...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Pulling a data from array of checkboxes

2002-07-27 Thread John Holmes

> I am passing a value of checkboxes in a form to a new page like this
(see
> example here: http://www.gibsonusa.com/test/check/)
> In a new page how can I pull the data from a MySQL database according
to
> each value I passed from a previous page? In other words: Assume that
the
> value of a checkbox equal to the ID of the record in a database. The
value
> of checkbox 1 (for example) is 12345 and the value of checkbox2 is
67890.
> After passing those values to a new page how can I pull the rest of
the
> information from a database for those values?

http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Hide the undefined offset error for the array?

2002-07-30 Thread John Holmes

> I have one of the website on windows and I get the undefined offset
error,
> I
> don't have that problem on UNIX / Linux.  Anyone know what method
would
> work??  Here's the script!  In this case, the $raw_data array is
empty, so
> window complain of the empty data by displaying hte error message,
> "Undefined offset ".
> 
> --clip--
> if ($raw_data[$num_count] != $match_array[$x]) {
> --clip--

It's now a Windows/Unix thing...your installations of PHP have different
error reporting levels set in PHP.ini. So, either change the error
reporting in PHP.ini or with the error_reporting() function, hide the
warning by using @, or check and make sure the variable exists before
you use it.

if(@$raw_data[$num_count] != $match_array[$x])

or...

if(isset($raw_data[$num_count]) && $raw_data[$num_count] !=
$match_array[$x])

Hmm...what are you doing, btw? Are you use you couldn't make use of
in_array()??

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] $row and alias

2002-07-30 Thread John Holmes

Use ibase_fetch_row() instead... Then you can use count() on it to see
how many columns there are and loop through them all. 

---John Holmes...

> -Original Message-
> From: Saci [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, July 30, 2002 2:44 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] $row and alias
> 
> I would like to show some fields based on a Interbase database,
everthing
> is
> working when i type the fields name usinf $row-> field
> 
>  something like this
> 
> while ($row = ibase_fetch_object($sth)) {
>   echo "$row->RAZAO_SOCI";
>   echo"$row->ENDERECO\n" ;
> }
> 
> But I would like to make a generic output without declaring the field
name
> in code.
> 
> I discover that the code bellow show-me the field names and alias for
any
> feetched database
> 
> while ($row = ibase_fetch_object($sth)) {
>   for ($i=0; $i < $coln; $i++) {
> $col_info = ibase_field_info($sth, $i);
> echo "name: ".$col_info['name']." ";
> echo "alias: ".$col_info['alias']."";
> 
> }
> 
> 
> How can I output the data field content based on field alias  (
> .$col_info['alias'].""; )
> 
> 
> 
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] shorter way to write include function?

2002-07-31 Thread John Holmes

No.

---John Holmes...

> -Original Message-
> From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 31, 2002 7:58 AM
> To: PHP General
> Subject: [PHP] shorter way to write include function?
> 
> Hello,
> 
> i have
> /include/dotest.php:
>  function dotest() {echo 'test';}
> ?>
> 
> and test.php:
>  include('/include/dotest.php');
> dotest();
> ?>
> 
> Us there a shorter way to write out that. I mean something like
> 
> include::dotest;
> 
> Thanks,
> 
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Can several different sessions coexist?

2002-08-01 Thread John Holmes

> I'd like to register a session and create several session variables.
In
> another part of my site, I'd like to register another session again
> creating
> session variables.  After a bit, I'd like to destroy this second
> registered
> session keeping the first intact.  Thus far, whenever I issue:
> 
> session_unset();
> session_destroy();
> 
> both sessions are obliterated.  Is there a method of managing
different
> sessions where I can create additional sessions and destroy them
without
> losing my initial session?

There is only one $_SESSION. What you can do, though, assuming you're
using the latest version of PHP, is make $_SESSION a multi-dimensional
array.

So for one area of your site, you can assign variables to the session
like this:

$_SESSION['area_one']['value1'] = "This String";
$_SESSION['area_one']['value2'] = 10;

Then, in another area, you can do the same thing, basically...

$_SESSION['area_two']['value1'] = 'Something';
$_SESSION['area_two']['value2'] = 1000;

Then...when you want to drop the session values for Area Two, you just
do this:

Unset($_SESSION['area_two']);

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Why do i get this Notice Message?

2002-08-02 Thread John Holmes

> Could someone please tell me why i get the following Notice Message
> 
> Notice: Undefined variable: PHP_SELF in
> g:\apache_web\intern\looney\index.php on line 101
> 
> Code affected:
> 
> function WriteNewArticle()
> {
> Line 100:  $smarty = new Smarty;
> Line 101:  $smarty->assign("PHPSELF", $PHP_SELF);
> // etc.

Why? Because $PHP_SELF is an undefined variable. There is nothing
assigned to it and you're trying to use it in a function. 

But, you say, $PHP_SELF is supposed to be the current page. Yes,
normally it would with register_globals ON, but you are inside of a
function, so it is a whole new variable now. 

So, like someone else suggested, make it global inside your function

Global $PHP_SELF;

Or, if you're on a new version, just use $_SERVER['PHP_SELF'] and you
don’t have to worry about global.

---John Holmes...


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] PHP Hosting

2002-08-02 Thread John Holmes

Safe_mode = ON

Open_basedir restrictions

Use PHP in CGI mode and each runs as it's own user with access to only
it's own file (may require separate Apache's, too...)

---John Holmes...

> -Original Message-
> From: Matt Babineau [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 02, 2002 9:04 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] PHP Hosting
> 
> If any PHP hosts are out there I have a question:
> 
> How do you keep users from erasing / altering files out side of their
> web folder with PHP? Doesn't PHP run in the system user context? Is is
> possible to prevent a user from using PHP to alter anything but in
their
> Web folder?
> 
> Matt Babineau
> MCWD / CCFD
> -
> e:  <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
> p: 603.943.4237
> w:  <http://www.criticalcode.com/> http://www.criticalcode.com
> PO BOX 601
> Manchester, NH 03105
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] REGISTER_SHUTDOWN_FUNCTION() BUG -- Please Fix.

2002-09-17 Thread John Holmes

I'm not sure if that's a "bug", it's more of a feature request.

---John Holmes...

> -Original Message-
> From: Jason Caldwell [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 17, 2002 3:24 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] REGISTER_SHUTDOWN_FUNCTION() BUG -- Please Fix.
> 
> I'm posting this here to give this BUG attention.  It's a pretty
serious
> one
> for Win32 users, and it would be great if it could be fixed *very
> quickly* -- I posted this in the Bug Reports on PHP.net on May 27th,
2002.
> 
> Here's the link: http://bugs.php.net/bug.php?id=17461
> 
> I need to use this function to perform certain *required* tasks on a
> Timeout -- however (and please read the Bug Report, before replying)
the
> Timeout functionality of this function DOES NOT work on Win32 builds.
> 
> If your a C/C++ / PHP contributor and have a moment to look into this
--
> it
> would be great -- I would love to see this fixed in release 4.2.4 !!!
> 
> Thanks
> Jason
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] COOKIE Question.

2002-09-17 Thread John Holmes

> I do the print $_COOKIE["Acccess]"; and I still don't see any data
print.

Did you typo in your code like you did here??

Try to dump the whole $_COOKIE[] array and see what's in it. 

print_r($_COOKIE);

Did you mention what version of PHP you were using?

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] stopping repeated posts to a Bulletin Board

2002-09-17 Thread John Holmes

> What is the best way to avoid the "repeated comment/post" syndrome
> caused by the user clicking the submit button one too many times
> because he/she did not wait for the browser to return a confirmation
> page or the script took too long to execute.

Along with the other suggestions, 

You can use a processing page that doesn't output anything and just does
the insert and then redirects to a "success" page. Then, if they hit
refresh, then it will only refresh the "success" page, not the
processing page. 

You can also restrict the user to only posting once every XX seconds. 

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] stripslahes() | Common pitfalls?

2002-09-17 Thread John Holmes

> I'm using cookies to pre fill a form and, I can't work out why I can't
> get the stripslashes() function to work?
> 
> Are there any common pitfalls you can think of, I've tried just about
> everything...

Show some code. What's the actual value of the cookie before you
stripslashes() it?

I'll guess that you're not assigning the result to anything. Are you
doing this?

stripslashes($_COOKIE['value']);

instead of

$new_value = stripslashes($_COOKIE['value']);

??

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Urgent Installation Question

2002-09-18 Thread John Holmes

Have you tried the chapter in the PHP manual on installation? It walks
you right through it. 

MySQL is just a simple unzip and go, there's no real setup to it at all
other than changing the root password...

---John Holmes...

> -Original Message-
> From: César Aracena [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 18, 2002 5:39 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Urgent Installation Question
> 
> Hi all,
> 
> I know this has been answered a lot in this list, but I'm not at my
> computer where I have fast access to my e-mails. I'm about to make my
> first PHP - MySQL installation under Win2K + IIS 5.0 and really don't
have
> a clue of what to do (also sleepy). I've downloaded the 4.2.3 version
of
> PHP and the version 3.23.52 of MySQL for Windows... what now?
> 
> I'll leave the PDF, GD, and other libraries for another PHP
compilation
> for now. I just need to test my Win2K + IIS configuration.
> 
> Thanks in advance,
> 
> César Aracena


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Urgent Installation Question

2002-09-18 Thread John Holmes

There should be a php-ini.dist that you can rename to PHP.ini 

---John Holmes...

> -Original Message-
> From: César Aracena [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 18, 2002 6:03 AM
> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
> Subject: Re: [PHP] Urgent Installation Question
> 
> Thanks. I installed PHP first and will install MySQL (once the
download
> finishes) hoping they'll work together just fine. One thing's
missing...
> the
> phpinfo.php file, which should be here... but isn't... Should I grab
it
> from
> somewhere else?
> 
> Thanks again, C.
> 
> - Original Message -
> From: "John Holmes" <[EMAIL PROTECTED]>
> To: "'César Aracena'" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
> Sent: Wednesday, September 18, 2002 7:57 AM
> Subject: RE: [PHP] Urgent Installation Question
> 
> 
> > Have you tried the chapter in the PHP manual on installation? It
walks
> > you right through it.
> >
> > MySQL is just a simple unzip and go, there's no real setup to it at
all
> > other than changing the root password...
> >
> > ---John Holmes...
> >
> > > -Original Message-
> > > From: César Aracena [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, September 18, 2002 5:39 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] Urgent Installation Question
> > >
> > > Hi all,
> > >
> > > I know this has been answered a lot in this list, but I'm not at
my
> > > computer where I have fast access to my e-mails. I'm about to make
my
> > > first PHP - MySQL installation under Win2K + IIS 5.0 and really
don't
> > have
> > > a clue of what to do (also sleepy). I've downloaded the 4.2.3
version
> > of
> > > PHP and the version 3.23.52 of MySQL for Windows... what now?
> > >
> > > I'll leave the PDF, GD, and other libraries for another PHP
> > compilation
> > > for now. I just need to test my Win2K + IIS configuration.
> > >
> > > Thanks in advance,
> > >
> > > César Aracena
> >
> >



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Stripping specific tags

2002-09-19 Thread John Holmes

> I was wondering is there a way to strip ONLY the tags that you specify
> from
> a page, rather than having to include all the tags you do want (using
> strip_tags() )

A regular expression or str_replace() would be best for this. 

Realize this isn't a good method, though. What if you're trying to strip
images with an  tag, but a new spec comes out that allows 
tags. Now you're not protected against it. That's a simple example, but
it's a better policy to say X is good and allow it through, rather than
to say, I know Y is bad, but I'll let everything else through and assume
it's good.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Loop through POST-result

2002-09-19 Thread John Holmes

> I would like to get all the data from a POST-result into an array.
> 
> Is there a function like that adds all the vars from the post into an
> array
> where Key is the name of the form-field and Value is the value entered
in
> this field.
> 
> Like this:
> array('firstname' => 'fname', 'lastname' => 'lname');

Are you serious?

Take a look at the $HTTP_POST_VAR or $_POST array, which, amazingly, is
an array that holds your form data, with the key is the name of the form
field and the value is the value of the form element

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Stripping specific tags

2002-09-19 Thread John Holmes

> That's what I thought the answer would be. I guess I will have to see
if I
> can create a function to add to the next release of PHP to do this, as
> there
> certainly seems to be quite a demand for it, according to the archives
> anyway.

I hope not. That would be a worthless function to have. Did you read my
post? The basic idea is validation is to allow what you _know_ is good,
and kill the rest. You don't kill a couple things you know are bad, then
assume the rest is good and let it in.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Script Modificaton question

2002-09-19 Thread John Holmes

> I have a chat script that I downloaded and according to the license I
> can modify it as much as I want, and I'm a little stuck on a simple
> modification I want to make. When you type in a message it stores in
in
> a file called text.php and then the chat page does an include call for
> the text.php file.  Currently, the writer of this script has it setup
so
> all new text added is placed at the begining of the file using the
"w+"
> command, according to php.net with fopen if I switch the "w+" to "a+"
it
> shoudl place the new data at the end of the file. However, when I make
> this switch,  the data is still being placed at the begining of the
> text.php file. I've including the portion of the script that writes to
> text.php can someone help me find what I'm not seeing?
> 
> $filename = "text.php";
> $fileAr= file($filename);

It's reading the whole file into an array here. The newest lines will
still be first.

> exec("cat /dev/null > '$filename'");
> $fd = fopen( $filename, "w+" );

This opens the file and truncates it to zero length.

> $filemessage = " 
>
href=\"javascript:launcher('profile.php?username=$username');\">$user
na
> me:
> ";
> $filemessage .=" color=\"$fcolor\">$chat\n";
> fputs($fd,$filemessage);

This write the new, formatted message.
 
> $numLines = 20;
> for ($i=0;$i<$numLines;$i++) {
> fputs($fd,$fileAr[$i]);

And then write the first 20 lines of the file.

> }
> fclose( $fd );

So, if you want it in the new format of newest chat last in the file,
then use the same script, but fputs() the 20 old lines first, then the
new line. Just change the order.

This would work for you:

$numLines = 20;
$filename = "text.php";
//read whole file
$fileArr = file($filename);
//open file and truncate to zero
$fp = fopen($filename,"w+");
//write 20 lines of old file to new file
fputs($fp,array_slice($fileArr,0,$numLines);
//format $message
//write message to file
fputs($fp,$message);
//close file
fclose($fp);

Adapt to your needs...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Date Concat?

2002-09-20 Thread John Holmes

> I have two fields of type date in a MySQL table called training:
> 
> start_date
> end_date
> 
> I can format the date using a select, for example
> 
> SELECT
> DATE_FORMAT(start_date, '%M %d, %Y') as start_date,
> DATE_FORMAT(end_date, '%M %d, %Y') as end_date
> FROM training
> 
> This produces the following:
> 
> start_date: September 16, 2002
> end_date: Sepetember 20, 2001
> 
> Based on the above, I would like to echo out something like this:
> 
> You will be in training September 16 - 20, 2002.

SELECT 
  CONCAT(
'You will be training ',
DATE_FORMAT(start_date,'%M %d'),
' - ',
IF(MONTH(start_date)!=MONTH(end_date),
  DATE_FORMAT(end_date,'%M %d'),
  DATE_FORMAT(end_date,'%d')),
' ',
YEAR(end_date)) 
FROM training

Another option would be to just select out the individual month, day,
and year out of the database, instead of a formatted date. Or select out
a unix_timestamp and use date() to extract the individual parts and
create your string...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Sessions

2002-09-20 Thread John Holmes

You have session_start() on the second page, too, right??

> -Original Message-
> From: Erwin [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 5:45 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Sessions
> 
> Hi all,
> 
> I'm having a problem with sessions. I use PHP version 4.2.2.
> The project I'm working on, only uses the global variables, $_GET,
$_POST
> and $_SESSION.
> 
> When I store something in the $_SESSION variable, everything goes
well. I
> can print the contents of this array with print_r, and every variable
I
> stored is there. But when I leave the page with the header(...)
directive
> (or any other way), the session is empty!
> 
> The session file contains no data (so it is created!), the $_SESSION
> variable is empty...
> 
> Some extra information:
> - I've tried this on PHP 4.1.2, and that works OK
> - I've tried output_buffering (on and off)
> - I've tried registered_globals (on and off)
> - I've tried using "session_write_close()" before leaving the page
> - I've checked the "session_start()" statement (Yes, it's there :-) )
> 
> I hope someone can help me with this...
> 
> Thanks in advance,
> 
> Erwin
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Is php even right for this design?

2002-09-20 Thread John Holmes

> I don't know if this is possible, but in VB (I'd like to find
something
> similar in php) I would open a record set, and then filter / unfilter
it
> for
> similar issues (in a loop).  I'm assuming you could use a similar
approach
> somehow in php.

Seems like a waste of resources. Why not do the filtering with the SQL
query? Why are you selecting out more than you need?

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] return the amount of records in a mysql databace

2002-09-22 Thread John Holmes

Then do a SHOW DATABASES query before that and loop through the results,
counting the rows in each table. 

If you have to do this, though, I think you have some normalization
issues with your database...

---John Holmes...

> -Original Message-
> From: Jeff Bluemel [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 22, 2002 11:46 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] return the amount of records in a mysql databace
> 
> this is only going to return records in a table, and not in a database
> 
> 
> > select count(*) as n from ... where ...
> >
> > -Original Message-
> > From: Philip J. Newman [mailto:[EMAIL PROTECTED]]
> >
> > Can someone point me in the right direction to find out how i can
return
> the
> > amount of records in a mysql databace ?
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] mysql password function

2002-09-22 Thread John Holmes

Use this:

$result = mysql_query("SELECT PASSWORD(" . $_POST['password'] . ")");
$password = mysql_result($result,0);

or just use mysql_fetch_row() or AS in your query so you don't have to
recreate that complex column name.

---John Holmes...

> -Original Message-
> From: Murat Ö. [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 22, 2002 9:33 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] mysql password function
> 
> hi,
> i want to encode a string that users enter with mysql password
function.
> but
> sometimes this code works sometimes don't. mysql warns me:
> Warning: mysql_fetch_array(): supplied argument is not a valid MySQL
> result
> resource in 
> 
> the code is:
> 
> $result=mysql_query("select password(".$_POST['password'].")");
>   while ($p = mysql_fetch_array($result, MYSQL_ASSOC)):
>   $pswrd=$p['password('.$_POST['password'].')'];
>   endwhile;
> 
> thanks...
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Replace linefeed/newline from text inputs with tag?

2002-09-22 Thread John Holmes

> If i have a textarea form input for users and they enter in return
spaces,
> how can i replace the ascci chars with html tags?

It'd be great if they had a function for this...they could call it
nl2br() or something...

www.php.net/nl2br

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] FW: Cannot Redeclare?

2002-09-22 Thread John Holmes

Funcs.php is probably being included twice at some point in your code.

---John Holmes...

> -Original Message-
> From: Stephen Craton [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 22, 2002 10:56 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] FW: Cannot Redeclare?
> 
> Hello,
> 
> I was just wondering...again...why the heck I keep getting this error.
> I'm trying to make a function called login() and sometimes it works,
> other times it hates me and gives me this error:
> 
> Fatal error: Cannot redeclare login() in
> c:\apache\htdocs\wiredphp\member\funcs.php on line 5
> 
> Here's the contents of the function login():
> 
> function login($username, $password)
> {
>   $sql = "select * from members where username='$username' and passwd
=
> password('$password')";
>   $result = mysql_query($sql, $wired);
>   if (!$result)
>  return 0;
> 
>   if (mysql_num_rows($result)>0)
>  return 1;
>   else
>  return 0;
> }
> 
> Please help. I don't see why this keeps happening...
> 
> Thanks,
> Stephen
> http://www.melchior.us
> http://php.melchior.us
> 
> P.S. I'm sending this again because I don't know if the other got
> through or not...
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Help with mail...

2002-09-22 Thread John Holmes

Variables are not evaluated within single quotes. You are trying to send
an email to $address, literally. If you just have a single variable,
lose the quotes entirely.

Mail($address,$subject,$body);

---John Holmes...

> -Original Message-
> From: Chuck "PUP" Payne [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 22, 2002 11:41 PM
> To: PHP General
> Subject: [PHP] Help with mail...
> 
> Hi,
> 
> Well after read php.net and my copy php 4 bible. I am lost with mail.
I
> can
> get it to work if I do this...
> 
> Mail ('[EMAIL PROTECTED]', 'Data Added',
>$fname, $lname .);
> 
> But I can't get this to work...I know someone going to call me stupid
but
> I
> am really having people with mail(), Is there a special place to put
it?
> 
> Here example of my codeany way I trying to hammer it out and using
> google to see where the error of my way is.
> 
> Chuck Payne
> 
> 
> ---
> 
> 
> 
> Killers Added
> 
> 
> 
> 
>  
> if ($fname=="") {
> echo "You did not supply a first name. Please hit the 'Back'
button on
>   your browser and fill in a name.\n";
> exit;
>   }
> 
>   if ($lname=="") {
> echo "You did not supply a Last Name. Please hit the 'Back' button
on
>   your browser and fill in a name.\n";
> exit;
>   }
> 
>   if ($title=="") {
> echo "You did not supply a Movie Title. Please hit the 'Back'
button
> on
>   your browser and fill in a name.\n";
> exit;
>   }
> 
>  $dbh = mysql_connect("deathtoasp", "zombieuser", "eatmsbrains")
>  or die ("Unable to connect to database");
>   mysql_select_db("slashers", $dbh)
>  or die ("An error was reported");
> 
>   $table_name = "deathmovies";
> 
>   $statement = "INSERT INTO $table_name (fname, lname, title) VALUES
> (\"$fname\", \"$lname\", \"$title\")";
> 
>   $result = mysql_query($statement, $dbh);
> 
>   if ($result) {
> 
> echo "Adding the following record";
> echo "";
> echo "Actor/Actress:   $fname $lname
> ";
> echo "";
> echo "Movie:  $title";
> echo "Add more Actor/Actress and
Movie
> which they stared in";
> echo "";
> 
>$address = "[EMAIL PROTECTED]";
>$Subject = "The new movie and actor added to phpMovie Library";
>$body = "Adding the following record
> Actor/Actress: '$fname $lname'
> Movie: '$title'";
> 
> 
> mail('$address', '$Subject', '$body .');
> 
>   } else {
> 
> echo "There was an error saving your entry. Please try back in a
> little while.";
>   }
> 
> ?>
> 
> 
> 
> 
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Help with mail...

2002-09-23 Thread John Holmes

It's just part of the rules. Variables are not evaluated when they are
between single quotes, they are between double quotes.

Echo 'This is $var';

Will output that string, literally.

Echo "This is $var";

Will take the value of $var, if any, and place it in the string.

---John Holmes...

> -Original Message-
> From: Chuck PUP Payne [mailto:[EMAIL PROTECTED]]
> Sent: Sunday, September 22, 2002 11:53 PM
> To: [EMAIL PROTECTED]
> Cc: PHP General
> Subject: Re: [PHP] Help with mail...
> 
> Ok, that work. Why does the ' (quote) not make it work is it because
it's
> an
> array? Any thanks John that got it work.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] mysql_num_rows error

2002-09-23 Thread John Holmes

> I am new to php and that the folowing error: Warning:
mysql_num_rows():
> supplied argument is not a valid MySQL result resource in
> /home/tbonestu/public_html/smallimages.php
> 
> i dont know what i am doing wrong here is the code:
> 
>  @ $db = mysql_pconnect(connect info);
> 
>  mysql_select_db("images");
>  $query = "select * from images where type =".$type."";
>  $result = mysql_query($query);
>  $num_results = mysql_num_rows($result);

That generally means your query failed. Try to echo mysql_error() after
your query to see what the problem is. You probably need quotes around
$type or $type has no value.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Replace linefeed/newline from text inputs with tag?

2002-09-23 Thread John Holmes

Okay, you got me on that one, but why do you need to remove the
newlines? It should be stored in the database (if you're doing so) with
the  newlines and not the HTML breaks. You only use the nl2br() to
output it on a web page, so who cares if the new lines are still there?

The manual page explains this correctly, btw. It says that a ""
will be inserted before all newlines.

---John Holmes...

> -Original Message-
> From: David T-G [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 23, 2002 7:10 AM
> To: PHP General list
> Cc: John Holmes; 'Patrick Lebon'
> Subject: Re: [PHP] Replace linefeed/newline from text inputs with 
> tag?
> 
> John, et al --
> 
> ...and then John Holmes said...
> %
> % > If i have a textarea form input for users and they enter in return
> % spaces,
> % > how can i replace the ascci chars with html tags?
> %
> % It'd be great if they had a function for this...they could call it
> % nl2br() or something...
> 
> Yeah.  It would be even cooler if that's what it did, eh?  Maybe
someone
> should rename that nl2nl+br and write a *real* nl2br for those of us
that
> want to GET RID OF the newlines.  I think that part of the reason this
> question comes up often is because nl2br doesn't really do what its
name
> would lead us, or at least me, to think that it does.
> 
> Patrick, I just went through this a few weeks ago (Sep 06).  I don't
know
> that the list has archives, or I'd send you there first (anyone with a
> URL?), so all I can do is give you my result:
> 
>   $fout = ereg_replace("(\n|\r)+","",$fin) ;
> 
> This translates any newline and/or carriage return in your $fin string
to
> a  and puts the results in $fout.  It will convert input like
> 
>   this is
>   some input
> 
> to
> 
>   this issome input
> 
> and you no longer have a newline in the way.  The only downside is
that
> 
>   this is
> 
>   some input
> 
> ends up the same way because the regexp is greedy, but the upside is
that
> it will work for UNIX (\n), Mac (\r), and DOS/Win (\r\n) input.
> 
> 
> HTH & HAND
> 
> :-D
> --
> David T-G  * It's easier to fight for one's
principles
> (play) [EMAIL PROTECTED] * than to live up to them. -- fortune
> cookie
> (work) [EMAIL PROTECTED]
> http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl
> Npg!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Encryption Question

2002-09-23 Thread John Holmes

> I want to compare a password to a encrypted password stored in my
mySQL
> database using password('password'), what's the best way to compare
the
> two?
> 
> Encrypted the password sent by the user and compare or pull the
password
> from the database based on username, decrypt it and then compare?

SELECT 1 FROM table WHERE password_column = PASSWORD('$password') AND
username = '$username'

If a row is returned, the username and password match what's in the
database. $password and $username would come from your form or
whatever...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Maybe a stupid question but can it be done?

2002-09-23 Thread John Holmes

Just run two inserts. You can't do it with just one.

I'd have to guess you have design issues if you have to do this
anyhow...

---John Holmes...

> -Original Message-
> From: Chuck "PUP" Payne [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 23, 2002 9:45 PM
> To: PHP General
> Subject: [PHP] Maybe a stupid question but can it be done?
> 
> Ok, Let's try this again, for some reason this didn't post from early
> today.
> 
> I have db that has two tables that I am needing to post the same
> information
> into both tables, I can't use ID. So I am want to see if there is a
sql
> statement that will let me or how I can do with a php page.
> 
> I am sorry to ask, I have looked around to see if there any on the net
or
> in
> my mysql and php books but this seems like a weird task.
> 
> Chuck Payne
> Magi Design and Support
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Another Encryption question

2002-09-23 Thread John Holmes

Look at a phpinfo() page, do you have mcrypt installed? I'd have to
guess no, because that's generally how you get this error. 

---John Holmes...

> -Original Message-
> From: Tom Ray [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 23, 2002 10:15 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Another Encryption question
> 
> also if I comment out $iv, I get the error  "Call to undefined
function
> mcrypt_encrypt()" on that line.. I just don't understand why it keeps
> doing this.
> 
> I'm running 4.2.2
> 
> Tom Ray wrote:
> 
> > I dipped into mcrypt about a month or so, and did this script back
> > then. I had it working, it would kick out the encrypted data for me
> > but today when I test it I get a Fatal error: Call to undefined
> > function: mcrypt_create_iv() in test2.php on line 3.
> > And I don't understand why...any help would be great...thanks!
> >
> >  >
> > $iv = mcrypt_create_iv (mcrypt_get_iv_size (MCRYPT_TripleDES,
> > MCRYPT_MODE_CFB), MCRYPT_RAND);
> >
> > $key = "Secret";
> > $sample2 = "Hello";
> > $sample3 = "Hello There";
> >
> > $lockdata = mcrypt_encrypt (MCRYPT_TripleDES, $key, $sample2,
> > MCRYPT_MODE_CFB, $iv);
> > $test = mcrypt_encrypt (MCRYPT_TripleDES, $key, $sample3,
> > MCRYPT_MODE_CFB, $iv);
> > echo "$lockdata\n";
> > echo "$test\n";
> >
> > ?>
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Crypt() =or= md5()

2002-09-23 Thread John Holmes

I couldn't find anything in the manual, but I don't think crypt() works
in windows...or at least 95/98. Or the function may be denied in your
PHP.ini for some reason.

---John Holmes...

> -Original Message-
> From: Anthony Ritter [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 23, 2002 10:25 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Crypt() =or= md5()
> 
> I get the following line when trying to use the crypt() function in
php
> ..
> 
> Fatal error: Call to undefined function: crypt() in c:\program
> files\apache
> group\apache\htdocs\handleform1.php on line 16
> 
> 
> 
> However, when I replace crypt() with md5() - the following script
works
> fine.
> 
> Using:
> Windpws 98 / Apache / php4
> ...
> 
> the script:
> 
> 
> 
> 
> HTML Form
> 
> 
>  $FirstName=trim($FirstName);
> $LastName=trim($LastName);
> $Email=trim($Email);
> $Comments=trim($Comments);
> $Name=$FirstName." ".$LastName;
> print("Your name is $Name\n");
> print("Your e-mail address is $Email\n");
> print("Your comments were: $Comments\n");
> $CryptName=md5($Name);
> print("This is the crypt()version of your name: $CryptName\n");
> ?>
> 
> 
> 
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] session and expiration function

2002-09-23 Thread John Holmes

> is it possible to have a function execute when a session expires using
> php4
> sessions?
> i know how to execute a function if i control the timeout (as
mentioned
> elsewhere in this group) but what about if the session times out
itself
> using the inbuilt garbage collection routine.
> if so, any ideas how?

I don't think there's a way to do it besides hacking the source code. If
you really have to do this, I'd set your own session.save_path() in your
scripts and then write a script to do the cleanup and function calling
for you.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] session and expiration function

2002-09-23 Thread John Holmes

Just use ini_set() to set a different session.save_path() than what's in
your PHP.ini. then the garbage collector won't touch it. Write your own
script to do the deleting and call whatever functions you need. Add that
to your cron script to run every hour or day, and you're good to go. You
made your own garbage collector. 

I'm going to have to do this for a sourceforge site I have. I started a
thread about this on the PHP board at Devshed and someone posted a
sample function to handle the cleanup.

---John Holmes...

> -Original Message-
> From: christian haines [mailto:[EMAIL PROTECTED]]
> Sent: Monday, September 23, 2002 11:06 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] session and expiration function
> 
> thanks john,
> 
> hmmm... i suspected as much...
> 
> i guess the way to do it would be to set a highly improbable garbage
> collection and long timeout via ini_set. then use a timeout function
> attached to the session which launches on expiration
> 
> cheers
> christian
> 
> "John Holmes" <[EMAIL PROTECTED]> wrote in message
> 002501c26374$e136db20$b402a8c0@mango">news:002501c26374$e136db20$b402a8c0@mango...
> > > is it possible to have a function execute when a session expires
using
> > > php4
> > > sessions?
> > > i know how to execute a function if i control the timeout (as
> > mentioned
> > > elsewhere in this group) but what about if the session times out
> > itself
> > > using the inbuilt garbage collection routine.
> > > if so, any ideas how?
> >
> > I don't think there's a way to do it besides hacking the source
code. If
> > you really have to do this, I'd set your own session.save_path() in
your
> > scripts and then write a script to do the cleanup and function
calling
> > for you.
> >
> > ---John Holmes...
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Maybe a stupid question but can it be done?

2002-09-23 Thread John Holmes

> if the 2 tables have the same name can't he just go
> 
> INSERT INTO table1, table2 (table1.name=$name, table2.name=$name ...
> blah);
> 
> think u can do that .. but again that relies on table names being the
same
> i
> guess...

No...That's not a valid query.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: html input and php (newbie), ask more

2002-09-24 Thread John Holmes

It's not a PHP issue, I'll tell you that. There is something that's not
set up correctly in your apache configuration. Someone here should be
able to give you the syntax, but you may find an answer on an Apache
list or FAQ faster...

---John Holmes...

> -Original Message-
> From: Remon Redika [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 24, 2002 11:07 PM
> To: Anna Gyor
> Cc: [EMAIL PROTECTED]
> Subject: [PHP] Re: html input and php (newbie), ask more
> 
> i have tried to change post file from input.php3 to input.php
> and it's done.
> i wanna ask more .., why if i used post var to input.php3 the script
> doesn't
> work. and i got message
> 
> 
> Method Not Allowed
> The requested method POST is not allowed for the URL /input.php3.
> 
>

-
> ---
> Apache/1.3.26 Server at www.reymond.com Port 1000
> 
> 
>  > if ($submit == "click"){
> >   echo "Hello, $UserName";
> > }
> > else{
> > ?>
> >   
> >
> ><--input.php3
> >
> >   Enter Your Name
> >   
> >
> >   
> >   
> >   
> >
> >   
> >  > }
> >
> > ?>
> 
> 
> Anna Gyor writes:
> 
> > Hi,
> >
> > I just began to learn php and I have te following code. How can I
get
> the
> > input field value in the php script? Because my script doesn't work.
> > $UserName is always an empty string.
> >
> >  > if ($submit == "click"){
> >   echo "Hello, $UserName";
> > }
> > else{
> > ?>
> >   
> >
> >   
> >
> >   Enter Your Name
> >   
> >
> >   
> >   
> >   
> >
> >   
> >  > }
> >
> > ?>
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] table-wide or database-wide search and replace?

2002-09-24 Thread John Holmes

It really wouldn't be that difficult, would it?

Give it a database name, the program find all the names of the tables,
then loops through them all. It find all the rows for each table (maybe
limit to just text based ones, to be fancy), and makes an sql statement
to call the ereg. To really be feasible, you'd want to use the replace
and regex functions already in MySQL. Only issues you may run into is
the 30 second time limit...

How much will you pay me to write it?? :)

---John Holmes...

> -Original Message-
> From: Justin French [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 24, 2002 11:34 PM
> To: php
> Subject: [PHP] table-wide or database-wide search and replace?
> 
> Has anyone seen or built an existing chunk of code to assist with
table-
> wide
> or database-wide search and replace in MySQL?
> 
> For example a simple str_replace() style function that works on a
whole
> MySQL table would be great, database-wide would be even better,
> ereg_replace
> would be even better again, and so would the ability to specify case
> sensitivity would be better again :)
> 
> I'm happy for it to be a commerical product, open source, a project or
> whatever.
> 
> If it doesn't exist, does anyone want to start work on one with me?
> 
> Found these notes:
> http://myezserver.com/downloads/mitel/howto/mysql-search-and-replace-
> howto.h
> tml
> 
> So it doesn't seem too hard in theory.
> 
> 
> Justin French
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Showing online users!

2002-09-24 Thread John Holmes

How about:

SELECT sUser FROM members WHERE sUpdated > NOW() - INTERVAL 10 MINUTE;

as your query... I assume you are using a MySQL format
date/datetime/timestamp column for sUpdated?

---John Holmes...

> -Original Message-
> From: Philip J. Newman [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 24, 2002 11:48 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Showing online users!
> 
> The best way to show online users ...
> 
> every page that is loaded while a user is online the time stamp is
updated
> in there profile
> 
>  
> $sql = "SELECT sUser FROM members WHERE sUpdated  >
> from_unixtime(unix_timestamp(now())-(10*60))";
> $sql_result = mysql_query($sql, $connection) or die (mysql_error());
> 
> while ($row = mysql_fetch_array($sql_result)) {
> $sUser=$row["sUser"];
> 
> echo"
href=\"/actual/thesite.php?startWeb=profile&sUser=$sUser\">$sUser,
> ";
> 
> }
> 
> ?>
> 
> Is this the best way to do this?
> 
> ---
> Philip J. Newman.
> Head Developer.
> PhilipNZ.com New Zealand Ltd.
> http://www.philipnz.com/
> [EMAIL PROTECTED]
> 
> Mob: +64 (25) 6144012.
> Tele: +64 (9) 5769491.
> 
> Family Site:
> Philip J. Newman
> Internet Developer
> http://www.newman.net.nz/
> [EMAIL PROTECTED]
> 
> *
>   Friends are like Stars,
>   You can't always see them,
>   But you know they are there.
> 
> *
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] RFE: Multiple auto_prepend_file statements to work in Apache

2002-09-24 Thread John Holmes

Even if it's only one file, have that file include the other necessary
files... so two.php would include one.php, three.php, etc. You could
even build the logic into two.php so it decides which other files to
include based on any number of conditions. 

---John Holmes...

> -Original Message-
> From: Alex Vincent [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, September 24, 2002 11:34 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] RFE: Multiple auto_prepend_file statements to work in
> Apache
> 
> Dear Sirs,
> 
> I'm wondering if it might be possible to prepend multiple files to PHP
> scripts using the .htaccess file.
> 
> For instance, the following:
> 
> php_value auto_prepend_file "two.php"
> php_value auto_prepend_file "../one.php"
> 
> will produce a prepend from only ../one.php .  This may be technically
> correct, but it's also a bit limited.  It may be better to allow for
> multiple files to be prepended in this fashion, if Apache will let us.
> 
> Is it possible for PHP to support such a feature?  Being able to
prepend
> multiple PHP scripts to a certain PHP script, based on which
directories
> and subdirectories the main script is in, would be useful to me.
> 
> If anyone here has studied the W3C DOM Level 2 Events specification,
you
> may see the relationship between current practices with PHP and the
> suggested model above as the difference between event handlers and
event
> listeners.  (If you haven't seen DOM-2 Events, don't worry about it.)
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Getting at the variable name itself

2002-09-24 Thread John Holmes

> Hi.  I'm putting together a form that needs to have multiple pairs of
both
> text inputs and checkboxes.  On the submit page I need to be able to
> associate one with the other, and the variable names themselves have
other
> identifying values embedded in their names.  What I need to know is
how do
> I
> access the variable name?  Suppose I have a variable name like this:
> 
> $method_valueA_valueB
> 
> I intend to use the name itself as a string I can then explode to
recover
> the embedded data.
> 
> How do I operate on the variable name itself?

You can't, AFAIK. You'd probably be better off by naming your input
elements as arrays.



etc... and then access it by $method['A']['B']...

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] script to check for register_gloabs=off compatibility

2002-09-24 Thread John Holmes

Kind of defeats the purpose. You could easily use extract() or the
import_request_variables() function to do what you want. It would be the
same as having register globals on, though...

---John Holmes...

> -Original Message-
> From: Thom Porter [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 12:05 AM
> To: Justin French; [EMAIL PROTECTED]
> Subject: Re: [PHP] script to check for register_gloabs=off
compatibility
> 
> Justin,
> 
> Thanks for the response.
> 
> The applications vary from site to site.  Many of them use include
files,
> some of them don't.  One thing that is nice is any apps that use
cookies
> or
> sessions go through the _COOKIE or _SESSION arrays already.
> 
> I did think of something that could be very useful, but I'm not sure
if
> it's
> just as bad as having register_gloabls on or not... but basically,
> something
> like this:
> 
> foreach($_POST as $k=>$v) {
> $$k = $v;
> }
> 
> Does that not defeat the purpose, or is it just a really good idea?
> 
> Thanks!
> 
> Thom Porter
> - Original Message -
> From: "Justin French" <[EMAIL PROTECTED]>
> To: "Thomas Porter" <[EMAIL PROTECTED]>;
<[EMAIL PROTECTED]>
> Sent: Tuesday, September 24, 2002 6:23 PM
> Subject: Re: [PHP] script to check for register_gloabs=off
compatibility
> 
> 
> > I'm not aware of anything like that, apart from PHP itself :)
> >
> > Turn your error reporting to the strictest setting, and go through
your
> > applications, and it should complain whenever is has to echo/use a
> undefined
> > variable.
> >
> > Although that sounds a little daunting with 8000 pages... are you
using
> lots
> > of include files (for all files which are in a certain section)?  if
so,
> it
> > quite possible that you only have to modify the header include to
keep
> > things up to date on many pages.
> >
> > If you do find such a script, I'd be keen to hear about it.
> Essentially,
> > you need to munch through each of your scripts WITH the
> include/require's
> > inline, looking for an undefined variable.
> >
> > Then for each of those undefined variables, figure out if the were
> supposed
> > to be from GET, POST, FILES, COOKIE or SESSION, and put a few lines
at
> the
> > top of the file:
> >
> > $myvar = $_GET['myvar'];
> > $myvar2 = $_POST['myvar2'];
> >
> >
> > It's also probably a lesson in documentation... when I first started
in
> PHP
> > I was paranoid about everything, and spent AGES on documentation and
> > comments at the top of files. But I was really thankfull I did,
because
> it
> > saved me HOURS later on, because I had everything documented...
which
> vars
> > came from post/get/cookies/sessions/etc.
> >
> >
> > Good luck,
> >
> > Justin
> >
> >
> > on 25/09/02 4:00 AM, Thomas Porter ([EMAIL PROTECTED]) wrote:
> >
> > > I currently maintain about 100 sites that use PHP.  Many of them
were
> > > programmed pre 4.2, and are not compatible with the
> register_globals=off
> > > setting.  Since we use virtual hosts in apache I have been able to
> modify
> > > that one ini setting for the sites that need it, but now my job is
to
> modify
> > > all of these scripts to be compatible with the
register_globals=off
> setting
> > > so they will be more secured.  I'm wondering if anyone out there
has
> written
> > > a script that can look at the PHP scripts and see if they are
> compatible
> or
> > > not.  I'm sure this would be no easy task, but it would be most
useful
> at
> > > the same time.  I've done a find for all of the PHP scripts on our
> server
> > > and am confronted with over 8,000 scripts that need to be looked
at,
> and
> > > that's just files with the .php extension we've got plenty of
> .inc's
> and
> > > other various extensions (including a few sites that parse .html
as
> PHP)
> > > that would need to be checked as well.
> > >
> > > Anybody got any ideas?
> > >
> > >
> >
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Installing php in windows 95

2002-09-24 Thread John Holmes

The .dll is there. Look in the dlls folder for where every you installed
PHP.

You downloaded the binary and not the source code, right?

---John Holmes...

> -Original Message-
> From: Uma Shankari T. [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 12:13 AM
> To: PHP
> Subject: [PHP] Installing php in windows 95
> 
> 
> Hello,
> 
>   I need to install php for windows under particular folder namely
under
> C:\web..In the installation manual it is mentioned that dll should be
> copied to c:\windows..but the dll is not available under c:\web...can
any
> please telll me how to do this..
> 
> Regards,
> Uma
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] java script & session?

2002-09-24 Thread John Holmes

And there is any reference to PHP in your question where

> -Original Message-
> From: Jeff Bluemel [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 12:34 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] java script & session?
> 
> I want drop down menu's in my setup that I am creating.  however,
when
> the
> java script opens the links then the session information is not
passed.
> here's how the stuff is used in my .phtml files.
> 
> 
> 
>  src="resources/custom_original.js">
> addMainItem("home.phtml","Home",120,"center","");
> 
> 
> 
> --
> 
> Thanks,
> 
> Jeff Bluemel
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] HT authentication question

2002-09-24 Thread John Holmes

> Is there a PHP function/method that destroys or expires a HT
> authentication
> session?  So, for example, you're using a .htaccess file to control
access
> to a directory on a server, is there a way to destroy that session
without
> closing the browser window?

Quote from manual:

Both Netscape Navigator and Internet Explorer will clear the local
browser window's authentication cache for the realm upon receiving a
server response of 401. This can effectively "log out" a user, forcing
them to re-enter their username and password. Some people use this to
"time out" logins, or provide a "log-out" button.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] java script & session?

2002-09-24 Thread John Holmes

You aren't opening any PHP files, you are opening javascript files. Do
you want the session info passed to the .js files? Is .js parsed as PHP
on your server? Do you lose the session in your .phtml page after you
call the given javascript? What is your question?

---John Holmes...

> -Original Message-
> From: Jeff Bluemel [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 12:50 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] java script & session?
> 
> what do you think the SESSIONS are???  possibly php session info ?  ;)
> 
> 
> "John Holmes" <[EMAIL PROTECTED]> wrote in message
> 001401c2644d$8fb8d670$b402a8c0@mango">news:001401c2644d$8fb8d670$b402a8c0@mango...
> > And there is any reference to PHP in your question where
> >
> > > -Original Message-
> > > From: Jeff Bluemel [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, September 25, 2002 12:34 AM
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] java script & session?
> > >
> > > I want drop down menu's in my setup that I am creating.  however,
> > when
> > > the
> > > java script opens the links then the session information is not
> > passed.
> > > here's how the stuff is used in my .phtml files.
> > >
> > >
> > > 
> > >  > > src="resources/custom_original.js">
> > > addMainItem("home.phtml","Home",120,"center","");
> > > 
> > > 
> > >
> > > --
> > >
> > > Thanks,
> > >
> > > Jeff Bluemel
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Ah ha ... confirm delete.

2002-09-24 Thread John Holmes

Huh? Are you talking about the result of the javascript confirm()
function? Yes, it returns true or false. You can't pass that value
anywhere (well, you could assign it to a form elements value). You
generally use the result of the confirm() function to decide whether you
submit the form or not. If confirm() returns true, submit and process
the form, otherwise, do nothing.

---John Holmes...

> -Original Message-
> From: Philip J. Newman [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 12:44 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Ah ha ... confirm delete.
> 
> confirm() returns a true or fulse.
> 
> what is confirm called as a veriable?
> 
>   
>  if ($confirm == "true") {
> 
>  $sql = "DELETE FROM stompers WHERE sUser='$sUser' AND
sEmail='$sEmail'
> LIMIT 1";
> 
>  $sql_result = mysql_query($sql, $connection) or die ("Could not get
> Query");
> 
>  } else if ($confirm == "false") {
> 
>  }
> 
>  ?>
> 
> ---
> Philip J. Newman.
> Head Developer.
> PhilipNZ.com New Zealand Ltd.
> http://www.philipnz.com/
> [EMAIL PROTECTED]
> 
> Mob: +64 (25) 6144012.
> Tele: +64 (9) 5769491.
> 
> Family Site:
> Philip J. Newman
> Internet Developer
> http://www.newman.net.nz/
> [EMAIL PROTECTED]
> 
> *
>   Friends are like Stars,
>   You can't always see them,
>   But you know they are there.
> 
> *
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] table-wide or database-wide search and replace?

2002-09-25 Thread John Holmes

> -Original Message-
> From: Justin French [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 1:19 AM
> To: [EMAIL PROTECTED]; 'php'
> Subject: Re: [PHP] table-wide or database-wide search and replace?
[snip]
> > Give it a database name, the program find all the names of the
tables,
> > then loops through them all. It find all the rows for each table
(maybe
> > limit to just text based ones, to be fancy), and makes an sql
statement
> > to call the ereg. To really be feasible, you'd want to use the
replace
> > and regex functions already in MySQL. Only issues you may run into
is
> > the 30 second time limit...
> 
> good point... specifically, is that a time limit imposed by mysql, php
or
> the browser you are referring to?

PHP limitation that scripts have 30 seconds to complete. This can be
changed in PHP.ini or with a function call at the beginning of the
script.

> because i could do this on the command line (once off), and could also
> break
> the process into individual tables, or even groups of 50 rows or
something
> if needed -- although i'd do almost anything to avoid it :)

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] slashes added before '

2002-09-25 Thread John Holmes

Use stripslashes() on the text before you write it to the file. Where is
this text coming from? The slashes are probably getting added by
magic_quotes.

---John Holmes...

> -Original Message-
> From: Khalid El-Kary [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 8:08 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] slashes added before '
> 
> this code snippet:
> 
> function save($file)
> {
>$my_file=fopen($file,"wb");
>$my_status=fwrite($my_file,$text);
>fclose($my_file);
> }
> 
> is intended to overwrite a file or create a file and write to it from
a
> string that's already containing text.
> 
> the problem is the after the script writes the file i find "\" before
all
> single and double qoutes in the whole file
> 
> this problem occured on red hat linux but in windows it didn't happen.
> 
> can any one help?
> 
> khalid
> 
> 
> _
> Send and receive Hotmail on your mobile device: http://mobile.msn.com
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Set a default global - $_GET[]

2002-09-25 Thread John Holmes

> How do i set a default value for a url parameter ($_GET[".."]) in PHP
4.1?
> I currently have a class that sets a default global value but this
does
> not
> work in this version - the script displays an error if no url value is
> passed in the url.

if(!isset($_GET['...']))
{ $_GET['...'] == "default value"; }

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Cronjob

2002-09-25 Thread John Holmes

Use lynx or wget to call your web page.

lynx --dump http://www.domain.com/my_cron_page.php

---John Holmes...

> -Original Message-
> From: Daren Cotter [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 12:36 PM
> To: PHP General Mailing List
> Subject: [PHP] Cronjob
> 
> I have PHP installed on a Cobalt RaQ550. I know there
> are two ways of installing PHP, one as a binary, and
> one as an Apache module. I am pretty sure PHP gets
> installed as an Apache module for the Cobalt
> installation.
> 
> My problem, is that I absolutely NEED to run a PHP
> script using crontab. The script needs to send
> numerous queries to a database every hour. Is there
> any way I can accomplish this, directly or indirectly?
> 
> __
> Do you Yahoo!?
> New DSL Internet Access from SBC & Yahoo!
> http://sbc.yahoo.com
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] PHP POST arrar is dropping 4 characters

2002-09-25 Thread John Holmes

This was just talked about last week, search the archives. IIRC, it was
a bug, so maybe search the buglist, too.

---John Holmes...

> -Original Message-
> From: David Busby [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, September 25, 2002 7:29 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] PHP POST arrar is dropping 4 characters
> 
> List,
>   I'm using PHP on my RH73 box and when I post it drops 4
characters
> out of
> the post array.  Can someone look at the code below and tell me if I'm
> missing something?  Why would it cut four characters off?  Perhaps
cause
> the name is four chars?  Bug?
> 
> TIA
> /B
> 
> HTML that is sent to browser
> 
>  value="24033CD9-7C60-4AB0-9D7D-180D885DC857" />Item One
>  value="8D86D6B8-A42E-4B19-B930-826AAECA2AB4" />Item Two
>  value="3D6A7538-55ED-47C9-9447-0083EE6525F5" />Item Three
>  value="9CAC5C80-AEAA-4EF3-9B96-750994A3E787" />Item Four
> 
> PHP that reads the post:
> 
> $ar_ei = $_POST['ei'];
> if (is_array($ar_ei))
> {
> $c = sizeof($ar_ei);
> for ($i=0;$i<$c;$i++)
> {
>   // Right here is where the first four characters are cut off
from
>   // the 'ei[]' value, should be
>   // "24033CD9-7C60-4AB0-9D7D-180D885DC857" but instead is
>   // "3CD9-7C60-4AB0-9D7D-180D885DC857"
>   echo $ar_ei[$i]."";
> }
> }
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Finding out when a Web page has changed

2002-09-26 Thread John Holmes

You could cache/save the actual contents of the file, then when you read
it next time, compare it to what you saved and see if it changed. You
may want to filter out everything but what's between  and ,
so you're not thinking it changed just b/c of something in the
headers...

---John Holmes...

> -Original Message-
> From: Vikram Vaswani [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 26, 2002 7:04 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Finding out when a Web page has changed
> 
> Hi all,
> 
> I need to write an application that accepts a list of URLs and checks
them
> on a daily basis (via cron) to see if the pages have changed in the
past
> day.
> 
> I need some help with this. Does anyone know the most optimal way to
find
> out when a particular Web page has been modified? I am thinking about
> using
> the Last-Modified: HTTP header - however, all servers do not return
this
> header - any ideas on what the fallback should be?
> 
> TIA,
> 
> Vikram
> --
> "I find your lack of faith disturbing."
>   --Darth Vader
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Finding out when a Web page has changed

2002-09-26 Thread John Holmes

Yeah, true. Maybe you could just ereg() out the content. Each url would
need it's own ereg, though, so it won't be as easy to set up.

But, technically, if the quote changes, then the page has been updated,
even if it's dynamic. How do you define "updated"??

---John Holmes...

> -Original Message-
> From: Justin French [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 26, 2002 10:25 AM
> To: Marek Kilimajer; PHP
> Subject: Re: [PHP] Finding out when a Web page has changed
> 
> Same with sites that have negligible daily changes (like today's date
> dynamically inserted), or random changes (a random quote, tip, stock
> quote,
> product, image, etc etc would all screw that up).
> 
> Justin
> 
> 
> on 26/09/02 11:03 PM, Marek Kilimajer ([EMAIL PROTECTED]) wrote:
> 
> > Hope the sites have no banners :),  they change all the time
> >
> > John Holmes wrote:
> >
> >> You could cache/save the actual contents of the file, then when you
> read
> >> it next time, compare it to what you saved and see if it changed.
You
> >> may want to filter out everything but what's between  and
> ,
> >> so you're not thinking it changed just b/c of something in the
> >> headers...
> >>
> >> ---John Holmes...
> >>
> >>
> >>
> >>> -Original Message-
> >>> From: Vikram Vaswani [mailto:[EMAIL PROTECTED]]
> >>> Sent: Thursday, September 26, 2002 7:04 AM
> >>> To: [EMAIL PROTECTED]
> >>> Subject: [PHP] Finding out when a Web page has changed
> >>>
> >>> Hi all,
> >>>
> >>> I need to write an application that accepts a list of URLs and
checks
> >>>
> >>>
> >> them
> >>
> >>
> >>> on a daily basis (via cron) to see if the pages have changed in
the
> >>>
> >>>
> >> past
> >>
> >>
> >>> day.
> >>>
> >>> I need some help with this. Does anyone know the most optimal way
to
> >>>
> >>>
> >> find
> >>
> >>
> >>> out when a particular Web page has been modified? I am thinking
about
> >>> using
> >>> the Last-Modified: HTTP header - however, all servers do not
return
> >>>
> >>>
> >> this
> >>
> >>
> >>> header - any ideas on what the fallback should be?
> >>>
> >>> TIA,
> >>>
> >>> Vikram
> >>> --
> >>> "I find your lack of faith disturbing."
> >>> --Darth Vader
> >>>
> >>> --
> >>> PHP General Mailing List (http://www.php.net/)
> >>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>
> >>>
> >>
> >>
> >>
> >>
> >>
> >
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Encrypted MySQL passwords

2002-09-26 Thread John Holmes

> I am connecting to  a mysql server on a remote machine, and opened up
port
> 3306 for this purpose. But, I am concerned about sending a clear text
> password, via the mysql_pconnect() call. My question is, what is the
> procedure for connecting to a remote server with an encrypted
password?
> Or, does mysql_pconnect handle this?

Nope, it's all in the clear. MySQL 4.0 has support for doing this over
SSL, I think.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Encrypted MySQL passwords

2002-09-26 Thread John Holmes

> BTW (and I have not checked the CVS/TODO, so I ask here), is
> there planned support for SSL & MySQL 4.x.x in PHP?.

Yes. More info in Chapter 4.3.9.1 of the MySQL manual.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] REMOTE ADDR

2002-09-26 Thread John Holmes

> This is php code

Yeah, you can tell by the fact that there is no  Anderson O Muniz
> 
> Jesse Cablek <[EMAIL PROTECTED]> escreveu nas notícias de
> mensagem:001c01c2659b$9b3b3480$[EMAIL PROTECTED]
> > Anderson O Muniz  scribbled;
> > >
> > > 
> > > 
> > > 
> > > 
> > > 
> > >
> > >
> >
> > Is that PHP code, or SSI?
> >
> > -jesse
> >
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] I don't want multiple form submitted

2002-09-26 Thread John Holmes

> I have a message board written in PHP w/MySQL.
> So when a person submitting a post, it goes to a list_view.
> If this person refresh the list_view.
> The message he submitted will get submitted again.
> How can I avoid this problem?
> Please let me know if you know the answer. Thanks

This question is asked every week, it seems. Best method is to use a
"middle-man". Use a middle page that processes the new post, then
redirects the user to the next page. You can use a PHP header()
solution, or a javascript META-REFRESH method. 

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Help with Regular Expressions

2002-09-26 Thread John Holmes

> I need to filter out certain characters from being
> stored in the database from our signup form. The
> fields include first name, last name, street address,
> city, zip, etc.
> Question 1: What characters should be allowed, other
> than lowercase, uppercase, digits, and the space
> character?

Some names have ' or - in them, same for addresses.
 
> Question 2: What is a regular expression for this?

Yes...there is a regular expression for everything. :)

Just come up with some functions that filter the input based on a few
regex. You can display it with htmlentities() and it'll stop javascript
and html from being evaluated.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] $_SESSION[] and register_globals=on

2002-09-27 Thread John Holmes

> My IP informed me that they have register_globals=on in their php.ini.
Is
> this going to cause problems with my scripts that were written  using
> $_POST,
> $_SESSION, etc?

If you can turn it off via, .htaccess, you'd be better. The scripts will
run fine with $_POST or whatever, but realize your open to the
vulnerabilities that made OFF the default. If you use if($value)
anywhere, that value could come from the user. Just something to be
aware of.

Also, with register_globals ON, unregistering a session variable is
tricky. You have to use session_unregister("value") and
unset($_SESSION['value']) and maybe even unset($value); If you don't
ever unregister variables, then you won't have a problem.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Regular expression help converting doc to xml

2002-09-27 Thread John Holmes

> I have a fairly large html document that I need to convert to xml.
> The current format is is:
>  A whole bunch of text
>Something else 
> (There is a new line in there before )
> 
> Which I need to convert to
>  A whole bunch of text 
>Something else 

$new_text = str_replace("\n\t","\n\t",$your_text);

Assuming there is a tab in there...

You'd be better off getting an editor that'll do this for you. Textpad
lets you search and replace with regular expressions. Other programs do
too.

---John Holmes...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Logic -- conditional statements

2002-06-04 Thread John Holmes

Switches come in handy here...

Switch($valueChk)
{
  case 1:
do_whatever1();
  case 2:
do_whatever2();
  case 3:
do_whatever3();
break;
}

If the variable is 1, then all three functions will be called. 

I don't remember what the original question was or if this even applies,
but it's a better solution than all of the IFs that was just posted...

---John Holmes...

> -Original Message-
> From: Naintara Jain [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 04, 2002 5:47 PM
> To: Ricardo Fitzgerald
> Cc: Php-General@Lists. Php. Net
> Subject: FW: [PHP] Logic -- conditional statements
> 
> One correction, Ricardo
> 
> for appending the rows, you will have to change the condition
> 
> //for 1st row
> if($valueChk >= 1 && $valueChk <= 3)
> 
> //for 2nd row
> if($valueChk >= 2 && $valueChk <= 3)
> 
> //for 3rd row
> if($valueChk == 3)
> 
> 
> 
> -Original Message-
> From:
[EMAIL PROTECTED]
>
[mailto:[EMAIL PROTECTED]
> t]On Behalf Of Naintara Jain
> Sent: Tuesday, June 04, 2002 2:37 PM
> To: Ricardo Fitzgerald; [EMAIL PROTECTED]
> Subject: RE: [PHP] Logic -- conditional statements
> 
> 
> The problem here is that you have defined three different variables
> $value1,$value2,$value3.
> 
> Keep only one variable (say,$valueChk) that can take values 1,2 or 3.
> Then check for the condition.
> And there's another mistake in the script, you are checking
> ---if ($value2 ==0)---
> twice, you probably mean to check for "$value1 ==1" (for the first of
the
> "$value2 ==0" checks).
> 
> Once you are through with these changes, your script will work
perfectly.
> And if you feel like improving it you need not repeat the 
statements.
> You can merely append the additional rows depending on the value of
the
> variable you set (say, $valueChk).
> 
> the following isn't the actual script, but mainly the logic.
> 
> $table=""
> if($valueChk==0)
> exit
> if($valueChk==1)
> {
> //.append the first  statement to $table variable
> $table .= " ";
> 
> }
> 
> if($valueChk==2)
> {
> //.append the second  statement to $table variable
> }
> 
> if($valueChk==3)
> {
> //.append the third  statement to $table variable
> }
> 
> //now close the table tag and echo the $table variable
> 
> you'll get the table with the desired number of rows.
> 
> -Naintara
> 
> -Original Message-
> From:
[EMAIL PROTECTED]
>
[mailto:[EMAIL PROTECTED]
> t]On Behalf Of Ricardo Fitzgerald
> Sent: Friday, July 10, 2893 3:44 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Logic -- conditional statements
> 
> 
> Hi to all,
> 
> I'm trying to echo a neat table with values from a form, depending on
> the values it echoes a table with one row with two or with three:
> Then I have conditional nested statements, to validate these variables
> and wrote the table with the proper values in each case, the problem
> is the table is displayed 3 times instead of 1 each time it finds a
> value TRUE!
> 
> I need it to display only once, I mean in the first instance the
> table, has 1 row, the second 2 rows, the third 3 rows, and they are
> independent.
> 
> The code is something like:
> //Value1 is always 1
> if ($value1 == 0)
> {
> exit
> }
> if ($value2 ==0)
> {
> echo // echoes the table
> .
> .
> ."$variable1 ...
> ."$variable2...
> ."$variable3 ...
> ."$variable4 ...
> 
> }
> if($value2 == 0)
> {
> 
> .
> .
> echo // echoes the table
> .
> .
> ."$variable1 ...
> ."$variable2...
> ."$variable3 ...
> ."$variable4 ...
> 
> ."  /next row
> .
> ."$variable5 ...
> ."$variable6...
> ."$variable7 ...
> ."$variable8 ...
> ."
> .
> .
> }
> if($value3 == 3)
> {
> 
> .
> .
> echo // echoes the table
> .
> .
> ."$variable1 ...
> ."$variable2...
> ."$variable3 ...
> ."$variable4 ...
> 
> ."  /next row
> .
> ."$variable5 ...
> ."$variable6...
> ."$variable7 ...
> ."$variable8 ...
> ."
> .
> .
> ."$variable9 ...
> ."$variable10...
> ."$variable11 ...
> ."$variable12 ...
> ."
> .
> .
> //and then closes the php script,
> 
> TIA
> 
> Regards,
> 
> Rick
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).

RE: [PHP] User Authentication

2002-06-04 Thread John Holmes

Sessions use cookies as it is...so what do you really want to do...what
do you want to protect?

---John Holmes...

> -Original Message-
> From: Jule Slootbeek [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 04, 2002 9:49 PM
> To: php-general
> Subject: [PHP] User Authentication
> 
> Hey guys,
> 
> What is the best way for user authentication (now i'm talking about
the
> most secure and easiest way).
> Now i've been using sessions, and i was wondering if cookies were
better
> and easier...
> 
> any thoughts?
> thanks,
> 
> Jule
> --
> Jule Slootbeek
> [EMAIL PROTECTED]
> 
> http://blindtheory.cjb.net
> 
> 
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Modifying the sort order of a query

2002-06-05 Thread John Holmes

> My understanding was that he wanted to see the same 30 rows, but
sorted in
> a different way.
> 
> For instance, he wanted to see entries 30-60 as sorted by age, but to
have
> those sorted by height when displayed.
> 
> miguel


Maybe you could have a hidden field that lists the 30 IDs that are
displayed on the page, as a comma separated list. Then, if the user
chooses to resort those 30 results, based on another column, you can use
that hidden field in your query to limit the IDs.

i.e.



Where the actual numbers would be generated from your result set.

Then, use those numbers in your query.

SELECT * FROM table WHERE ... AND ID IN($display_ids) ORDER BY
<>

Hopefully PG supports IN(). 

My $0.02, I'm sure there are other ways...or maybe this isn't even what
you're looking for. :)

---John Holmes...

> On Thu, 6 Jun 2002, Bogdan Stancescu wrote:
> > That's at least curious - limiting and offsetting will most
certainly
> > affect the results which are then sorted... I don't think that's
what he
> > was after. Just my 2c.
> >
> > Bogdan
> >
> > Miguel Cruz wrote:
> >
> > >Try a sub-select:
> > >
> > >SELECT * FROM (SELECT * FROM rap ORDER BY
rcountry,rcity,rsname,rfname
> > >DESC LIMIT 30 OFFSET 30) ORDER BY whatever;
> > >
> > >miguel
> > >
> > >On Wed, 5 Jun 2002, Andre Dubuc wrote:
> > >
> > >
> > >>Apache 1.3.23 + PHP 4.1.2 + PostgreSQL 7.2
> > >>
> > >>I have a query that sorts by name, country, and city, then pages
in
> groups of
> > >>30 records. Originally, I had also coded two buttons: "Sort by
> Country',
> > >>'Sort by City' since I wanted to offer users the options of these
> choices.
> > >>
> > >>Unfortunately, these buttons work well, but re-select the whole
> shebang
> > >>(which I guess is to be expected), destroying any paging that had
> already
> > >>started. I've tried all sorts of ways, tried re-arranging the
order of
> > >>execution, but the result is the same.
> > >>
> > >>I'm at a loss on how to proceed. I've deleted the choice (for now)
and
> run it
> > >>as a simple select order by name query.The problem seems to be: I
need
> a
> > >>sub-query select function that retains the original query, simply
> > >>re-organizing it according to the new criteria, and retains the
> original
> > >>paging. (Perhaps I shouldn't care whether the paging is messed up
as
> long as
> > >>the results are the same.)
> > >>
> > >>I realize that the way it's set up below, it will automatically
send a
> NEW
> > >>query, which is not what I want. I'd like to work with the results
of
> the
> > >>original query and modify it with the new criteria
> > >>
> > >>Any suggestions how I can achieve this, or whether it's even
possible?
> I
> > >>would greatly appreciate any assistance or comments.
> > >>
> >
>
>>**
**
> **
> > >>
> > >>Snippet of offending code:
> > >>
> > >> > >>
> > >>//snippet follows:
> > >>
> > >>print "";
> > >>print " ";
> > >>print "";
> > >>
> > >>// more code
> > >>
> > >>if($_POST['submit'] == "Sort by Name"){
> > >>  $query = "SELECT * FROM rap ORDER BY
> > >>  rsname,rfname,rcountry,rcity,DESC LIMIT 30 OFFSET 30";
> > >>}
> > >>elseif($_POST['submit'] == "Sort by Country"){
> > >>  $query = "SELECT * FROM rap ORDER BY
> > >>  rcountry,rcity,rsname,rfname DESC LIMIT 30 OFFSET 30";
> > >>}
> > >>
> > >>//more code, including paging functions
> > >>?>
> > >>
> >
>
>>**
**
> 
> > >>
> > >>Tia,
> > >>Andre
> > >>
> > >>
> > >>
> > >>
> > >>
> > >
> > >
> > >
> > >
> >
> >
> >
> >
> >
> 
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




  1   2   3   4   5   6   7   8   9   >