Re: [PHP] problems with a netscape post

2001-08-19 Thread Steve Lawson

Try giving the form a name?

I normally use something like...

FORM NAME=myform METHOD=post ACTION=?=$PHP_SELF?

Any it works in NS 4+

SL

- Original Message -
From: Quentin Gillet [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Sunday, August 19, 2001 10:06 AM
Subject: RE: [PHP] problems with a netscape post


 I have the same problem, I'm curious to hear what people say about
this

 -Message d'origine-
 De : [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Envoyé : dimanche 19 août 2001 16:34
 À : [EMAIL PROTECTED]
 Objet : [PHP] problems with a netscape post


 Hi,

 I am trying to post some form data to a php page that then updates a
 mysql database and echos back to the browser that the data has been
 inputted. Here is the general form of my post;-

 form action=blah.php3 method=post

 .. form widgets here .

 input type=submit value=blahblah
 /form

 this works perfectly with IE and opera, but with netscape 4.* it
 either takes ages for the event to transpire or times out.  I am not
 trying to post any files ect, just text field data, 1k max, anyone
 have any ideas what is going wrong?

 thanks


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



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



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




Re: [PHP] SQL Query time?

2001-04-25 Thread Steve Lawson

Sup,
Adding explain before the select query will show you how long it will
take, along with some other info, but it won't actually give you the
results.

I use a the function microtime (http://php.net/microtime) to figure
execution time.  When called, microtime will return a string with
miliiseconds then seconds seperated by a space.  So you have to do something
like this...

function sn_Msecs()
{
   $mt = microtime();
   $mt = explode(  , $mt);

   return ($mt[1] + $mt[0]);
}

That will return seconds.milliseconds or something like 13123141.1231, it is
not in proper math form.

 Just call it before a block of code or query, then call it after and
subtract the second one from the first.

SL.


- Original Message -
From: James, Yz [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, April 25, 2001 2:17 PM
Subject: [PHP] SQL Query time?


 Hi all,

 I have seen a few pages that echo the time it's taken to execute an SQL
 query, like The results in the database were returned in 0.3 seconds.
 Anyone know if there's a built in function to display this, and if there
is,
 what it is?  My more-than-useless-ISP seems to have taken an aversion to
 allowing me to surf tonight without disconnecting me.

 Thanks.
 James.



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



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




Re: [PHP] getting rows from separate tables stacked in a single array ? (newbie, mysql)

2001-04-24 Thread Steve Lawson

Sup,
It can be done...but it will be complicated.  First off.  You should
check out the extract() php command.

http://php.net/extract

This function makes entries in an array into local variables.  Let's say
your row array has 2 columns, title and duration.

You can do:

while( $row = mysql_fetch_assoc($result) )
{
   extract( $row , EXTR_PREFIX_ALL , qt_);  // last parameter is a prefix
to add onto the var names

   echo title = $qt_title , duration = $qt_durationBR;
}

---

Now onto the mysql goodness.  I don't know of any way to stack rows from
different tables.  It really wouldnt work because the column names would
probably be different.  Doing a join isn't going to work either because the
tables will probably not contain the same number of rows.

I suggest selecting just the row id and creation time from each of your
tables.  Like:

$result1 = mysql_query();
$result2 = mysql_query();
$result3 = mysql_query();

Then

while( !$dead1 || !$dead2 || !$dead3 )
{
   if(!$row1  !$dead1)  $row1 = mysql_fetch_assoc() or $dead1 = true;
   if(!$row2  !$dead2)  $row2 = mysql_fetch_assoc() or $dead2 = true;
   if(!$row3  !$dead3)  $row3 = mysql_fetch_assoc() or $dead3 = true;

   // compare all 3 times, find nearest one
   // store winning row id into a temp var, like win_id;
   // have a list of table names which corresponds to the rows.  row1 =
blah_tbl , row2 = eh_tbl , row3 = wow_tbl
   // store table name from winning row, store in win_table;
   // and finally set the winning row to 0, so that row will be fetched next
time through the loop

   $each_result = mysql_query(select * from $win_table where id =
$win_id);
   Output_my_Result( $each_result );
}

It sure ain't pretty, but that's how I could do it...Hopefull all that helps
you somehow.

SL.


- Original Message -
From: Nicolas Mermet [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 24, 2001 2:42 PM
Subject: [PHP] getting rows from separate tables stacked in a single array ?
(newbie, mysql)


 Hi.

 This will probably sound simple to all of you but I am hitting my head on
 a brick wall so far :-).

 I need to generate a list (sorted by descending time) of different objects
 referenced in multiple tables. All those objects share a key related to a
 project.


 This works splendidly from a single table :




 $sql=select * from storyboards, where spot_id = \$spot_id\ order by
 date_posted desc;
 $result=MySQL_query($sql,$db);
 while($row=MySQL_fetch_array($result))
 {
 $qt_title = $row[title];
 $qt_duration = $row[duration];
 $qt_date_posted = $row[date_posted]; //(timestamp)
 $qt_description = $row[description];
 $qt_id = $row[quicktime_id];


 }

 Is there a mysql query that would allow me to stack complete rows in
 multiple tables at once (It seems more elegant because I can sort them
 while extracting them) or is there a way in PHP to concatenate results in
 a single array and then sort them by time... ?

 I tried to use a join query, wich produced an invalid query error. (I
 think it tries to produce a table with merged data, not just a stack of
 rows).


 $sql4=select * from quicktimes, other_images, storyboards, where
 quicktimes.spot_id, other_images.spot_id, storyboards.spot_id =
 \$spot_id\ order by date_posted desc;

 thank you for your help !
 nicolas

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



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




Re: [PHP] random letters and numbers

2001-04-24 Thread Steve Lawson

Sup,
I made this and have been using it for about 6 months without problem.
mt_rand() is 4 times faster than normal rand(), remember to use mt_srand()
to seed.  The 8 in the while controls how long the $password will be...


$count = 0;

mt_srand( (double) microtime() * 100);

while( $count  8 )
{
   $randval = mt_rand(48 , 122);
   $timeout++;

   // currently allows 0-9 and a-z (lowercase), add 65-90 for uppercase
   if(($randval  47  $randval  58) || ($randval  96  $randval  123))
   {
  $password .= chr($randval);
  $count++;
   }
}

SL.


- Original Message -
From: Randy Johnson [EMAIL PROTECTED]
Cc: Php-General [EMAIL PROTECTED]
Sent: Tuesday, April 24, 2001 12:10 AM
Subject: [PHP] random letters and numbers


 Is there a way to generate a random set of characters ranging from 8 to 12
 characters and numbers where it is crucial that the letters and numbers
are
 truly random because I need to create temporary files for people to
download
 information.

 Any links/suggestions would be greatly appreciated

 Thanks

 Randy


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



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




Re: [PHP] getting rows from separate tables stacked in a single array ? (newbie, mysql)

2001-04-24 Thread Steve Lawson

Doh, I shoulda thought of that, a temp table is the best way to do it.
Altho, I don't see why you have a spot_id as a key for that table.  Your are
probably never going to access that table via that arbitrary number.  If
anything, you should make item_id the key.  The id on your other tables
should also be keys.

SL.

- Original Message -
From: Nicolas Mermet [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 24, 2001 8:50 PM
Subject: Re: [PHP] getting rows from separate tables stacked in a single
array ? (newbie, mysql)



 Thanks a bunch, SL. I was expecting some heavy manipulation of that sort.
 Wouldnt have been able to write that code. (yet ! ;-). I will try that
 tomorow.

 This afternoon In despair I ended tweaking the db and creating an extra
 table to link all the desired tables with a time indice, temporarily
 solving my problem but promising future headaches when I devellop the db
 admin page. Here is how I dit it:



 table all_items
 item_id (id of the items in their original tables)
 date_posted (original item post date)
 table_name (where the item comes from)
 spot_id (key to the project)


 It works with this code:




 //connecting to the link table to get time-ordered list of relevant items,
 their origin and their keys

 $sql4=select DATE_FORMAT(date_posted, '%a %m/%d/%y at %l:%i %p.'),
 item_id, item_table from spot_items where spot_id = \$spot_id\ order by
 date_posted desc;
 $result4=MySQL_query($sql4);
 while($spotitems=MySQL_fetch_array($result4))
 {
 list($items_date_posted, $items_id, $items_table) = $spotitems ;

 //linking to the real tables to get the real item info


 $sql5=select * from $items_table where item_id = \$items_id\;
 $result5=MySQL_query($sql5);
 while($items=MySQL_fetch_array($result5))
 {
 $items_title = $items[title];
 $items_description = $items[description];
 $items_duration = $items[duration];
 }

 //outputing in fonction of the item origin

 if ($items_table == movie)
 echo $items_title (Quicktime, duration: $items_duration)
 $items_date_postedbr$items_descriptionbr;

 if ($items_table == storyboard)
 echo $items_id\ $items_title (Storyboard) $items_date_postedbr
 $items_descriptionbr;

 if ($items_table == picture)
 echo $items_title(Picture) $items_date_posted
br$items_descriptionbr;


 }
















 thanks again,
 Nicolas.

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




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




Re: [PHP] problem with storing displaying image in db

2001-04-22 Thread Steve Lawson

Why not just store the filename?

SL.

- Original Message -
From: "Keyur Kalaria" [EMAIL PROTECTED]
To: "php" [EMAIL PROTECTED]
Sent: Saturday, April 21, 2001 9:52 AM
Subject: [PHP] problem with storing  displaying image in db


 Hello everybody,

 I am facing a strange problem while uploading and displaying images in a
 database table.

 I have taken blob field to store the images.

 Images which are less then around 100kb are stored  displayed properly
but
 images which are greater than 100kb are giving problems while displaying
 although no errors were generated while inserting them in database.

 what could be the problem ? is it due to the blob type ?

 i am using the following statements to insert the file to database.

 insert.php
 ***
 $imgsize=GetImageSize($photofile);
 $photo=addslashes(fread(fopen($photofile, "r"), filesize($photofile)));
 $query="insert into photo(photoformat,photo,photowidth,photoheight) values
 ('$photoformat','$photo',$imgsize[0],$imgsize[1])";

 $photoformat, $photofile are the input fields of the form which is
 submitted.

 ***

 in my html pages i use the following img :

 img src=display.php?id=1

 and my display.php is as follows:

 display.php
 ***
 $query="select * from photo where id='$id'";
 $result=mysql_query($query);
 $photo_rec=mysql_fetch_array($result);
 Header( "Content-type: image/$photo_rec[photoformat]; name=".microtime());
 echo $photo_rec["photo"];

 ***


 Thanks in advance

 Keyur
 $$$





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



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




Re: [PHP] PERL vs. PHP

2001-04-20 Thread Steve Lawson

No, you won't.

PHP is has very similar syntax to c/c++ and perl but the concepts are
extremely different.

SL.


- Original Message -
From: "Jason Caldwell" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, April 20, 2001 3:10 PM
Subject: [PHP] PERL vs. PHP


 If I know PHP will I *basically* know PERL?  Looking at some PERL code...
it
 looks nearly identical.

 Thanks.
 Jason




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



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




Re: [PHP] Which is better coding style...

2001-04-19 Thread Steve Lawson

Personally, I hate trailing {'s

I think this

function blah()
{
   switch( $bob )
   {
  case 1:
 $var = "whatever";
  break;
   }
}

Is much easier to read and follow.  As for the exiting question...

The "proper" way is to use the breaks.  "They" say that multiple returns in
any function = bad programming.  The .0001 second that it takes to break and
return the value will never matter.

Plus, you or someone else may have to add to that function later.  Let's say
I wanted to add "/B" to the end of $retval.  If you use the normal way I
can just make one change, return $retval . "/B"; instead of changing 3
different returns.

SL.



- Original Message -
From: "Boget, Chris" [EMAIL PROTECTED]
To: "Php (E-mail)" [EMAIL PROTECTED]
Sent: Thursday, April 19, 2001 11:57 AM
Subject: [PHP] Which is better coding style...


 Which is better?

 function blah() {
   switch( $bob ) {
 case 1:
return "this";

 case 2:
   return "that";

 default:
   return "other";

   }
 }

 function blah() {
   $retval = "";

   switch( $bob ) {
 case 1:
$retval = "this";
break;

 case 2:
   $retval = "that";
break;

 default:
   $retval = "other";
break;

   }

   return $retval;

 }


 In other words, is it good practice to exit out of a block (any
 block... not just switch; if, for, while) prematurely as demon-
 strated in the first example?  Or should you do it as demon-
 strated in the second example?

 Chris



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




Re: [PHP] Site Searchable function

2001-04-19 Thread Steve Lawson

Hey,
Well, I would write two scripts.  One to pregen a reference database and
one to search using that database.

The pregen could use the readdir function that Matthew Luchak suggested.
You could use the fopen command to get the pages.
fopen("http://localhost/name-of-file") will return the rendered page instead
of the page with the mixed-in source.  You could then use the striptags()
function.  Now you have just the text and it has any dynamic content from
the php code.  Parse that file, throw out any words that are less than like
3 characters.

There are tons of ways to store the words and pages, the simpilest being to
just to store the word and then a list of the pages that it appears on.
Maybe even tie in how many times it appears in each page.

Anyway, throw that pregen page into a daily or hourly cron and boom, done.

Then write a search page that just looks for each word, find the correct
pages, and makes links to them.

I don't know of any sites that explain how to do search engines but this way
will work :)

SL.

- Original Message -
From: "Kevin A Williams" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, April 19, 2001 11:11 AM
Subject: [PHP] Site Searchable function


Hi,

I was wondering whether anyone could direct me in the direction of creating
a search function like the one on php.net?

I have tried looking rather fruitlessly to implement a system, would one
possible implementation be to use reference files for the information and
then use string matching to analyse the information, or search the source
.php files (although security issues of revealing scripts).

Thanks in advance




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




Re: [PHP] Starting PHP script with crontab

2001-04-19 Thread Steve Lawson

Sup,
You have to make the output write to a file.

Like

lynx http://www.page.come  /home/me/bleh.htm

SL.

- Original Message -
From: "Bertjan Schrader" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, April 19, 2001 4:15 AM
Subject: [PHP] Starting PHP script with crontab


 I need tot start a PHP script at night with the crontab. I tried to do it
 with lynx (lynx http://www.domain.nl/test.php) as a commandline within the
 crontab. Lynx is starting but the PHP script is not working. Anyone an
idea
 how to do it?

 OS:  Redhat Linux 5.2
 Apache
 PHP as a apache module

 thanks!



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



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




Re: [PHP] SQL - Select rand() ?

2001-04-17 Thread Steve Lawson

Sup,
In the newer versions of mySQL, you can get random results like

SELECT id FROM table ORDER BY rand() LIMIT 0,1

SL.



- Original Message -
From: "James, Yz" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, April 17, 2001 2:55 PM
Subject: [PHP] SQL - Select rand() ?


 Hi Guys,

 If I wanted to retrieve just one field randomly from a MySQL table, would
I
 just use something like:

 "SELECT RAND(id) FROM table  LIMIT 0,1" ?

 I suppose the best thing for me to do would be to try it, but I am fast
 losing the will to stay awake ;)

 Thanks, as always,

 James.



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



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




[PHP] cookies

2001-01-13 Thread Steve Lawson

You have to call setcookie() before anything is outputtedthat was it sounds like.

SL.



[PHP] User/Group for PHP

2001-01-13 Thread Steve Lawson

Yo,
Anyone know of a cfg option that would make files written by php be a different 
user/group than the apache server user/group?

With my current setup, the only way to give php write access also allows any surfer 
write access to that same folder...which is "not a good thing".

Thanks,
SL.