[PHP] Re: how to check for a static call from an object

2005-07-21 Thread Sebastian Mendel
Sebastian Mendel wrote:
 Hi,
 
 how can i check if a method is called statically when called from inside
 another object? (without debug_bactrace())
 
 
 class foo
 {
 function bar()
 {
 if ( isset( $this ) )
 {
 return 'not static';
 }
 return 'static';
 }
 
 function bar2() { foo::bar(); }
 }
 

sorry, my mistake

// returns 'static'
echo foo::bar();

// returns 'not static' but should be 'static'
$foo = new foo;
echo $foo-bar2();

 so, how can i prevent a method from called static or not called static?
 
 and btw. does anynone know why it is not good to let one function handle
 both mehtods of calling (static and not static) as in PHP 5 you will get
 notices if called wrong - but PHP doesnt support multiple
 function-definitions like:
 
 class foo
 {
 static function bar()
 {
 return ANY_DEFAULT_VALUE;
 }
 
 function bar()
 {
 return $this-value;
 }
 }
 
 or even
 
 
 class foo
 {
 static function bar( $param )
 {
 return $param;
 }
 
 function bar()
 {
 return $this-param;
 }
 }
 
 or is this at least an issue for the internals-list?
 


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



Re: [PHP] Re: Converting [and] to XML format- help/advise requested

2005-06-16 Thread Sebastian Mendel
Dotan Cohen wrote:
 On 6/15/05, Sebastian Mendel [EMAIL PROTECTED] wrote:
 Dotan Cohen wrote:

 Hi gurus. I'm having fun replacing the text within [ and ] to XML
 format on 4000+ files on a windows XP machine. I installed php (and an
 apache server) on the machine because it is the only language the I am
 remotely familiar with.

 I want and text that is with [ and ] to be enclosed with note and
 /note. Going through the archives I found this nice regex (I changed
 it a bit- I hope that I didn't break anything important) that fits
 into str_replace:

 str_replace(/[([a-zA-Z]+?)]/, note.$what
 was_inside_the_parethesis./note, $string);
 str_replace doesnt support regular expressions

 http://www.php.net/str_replace

 what you need is preg_replace()

 http://www.php.net/preg_replace


 But how on sweet mother Earth do I get the $what
 was_inside_the_parethesis variable to stick into the note tags? I
 tried functions that would remove the [ and ], then do
 $new_str=note.$what was_inside_the_parethesis./note;
 and then replace the whole [$what was_inside_the_parethesis] with
 $new_str. I did get that far.
 preg_replace( '/\[([^\]]+)\]/', 'note\1/note', $string);


 Now the catch! If $what_was_inside_the_parethesis contains the word
 'algebra' then I want nothing returned- in other words [$what
 was_inside_the_parethesis] should be cut out and nothing put in it's
 place. I added an if function in there that checked the presence of
 the word algebra, but it ALWAYS returned blank.
 preg_replace( '/\[(algebra|([^\]]+))\]/', 'note\2/note', $string);


 just to mention, you need only the second example, the first ist just to
 explain the step toward the final ocde.
 The code works great for [] tags that do not contain the word algebra.
 If the word algebra is alone between the tags then it returns
 note/note, which I can easily remove with one more line of code.
 But if the word algebra appears with another word, then it is
 converted to a note just as if it did not contain the word.

 $search = array(
 '/\[[^\]*algebra[^\]*\]/',
 '/\[([^\]]+)\]/',
 );

 $replace = array(
 '',
 'note\1/note',
 );

 preg_replace( $search, $replace, $string);
 
 Thank you Sebastian. Know that I not only appreciate your assistance,
 but that I also make a genuine effort to learn from your example. I
 think that it's about time that I learned to brew regexes. On my to
 google now...

there are just two things you need to learn regular expressions:

the PHP-manual:

http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
http://www.php.net/manual/en/reference.pcre.pattern.syntax.php

http://www.php.net/manual/en/ref.pcre.php
http://www.php.net/manual/en/ref.regex.php

and the regex coach:

http://www.weitz.de/regex-coach/


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: incrementing a register global

2005-06-16 Thread Sebastian Mendel
Aaron Todd wrote:

 I am posting data to a php script.  I have several variables that are the 
 same except the number at the end is different.  So the url of the called 
 script will be something like:
 
 http://www.something.com/test.php?name1=Samname2=Billname3=Joe
 
 On my script I am using substr() and strrchr() to get the number of last 
 variable:
 
 $names = substr(strrchr($_SERVER['QUERY_STRING'],),7,1);
 
 I am then trying to run a loop to call each variable and just print it on 
 the screen:
 
 for($i=1;$i=$boxes;$i++){
   echo $_GET['name'].$i;
 }

did you tried foreach() with $_GET ( or $_REQUEST ) ?


foreach ( $_GET as $key = $var )
{
echo $key . ' = ' . $var;
}


but this is not incrementing a register global but 'accessing a
superglobale array'


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: Freing memory resources?

2005-06-16 Thread Sebastian Mendel
Gustav Wiberg wrote:
 Hi there!
 
 I have a script that runs about 10 minutes... Localy on my computer
 (Windows XP 2.6Ghz, Apache) the computer hangs a little now and then
 when the script is running. Is there any good way of releasing more
 memory while the script is running? The script could take 20 minutes,
 it's not a big matter how long the script takes. (As long as the server
 can do other things at the same time)

