[PHP] null as function argumnent?

2004-12-08 Thread Bas Jobsen
Hi,

I want to use a ?: statement. If not true de default function argument have to 
be used. How to do this

?
function test($test='default')
{
echo $test;
} 
test(($value==1)?'no default':null);
?

What do i have to pass instead of null to get default print?

Tnx,

Bas

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



[PHP] error reporting linenumber and filename

2003-06-16 Thread Bas Jobsen
Hi,

Running the code below, shows an errror in line 2 as expected.
How do i get the linenumber of the function call? 3 here.

?
function test($x){if($x!='a')trigger_error('error: call test with argument 1 
equals a',E_USER_ERROR);}
test('b');
?

Best regards,

Bas

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



Re: [PHP] error reporting linenumber and filename[Scanned]

2003-06-16 Thread Bas Jobsen
Hi Michael,

 I'm not sure that there is a way beyond this to show the line within the
 function but I don't see that this would be necessary - at least not for
 resolving errors.

i'm building a class for html table, will give you a short example (see 
below).
Running testtable.php will produce Error: you can't open a new table on line 
13 on file /home/table.php, but i will get line 7 on testtable.php cause 
the wrong function is call there.

table.php:
--
?
class table
{
var $open;

function table()
{
$this-open=false;
}

function open()
{
if($this-open)echo 'Error: you can\'t open a new table on line 
'.__LINE__.' on file '.__FILE__;
else 
{
?table?
$this-open=true;
}

}
function close()
{
if(!$this-open)echo 'Error: you can\'t close a table which not open 
on 
line '.__LINE__.' on file '.__FILE__;
else 
{
?/table?
$this-open=false;
}   
}   
}   
?
--

testtable.php:
--
?
include('table.php');
$TABLE=new table;
$TABLE-open();
$TABLE-close();
$TABLE-open();
$TABLE-open();
?
--
 


Op maandag 16 juni 2003 15:10, schreef u:
 Bas,

 The __LINE__ constant will return the line number of the script from which
 the call is made.  This should be enough to isolate any error.

 I recently had a detailed look at the phpBB (www.phpbb.com)  application
 and they use their own 'message_die' function which ensures that whenever
 errors occur they give a detailed explanation of the error together with
 the file name ( __FILE__ ) and the line number which produced the error.

 I'm not sure that there is a way beyond this to show the line within the
 function but I don't see that this would be necessary - at least not for
 resolving errors.

 HTH,

 Michael Egan

 -Original Message-
 From: Bas Jobsen [mailto:[EMAIL PROTECTED]
 Sent: 16 June 2003 13:14
 To: Michael Egan
 Subject: Re: [PHP] error reporting linenumber and filename[Scanned]


 Dear Michael,

 Thanks for your respons, maybe i don't inderstand your solution but:

 1function line()
 2{
 3 echo __line__;
 4}
 5line();

 will print 3 and not 5

 best regards,

 Bas

 Op maandag 16 juni 2003 14:05, schreef u:
  Use the predefined constant:
 
  __LINE__
 
  Regards,
 
  Michael Egan
 
  -Original Message-
  From: Bas Jobsen [mailto:[EMAIL PROTECTED]
  Sent: 16 June 2003 12:50
  To: PHP General
  Subject: [PHP] error reporting linenumber and filename[Scanned]
 
 
  Hi,
 
  Running the code below, shows an errror in line 2 as expected.
  How do i get the linenumber of the function call? 3 here.
 
  ?
  function test($x){if($x!='a')trigger_error('error: call test with
  argument 1 equals a',E_USER_ERROR);}
  test('b');
  ?
 
  Best regards,
 
  Bas

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



Re: [PHP] Help inserting compressed data into a mysql database

2003-06-16 Thread Bas Jobsen
extract from database
$data = @gzinflate(stripslahes($data));

Op maandag 16 juni 2003 18:03, schreef u:
 Hi,

 I am trying to insert compressed data into a database.

 Inserting it in seems to work file:

 $data = addslashes(gzdeflate($data, 9));
 insert into database

 For the most part it works on reteiving the data but sometimes the data is
 unreadable.

 extract from database
 $data = @gzinflate($data);

 What is the best way to be able to store any charater in the database so
 that I can guarantee the data is going to be good?

 Thanks! :))

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



Re: [PHP] categorise list

2003-06-09 Thread Bas Jobsen
$letter='';

$while($row=mysql_fetch_array($result))
{
if($letter!=$row[name][0])
{
echo $row[name][0].'br';
$letter=$row[name][0];
}
echo $row[name].'br';
}


Op maandag 09 juni 2003 12:41, schreef u:
 I am dispalying data from mysql database using the codes below:

 $while($row=mysql_fetch_array($result))
 {
 echo $row[name];
 }

 How can i format the above data in this format as shown below? in
 alphabetical order

 A
 ---
click to go up Apple
 Armchair

 B
 ---
click to go up Basket
 Baseball

 C
 ---
click to go up Car


 
 and so on


 any suggestions??

 Many thanks,
 awlad

 ___

 Sheridan Phoenix Company
 The Business Centre  Kimpton Road  Luton  Bedfordshire  LU2 0LB

 Email:  [EMAIL PROTECTED]
 Phone:  01582 522 330
 Fax:01582 522 328
 ___

 This electronic transmission is strictly confidential and intended
 solely for the addressee.  If you are not the intended addressee, you
 must not disclose, copy or take any action in reliance of this
 transmission.  If you have received this transmission in error it would
 be helpful if you could notify The Sheridan Phoenix Company Ltd as soon
 as possible.

 Any views expressed in this message are those of the individual sender,
 except where the sender specifically states them to be the views of The
 Sheridan Phoenix Company Ltd.

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



Re: [PHP] convert seconds to hours, minutes, seconds

2003-06-04 Thread Bas Jobsen
function secondstohours($seconds)
{
/* [EMAIL PROTECTED] */
$sec=$seconds%3600;
return (($seconds-$sec)/3600).':'.($sec/60).':'.($sec%60);
}

echo secondstohours(7500);

Op dinsdag 03 juni 2003 14:38, schreef u:
 Hello everybody,
 I have a value 178607, which is stored as seconds. I
 like to convert it (178607 Secs) to Hours, Minutes and
 Seconds appropiatly.
 Can anybody help me supplying the code?
 Thank You,
 - Chinmoy

 __
 Do you Yahoo!?
 Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
 http://calendar.yahoo.com

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



Re: [PHP] Correct number format (curency)

2003-02-20 Thread Bas Jobsen
 Example

 1.000,00
 1000.00
 1,000.00

 I would like to convert those to a single format
 1000.00
?
function money($money)
{
/* written by [EMAIL PROTECTED] */
$money=str_replace(array(',','.'),'',$money);
$money=substr($money,0,strlen($money)-2).'.'.substr($money,-2);
}
$money='1.000,00';
money($money);
echo $money.\n;
$money='1000.00';
money($money);
echo $money.\n;
$money='1,000.00';
money($money);
echo $money.\n;
?

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




Re: [PHP] recursion?????

2003-02-14 Thread Bas Jobsen
not tested 
 Basically, have the form action call itself  hince the recursion.
 Any suggestion/examples?
?
$field1=false;
if(isset($_POST['submit']))
{
/*check*/
if(isset($_POST['field1'])  $_POST['field1']=='okay')header('Location:  
registration.php');
else $field1=true;
}
?
form action=?=$SERVER['PHP_SELF']? method=POST
input type=text  name=field1 
value=?=isset($_POST['field1'])?$_POST['field1']:''??=$field1?'*':''?
input type=submit  name=submit value=GO
/form

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




Re: [PHP] array_search() problem

2002-09-12 Thread Bas Jobsen


 Hi I'm runing a PHP Version 4.0.4pl1 on Solaris 8 X86 on apache, and I'm
 trying to search an array

From the manual: array_search (PHP 4 = 4.0.5)

send earlier to this list:

Re: [PHP] Array - Match
From: Bas Jobsen [EMAIL PROTECTED]
To: N. Pari Purna Chand [EMAIL PROTECTED], 
[EMAIL PROTECTED]


?
$sub = abcd;

$subs[] = cde;
$subs[] = iyu;
$subs[] = abc;
$subs[] = xyx;
$match=false;
foreach($subs as $value)
{
 if($sub==$value){$match=true; break;}
}
if($match) echo 'found!';
else  echo 'not found!';

//or better use
//for PHP 4
if(in_array($sub,$subs))echo 'found!';
else  echo 'not found!';

//also possible
//for PHP 4 = 4.0.5   4.2.0
if(is_null(($b=array_search($sub,$subs  echo 'not found!';
else echo 'found! In $sub['.$b.']';
//or for  PHP 4 = 4.2.0
if(($b=array_search($sub,$subs)))  echo 'found! In $sub['.$b.']';
else echo 'not found!';
?

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




Re: [PHP] array_search() problem

2002-09-12 Thread Bas Jobsen

 What I was  looking for was finding out what was the index of thet
 value, lets say I have a array with some values like (23, 56, 45, 47)
 and i don't know where the walue I'm looking for is indexed in the array
 and I want to find out what the indexnumber is, how would that be
 possable

?

function array_index($array,$needle)
{
/* written by [EMAIL PROTECTED] */
foreach($array as $key=$value)
if($value==$needle)
return $key;
return -1;
}

$array=array(23, 56, 45, 47);

echo array_index($array,45);
echo array_index($array,48);
if(array_index($array,48)0)echo 'not found';
else echo 'found';
?


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




Re: [PHP] split() - not working in this case

2002-09-08 Thread Bas Jobsen

?
function split_addresses($addr) {
 $ad = array();
 $ad = split(,,$addr);
 return $ad;
}

$tos=array();
$to =  abcd [EMAIL PROTECTED], efgh [EMAIL PROTECTED];
$tos=split_addresses($to);
echo $tos[1];
?

echos efgh [EMAIL PROTECTED] ?? Whats the problem? Maybe you output to a browser 
and don't see [EMAIL PROTECTED] cause its between 



Op zondag 08 september 2002 10:17, schreef N. Pari Purna Chand:
 I have a string
 $to =  abcd [EMAIL PROTECTED], efgh [EMAIL PROTECTED] ;

 I want a function returning an array of
 indivial names+mailids like from the $to seperated by ,
 something like
 $tos[0] = abcd [EMAIL PROTECTED];
 $tos[1] = efgh [EMAIL PROTECTED];

 Now split() in the following function*** is notworking as needed.
 ie, I'm getting
 $tos[0] = abcd;
 $tos[1] = efgh;

 Not the complete name + mailid,
 Why ?
 /Chandu

 ***
 function split_addresses($addr) {
  $ad = array();
  $ad = split(,,$addr);
 return $ad;
 }

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




Re: [PHP] Array - Match

2002-09-07 Thread Bas Jobsen

?
$sub = abcd;

$subs[] = cde;
$subs[] = iyu;
$subs[] = abc;
$subs[] = xyx;
$match=false;
foreach($subs as $value)
{
 if($sub==$value){$match=true; break;}
}
if($match) echo 'found!';
else  echo 'not found!';

//or better use
//for PHP 4
if(in_array($sub,$subs))echo 'found!';
else  echo 'not found!';

//also possible
//for PHP 4 = 4.0.5   4.2.0
if(is_null(($b=array_search($sub,$subs  echo 'not found!';
else echo 'found! In $sub['.$b.']';
//or for  PHP 4 = 4.2.0
if(($b=array_search($sub,$subs)))  echo 'found! In $sub['.$b.']';
else echo 'not found!';
?


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




Re: [PHP] String operation

2002-09-04 Thread Bas Jobsen

$string3 = str_replace($string1,'',$string2); ???
Op woensdag 04 september 2002 17:04, schreef Richard Fox:
 Hi

 Given

 string1 = /home/web/
 string2 = /home/web/www/index.php

 How can I elegantly do an exclusive or of string1 with string2, that is, I
 want to end up with

 string3 = www/index.php

 Thanks!

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




Re: [PHP] limit in a loop function to prevent server load

2002-09-03 Thread Bas Jobsen


Op dinsdag 03 september 2002 10:46, schreef u:
 hi there i was wondering if there was a way to limit the ammount of items
 in a loop to execute sleep then execute the rest of the items to prevent
 server load ?

for($i=0;...)
{
if($i0$i%100==0)sleep(10);
}

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




Re: [PHP] wordwrap function (that skips html tags)

2002-09-03 Thread Bas Jobsen

Hello,

What's your php version?
Take at look at:
http://www.php.net/manual/en/function.wordwrap.php
and
http://www.php.net/manual/en/function.strip-tags.php
b.e.
$str='http://www2.snm-hgkz.ch/~rieger/notepool/addnote.php';
echo wordwrap(strip_tags($str),8,'br',1);

i you can't use wordwrap(), try:
?
/* written by [EMAIL PROTECTED] */
function wordwraphtml($string,$length,$endline='br',$striphtml=true)
{
if($striphtml)$string=strip_tags($string);
$temp='';
$sublength=strlen($string);
if($sublength$length)return $string;
while($sublength$length)
{
$temp.=substr($string,0,$length).$endline;
$string=substr($string,$length+1);
$sublength=strlen($string);
}
return $temp;   
}

$string='a href=http://www.startpunt.cc/a';
echo wordwraphtml($string,8);

?

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




Re: [PHP] greeting based on time

2002-09-03 Thread Bas Jobsen

?
$hour=date('H');
switch(true)
{
case ($hour 12):   echo 'Good Morning';break;
case ($hour 18):   echo 'Good Afternoon';  break;
default:echo 'Good Night';  break;
}
?


Op dinsdag 03 september 2002 13:01, schreef Javier Montserat:
 really simple one -

 does someone have a bit of code that will variously display 'good morning',
 'good afternoon', 'good evening' based on the current time?

 good morning from london,

 Javier



 _
 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




Re: [PHP] Refering to an object from within an array variable in another class

2002-09-03 Thread Bas Jobsen

 Any insight appreciated. In a best case if someone can add in the required
 ''s to the following code that would be great.
  ?php
 echo 'pre' ;
 error_reporting ( E_ALL ) ;

 class Foo {
 var $bars = array() ;

 function AddBar($id,$text)
 {
 $obj = new Bar ( $text ) ;
 $this-SetBar ( $id , $obj ) ;
 }

 function SetBar($id,$bar)
 {
 $this-bars[$id] = $bar ;
 }

 function GetBar($id) {
 return $this-bars[$id];
 }

 function SetBarMarklarSyntaxA ($id,$value)
 {
 /*
 This syntax works...
 */
 $this-bars[$id]-SetMarklar($value) ;
 }

 function SetBarMarklarSyntaxB ($id,$value)
 {
 $reference_to_bar = $this-GetBar($id) ;
 $reference_to_bar-SetMarklar($value) ;
 }
 }

 class Bar {
 var $marklar = '' ;

 function Bar($marklar) {
 $this-SetMarklar($marklar) ;
 }

 function SetMarklar($value)
 {
 $this-marklar = $value ;
 }
 }

 //---

 $foo = new Foo ;
 $foo-AddBar('one','un') ;
 $foo-AddBar('two','duex') ;

 print_r($foo) ;

 //Works
 $foo-SetBarMarklarSyntaxB('one','eins') ;
 $foo-SetBarMarklarSyntaxB('two','zwei') ;

 print_r($foo) ;

 echo '/pre' ;
?



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




Re: [PHP] How do I call a CGI script from PHP?

2002-08-26 Thread Bas Jobsen

 PHP page, nothing fancy. .In SSI, I just use the #exec cgi= line--is

$test = `path_to_your_cgi 21`;

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




Re: [PHP] problem with using link variables

2002-08-25 Thread Bas Jobsen

 If the variable provnum contains text such as: hello  there

urlencode($provnum);


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




Re: [PHP] Count number of rows in table.

2002-08-25 Thread Bas Jobsen

 $sql = select count(*) from table_name WHERE .;
 $result = mysql_query($sql) or die(mysql_error);
 $row = mysql_fetch_row($result);
 $rowCount=$row[0];
or 
$sql = select count(*) from table_name WHERE .;
$result = mysql_query($sql) or die(mysql_error);
$rowCount=mysql_result($result);

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




Re: [PHP] Help with matchng strings

2002-08-25 Thread Bas Jobsen

$lista=array(1,2,3,4,5,6,7,8,9);
$listb=array(4,6,8);
$listc=array_intersect($lista,$listb);
$listd=array_diff($lista,$listb);


Op maandag 26 augustus 2002 01:48, schreef Rasmus Lerdorf:
 array_intersect() will give you listC directly.  Just feed it list A and
 B.  Then you can take a copy of listA and do a foreach on the array_keys()
 of listC and unset() them.  Now this copy with the removed elements
 becomes your listD

 -Rasmus

 On Sun, 25 Aug 2002 [EMAIL PROTECTED] wrote:
  I have two list one is listA and the other is listB I would
  like to take the values in listB and compare them with listA if any of
  them match then I what to create a new list listC and put the values
  that match in it. If they do not match I want the values to go into
  listD. I have been messing with this for three days and have not been
  able to get it to work. I have used foreach statements and array_search
  but what ever I try I just can't seam to get it. What I need is something
  like below. Could somebody please help.
 
 
   If LISTB MATCHES LISTA If NO Match
  LISTA LISTB  Make LISTC  Make LISTD
 
 
  test1 test4 test4   test1
  test2 test6 test6   test2
  test3 test8 test8   test3
  test4   test5
  test5   test7
  test6   test9
  test7
  test8
  test9
 
 
  --
  Best regards,
   rdkurth  mailto:[EMAIL PROTECTED]
 
 
  --
  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] Eregi_replace

2002-08-22 Thread Bas Jobsen

eregi_replace('a href[^]+','',$string);

Op donderdag 22 augustus 2002 14:42, schreef Roman Duriancik:
 How to create pattern for function eregi_replace to
 replace in html document every html tag a href= for empty string.

 Thanks


 roman

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




Re: [PHP] array_splice()

2002-08-21 Thread Bas Jobsen




$test=array('a'=1,'b'=2,'c'=3);
foreach ($test as $key=$value)
{
 if ($value==2) unset($test[$key]);
}

or

$test=array('a'=1,'b'=2,'c'=3);
$i=0;
foreach ($test as $key=$value)
{
 if ($value==2) array_splice($test,$i,1);
$i++;
}


Op woensdag 21 augustus 2002 12:17, schreef u:
 Hi evey1,
 sorry if I' ve already posted this :
 in order to remove a whole array of values from a multidimensional array
 I tried the following:

 foreach($bkmks as $val) {

 if($val[8]==$cod){
array_splice($bkmks,$val,1);
}
   }It works fine for all the
 arrays but the first ($bkmks[0])
  When I try to remove that array this is what I get :
 Fatal error: Maximum execution time of 30 seconds exceeded in .
  after that if I read $bkmks all the arrays have been removed but
 $bkmks[0]
 (the array I wanted to  remove)
 Why ?
 Is there a better way to do it ?

 thanks again

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




Re: [PHP] Exiting from an include or required file

2002-08-21 Thread Bas Jobsen

Do:
 FILE A:

 ?php
 if (empty($_POST['search_criteria'))
 {
   echo You must provide search criteria;

   // exit the include file here But how?
  }
 else
{
 echo You have provided serach criteria;
}
 ?


Op woensdag 21 augustus 2002 16:39, schreef Henry:
 Hi All,

 I would like to exit from an include file and continue in the calling
 script!

 As an example

 FILE A:

 ?php
 if (empty($_POST['search_criteria'))
 {
   echo You must provide search criteria;

   // exit the include file here But how?
  }

 echo You have provided serach criteria;
 ?


 FILE B

 #include A;

 form method=post
 input name=search_criteria type=text
 /form

 TIA

 Henry

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




Re: [PHP] !--#exec cgi= equivalent in PHP

2002-08-20 Thread Bas Jobsen

echo `PATH_TO_PERLSCRIPT.CGI 21`;

Op dinsdag 20 augustus 2002 09:47, schreef Peter Janett:
 I'm converting over some .shtml files that call an external Perl script
 with the following format:
 !--#exec cgi= PATH_TO_PERLSCRIPT.CGI --

 I'm not sure what php function to use, as I'm returning the results of a
 Perl script, not really a UNIX command.

 Thanks,

 Peter Janett

 New Media One Web Services
 
 New Upgrades Are Now Live!!!
 Windows 2000 accounts - Cold Fusion 5.0 and Imail 7.1
 Sun Solaris (UNIX) accounts - PHP 4.1.2, mod_perl/1.25,
 Stronghold/3.0 (Apache/1.3.22), MySQL 3.23.43
 
 PostgreSQL coming soon!

 http://www.newmediaone.net
 [EMAIL PROTECTED]
 (303)828-9882

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




Re: [PHP] quick ereg() question

2002-08-17 Thread Bas Jobsen

if (ereg(((\.)(php|inc))$,$o0o)  !ereg(\/\.\., $o0o)){

Op zaterdag 17 augustus 2002 23:53, schreef eriol:
 I checked the manual and it's comments as well as google, but didn't find
 the simple answer i'm wanting..

 I have the following line in a show php source code page:


 if (ereg((\.php)$,$o0o)  !ereg(\/\.\., $o0o)){
   ...
 }


 It works fine on .php files but I was hoping I could include .inc files as
 well when someone wanted to view the source of them.. To include .inc files
 as viewable php source code, I'd rewrite it similar to below I assume, but
 I'm not understanding the syntax I'm missing..


 if (ereg((\.inc | .php)$,$o0o)  !ereg(\/\.\., $o0o)){
   ...
 }


 I know I have to use a pipe to seperate allowable file types, but that's
 the extent of what I know.. Any help would be appreciated.. TIA..

 Take care.. peace..
 eriol

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




Re: [PHP] preg_match help?

2002-08-17 Thread Bas Jobsen

preg_match(/.*b[^]+(.*)font face=\Verdana\ size=\3\.*/, 
$contents,$story);
echo $story[1];

preg_match always return a array. The first element ($array[0])contains your 
complete regexp. The next ($array[1])one the first match between () etc.
Don't use ! but /




Op zondag 18 augustus 2002 01:27, schreef Jason Soza:
 I seriously need some help trying to make a match here. Obligatory
 disclaimer: yes, I've searched google.com, I've read the PHP manual section
 on preg_match(), and I've sat here for 3 hours trying to resolve this on my
 own. :) Any help would be great:

 I need to match everything between:

 b$headline

 Where $headline is a variable that will be filled out of a foreach() loop.
 The pattern should return everything until it hits:

 font face=Verdana size=3

 The text file this is taken out of looks like:

 font face=Verdana size=3bHeadline here/b/fontp

 News story, blah, blah, blah...

 font face=Verdana size=3bAnother headline/b/fontp

 More news, blah, blah...

 ...

 The contents of the text file echo correctly before the preg_match, but the
 preg_match I've tried:

 preg_match(!b[^]+(.*)font face=\Verdana\ size=\3\!, $contents,
 $story);

 Returns array(), so no matches are made. Any suggestions?

 TIA,

 Jason Soza

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




Re: [PHP] fopen and sort by date modified

2002-08-14 Thread Bas Jobsen

Op woensdag 14 augustus 2002 13:04, schreef electroteque:
 hi there i was wondering how i could fopen a directory and then sort the
 files by date modified is there a way ?


?php
// Note that !== did not exist until 4.0.0-RC2
$dir='/home';
if ($handle = opendir($dir))
{
echo Directory handle: $handle\n;
$lasttime=0;
   $temp=array();
while (false !== ($file = readdir($handle)))
{
echo $file;
if(is_file($file))$temp[$file]=filemtime($file);
}
}
asort($temp,SORT_NUMERIC);
reset($temp);
while(list($k,$v)=each($temp))
echo $k.':'.date('r',$v).\n;
?

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




Re: [PHP] [Class] Behaviour global variables

2002-08-14 Thread Bas Jobsen

$TEST= new TEST;
$a=3;
$b=4;
$TEST-Show();

works, fine

better to use $GLOBALS['a'] instead of global $a

Op woensdag 14 augustus 2002 15:27, schreef Tim Stoop:
 Hi there,

 I'm forgetting something, but I can't seem to get to it... Consider the
 following Class.

 class Test
 {
 var $a;
 var $b;

 function Test()
 {
 $this-a = 2;
 $this-b = 5;
 }

 function Show()
 {
 global $a, $b;

 echo(a: .$a);
 echo(a: .$this-a);
 echo(b: .$b);
 echo(b: .$this-b);
 }
 }

 After proper initialisation, calling the function Show() gives:

 a:
 a: 2
 b:
 b: 5

 What am I forgetting here? Tia for answers!

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




Re: [PHP] how many files are in a directory

2002-08-14 Thread Bas Jobsen

Op woensdag 14 augustus 2002 20:00, schreef Harry.de:
 does anybody now a way in php to read out,
 how many files are in a directory

?php
// Note that !== did not exist until 4.0.0-RC2
clearstatcache();
$dir='/home/';
if ($handle = opendir($dir))
{
echo Directory handle: $handle\n;
$counter=0;
while (false !== ($file = readdir($handle)))
{
  if(is_file($dir.'/'.$file))$counter++;
}
}

echo  $counter.\n;
?


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




Re: [PHP] error reporting

2002-08-14 Thread Bas Jobsen

start your file with :
error_reporting(E_ALL);

Op woensdag 14 augustus 2002 20:09, schreef Georgie Casey:
 rite,

 without access to the php.ini file, how can i get php to print all errors
 on my web server. it runs linux
 --
 Regards,
 Georgie Casey
 [EMAIL PROTECTED]

 ***
 http://www.filmfind.tv
 Online Film Production Directory
 ***

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




Re: [PHP] regex match problem

2002-08-14 Thread Bas Jobsen

To Match: Tue, Jul 29, 2003

 $pregmatchstring=/([\s])*(Renewal\DDate|Registered\sthrough|Expires|Record
\sExp ires|Domain\sExpires|Expiry\sDate)([\D\s]*)(.*)/i;

You can change the last part of $pregmatchstring in:

Expiry\sDate)([\D\s]*|\w{3},\s\w{3}\s\d{2},\s\d{4})(.*)/i;
You can feed this match also to strtotime().

See:
?php

$testdate='works: Tue, Jul 29, 2003 works';

$pregmatchstring=/(.*)(\w{3},\s\w{3}\s\d{2},\s\d{4})(.*)/i;

preg_match($pregmatchstring,$testdate,$matches);
echo strtotime($matches[2])-strtotime('29 July 2003');

?

this will echos zero, zo i think it works.





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




Re: [PHP] Array question

2002-08-14 Thread Bas Jobsen

 How can I echo the name of the of the second array (subArray)?  The name
for value
?php

$test=array (
'a'=array('1','2'.'3'),
'c'=array('6','5'.'4'),
'd'=array('8','9'.'10'),
);


$r=next($test);
echo $r[0].' or :'.\n;
foreach (next($test) as $value) echo $value;
?

or do you need the keys?
something like:
echo implode(,,array_keys(next($test))); 

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




Re: [PHP] problem with $_POST

2002-08-14 Thread Bas Jobsen

Op woensdag 14 augustus 2002 20:57, schreef Adam Williams:
 Does anyone know why it is not working with $_POST but works fine with
 $_GET?

I don't know, but maybe you has to put  around POST, method=POST. It 
works then with GET, cause that's default. 

Maybe something else is wrong, so method isn't set to post. The same fault 
with get doesn't matter cause the default method.

You can test it. Use your post method and read out $_GET. I think you find 
your value.




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




Re: [PHP] [Class] global again, not working?

2002-08-14 Thread Bas Jobsen

Hi,
do
--
echo $data[0]*$data[1]);
return ($data[0]*$data[1]);
--
i think its empty.

In the first place, i thought it was maybe impossible to call a 
class-functions in your constructor. (Cause the class function don't exists 
at the moment you call your constructor).

But the code below showed it isn't that:
?
class test
{
var $limiet;

function test()
{
$this-limiet=$this-test2();
}

function test2()
{
return 5;
}

function test3()
{
echo 'Limiet:'.$this-limiet;
return $this-limiet;
}
}

$TEST= new test();
echo 'Limiet:'.$TEST-test3();
?

global $WORKDIR;
NOTE: You should prefer $GLOBALS['WORKDIR'];
read: http://www.php.net/manual/en/migration4.variables.php




Op woensdag 14 augustus 2002 22:53, schreef Tim Stoop:
 Hi people,

 Again, a problem with global. Maybe you can shed a light on this one...

 Consider this part of a class (with [...] I marks things I left out, which
 aren't important for the problem, FAFAIK):

 class FotoView
 {
 [...]
 var $fotos;
 var $cats;
 var $start;
 var $limiet;
 [...]

 /**
  * Constructor
  */
 function FotoView($start,$cats=NULL,$admin=FALSE)
 {
 $this-limiet = $this-getLimit();

 [...]

 $this-start = $start;

 [...]

 echo(1:.$this-start. .$this-limiet);

 $this-fotos = $this-findFotos();
 }

 function getLimit()
 {
 global $WORKDIR;
 include_once($WORKDIR.obj/dbconnection.obj.php);

 $db = new DBConnection();
 $result = $db-query(SELECT lijst_x, lijst_y FROM
 config); $data = mysql_fetch_row($result);
 return ($data[0]*$data[1]);
 }

 [...]

 function findFotos()
 {
 global $start, $cats, $limiet, $urlfotoview, $WORKDIR;

 echo(2:.$this-start. .$this-limiet);

 echo(3:.$start. .$limiet);
 [...]

 Okay, $WORKDIR is set in the page that calls this class, it works (checked
 it). You can see three echo's in there. The result from those are:
 1: 0 20
 2: 0 20
 3: 0

 Can anyone explain to me why in findFotos() the defining of $limiet doesn't
 work correctly? Why isn't a reference made to $this-limiet? I'm really at
 a lost, here... Any help is appreciated!

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




Re: [PHP] file_get_contents ( string filename [, int use_include_path])

2002-08-14 Thread Bas Jobsen

 string filename
The name of the file. b.e test.html or $_SERVER['DOCUMENT_ROOT'].'test.html'
 int use_include_path
Optional 1 true or 0 (or nothing) false the file above is in my default 
include path.
Manual: you can use the optional second parameter and set it to 1, if you 
want to search for the file in the include_path, too. 

The default include path is defined in your php.ini:
Specifies a list of directories where the require(), include() and 
fopen_with_path() functions look for files. 

So call it like:
$string_with_file_contents=('file_with_the_wanted_content.ext');
 

Op donderdag 15 augustus 2002 00:06, schreef [EMAIL PROTECTED]:
 Can someone explain me more abou the usage of this code:

 file_get_contents ( string filename [, int use_include_path])

 I just got it from the annual, and I still don't get what they mean by

 string filename

 and

 int use_include_path

 Thanks,

 This has to do with the other question I posted earlier, yes

 - Vic



 __
 Post your ad for free now! http://personals.yahoo.ca

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




Re: [PHP] SESSION Security

2002-08-14 Thread Bas Jobsen


Op donderdag 15 augustus 2002 01:03, schreef u:
 So, if somebody gets an ftp account somehow, he will be able to get session
 vars via a system() command?

You holds him in its own dir by the chroot setting of you ftpserver.
 via a system();
you mean if they upload a php file?
prevent that with your php.ini settings:

open_basedir string:  Limit the files that can be opened by PHP to the 
specified directory-tree.
or
safe_mode boolean
  Whether to enable PHP's safe mode. Read the Security and Safe Mode chapters 
for more information. 

if you allow cgi, you must built the same sort restrictions for that too. 



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




Re: [PHP] mysql_num_rows($Result)

2002-08-14 Thread Bas Jobsen

In your database design you need the following
every username/pass comb is unique.
so a query like ... WHERE username='$testvalue' AND password='$testvalue2'
Have to give you one row for a good user/passcombination ALWAYS. And 0 rows 
for a wrong combination.
If NOT your design doesn;t fit your needs!!


Op donderdag 15 augustus 2002 01:18, schreef Sascha Braun:
 Mh,

 right yet I have another problem. I want to select a username an a =
 password from a database. The Values for tghe select are stored in a =
 session variable.

 And my problem is, that when I run the Query there is no difference in =
 the mysql_num_rows($Result)

 it both time (When the User is in the Database, or the Username is =
 emtpy) 0.

 How am i able to ckeck the value to do some branching?

 Schura

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




Re: [PHP] Include/require and the HTML Code

2002-08-14 Thread Bas Jobsen

 Can anybody tell me why I get a Parse error: parse error,
 unexpected '}' in /usr/local/apache/htdocs/logbook/Functions.inc on line

begin and end your include files with ? and ?
?
 function HtmlHeader()
 {
 ?
bllaalla

?
return;
}
?


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




Re: [PHP] Template and Replacement

2002-08-13 Thread Bas Jobsen

http://www.php.net/manual/en/function.str-replace.php
In PHP 4.0.5 and later, every parameter to str_replace() can be an array. 

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




Re: [PHP] newbie array question

2002-08-13 Thread Bas Jobsen

Op dinsdag 13 augustus 2002 20:50, schreef Alexander Ross:
 If I have a string variable that is already of the form
 ('item','item2','item3')   [including the parens and quotes in the string],
 is there an easy way to change that variable into an array??
 Array($var) doesn't work. Thanks
?
$var=('item1','item2','item3');
$array=explode(',',str_replace(array('(',')','\''),'',$var));
?

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




Re: [PHP] Read file dates for most recent

2002-08-13 Thread Bas Jobsen

Op dinsdag 13 augustus 2002 23:25, schreef Mike Davis:
 I need to read a directory full of PDF files, and get the file date of the
 most recent.
 Can someone get me started?

?php
// Note that !== did not exist until 4.0.0-RC2
$dir='/home/allop/';
if ($handle = opendir($dir))
{
echo Directory handle: $handle\n;
$lasttime=0;
$lastfile='';
while (false !== ($file = readdir($handle)))
{
   
if(is_file($file)  filemtime($file)$latime)
{
   $lasttime=filemtime($file);
   $lastfile=$file;
}
}
}
echo $lastfile.':'.date('r',$lasttime),'\n';
?

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




Re: [PHP] no HTML in a form textarea field

2002-08-13 Thread Bas Jobsen

http://www.php.net/manual/en/function.strip-tags.php
Op woensdag 14 augustus 2002 02:24, schreef Roger Thomas:
 i presented my visitor to fill up some description about themselves via
 HTML's textarea FORM element.

 how do i block them from entering unwanted HTML tags into the textarea
 field?

 --
 roger


 __
 Do You Yahoo!?
 HotJobs - Search Thousands of New Jobs
 http://www.hotjobs.com

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




Re: [PHP] passing an array in a link

2002-08-11 Thread Bas Jobsen

print a href=\/myscript.php?keylist=.str_replace( 
,+,implode(+,$keylist)).\link/a ;


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




Re: [PHP] Good Damn

2002-08-11 Thread Bas Jobsen

 if ($Result) {
if(mysql_num_rows($Result)0)

Op zondag 11 augustus 2002 16:32, schreef Sascha Braun:
 $Query = SELECT * FROM basket_db WHERE session_id = '$PHPSESSID';
 $Result = mysql_query($Query, $connect);
 if ($Result) {
 while ($arrResult = mysql_fetch_array($Result, MYSQL_ASSOC)) {
   echo 'tr bgcolor=#fffdd7 class=text01';
   echo 'td'.$arrResult['image_id'].'/td';
   echo 'td'.$arrResult['name'].'/td';
   echo 'tda class=text01
 href='.$PHP_SELF.'?action=deleteid='.$arrResult['id'].'delete/a/td'
; echo 'td Hier Preis'.$arrResult[''].'/td';
   echo 'td hier gesamt'.$arrResult[''].'/td';
   echo '/tr';
 }
 } else {
   echo 'tr bgcolor=#fffdd7 class=text01';
   echo 'td colspan=5There are no Artikles in Cart./td';
   echo '/tr';
 }

 This script is not doing what I want it too!

 Ich want to see : There are no Artikles in Cart

 when there are no Artikels in Cart

 But it good damn doesn't work!

 Please tell me why

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




Re: [PHP] Problem with $PHP_SELF on PWS

2002-08-11 Thread Bas Jobsen

 form action=?php $PHP_SELF; ? 
 form action=?=$PHP_SELF? 
or
 form action=?php echo $PHP_SELF; ? 


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




Re: [PHP] Problem with echo

2002-08-11 Thread Bas Jobsen

Op zondag 11 augustus 2002 16:42, schreef Kristoffer Strom:
 Got a problem when echo:ing a variable containing alot of text.
 When echoing it backslashes (\) every apostrophe (') and quote ().
 This I don't like.
 And I can't use HTMLSPECIALCHARS or HTMLENTITIES since the text has alot of
 html tags that I want to keep intact.

 /Kris

echo stripslaches($var);

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




[PHP] why true?

2002-08-11 Thread Bas Jobsen


echo ('test'==0);
gives 1 why?

Thanks,

Bas

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




Re: [PHP] mkdate error?

2002-08-11 Thread Bas Jobsen

YOU use $parsed_date[2] in stead of $parsed_end_date[2]

Op maandag 12 augustus 2002 00:01, schreef jc:
 The following bit of code completely baffles me as to why it doesn't work.
 I am doing a very simple validation where I check to see if the end date
 field of an inputted record is an older date than the start date.

 I checked this by putting in the same date for both end and start dates.
 Yet mkdate gives me a different value for each even though since they are
 both the same date, I should get the same value returned.  Right?

 //notice the start and end date is the same.  Therefore, you should get the
 same value for each, right?
 START LITTLE CODE SNIPPET
  $parsed_start_date=split(/, 08/02/2002);
  $parsed_end_date=split(/, 08/02/2002);
  $start_dts = mktime(, , , $parsed_start_date[0],
 $parsed_start_date[1], $parsed_start_date[2]);
  $end_dts = mktime(, , , $parsed_end_date[0], $parsed_end_date[1],
 $parsed_date[2]);
  if ($start_dts  $end_dts) {
echo This function thinks the end date is older than the start date.;
  }
  else {
echo Whoah, it actually worked.;
  }
 END LITTLE CODE SNIPPET

 What am I not seeing?
 Thanks in advance,
 J. Chyun

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




Re: [PHP] Asking for help...

2002-08-08 Thread Bas Jobsen

Op donderdag 08 augustus 2002 23:22, schreef Ashley M. Kirchner:
 DELETES another field and resubmits.  At this point, that variable
 was already registered, and deleting the value from the form has no
 effect.  The old value is still there and gets submitted.  I need
 to check for this somehow.

You shouldn't register before the form is complete right and not after every 
submit. 
something
like:
?
$error='';
if(isset($_POST['yes']))
{
if($_POST['field1'])!=1)$error='field1 is not1 !';
etc...
}

if(empty($error))
{
session_start();
$_SESSION['field1']=$_POST['field1'];
header(Location: next_page);
exit;
}

if(!empty($error)){ echo error.'br'}

?
form action=?=$_SERVER['PHP_SELF']? method=post
input type=text name=field1 value=?=isset($_POST['field1']) ?  
$_POST['field1'] : ''?
etc
input type=sumbit name=yes
/form





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




Re: [PHP] Creating variables...

2002-08-02 Thread Bas Jobsen

 That same script also gets a value ($step) from another one.  Now I
 need to figure out which $var_list# to use based on this $step value.  Any
 suggestion on how to do this?
${'var_list'.$step}

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




[PHP] shorter way to write include function?

2002-07-31 Thread Bas Jobsen

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




Re: [PHP] Speed issues.

2002-07-28 Thread Bas Jobsen

Hello,

You can also find something about your questions on:
http://www.php9.com/index.php/section/articles/name/PHP%20Guidelines

I had tested out by printing (repeated times):
1) echo 'br'.$k.': hallo '.$string.', dit is hetbr'.\n;
2) echo br$k: hallo $string, dit is hetbr.\n;
3) ?br?=$k?: hallo ?=$string?, dit is hetbr?=\n??
$k=1;
$string='test';

I found: The fastest way to print was 3)
Second came 1) (no much difference) and
the slowest way 2) (about 2 times slower).

I haven't tested printf(trtd 

Best regards,

Bas Jobsen


Op zondag 28 juli 2002 09:56, schreef Yves Vrancken:
 Greetings,

 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 table
 td and so forth, and then inside the td calling up the PHP in order to
 display the information. For example: td ?php .. ? /td

 (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(trtd  and so forth.

 Thanks,

 Yves Vrancken

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




[PHP] string comparison

2002-07-27 Thread Bas Jobsen

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; $a10; $a++) if(strcmp($t1,$t3));//nonmatch
echo getmicrotime()-$start;
?
br
1000x:?
$start=getmicrotime();
for($a=0; $a10; $a++) if($t1!=$t3);//nonmatch
echo getmicrotime()-$start;
?

br
1000x:?
$start=getmicrotime();
for($a=0; $a10; $a++) if(!strcmp($t1,$t3));//match
echo getmicrotime()-$start;
?
br
1000x:?
$start=getmicrotime();
for($a=0; $a10; $a++) if($t1==$t3);//match
echo getmicrotime()-$start;
?
br

1000x:?
$start=getmicrotime();
for($a=0; $a10; $a++) if(strcmp($t1,$t2));//nonmatch
echo getmicrotime()-$start;
?
br
1000x:?
$start=getmicrotime();
for($a=0; $a10; $a++) if($t1!=$t2);//nonmatch
echo getmicrotime()-$start;
?

br
1000x:?
$start=getmicrotime();
for($a=0; $a10; $a++) if(!strcmp($t1,$t2));//match
echo getmicrotime()-$start;
?
br
1000x:?
$start=getmicrotime();
for($a=0; $a10; $a++) if($t1==$t2);//match
echo getmicrotime()-$start;
?
br



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




Re: [PHP] String Manipulation

2002-07-25 Thread Bas Jobsen

Maybe something like:
eregi('([a-z]*)( *)(\(*)([a-z]+)( *)(\)*)([a-z]*)',$string,$matches);
echo $matches[4];

Op donderdag 25 juli 2002 17:13, schreef Mike:
 Hello all,
 I know that this has probably been discussed before and that you will
 tell me to go through all the back messages on the list but I really
 don't have time to do that because I am on a really tight schedule, but
 I was wondering if anyone could give me some pointers on how to pull
 some information out of a string. I have something like this:
 (Something) - is wrong with me
 or
 something - (is wrong with me)
 or
 something - (is wrong with me

 what I need to know how to do is take the stuff that is inside the
 Brackets (or partial brackets) and put them into another string
 the way I am currently doing it is like this:
 Variable names have been changed per my boss(My Boss wanted me to change
 them for some reason)
 ?
 $parenpos = strpos($tartist,));
 $bracketpos = strpos($tartist,]);
 if($parenpos){
   $artist = trim(substr($tartist,0,$parenpos));
   $title  = trim(substr($tartist,$parenpos+3));
   $secondparenpos = strpos($title,();
   $secondbracketpos = strpos($tartist,[);
   $title = trim(substr($title,0,$secondparenpos));
   }elseif($bracketpos){
   $artist = chop(substr($tartist,1,$bracketpos-1));
   $title  = trim(substr($tartist,$bracketpos+3));
 }
 ?

 I know that there has to be a shorter version of this, can anyone help
 me out with it?

 Thank You,
 Mike
 [EMAIL PROTECTED]
 [EMAIL PROTECTED]

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




Re: [PHP] an array_key_exists() substitute for php 4.0 4.1 ?

2002-07-25 Thread Bas Jobsen

http://www.php.net/manual/en/function.array-key-exists.php:
Note:  The name of this function is key_exists() in PHP version 4.0.6. 

Op donderdag 25 juli 2002 18:53, schreef David D:
 hello all,

 I download a gni script path2vars that manipulate query_string for web
 crawlers.
 But I have php 4.06 that doesnt support function :
 uses array_key_exists() (PHP = 4.1.0).
 Is there a way to substitude it ?
 Is there a way to detect php version and incluse the functions or it
 substitute ?


 Thanks.

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




[PHP] unset array here?

2002-07-25 Thread Bas Jobsen

Hello,

I have this  example code:
function doprint($a){foreach($a as $value)echo $value;}
doprint(array('1','test','hello','and'));

Question, is the array in memory after the function call?
So, should it be better to use this:

function doprint($a){foreach($a as $value)echo $value;}
doprint($temp=array('1','test','hello','and'));
unset($temp);

Thanks,

Bas

-- 
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 Bas Jobsen

 Umm...I hope register_globals is off...
And if not.
form action=http://www.yourdomain.com/yourpage.php; method=post
input type=text name=username
input type=submit
/form
Can be used from every server to login.
Op dinsdag 23 juli 2002 12:42, schreef 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] Can a form submit to two PHP form processers in succession?

2002-07-22 Thread Bas Jobsen

//post to this script
if($value_found_in_database) include('error_document.php');
else include('handling_script.php');

Op maandag 22 juli 2002 16:59, schreef DonPro:
 Hi,

 I'm not sure how to do this but I have a form which I wish to do the
 following.

 When the uses clicks the submit button, I wish to perform a check where I
 look for a value in a MySQL database.  If found, I need to return an error
 page telling the user that the value already exists.  I assume that I can
 just POST to a PHP page that performs the check.

 If the value was not found, I would like to POST the results to a PHP form
 handling script I use.

 The above tow are separate PHP documents that are not connected.  In
 essence, it is akin to one form processing page handing off the information
 to another page.  Can this be done in PHP?

 Thanks,
 Don

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




[PHP] no-cache konqueror/opera

2002-07-16 Thread Bas Jobsen

Hello,

How do i make a page which isn't cached for konqueror/opera browers?

Now i have:

$now = gmdate('D, d M Y H:i:s') . ' GMT';
header('Expires: ' . $now);
header('Last-Modified: ' . $now);
header('Cache-Control: no-store, no-cache, must-revalidate,pre-check=0, 
post-check=0, max-age=0'); 
header('Pragma: no-cache'); 
header('Content-Type: text/html; charset=iso-8859-1');

works fine for IE and NS, but doesn't for konqueror/opera. Who knows how to 
fix this, thanks!

Bas

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




Re: [PHP] activating php scripts via cron

2002-07-16 Thread Bas Jobsen

Instead of a second version, you can call your script via lynx:

TERM=vt100
0 * * * * lynx -dump http://www.domeinnaam.nl/yourscript.php



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




Re: [PHP] substr_count() and regex

2002-03-17 Thread Bas Jobsen

?
function count_hebrew($string)
{
$i=0;
while(preg_match(/[à-ú]/,$string))
{
$string=preg_replace(/[à-ú]/,,$string,1);
$i++;
}
return $i;
}

$hebrew_characters=??? àhhjúkkk;
$number_of_hebrew_characters=count_hebrew($hebrew_characters);
echo $number_of_hebrew_characters;
?

Op zondag 17 maart 2002 20:15, schreef Gil Disatnik:
 Hello there,
 I am trying to use substr_count() to count the number of Hebrew characters
 in a string,
 I tried substr_count($test, /[à-ú]/), but it returns 0 as if it can't
 match the regex I have inserted there, I hoped it will work the same as
 preg_match() that works great (preg_match(/[à-ú]/, $test)) for example
 works just fine, but I guess substr_count() is a bit different...

 Is there a way for me to do that? maybe with another similar function? (If
 not I will have to solve it in an ugly while loop that searches for Hebrew
 characters one by one...)

 Thank you.



 Regards

 Gil Disatnik
 UNIX system/security administrator.

 GibsonLP@EFnet

 _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
 Windows NT has detected mouse movement, you MUST restart
 your computer before the new settings will take effect, [ OK ]
 
 Windows is a 32 bit patch to a 16 bit GUI based on a 8 bit operating
 system, written for a 4 bit processor by a 2 bit company which can
 not stand 1 bit of competition.
 -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-

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




[PHP] where is http_cookie ?

2002-03-16 Thread Bas Jobsen

Hello,

I have installed php 4.1.2. as a cgi module.
But http_cookie isn't set. I don' know whats wrong.
You can find the output of phpinfo() at
http://www.tgp2stats.com/test.php

Tnx,

Bas Jobsen

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




Re: [PHP] where is http_cookie ?

2002-03-16 Thread Bas Jobsen

Hi,

Well okay. But now i'm using this code:

test.php (http://www.tgp2stats.com/test.php):
--
?
$test=bas;
session_start();
session_register(test);
header(Location: test2.php);
?
--
test2.php (http://www.tgp2stats.com/test2.php):
--
?
session_start();
session_register(test);
echo test: .$test;
phpinfo();
?
--

For netscape(linux) $test print bas, but is empty when using Konquerer, 
Opera or even IE (on a win98 system).

This code will work for all this browsers with php4.1.2 as module.
Has this something to do with CGI vs module? Or is there a configuration 
mistake?

Bas







Op zaterdag 16 maart 2002 18:02, schreef Jackson Miller:
 HTTP COOKIE will only be set
 if you have a cookie from that
 domain on your computer.  Try
 setting a cookie with
 setcookie() before your
 phpinfo() line on your
 test.php page.

 Hope this helps.


 -Jackson

 -Original Message-
 From: Bas Jobsen
 [mailto:[EMAIL PROTECTED]]
 Sent: Saturday, March 16, 2002
 11:36 AM
 To: PHP General
 Subject: [PHP] where is
 http_cookie ?


 Hello,

 I have installed php 4.1.2. as
 a cgi module.
 But http_cookie isn't set. I
 don' know whats wrong.
 You can find the output of
 phpinfo() at
 http://www.tgp2stats.com/test.
 php

 Tnx,

 Bas Jobsen

 --
 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] write to specific place in file

2002-03-15 Thread Bas Jobsen

First read it, then split and then write it.

$fp=fopen($file,r);
$content=fread($fp,filesize($file));
fclose($file);
$parts=explode($splitsign,$content);
$fp=fopen($file,w);
fwrite($fp,$parts[0].$insert.$splitsign.$parts[1]);
fclose($file);


Op vrijdag 15 maart 2002 19:09, schreef John P. Donaldson:
 How do I write to a specific place in a file instead
 of just using fputs to append text to the end of the
 file?

 Thanks,
 John

 __
 Do You Yahoo!?
 Yahoo! Sports - live college hoops coverage
 http://sports.yahoo.com/

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




Re: [PHP] Real world regex

2002-03-04 Thread Bas Jobsen

 For another I need to get the 3rd opening table row tr tag after the 7th
 opening table tag.

not tested:
(table[^]+.*){6}(table[^]+)([ ]*)(tr[^]*)(.*){2}(tr[^]*)(.*)


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




Re: [PHP] Probably basic but seems advanced to me, PHP/SQL generation.

2002-02-28 Thread Bas Jobsen

while ($row=mysql_fetch_row($result))
{
echo 1 $row[0]
for($x=1; $xcount($row); $x++) 
if(!empty($row[$x])) 
{
echo $x+1;
echo  .$row[$x];
}
}


Op donderdag 28 februari 2002 14:40, schreef DARCY,MATTHEW 
(Non-HP-UnitedKingdom,ex2):
 Hello PHP'ers.

 First of all - scince joining this list I have got some great help and it
 is really helping my build me site so a BIG thank you to all.

 Now back to the help..

 I have a table with cols, and say 20 rows in this table.


 col: 12   3   4   5   6   7   8   9   10
 row: notnull  stuff   4   testblahduh dud
  notnull  stufblahblahtestduh dud


 as you can see col 1 is ALWAYS populated as it is notnull the rest
 are/aren't populated.

 I want to search on this table (in real life it has hundreds of rows)

 so select * from testable;

 I then want to generate a HTML table in php DEPENDING on how many rows are
 populated

 so for example the table for row 1 would look like this

 1 notnull
 4 stuff
 5 4
 7 test
 8 blah
 9 duh
 10dud

 while row 2 would look

 1 notnull
 3 stuff
 5 blah
 6 blah
 7 blah
 9 duh
 10dud

 I am thinking I would have to do some sort of while loop on an array of all
 fields, but how would I single out the null fields in the array and
 generate everything else 

 thanks

 Matt

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




Re: [PHP] excluding files

2002-02-28 Thread Bas Jobsen

if (($file_name != .)  ($file_name != ..)  
!eregi([a-z0-9]+pv\.html,$file))

Op donderdag 28 februari 2002 16:32, schreef Craig Westerman:
 while ($file_name = readdir($dir))

  if (($file_name != .)  ($file_name != ..))

$file_list .= $file_name;
  }


 This excludes . and .. files. How would I exclude files that contained
 pv.

 Thus filenamepv.html would be excluded, but filename.html would not?

 Thanks

 Craig 
 [EMAIL PROTECTED]

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




Re: [PHP] Probably basic but seems advanced to me, PHP/SQL genera tion.

2002-02-28 Thread Bas Jobsen

Hi Matt,

 couple of questions (I like to understand what I am doing to that I don't
 need to ask again)
 Well, okay, i understand and will try. Please take a look in the manuel too.

each() will return a array and sets the array pointer to the next element of 
the input array. The returned array contains the key and the value of the 
input array element. This function returns false when the end of the array 
reached.
List() makes a list of the values of an array.

So we do list($key,$value)=each($row) to walk trought the whole array we put 
this statement in a while loop. 

 the the value is not null then ??? don't understand the || $i==0

The first time you walk trought this while loop $i is 0, all other loops it 
is not 0 (cause the $i++ in the loop)

We need this, cause you said in your explanation. that you would the first 
element always ($i==0) and the other element only when there are not null 
values (empty($value))

 where are the column title being displayed for each row ??
the function mysql_fetch_row($database_result)
return an array with the column title/name (more exactly the name you have 
used in your query, SELECT column1, column2, so i mean  column1 here ) as key 
en the fieldvalue assinged to it as value. The result pointer is also set to 
the next row.

BE: 
--
$result=mysql_query=(SELECT name, address FROM users);
$row=mysql_fetch_row($result);
will be the same as:
$row[name]=Matt;
$row[address]=The Street 1;
--

So $key above is the same as your column title.

 as I see it there should be a seperate table per record.

Yepp

 Each table containing the field name on the left and then the data on the
 right.

Yepp.



Op donderdag 28 februari 2002 17:11, schreef u:
 great bit of php...

 couple of questions (I like to understand what I am doing to that I don't
 need to ask again)

 what does this section do ???

 $i=0;
 while(list($key,$value)=each($row))
 {
 if(!empty($value) || $i==0)
 {
 ?

 I think it is while there are rows in the array list the table key and data
 for each row,

 the the value is not null then ??? don't understand the || $i==0


 where are the column title being displayed for each row ??

 as I see it there should be a seperate table per record.

 Each table containing the field name on the left and then the data on the
 right.

 Is that clear to you ?

 Matt.



 -Original Message-
 From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, February 28, 2002 3:05 PM
 To: DARCY,MATTHEW (Non-HP-UnitedKingdom,ex2)
 Subject: Re: [PHP] Probably basic but seems advanced to me, PHP/SQL
 genera tion.



 while($row=mysql_fetch_row($result))
 {
 echoTABLE BGCOLOR=#191970 WIDTH=400 HEIGHT=20;
 $i=0;
 while(list($key,$value)=each($row))
 {
 if(!empty($value) || $i==0)
 {
 ?
 TR HEIGHT=14
 TD FONT FACE=arial SIZE=4 COLOR=ff9900 ?
 echo $key; ? /FONT /TD
 /TR

 TR HEIGHT=14
 TD FONT FACE=arial SIZE=4 COLOR=ff9900 ?
 echo $value; ? /FONT /TD
 /TR
 ?
 }
 $i++;
 }
 echo /TABLE;
 }

 Op donderdag 28 februari 2002 15:39, schreef u:
  glad you understand,
 
  i had a hard time putting what I wanted into an email.
 
 
 
  -Original Message-
  From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, February 28, 2002 2:45 PM
  To: DARCY,MATTHEW (Non-HP-UnitedKingdom,ex2)
  Subject: Re: [PHP] Probably basic but seems advanced to me, PHP/SQL
  genera tion.
 
 
  Hi Matt,
 
  Okay, i understand give me minutes...
 
  Op donderdag 28 februari 2002 15:27, schreef u:
   Hi baz, thanks for the reply.
  
   I was thinking like this.
  
  
   TABLE LAYOUT.
  
  
   COLS: POSITION_TITLE  POSITION_REFERENCE

 POSITION_CONTACT

   POSITION_SALARY   POSITION_GRADE  etc etc
   ROWS  Support Operator11212

 jim

   daviesB
 ben the boffin  ATJRdean taylor
   £12 PAC+
 toilet Cleaner  BOGSKelly the
   cleaner   U
  
  
   as you can see there are fields which will always be populated like
   POSITION TITLE and POSITION_REFERENCE but things like salary and grade
   may not be (there are more fields)
  
   when say salary is empty I would not like to display it
  
   Here is how the HTML would look for displaying rows 2 and 1
   ie  for row 2
  
   HTML
   HEAD
   TITLE YOUR SEARCH RESULTS /TITLE
  
  
   TABLE BGCOLOR=#191970 WIDTH=400 HEIGHT=20
   TR WIDTH=400 HEIGHT=6 BGCOLOR=#ff9900
   TD WIDTH=400 FONT FACE=arial SIZE=4
   COLOR=#191970CENTER ? ($row{POSITION_TITLE) ? /FONT/TD
   /TR
   TR HEIGHT=14
   TD FONT FACE=arial SIZE=4 COLOR=ff9900 ?
   ($row[POSITION_REFERENCE] ? /FONT /TD
   /TR
  
   TR HEIGHT=14
   TD FONT FACE=arial SIZE=4 COLOR=ff9900 ?
   ($row[POSITION_CONTACT] ? /FONT /TD
   /TR
  
   TR HEIGHT=14

[PHP] fsockopen and HTTP Authorization

2002-02-27 Thread Bas Jobsen

Hello,

I try to do a HTTP Authorization with a fsockopen, but it doesn't seem to 
work. Who can help?
$user and $passwd are set well, my code:
--
$auth=base64_encode($user.:.$passwd);
$header=GET /pa2/ HTTP/1.0\r\n\r\n;
$header.=Accept: text/html\r\n;
$header.=Authorization: Basic $auth\r\n\r\n;

$fp = fsockopen (localhost, 80, $errno, $errstr, 30);
if (!$fp) echo $errstr ($errno)br\n;
else
{
fputs ($fp,  $header);
while (!feof($fp)) echo fgets ($fp,128);
}
fclose ($fp);
--

Thanks,

Bas

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




Re: [PHP] CGI

2002-02-26 Thread Bas Jobsen

in index.php, you can do:
?
if (action==cgi) header(Location: cgi-bin/cgiscripts/.$scripts);
?

or 
?
if (action==cgi) echo `./cgi-bin/cgiscripts/${scripts} 21`;
?

Op dinsdag 26 februari 2002 15:30, schreef u:
 Hey

 I have some cgi files who are in the /usr/lib/xxx/cgi-bin/ directory
 How can i make them a part of my php meaning that in the current situation
 the url is something like this
 http://x.x.xxx/cgi-bin/cgiscripts/.cgi
 and i want it to be something like this
 http://../index.php?action=cgiscripts=xxx.cgi

 Maybe a stupid question but 


 Kind regards
 Sven
Op dinsdag 26 februari 2002 15:30, schreef Sven Jacobs:
 Hey

 I have some cgi files who are in the /usr/lib/xxx/cgi-bin/ directory
 How can i make them a part of my php meaning that in the current situation
 the url is something like this
 http://x.x.xxx/cgi-bin/cgiscripts/.cgi
 and i want it to be something like this
 http://../index.php?action=cgiscripts=xxx.cgi

 Maybe a stupid question but 


 Kind regards
 Sven

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




Re: [PHP] CGI

2002-02-26 Thread Bas Jobsen

Well, okay. It was an example.
Then do:
if (action==cgi  file_exists($script))  

Op dinsdag 26 februari 2002 16:00, schreef bvr:
 Please note that plain this:
 or
 ?
 if (action==cgi) echo `./cgi-bin/cgiscripts/${scripts} 21`;
 ?

 is not a good idea, because it allows a visitor to run arbitrary
 commands on your server.

 bvr.

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




Re: [PHP] INT function?

2002-02-20 Thread Bas Jobsen

$z = intval($x / $y);

Op donderdag 21 februari 2002 02:06, schreef James Taylor:
 Just curious what the function is to convert x into an integer if it's a
 float Say for example I have something like this


 $x = 7;
 $y = 3;

 $z = $x / $y;

 I want $z to equal 2.  In perl it would be

 $z = int($x / $y);

 I'm just not sure how to do this in PHP, as int apparently doesn't work
 (darn).  I'm using 4.06 by the way, so if there's some new function in 4.1
 that does this, I can't use it... so  4.1 functions please

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




[PHP] test for cookies, without reloading

2002-02-17 Thread Bas Jobsen

Hello,

Is there a way to test for cookies enabled/disabled, without reload the page 
and test for the preset cookie?

echo setcookies(test);
seems to be 1 always.

Tnx,

Bas

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




Re: [PHP] arrays with form data?

2002-02-13 Thread Bas Jobsen

?
List($text,$number)=explode(|,$FORM_ITEM);
?
form method=post action=? echo $php_self; ?
input type=radio name=FORM_ITEM value=TextHere|5
input type=radio name=FORM_ITEM value=OtherText|10
/form

Op woensdag 13 februari 2002 23:04, schreef Police Trainee:
 good evening gentlemen. I am attempting (with my oh so
 limited php writing abilities) to write a script that
 will take the second part of a form item's data and
 process it separately. To elaborate:
 form method=post action=$php_self
 input type=radio name=FORM_ITEM value=TextHere,5
 input type=radio name=FORM_ITEM value=OtherText,10
 /form

 When processing, I want the first part of the value
 (TextHere or OtherText) to be used for one thing and
 the second part (5 or 10) to be used to compute
 something else. How would I write a script to
 separate or pull only one of the parts of the value
 out?

 help greatly appreciated as i continue my learning
 process of php.

 -mark

 __
 Do You Yahoo!?
 Send FREE Valentine eCards with Yahoo! Greetings!
 http://greetings.yahoo.com

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




Re: [PHP] Help with query

2002-02-09 Thread Bas Jobsen

$number=mysql_num_rows(mysql_query(SELECT DISTINCT date FROM $table));
Op zaterdag 09 februari 2002 13:41, schreef Daniel Alsén:
 Hi,

 i can´t seem to get my head to wake up...

 How would i do to count how many different values that exists in a mysql
 field? Ie i have a date-field and need to know how many different dates
 that exists in the table.

 Regards
 # Daniel Alsén| www.mindbash.com #
 # [EMAIL PROTECTED]  | +46 704 86 14 92 #
 # ICQ: 63006462   | +46 8 694 82 22  #
 # PGP: http://www.mindbash.com/pgp/  #

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




Re: [PHP] Regex function needed

2002-02-07 Thread Bas Jobsen

Op donderdag 07 februari 2002 23:58, schreef Michael Kimsal:
 Looking for a regex (preg or ereg) to remove
 all 1, 2 and 3 character words.

?
$string=over deze regex loop ik nu al de hele dag en een uur te piekeren. 't 
wil niet! of wel! l'a.;
$string= .$string;
while (preg_match(/\W\w{1,3}\W/i,$string))
$string = preg_replace(/\W\w{1,3}\W/i,  , $string); 
$string=substr($string,1);
echo $string;
?

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




[PHP] add value to serialized array?

2002-02-05 Thread Bas Jobsen

Hi,

At start test.txt contains a serialized array with value one and two.
a:2:{i:0;s:3:one;i:1;s:3:two;}
after one run this is:
a:3:{i:0;s:3:one;i:1;s:3:two;i:2;s:4:tree;}

But the last row prints nothing. Why?

Tnx,

Bas 

?
$array=array();
$fp=fopen(test.txt,r);
flock($fp,1);
$array=unserialize(fread($fp,filesize(test.txt)));
flock($fp,3);
fclose($fp);

array_push($array,tree);

$fp=fopen(test.txt,w+);
flock($fp,2);
fwrite($fp,serialize($array));
flock($fp,3);
fclose($fp);

$fp=fopen(test.txt,r);
flock($fp,1);
$array=unserialize(fread($fp,filesize(test.txt)));
flock($fp,3);
fclose($fp);

echo $array[0].$array[1].$array[2];
?

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




Re: [PHP] add value to serialized array?

2002-02-05 Thread Bas Jobsen

Hello,

OKay, when i replace the last rows with:

$fp=fopen(test.txt,r);
flock($fp,1);
$array=array_merge($array,unserialize(fread($fp,filesize(test.txt;
flock($fp,3);
fclose($fp);

it works.

But now i want to place this in a class, and it goes wrong again.

Hope you can help, thanks,

Bas
 
--
?
class test
{

function test(){;}  

function read()
{
$array=array();
$fp=fopen(test.txt,r);
flock($fp,1);
$array=unserialize(fread($fp,filesize(test.txt)));
flock($fp,3);
fclose($fp);
return $array;
}

function save($array)
{
$fp=fopen(test.txt,w+);
flock($fp,2);
fwrite($fp,serialize($array));
flock($fp,3);
fclose($fp);
}

function push($array,$value)
{
array_push($array,$value);
$this-save($array);
}

}
$test= new test;

$array=$test-read();

echo $array[0].$array[1].$array[2];

$test-push($array,three);
//$test-save($array);

$array=$test-read();

echo $array[0].$array[1].$array[2];

?
--



Op dinsdag 05 februari 2002 12:24, schreef u:
 Hi,

 At start test.txt contains a serialized array with value one and two.
 a:2:{i:0;s:3:one;i:1;s:3:two;}
 after one run this is:
 a:3:{i:0;s:3:one;i:1;s:3:two;i:2;s:4:tree;}

 But the last row prints nothing. Why?

 Tnx,

 Bas

 ?
 $array=array();
 $fp=fopen(test.txt,r);
 flock($fp,1);
 $array=unserialize(fread($fp,filesize(test.txt)));
 flock($fp,3);
 fclose($fp);

 array_push($array,tree);

 $fp=fopen(test.txt,w+);
 flock($fp,2);
 fwrite($fp,serialize($array));
 flock($fp,3);
 fclose($fp);

 $fp=fopen(test.txt,r);
 flock($fp,1);
 $array=unserialize(fread($fp,filesize(test.txt)));
 flock($fp,3);
 fclose($fp);

 echo $array[0].$array[1].$array[2];
 ?

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




[PHP] variable function call (Re: [PHP] unset a function?)

2002-01-31 Thread Bas Jobsen

Hello,

 Thanks all. I will rename the second function.

Now if have:

if($wat==naam)$temp=make_naam($this);
else if($wat==anderenaam)$temp=make_anderenaam($this);
//etc..

But i would prefer something like
$temp=make_$wat($this);

How can i do this?

Tnx,

Bas

-- 
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] variable function call (Re: [PHP] unset a function?)

2002-01-31 Thread Bas Jobsen

Hello,

 $func = make_ . $wat;
 $temp = $$func($this);

I think one $.
$func = make_ . $wat;
$temp = $func($this);
will work

Bas


Op donderdag 31 januari 2002 12:17, schreef u:
 Hoi Bas,

 $func = make_ . $wat;

 $temp = $$func($this);

 bvr.

 On Thu, 31 Jan 2002 11:55:12 +0100, Bas Jobsen wrote:
 Hello,
 
  Thanks all. I will rename the second function.
 
 Now if have:
 
 if($wat==naam)$temp=make_naam($this);
 else if($wat==anderenaam)$temp=make_anderenaam($this);
 //etc..
 
 But i would prefer something like
 $temp=make_$wat($this);
 
 How can i do this?
 
 Tnx,
 
 Bas
 
 --
 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] COS function

2002-01-31 Thread Bas Jobsen

Cause there is no exact representation of PI, you get a floatingpoint 
representation of nearly zero.

Try:
echo intval(cos(0.5*pi()));
echo printf(%.1f,cos(0.5*pi()));

Op donderdag 31 januari 2002 13:39, schreef michael Rabbitte:
 I was wondering about the cos fuction in PHP when I try to get cos of 90
 degrees I'm not getting 0 but some weird no. (i.e 6.28...E-17) is there
 anything I can do to get zero as my answer. P.S. I have converted my
 degrees to radians!
 Mike.

-- 
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] unset a function?

2002-01-30 Thread Bas Jobsen

Hello,

I have this:
?
include(file1);
function_somename();
include(file2);
function_somename();
?

file1 and contain a function definition, but the function in both files had 
the same name. This will give Cannot redeclare . So can i unset the 
function before the second include?

Tnx,

Bas

-- 
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] unset a function?

2002-01-30 Thread Bas Jobsen

Hi,

?
function bas() {echo hello 1;}
bas();
unset(bas);
function bas() {echo hello 2;}
bas();
?

output:
parse error, expecting `T_VARIABLE' or `'$''




Op woensdag 30 januari 2002 21:51, schreef Rick Emery:
 what happened when you tried unset()?

 -Original Message-
 From: Bas Jobsen [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, January 30, 2002 2:52 PM
 To: PHP List
 Subject: [PHP] unset a function?


 Hello,

 I have this:
 ?
 include(file1);
 function_somename();
 include(file2);
 function_somename();
 ?

 file1 and contain a function definition, but the function in both files had
 the same name. This will give Cannot redeclare . So can i unset the
 function before the second include?

 Tnx,

 Bas

-- 
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] unset a function?

2002-01-30 Thread Bas Jobsen

Hi,

Thanks all. I will rename the second function.

Bas

-- 
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] strange problem

2002-01-18 Thread Bas Jobsen

 No idea, but a fella on this list told me [] had been deprecated in
 favour of {} Maybe that has something to do with it?

Maybe:

 $a[${'%coding'}] = 'red';

this works:

?
${'%coding'}='blue';
$a[${'%coding'}]='red';
echo $a[blue];//print red
?

-- 
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] find the fake users

2001-12-28 Thread Bas Jobsen

Hello,

On this list yesterday: As long as these tools are out
there, it should keep all of us on our toes, and programming with security
constantly on our minds.

Today i have tested,  Smart HitBot (http://www.hitbot.f2s.com/). Bad stuff 
for stats, toplist, searchengines etc.

Now i want filler out this requests. Do you have some ideas?

I will start with a simple script, say:
?php

include(counter.php);
if(!real_one()) $counter-=2;
$counter++;

$fp=fopen(counter.php,w+);
fwrite($fp, ?\n \$counter=$counter; \n?);
fclose($fp);

? 

Maybe i can do something with the interval between 2 requests, with real 
users this should be 'random', someting like:
?
function real_one()
{
include(real.php);

if ($interval==0)
{
   $interval=time()-$last;
   $last=time();
}
else if($interval==(time()-$last))
{
$interval=0;
$last=time();
}
else 
{
$interval=time()-$last;
$last=time();
}

$fp=fopen(real.php,w+);
fwrite($fp, ?\n \$interval=$interval;\n \$last=$last; \n?);
fclose($fp);
return $interval;
}

?


It's something, but not safe. one real user between two fake - count 2 
fakers.

If have also looked at $HTTP_USER_AGENT:
--
request1: 
Mozilla/4.0 (compatible; MSIE 5.01; Windows 98)
request2: 
Mozilla/4.0 (compatible; MSIE 5.0; Windows 98)
request3: 
Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)
etc.
--

So this will always start with Mozilla/4.0 (
This will be the same as the header from IE6.0 installed on the same machine. 
It will be different  from faker to faker(???) depending on the installed 
browser(s).

Thanks for your help.

Bas

-- 
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] phpmyadmin blob blues

2001-12-28 Thread Bas Jobsen

In config.inc.php:
--
// In browse mode...
$cfgShowBlob  = FALSE;  // display blob field contents
--
Maybe put it on TRUE?

Op vrijdag 28 december 2001 16:52, schreef Paul S.:
 I had been using blob for a lot of mysql text fields, even email
 address as well as other data. all of a sudden, it seems, instead of
 seeing and editting these blob values in phpmyadmin (i currently have
 2.2.2) tables all i see in the fields is [BLOB] and I am ubnable to
 edit the fields.

 Does anyone know what is going on?

-- 
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] Counting Views on records in DB!

2001-12-21 Thread Bas Jobsen

UPDATE $table views=views+1


Op vrijdag 21 december 2001 21:38, schreef Thomas Edison Jr.:
 Hi,
 I was just going through some Message Board system and
 noticed that there is a Views column which gives how
 many times the Message has been viewed.

 I created a similar message board, where Messages are
 stored in a MySQL DB Table. But i have no idea how to
 do this, that the number of times that Record is
 picked up is counted!! Can anyone guide me as to how
 this can be achieved?

 Thanks,
 T. Edison jr.


 __
 Do You Yahoo!?
 Send your FREE holiday greetings online!
 http://greetings.yahoo.com

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




[PHP] call php with javascript

2001-11-27 Thread Bas Jobsen

Hi,

i have test.php:
?
echo test;
?

to call this in the html, i use
SCRIPT LANGUAGE=Javascript SRC=test.php/script

this works fine for IE, but is there an alternative for Netscape to do this?

Tnx,

Bas

-- 
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] Safe mode and dir permissions

2001-11-16 Thread Bas Jobsen

Hello,

You can't change permissions in safe_mode.

and for every new people
 inserted the system creates a Directorie and will upload things

Maybe you give the new people something like a autonumbered userid. So you
can created the dirs
/userid0/, /userid1/ etc. already by hand.



- Original Message -
From: Rodrigo Peres [EMAIL PROTECTED]
To: PHP [EMAIL PROTECTED]
Sent: Friday, November 16, 2001 2:02 PM
Subject: [PHP] Safe mode and dir permissions


 Hi List,

 My ISP runs the PHP in Safe Mode, this is causing me a lot of trouble. In
 safe mode how can I change the permission of a dir to 0777?, my problem is
 that I've built a Content management system, and for every new people
 inserted the system creates a Directorie and will upload things
 automatically on it, but I couldn't create it with 0777 permission, so I
 can't upload nothing with PHP, and I don't have how change every single
 folder permissio by hand.

 Thank's

 --


 Rodrigo


 --
 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] PHP Redirect / header(location: )

2001-11-09 Thread Bas Jobsen

 Am I doing something wrong?  Thank you.
You may print nothing before the redirect header!
?
echo hello;
header(Location: go);
exit;
#wrong!
?

?
?
header(Location: go);
exit;
echo hello;
#oke, but hello isn't print
?
?
- Original Message - 
From: phantom [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, November 09, 2001 10:01 AM
Subject: [PHP] PHP Redirect / header(location: )


 I am trying to set up a redirect scirpt that in ASP was
 response.redirect(escape(newpage.asp)).
 
 I tried in PHP  header(location: newpage.php)
 
 but all i got was an error message saying that my header content had
 already been sent.  This PHP script was above the html script.
 
 Am I doing something wrong?  Thank you.
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]
 


-- 
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]