why do you expect this comes from memory-consumption?

did you check your Querys? try 'EXPLAIN SELECT ...' and check your indices

how large are your tables?


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: Freing memory resources?

2005-06-16 Thread Sebastian Mendel
Sebastian Mendel wrote:
 Gustav Wiberg wrote:
 Hi there!

 I have a script that runs about 10 minutes... Localy on my computer
 (Windows XP 2.6Ghz, Apache) the computer hangs a little now and then
 when the script is running. Is there any good way of releasing more
 memory while the script is running? The script could take 20 minutes,
 it's not a big matter how long the script takes. (As long as the server
 can do other things at the same time)
 
 why do you expect this comes from memory-consumption?
 
 did you check your Querys? try 'EXPLAIN SELECT ...' and check your indices
 
 how large are your tables?
 
 Hi Sebastian!
 
 The table are about 600-700 rows, but i only select 25 rows at a time, so I 
 guess that isn't the issue.
 For each row, a comparison is done with a textfile that has almost 30.000 
 rows. I guess this is the problem is... It takes time to load same textfile 
 for each row, but an array for 30.000 rows should not be done either or 
 should it? Is there a better way of solving this?
 
 The script loads after 25 rows, because of I don't want to get any timeout... 
 We don't have any own webserver, so we have to rely on our Webhotel-supplier. 
 And our webhotel doesn't wan't to change certain thing for security reasons. 

why not move the text-file into the DB? of course not as a whole.

or why not elsewise take 25 lines from the textfile against the 700 rows
in the DB?

or not load the whole file in the array, check line by line -
http://www.php.net/fgets


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: unable to load php_gd2.dll

2005-06-15 Thread Sebastian Mendel
ddiffa wrote:
 Okay I at loss.  I have tried but i can seem to get the
 php_gd2.dll to work properly.  Any help this is what i have
 done so far.   
 
 I have in my php.ini file, 

check phpinfo() that you are using the right php.ini


 ; Directory in which the loadable extensions (modules)
 reside.
 extension_dir = C:\PHP\extensions
 
 I have also uncommented the 
 
 extension = php_gd2.dll
 
 I have in the c:\php\extension folder the php_gd2.dll 
 
 I have restarted IIS but still nothing
 
 I am using Window XP $ 2000 with IIS 5.0 but still nothing

what means 'nothing'? does it start? or does it report any errors?

what says phpinfo() about gd?


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



Re: [PHP] Re: Converting [and] to XML format- help/advise requested

2005-06-15 Thread Sebastian Mendel
Dotan Cohen wrote:

 Hi gurus. I'm having fun replacing the text within [ and ] to XML
 format on 4000+ files on a windows XP machine. I installed php (and an
 apache server) on the machine because it is the only language the I am
 remotely familiar with.

 I want and text that is with [ and ] to be enclosed with note and
 /note. Going through the archives I found this nice regex (I changed
 it a bit- I hope that I didn't break anything important) that fits
 into str_replace:

 str_replace(/[([a-zA-Z]+?)]/, note.$what
 was_inside_the_parethesis./note, $string);
 str_replace doesnt support regular expressions

 http://www.php.net/str_replace

 what you need is preg_replace()

 http://www.php.net/preg_replace


 But how on sweet mother Earth do I get the $what
 was_inside_the_parethesis variable to stick into the note tags? I
 tried functions that would remove the [ and ], then do
 $new_str=note.$what was_inside_the_parethesis./note;
 and then replace the whole [$what was_inside_the_parethesis] with
 $new_str. I did get that far.
 preg_replace( '/\[([^\]]+)\]/', 'note\1/note', $string);


 Now the catch! If $what_was_inside_the_parethesis contains the word
 'algebra' then I want nothing returned- in other words [$what
 was_inside_the_parethesis] should be cut out and nothing put in it's
 place. I added an if function in there that checked the presence of
 the word algebra, but it ALWAYS returned blank.

 preg_replace( '/\[(algebra|([^\]]+))\]/', 'note\2/note', $string);


 just to mention, you need only the second example, the first ist just to
 explain the step toward the final ocde.
 
 The code works great for [] tags that do not contain the word algebra.
 If the word algebra is alone between the tags then it returns
 note/note, which I can easily remove with one more line of code.
 But if the word algebra appears with another word, then it is
 converted to a note just as if it did not contain the word.


$search = array(
'/\[[^\]*algebra[^\]*\]/',
'/\[([^\]]+)\]/',
);

$replace = array(
'',
'note\1/note',
);

preg_replace( $search, $replace, $string);


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: unable to load php_gd2.dll

2005-06-15 Thread Sebastian Mendel
Sebastian Mendel wrote:

 ; Directory in which the loadable extensions (modules)
 reside.
 extension_dir = C:\PHP\extensions

 I have also uncommented the 

 extension = php_gd2.dll

 I have in the c:\php\extension folder the php_gd2.dll 

 I have restarted IIS but still nothing

 I am using Window XP $ 2000 with IIS 5.0 but still nothing
 
 what means 'nothing'? does it start? or does it report any errors?
 
 what says phpinfo() about gd? 
 
 Well, this is the error i get
 
 PHP Warning: PHP Startup: Unable to load dynamic library
 'c:/windows/system32\php_gd2.dll' - The specified module
 could not be found. in Unknown on line 0 
 I have also tried pointing the extension_dir to the
 c:/php/extension, but it still give the same error

did you check your Windows System Eventviewer?

this error doesnt mean that 'php_gd2.dll' can not found, but that
another dll, required by php_gd2.dll can not be found.


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: unable to load php_gd2.dll

2005-06-15 Thread Sebastian Mendel
 ; Directory in which the loadable extensions (modules)
 reside.
 extension_dir = C:\PHP\extensions

 I have also uncommented the 

 extension = php_gd2.dll

 I have in the c:\php\extension folder the php_gd2.dll 

 I have restarted IIS but still nothing

 I am using Window XP $ 2000 with IIS 5.0 but still nothing
 what means 'nothing'? does it start? or does it report any errors?

 what says phpinfo() about gd? 
 Well, this is the error i get

 PHP Warning: PHP Startup: Unable to load dynamic library
 'c:/windows/system32\php_gd2.dll' - The specified module
 could not be found. in Unknown on line 0 
 I have also tried pointing the extension_dir to the
 c:/php/extension, but it still give the same error
 
 did you check your Windows System Eventviewer?
 
 this error doesnt mean that 'php_gd2.dll' can not found, but that
 another dll, required by php_gd2.dll can not be found.
 
 I checked the even view but no help there. What dll do you
 think i would need?  Please I appreciate your help.


extension_dir = c:\php\extensions\

http://www.php.net/manual/en/install.windows.extensions.php

Please do not forget the last backslash


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: formatting paragraphs in to strings

2005-06-14 Thread Sebastian Mendel
Paul Nowosielski wrote:

  I'm having a perplexing problem. I'm gather data through a textarea
 html from field and dumping it to MySQL.
 
  I want to display the data as a long string with no carriage returns or
 line breaks in a dhtml div window.
 
 The problem I'm have is that the form data is remembering the carriage
 returns. I tried using trim() and rtrim() with no luck. The data is
 still formatted exactly like it was inputed.

this happens only if the text is dsiplayed as pre-formated, like inside
pre/pre-tags, but this can also be done by CSS


 Any ideas why this is happening and how I can format the text properly??

not, with any look at your code or results


try

preg_replace( '|\s*|', ' ', $string );


it will replaces any occurence of one or more white-space-characters
with one single space


http://www.php.net/manual/en/reference.pcre.pattern.syntax.php

-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: DB relationship chart generator?

2005-06-14 Thread Sebastian Mendel
Thomas wrote:

 Is there an app out there that can easily create a relationship (flow)
 diagram of a given database?


DBDesigner at

http://www.fabforce.net/dbdesigner4/


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: Right syntax for max value??

2005-06-14 Thread Sebastian Mendel
twistednetadmin wrote:
 I am making a table at my homepage that automatically collects the
 latest news from mysql db.
  I have got it to work at my own server at home, but not at
 www.torewestre.com (my remote site)
 
 Local settings:(WinXP Pro) Apache 2.0.54, PHP 5.0.4 and MySQL 4.1.11
 
 Remote settings:(Unix) Apache 1.3.27, PHP 4.3.4 and MySQL 3.23.54
 
 This is the query that works on localhost:
 
 
 $getnewstitle = SELECT newstitle FROM `news` WHERE news_id = ( SELECT
 max( news_id ) FROM news ) ;

MySQL 3.x doesnt support sub-querys


 What it does:
 
 collects the newstitle from the field where PRIMARY key(news_id) is
 the highest auto_increment number.
 
 This works just as excpected on localhost but not on remote.
 
 Does anybody know the right syntax?

   SELECT `newstitle`
 FROM `news`
 ORDER BY `news_id` DESC
LIMIT 1


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: Converting [and] to XML format- help/advise requested

2005-06-14 Thread Sebastian Mendel
Dotan Cohen wrote:
 Hi gurus. I'm having fun replacing the text within [ and ] to XML
 format on 4000+ files on a windows XP machine. I installed php (and an
 apache server) on the machine because it is the only language the I am
 remotely familiar with.
 
 I want and text that is with [ and ] to be enclosed with note and
 /note. Going through the archives I found this nice regex (I changed
 it a bit- I hope that I didn't break anything important) that fits
 into str_replace:
 
 str_replace(/[([a-zA-Z]+?)]/, note.$what
 was_inside_the_parethesis./note, $string);

str_replace doesnt support regular expressions

http://www.php.net/str_replace

what you need is preg_replace()

http://www.php.net/preg_replace


 But how on sweet mother Earth do I get the $what
 was_inside_the_parethesis variable to stick into the note tags? I
 tried functions that would remove the [ and ], then do
 $new_str=note.$what was_inside_the_parethesis./note;
 and then replace the whole [$what was_inside_the_parethesis] with
 $new_str. I did get that far.

preg_replace( '/\[([^\]]+)\]/', 'note\1/note', $string);


 Now the catch! If $what_was_inside_the_parethesis contains the word
 'algebra' then I want nothing returned- in other words [$what
 was_inside_the_parethesis] should be cut out and nothing put in it's
 place. I added an if function in there that checked the presence of
 the word algebra, but it ALWAYS returned blank.

preg_replace( '/\[(algebra|([^\]]+))\]/', 'note\2/note', $string);


just to mention, you need only the second example, the first ist just to
explain the step toward the final ocde.


-- 
Sebastian Mendel

www.sebastianmendel.de
www.sf.net/projects/phpdatetime | www.sf.net/projects/phptimesheet

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



[PHP] Re: Holding an array in a session

2004-11-19 Thread Sebastian Mendel
Shaun wrote:
Hi,
I have created an array of tables in my database and put it into a session 
using the following code:

  $_SESSION['ses_csv_files'][] = array();
$_SESSION['ses_csv_files'] = array(); // without []
  $qid = mysql_query(SHOW TABLES);
  $num = mysql_num_rows($qid);
  for ($i = 0; $i  $num; $i++) {
   $r = mysql_fetch_array($qid);
   $_SESSION['ses_csv_files'][$i] = $r[0];
  }
$qid = mysql_query(SHOW TABLES);
while ( $r = mysql_fetch_assoc( $qid ) )
{
$_SESSION['ses_csv_files'][] = $r[0];
}

I would like to be able to print the current value of the session on various 
pages in my application, however I can only find reference to looping 
through an array in one go. I know I can use next() to increment the pointer 
in the array, is it possible for the session to hold the current pointer in 
the array, if so how can I display its value?#
$_SESSION['key'] = $current_array_key; // f.e. 0 on the first page
echo $_SESSION['ses_csv_files'][$_SESSION['key']];

--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Confused with constructors

2004-11-19 Thread Sebastian Mendel
Gerald Wharney wrote:
I'm trying the example at:
http://www.php.net/manual/en/language.oop.constructor.php
?php
class A
{
   function A()
   {
   echo I am the constructor of A.br /\n;
   }
   function B()
   {
   echo I am a regular function named B in class
A.br /\n;
   echo I am not a constructor in A.br /\n;
   }
}
class B extends A
{
   function C()
   {
   echo I am a regular function.br /\n;
   }
}
// This will call B() as a constructor.
$b = new B;
?
Running this on 4.3.9 both as an apache module and
from CLI I get:
I am a regular function named B in class A.
I am not a constructor in A.
This is contrary to what the manual says:
This is fixed in PHP 4 by modifying the rule to: 'A
constructor is a function of the same name as the
class it is being defined in.'. Thus in PHP 4, the
class B would have no constructor function of its own
and the constructor of the base class would have been
called, printing 'I am the constructor of A.br /'.
Is this an error in the manual?
Or a bug in php 4.3.9?
Or just me being stupid?
as i understand it exactly as you, it must be a bug/error
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Understanding Static Methods

2004-11-19 Thread Sebastian Mendel
Jordi Canals wrote:
I'm trying to understand static methods in a test class. Reading the
manual, it says: A member or method declared with static can not be
accessed with a variable that is an instance of the object and cannot
be re-defined in an extending class.
Test code:

?php
class B
{
private $str;

public final function __construct()
{
$this-str = 'Hello world';
}

public function showB()
{
echo $this-str, 'br';
echo 'Showing Bbr';
$this-TestStatic();
}

public static function TestStatic()
{
echo 'brInside Staticbr';
}
}
echo error_reporting() . 'br';
$test = new B;
$test-TestStatic();
$test-showB();
echo -- END --;
?
Output:
=
4095
Inside Static-- Called by $test-TestStatic()
Hello world
Showing B
Inside Static-- Called from $test-showB with $this-TestStatic()
-- END --
Comments:

I'm running PHP 5.0.2 and error_reporting = E_ALL | E_STRICT. As
reported in the output, the values for error_reporting are well set
(4095 == E_ALL | E_STRICT)
with zend engine 1.3 compatiblity on ?
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Sorting multidim array and keeping associations

2004-11-18 Thread Sebastian Mendel
Peter Lauri wrote:
I have an multidim array that looks something like this:
[40] = [1]=32, [2]=55, [total]=87
[22] = [8]=2, [7]=105, [total]=107
[142] = [2]=3, [7]=8, [total]=11
I want to sort this array according to the total and still keep the
acc. with the basekey. I know I can easily do this by writing an function 
myself.
But are there any built in functions for this? I have looked at usort,
uksort and more, but they do not seem to solve my problem.
uksort() or array_multisort() should do fine
I have tried to figure it out how to use it with those, but I can not find a
solution.
and whats the problem? did you tried uksort() ?
what did you tried? post the code, and someone will take a look and give 
a hint!

sorry, but if you want a complete solution, go hire a php-programmer!
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Sequrity without HTTPS?

2004-11-18 Thread Sebastian Mendel
Peter Lauri wrote:
Best groupmember,
I am about to develop an simple admintool for a webpage. My webhost (crappy
but nonexpensive) does not support HTTPS and I still want to be able to
create some sort of secure login.
For the moment I am just using a form that sends the username and passwd
with POST method that verifies the username and passwd in a script. When
this is set I put a $_SESSION['usertype']=admin and when a adminpage is
beeing requested I check so that this sessionvariable is admin, othervise
I redirect to the loginpage and unset all session variables.
Can someone from outside set a $_SESSION variable with some hacker
techniqe?
I assume it is easy to listen to the USERNAME and PASSWORD in the POST-form.
Someone with some tips and tricks to get a secure system without using
HTTPS?
if you have no https you can try a javascript-solution
encode with a encode-key with javascript before sending and decode with 
a decode-key when recieving!

just what you need is key who can encode but not decode! und the 
appropriate decode key on the server, to decode it.

just try to look for some javascript in the web!
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] How to assure that php.ini is being obeyed?

2004-11-18 Thread Sebastian Mendel
Llc Mailit wrote:
My problem: To upload large files.
Although /etc/php.ini on my Linux server specifies
upload_max_filesize = 8M
post_max_size = 8M
only files smaller than 512 kB are uploaded, while larger files fail 
with message
This document contains no data
quota?
free space?
try setting display_errors and startup_errors on
try track_errors with on
also, when using apache 1.3.2 or later, see the LimitRequestBody 
directive.
I set display_errors, startup_errors, track_errors On in php.ini, restarted 
Apache and reran an upload session.
The only error message displayed upon attempt to upload a large file is This 
document contains no data
The specified log file is empty.
did you check $php_errormsg ?
track_errors  boolean
If enabled, the last error message will always be present in the 
variable $php_errormsg.

--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: require() in other directories?

2004-11-18 Thread Sebastian Mendel
Peter Lauri wrote:
Best groupmember,
I have an webapplication that uses different languages and therefor I have
set up different directorys for each language. All languages use the same
classes.
The problem I have is when I want to require() the classfile I can not
require a file that is not in the same directory as my .php file. I have
tried the following:
require(../classes.php);
require(http://www.mydomain.com/classes.php;);
totally wrong!!!
and more.
All gives me error messages, why?
the relative path in require must be reltaive to the _executing_ script 
NOT to the _included_ script!

f.e. with classes.php in /webroot/
/webroot/index.php:
require 'lang/en.php';
/webroot/lang/en.php:
//WRONG:
require '../classes.php';
//RIGHT:
require 'classes.php';
// or
require '/webroot/classes.php';

--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Sequrity without HTTPS?

2004-11-18 Thread Sebastian Mendel
Peter Lauri wrote:
If you use the Autority HTTP that pops up a login window by default, is that
safe against listeners?
IMHO, the login-data is sent as plain text also, and this with every 
subsequent request! and not only with the first!

--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: PHP-editor connected to FTP?

2004-11-18 Thread Sebastian Mendel
Peter Lauri wrote:
Best groupmember,
What editor do you use when working with websites (php) connected directly
to the FTP?
I like Eclipse 3.0 with the PHP plugin, but it do not have the future to
connect to the FTP.
did you tried the FTP-WebDAV plugin?
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Sorting multidim array and keeping associations

2004-11-18 Thread Sebastian Mendel
Peter Lauri wrote:
The problem was more complex than I described, I instead wrote a sorting
algorithm for this specific purpose.
The array multi-dim array looks like this (short version). The total element
is just the sum of the other. This is a point system for golftournaments. I
wanted to sort them first on total and if the total was the same I wanted
to sort them with the highest point in a specific tournament, and so on. I
have not found an simple solution to this using any built in functions. So I
thought is was the best to sort it manually. My algorithm is problably not
efficient, but it works just fine for this solution. You can find the
algorithm in the end of this message.
Array
(
[40] = Array
(
[1] = 16
[2] = 20
[3] = 20
[4] = 10
[total] = 66
)
[49] = Array
(
[2] = 14
[total] = 14
)
)
// without totals
$score_board = uksort( $score_board, 'sortScoreBoard' );
function sortScoreBoard( $element_1, $element_2 )
{
   if ( array_sum( $element_1 )  array_sum( $element_2 ) ) {
   return -1;
   }
   elseif ( array_sum( $element_1 )  array_sum( $element_2 ) ) {
   return 1;
   }
   elseif ( max( $element_1 )  max( $element_2 ) ) {
   return -1;
   }
   elseif ( max( $element_1 )  max( $element_2 ) ) {
   return 1;
   }
   return 0;
}
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Sorting multidim array and keeping associations

2004-11-17 Thread Sebastian Mendel
Peter Lauri wrote:
Best groupmember,
I have an multidim array that looks something like this:
[40] = [1]=32, [2]=55, [total]=87
[22] = [8]=2, [7]=105, [total]=107
[142] = [2]=3, [7]=8, [total]=11
I want to sort this array according to the total and still keep the acc.
with the basekey. I know I can easily do this by writing an function myself.
But are there any built in functions for this? I have looked at usort,
uksort and more, but they do not seem to solve my problem.
uksort() or array_multisort() should do fine
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: File Handing Windows / Linux

2004-11-17 Thread Sebastian Mendel
Steve Vernon wrote:
Hiya!
I am trying to make some code which gets a handle to a directory, but has
different code for my localhost (Windows) and for online (Linux server). 

Basically, I want either of the below lines. Say if the first fails, it must
be on Linux and then it uses the line below. 

The two example lines are:
  @ $handle =
opendir(c:/websites/mywebsite/extra/photos/.$_GET['page']./);
  @ $handle =
opendir(/home/mywebsite/public_html/extra/photos/.$_GET['page']./);
Had a search on google, but not really sure what to look for!
why not ry relative path?
$handle = opendir(./extra/photos/.$_GET['page']./);
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Array unset

2004-11-17 Thread Sebastian Mendel
Bruno b b magalhães wrote:
The problem is that when I delete an specific array, it outputs  
something like this:

(
[0] = Array
(
[moduleId] = 4
[moduleName] = Contents
[modulePath] = contents
[moduleAliasPath] =
[moduleController] = administration
[moduleLevel] = 5
[moduleOrder] = 0
[moduleVisibility] = 1
[moduleType] = none
[moduleStatus] = 1
)
[2] = Array
(
[moduleId] = 1
[moduleName] = System
[modulePath] = system
[moduleAliasPath] =
[moduleController] = administration
[moduleLevel] = 5
[moduleOrder] = 2
[moduleVisibility] = 1
[moduleType] = default
[moduleStatus] = 1
)
[3] = Array
(
[moduleId] = 2
[moduleName] = Logout
[modulePath] = logout
[moduleAliasPath] =
[moduleController] = administration
[moduleLevel] = 5
[moduleOrder] = 3
[moduleVisibility] = 1
[moduleType] = alias
[moduleStatus] = 1
)
)
So, the question, how resort the numeric values to 1,2,3,4?
which numeric values ?
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: How to assure that php.ini is being obeyed?

2004-11-17 Thread Sebastian Mendel
Llc Mailit wrote:
My problem: To upload large files.
Although /etc/php.ini on my Linux server specifies
upload_max_filesize = 8M
post_max_size = 8M
only files smaller than 512 kB are uploaded, while larger files fail 
with message
File contains no data
Everything happens as if php.ini were being ignored, although the 
parameters in question appear
with correct values on the table generated by phpinfo()
It is failing on my server, but on another server upload works as 
defined by /etc/php.ini
It must be something in the initialization of the server, or apache, but 
I don't know where to look.
Did anybody have this experience before?
quota?
free space?
try setting display_errors and startup_errors on
try track_errors with on
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Dynamic Combo Box

2004-11-15 Thread Sebastian Mendel
Ankur Os wrote:
I want to create 3 dynamic combo box.
When i select the first combo(select) box then automatically the related details
[from database] will come in the second select box.and simultenously for second
to third.
Please help me.(give me some help through code)
I have to complete the project at last by today...
This is a javascript related problem!
Why not just take a look add any driver-section of a web-page from a 
hardware-manufacturer?

--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] calling function from function?

2004-11-12 Thread Sebastian Mendel
Jason wrote:
Rick Fletcher wrote:
function db( $host, $user, $pass, $dbnam ) {
 $db = @mysql_pconnect( $host, $user, $pass )or die( mysql_error( $db 
));
   @mysql_select_db( $dbnam )or die( mysql_error( $db ) );
 return $db;
}

function logs() {
 global $defined;
 db( $defined[9], $defined[1], $defined[2], $defined[3] );
 ... do some processing ...
}
what am i missing here? i get errors if i try to pass $db to logs. 
i.e. logs( $db );

What's missing?  The error message.  Include it, and the offending 
line(s) of code, and ask again.

--Rick
There isnt an error at all.  According to the die() functions at the end 
of the mysql() functions it should give it there, instead I get blank as 
if the function has not successfully completed.  The reason I say this 
is if you try to access the mysql resource pointer ( $db, in this case ) 
I get nothing, a return code of 0.  Example in point...

function db( $host, $user, $pass, $dbnam ) {
 $db = @mysql_pconnect( $host, $user, $pass )or die( font 
face=\arial\bphpDHCPAdmin currently not active, is under repair or 
is not configured correctly./bbrbrError Number:  .  mysql_errno( 
$db ) . brError Message:  . mysql_error( $db ) . brEmail 
Administrator: a href=\mailto:$defined[5]\;$defined[5]/a/font );
   @mysql_select_db( $dbnam )or die( font face=\arial\bCould 
not connect to database: $defined[3]/bbrError Message:  . 
@mysql_error( $db ) . br . Error Number:  . @mysql_errno( $db ) . 
brEmail Administrator: a 
href=\mailto:$defined[5]\;$defined[5]/a/font );
 return $db;
}

function logs() {
 global $defined;
 db( $defined[9], $defined[1], $defined[2], $defined[3] );
 $pagecount = 1;
 $tble = logs;
 $sql = @mysql_query( SELECT * FROM $tble WHERE session = 
\$_SESSION[hash]\, $db )
$db is not defined,
$db is not required,
at least if you want to use $db you have to ctach the return from db() 
in $db:

$db = db( $defined[9], $defined[1], $defined[2], $defined[3] );
as i assume, logs() does nothing more than update one row with session 
data in the DB?

if you have a primary key on `session` you can just user REPLACE instead of
if SELECT INSERT ELSE UPDATE
logs()
{
db( $defined[9], $defined[1], $defined[2], $defined[3] );
$sql = 'REPLACE INTO logs VALUES ( ... )';
mysql_query( $sql ) or die( '...' );
}
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Which PHP for MySQL 4.1

2004-11-12 Thread Sebastian Mendel
C.F. Scheidecker Antunes wrote:
Hello,
I would like to migrate my MySQL servers from 4.0 to 4.1.
As I use PHP as well as Java with these servers I wonder what PHP 4 
version would be compatible with MySQL 4.1.

Has anyone used MySQL 4.1 with PHP yet?
I appreciate your thoughts.
Thanks.
i run 4.1.x for a while, without problems,
after upgrading you have to rebuild you php to use the new mysql_librarys
and you have to run mysql_fix_privilege_tables on the linux/unix shell
4.1. uses a new display-format for timestamps!
4.1. uses a new encryption method for password(), with this function are 
all mysql_passwords stored in the db, thats why you have to run 
mysql_fix_privilege_tables

read carefully through all 4.1. changelogs!
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: parsing /'s in urls

2004-11-12 Thread Sebastian Mendel
[EMAIL PROTECTED] wrote:
My host recently upgraded PHP.  I had a script, download.php, that would
work like this
http://www.myhost.com/download.php/30/file.torrent
the download.php script would take the 30, look up the real filename in the
database, and readfile() it back.  this was a great setup because the
browser just thought it was accessing a direct link to a file.
But now download.php/30/file.torrent results in a 404.
Is this something I can change back?
this is an apache related thing
http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Which PHP for MySQL 4.1

2004-11-12 Thread Sebastian Mendel
Mario Bittencourt wrote:
I could not compile php 5.0.2 with the latest mysql 4.1.7.
I've installed the rpms (server,max,client,devel,shared) from mysql.com.
./configure --with-mnogosearch --with-xml  --with-mysql=/usr
--with-mysqli=/usr/bin/mysql_config --with-apxs2 --enable-soap
When I compile I get tons of messages like this
/usr/lib/mysql/libmysqlclient.a(net.o)(.text+0x250): first defined here
/usr/lib/mysql/libmysqlclient.a(net.o)(.text+0x330): In function
`net_write_command':
I have even tried only with mysqli or mysql and got the same result.
Any ideias ?
try one mysql-extension as shared:
--with-mysql=/usr,shared --with-mysqli=/usr/bin/mysql_config
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Question on functions

2004-11-11 Thread Sebastian Mendel
Jason wrote:
Looks like you understand already.  Did you have some broken code you
wanted help with?
yeah.. I should have posted it first.  Here it is:
/* User Defined Variables */
$defined = array( 0 = localhost,
1 = user,
2 = password );
/* Database connection */
function db() {
 global $defined;
 if( connection_status() != 0 ) {
  $db = @mysql_pconnect( $defined[9], $defined[1], $defined[2] ) or die();
is this a typo???
@mysql_pconnect( $defined[9]
shouldnt it be
@mysql_pconnect( $defined[0]
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] should basic data validation go outside a function or inside?

2004-11-11 Thread Sebastian Mendel
Brad Pauly wrote:
should basic data validation come before a function call or be performed
within the function?
I would do the validation inside the function. This avoids repeating
the validation everywhere the function is called. It also makes the
function more self-contained. It expects a certain input and
complains, or returns false, if it doesn't get it.
yes, and of course shouldnt every function check it parametres before 
proceeding?

--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: LINUX: Problem with php installation

2004-11-11 Thread Sebastian Mendel
Abhilash Kumar wrote:
I installed latest version of PHP from the source on a
AMD ATHELON64 system with REDHAT 9.0 installed with
apache server 2. There were no error upon running
configure or make or make install I have checked
the instalation procedures many times now but I get a
blank screen on the mozilla browser.
Upon viewing the source it shows the source of a blank
html page. The server works well with html pages. Only
the problem is with any php page. I have made the
mentioned additions to be done in the httpd.conf file
namely LoadModule and AddType.
The error log file is showing Segmentation fault.
try without modules
if it works try one module check again and so on...
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: header variable ?

2004-11-11 Thread Sebastian Mendel
Jerry Swanson wrote:
What variable header use? If I send something in header, what GLOBAL
variable header use?
do you mean $_SERVER ?
$_SERVER holds some header-information sent by the client to the webserver
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Question on functions

2004-11-11 Thread Sebastian Mendel
Jason wrote:
Looks like you understand already.  Did you have some broken code you
wanted help with?
yeah.. I should have posted it first.  Here it is:
/* User Defined Variables */
$defined = array( 0 = localhost,
1 = user,
2 = password );
/* Database connection */
function db() {
 global $defined;
 if( connection_status() != 0 ) {
  $db = @mysql_pconnect( $defined[9], $defined[1], $defined[2] ) or 
die();
is this a typo???
@mysql_pconnect( $defined[9]
shouldnt it be
@mysql_pconnect( $defined[0]
Sorry, yeah it is a typo
and? is it a typo in the message or in your source and solves this typo 
your problem?

--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: find duplicated values in array and count them

2004-11-11 Thread Sebastian Mendel
Patrick Fehr wrote:
Hi all
I need to compare values of multiple arrays, the tricky thing: I can't just
use array_diff, because I also need to count all the occurences and give
them back. The more tricky thing: It's a foreach loop through $arr[x
['comparable value'] while x is 1,4,3,6... so it's not that easy to compare
one item in the array under index 4 with the next one(which is in 3)
because foreach just loops.
The idea is: If two keys of different arrays hold the same value, I want to
just show one entry and tell the same time, how often it occurs(in other
arrays), so I don't show all the entries(as I would, if they weren't the
same.
But it is still a bit more complicated, because: only if the date_s value
lies 7 days from each other, I want to concatenate them to one entry +
show the number of occurences.
In the example below, the lessons 18 and 15 fit that need.
so I want them to be shown as:
  [room] : Raum1
  [teacher] : Marianne
  [class] : SundayClass
  starttime : 1099404000 (which is Array[19][date_s])
  endtime : 099418400 + 7*24*60*60 (which is Array[15][date_e])
  occurences : 2
   
eg --
print_r($my_big_array) shows:

Array
(
[7] = Array
(
[name] = course1
[comment] = my bad comment
[lessons] = Array
(
[14] = Array
(
[room] = Raum2
[teacher] = Andrew
[class] = Team2
[date_s] = 1100796900
[date_e] = 1100805000
)
)
)
[3] = Array
(
[name] = test
[comment] = testing
[lessons] = Array
(
[19] = Array
(
[room] = Raum1
[teacher] = Marianne
[class] = SundayClass
[date_s] = 1099404000
[date_e] = 1099418400
)
[15] = Array
(
[room] = Raum1
[teacher] = Marianne
[class] = SundayClass
[date_s] = 1099404000 + 7*24*60*60
[date_e] = 1099418400 + 7*24*60*60
)
[13] = Array
(
[room] = Raum1
[teacher] = Peter
[class] = Team1
[date_s] = 1100798160
[date_e] = 1100803500
)
)
)

loop through  all and create a new array foir counting
foreach ( your arrays to serach for as $array)
{
   counts[$array['room']][$array['teacher']][$array['class']]++;
   // or by whatever is relevant for you
}

--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Help: Database Search

2004-11-10 Thread Sebastian Mendel
Stuart Felenstein wrote:
I am creating a database search form and results.
Running into a problem though.
I have two form elements, both that are fed by tables
that have int values (1, 2 , etc)
my sql statement is such:
SELECT vendorjobs.PostStart, vendorjobs.JobTitle,
vendorjobs.Industry, vendorjobs.VendorID,
vendorjobs.LocationCity, vendorjobs.TaxTerm FROM
vendorjobs WHERE vendorjobs.Industry = '$Ind' AND
Date_Sub(Curdate(), interval '$Days' day) = PostStart

But if the user decides to only use one of the
elements, then I don't want the query to return
nothing because of the And in the where clause so I
have these 2 statements that set a default value
(shown here as 0 in the event one of the two elements
aren't selected:  (Having no luck as the form still
only works correctly if I've set both elements)
$Ind = 0;
if (isset($_POST['Ind'])) {
  $Ind = (get_magic_quotes_gpc()) ? $_POST['Ind'] :
addslashes($_POST['Ind']);
}
$Days = 0;
if (isset($_POST['Days'])) {
  $Days = (get_magic_quotes_gpc()) ? $_POST['Days'] :
addslashes($_POST['Days']);
$where = array();
if ( isset($_POST['Ind']) ) {
$where[] = 'vendorjobs.Industry = ' . (int) $_POST['Ind'];
}
if ( isset($_POST['Days']) ) {
$where[] = 'Date_Sub(Curdate(), interval ' . (int) $_POST['Days'] . 
' day) = PostStart';
}

$sql = '
 SELECT ...
   FROM vendorjobs
  WHERE ' . implode( ' AND ', $where );
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Question on functions

2004-11-10 Thread Sebastian Mendel
Jason wrote:
Could you give me a good example of the tip you recommend or point me to 
a good tutorial on it?
$GLOBALS holds all variables defined in main(), main() meaning outside 
any function or class

//main()
$my_var = 'test';
function myFunction()
{
echo $GLOBALS['my_var'];
// is the same as:
global $my_var
echo $my_var;
// 'global' just creates a local reference to the global variable
// global $my_var; is the same as:
$my_var = $GLOBALS['my_var'];
echo $my_var;
}

--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Array to $_GET variable

2004-11-10 Thread Sebastian Mendel
Mike Smith wrote:
I am trying to cache a database recordset so users can sort, etc
without hitting the database everytime. I'm using ADODB to access a
MSSQL database.
$s = SELECT id, part, description FROM parts\n;
$r = $db-Execute($s);
$parts = array(id=array(),part=array(),desc=array())
while(!$r-EOF){
array_push($parts['id'],$r-fields[0]);
array_push($parts['part'],$r-fields[0]);
array_push($parts['desc'],$r-fields[0]);
$r-MoveNext();
}
// print_r($parts) displays array data.
Here's what I'm doing:
$v = serialize($parts);
echo a href=\{$_SERVER['PHP_SELF']}?getvar=$v\Link/a\n;
If($_GET['getvar']){
$newvar = unserialize($_GET['getvar']); 

//This does nothing
echo $newvar;
print_r($newvar);
}
Am i missing something very simple? Should I make the array a
$_SESSION variable, or how do others cache a recordset?
i would prefer $_SESSION!
btw.
 - do you see the ...?getvar=... in the URL ?
 - what does var_dump( $_GET['getvar'] );
 - do you tried urlencode();
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php