Re: [PHP] $_SESSION v. Cookies

2008-05-08 Thread Németh Zoltán
 On Wed, May 7, 2008 at 2:35 PM, Robert Cummings [EMAIL PROTECTED]
 wrote:


 On Wed, 2008-05-07 at 14:29 -0600, Nathan Nobbe wrote:
  On Wed, May 7, 2008 at 2:22 PM, Robert Cummings [EMAIL PROTECTED]
  wrote:
 
  On Wed, 2008-05-07 at 16:03 -0400, tedd wrote:
   At 12:34 PM -0400 5/7/08, Robert Cummings wrote:
   
   The exception being when it performs cleanup. Cleanup
  should be
   relegated to a cron job.
  
   Rob:
  
   What clean-up?
 
 
  All the inactive session files... inactive and garbage
  collection time
  is denoted by the following php.ini settings:
 
  session.gc_probability= 1 ; percentual probability
  that the
   ; 'garbage collection'
  process is
   ; started
   ; on every session
  initialization
  session.gc_maxlifetime= 1440  ; after this number of
  seconds,
   ; stored data will be seen as
   ; 'garbage' and cleaned up by
  the
   ; gc process
 
  so where is the setting, using the stock session handler, to relegate
  the gc process to a cron job ?

 session.gc_probability = 0


 but wont it still try to run sometimes since that setting determines
 whether
 or not the gc will run *every* time ?  i would imagine if it was for *any*
 time, setting session.gc_probability = 0 would effectively disable the
 stock
 gc.


that setting is the chance (in percents) for the stock gc to run at any
request. so if it is set to 0, it does not have a chance ;)
of course it will try but it always decides not to run

greets,
Zoltán Németh

 Then do it yourself in a script called by cron.


 it would be nice if you could latch into the one they provide out of the
 box
 and just invoke it via cron..

 -nathan




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



Re: [PHP] included file var scope

2008-04-08 Thread Németh Zoltán

 In index.php rather than declaring vars like so...

 $var = 'value';

 ...declare them in the $GLOBALS array like so...

 $GLOBALS['var'] = 'value';

 $var is then in the global scope regardless of where it was set.

 -Stut


 That would work. However I'm looking for a more generic solution,
 independent of the system that is being included. So basically I want to
 be able to include a file in my function while stepping out of the
 context of the function itself.

 E

put all those variables in a singleton.
then just use MyGlobals::getInstance()-myvar all over the place and you
can do whatever you want with them. of course don't forget to include the
class definition everywhere you want to use it

greets,
Zoltán Németh


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





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



Re: [PHP] Can someone tell me what a tilde means ?

2008-04-08 Thread Németh Zoltán
 The humble tilde (~). I came across it the other day in some PHP code
 [code]~E_ERROR[/code]

 I'm curious, can't find any documentation on it. In math it refers to
 propostional logic, is it the same thing in PHP ?

~ $aNot  Bits that are set in $a are not set, and vice versa.

http://hu.php.net/manual/en/language.operators.bitwise.php

greets,
Zoltán Németh




 --
 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] Random Unique ID

2007-03-23 Thread Németh Zoltán
2007. 03. 22, csütörtök keltezéssel 12.58-kor tedd ezt írta:
 At 4:53 PM +0100 3/22/07, Németh Zoltán wrote:
 2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
 
As for efficiency, that's probably not even worth mentioning in this 
  case.
 
 why not? you would use 2 sql queries while I would use one most of the
 time and 2 in case of already reserved ID - that is almost twice as much
 processor time
 that may count much if the routine is used frequently
 
 Go ahead, try it, and tell me how much time it cost.
 
 From experience, there are things one can spend 
 their time optimizing and there are other things 
 that one should be able to see that aren't worth 
 pursing.
 
 I've been wrong before, but you're open to prove me wrong again, if you like.

okay, I've got up earlier and made a little benchmark. The result
suprised me, and proved you right. ;)

here is the code:

?php

$db = mysql_connect(localhost, testuser, test);
mysql_select_db(testdb);

// method 1
$time = microtime(TRUE);
for ($i = 1; $i = 5000; $i++) {
$done = FALSE;
while (!$done) {
$id = md5((microtime(TRUE) * (rand(1,1000) / 100)));
$sql = SELECT * FROM idtest WHERE id='$id';
$result = mysql_query($sql);
if (!($row = mysql_fetch_array($result))) { $done = TRUE; }
}
$sql = INSERT INTO idtest (id,cnt) VALUES ('$id', $i);
mysql_query($sql);
}
$end = microtime(TRUE) - $time;
echo method 1 time:  . $end . br;

// clean up table
$sql = DELETE FROM idtest;
mysql_query($sql);

// method 2
$time = microtime(TRUE);
for ($i = 1; $i = 5000; $i++) {
$done = FALSE;
while (!$done) {
$id = md5((microtime(TRUE) * (rand(1,1000) / 100)));
$sql = INSERT INTO idtest (id,cnt) VALUES ('$id', $i);
$result = mysql_query($sql);
if ($result) { $done = TRUE; }
}
}
$end = microtime(TRUE) - $time;
echo method 2 time:  . $end . br;

?

and the output:

method 1 time: 97.1539468765
method 2 time: 93.4973130226

this clearly shows that the method I suggested is only slightly faster,
so that difference really isn't worth mentioning as you said :)

however, the difference may be slightly bigger when using better ID
generation functions, mine above is very basic so it might have more
repetitions...

greets
Zoltán Németh

 
 Cheers,
 
 tedd
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 

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



Re: [PHP] Random Unique ID

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 08.13-kor Robert Cummings ezt írta:
 On Fri, 2007-03-23 at 09:15 +0100, Németh Zoltán wrote:
 
  // method 2
  $time = microtime(TRUE);
  for ($i = 1; $i = 5000; $i++) {
  $done = FALSE;
  while (!$done) {
  $id = md5((microtime(TRUE) * (rand(1,1000) / 100)));
  $sql = INSERT INTO idtest (id,cnt) VALUES ('$id', $i);
  $result = mysql_query($sql);
  if ($result) { $done = TRUE; }
  }
  }
  $end = microtime(TRUE) - $time;
  echo method 2 time:  . $end . br;
 
 One of the problems with the above style is that if the query fails for
 some other reason (typo, no permissions, database temporarily
 unavailable, etc) the code will run indefinitely (or until it gets
 killed for too much time). That's a very dirty way to manage failed
 inserts due to dupes.

yes, of course. that's good only for this small test, not for real life
use ;)
for real use one should check mysql_errno end take action based on that

greets
Zoltán Németh

 
 Cheers,
 Rob.

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



Re: [PHP] POST a variable

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt írta:
 Okay, I feel like the correct answer to this is about 2mm back in my grey
 matter.
 
 1. I have a query that pulls the last row number when a newly inserted
 record is added:
 
 $maximum=SELECT MAX(payment_id) FROM payment_request;
   $max_result=mssql_query($maximum);
   while($max=mssql_fetch_row($max_result)){
   }
   $max_id = $max[0];
 
 2. I have multiple selections for the user to pick, but regardless of what
 they choose I want the $max_id variable to be passed to the next page.
 
 3.  Would I go about this by assigning $max_id to a hidden field like below?
 
 input type=hidden value=?php echo $max_id; ? size=5
 maxlength=10 name=max_id /
 
 4.  And then to retrieve this value on my next page just get it out of
 $_POST['max_id']  ??
 
 Does that all sound correct?

basically yes
but if you want the id of the row you just inserted, using
mysql_insert_id() is better because if another insert is happening at
the same time, select max() may give you incorrect result

greets
Zoltán Németh

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



Re: [PHP] POST a variable

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 11.07-kor Dan Shirah ezt írta:
 The reason I have to use it as I posted is because I am using
 Microsoft SQL server instead of MySQL.  And I haven't found a php
 function for MSSQL that works the same as mysql_insert_id()

you wrote something earlier as far as I can remember about a MSSQL
function scope_identity() which returns the last inserted id

why not use that?

greets
Zoltán Németh

  
 So, to come out with a comparable function with pretty reliable
 results, I follow this process:
  
 1. User enters data into form
 2. User submits form
 3. Save page inserts info into the database
 4. Directly after the insert statement is my SELECT MAX query
 5. I assign the retrieved value to a hidden field
 6. I pass this value to the next form
  
 I figure the odds of another record being inserted inbetween the time
 it takes to go from step 3 to step 4 are very, very minimal.  We're
 talking about MAYBE a 2-3 millisecond gap?
 
  
 On 3/23/07, Németh Zoltán [EMAIL PROTECTED] wrote: 
 2007. 03. 23, péntek keltezéssel 10.45-kor Dan Shirah ezt
 írta:
  Okay, I feel like the correct answer to this is about 2mm
 back in my grey 
  matter.
 
  1. I have a query that pulls the last row number when a
 newly inserted
  record is added:
 
  $maximum=SELECT MAX(payment_id) FROM payment_request;
$max_result=mssql_query($maximum); 
while($max=mssql_fetch_row($max_result)){
}
$max_id = $max[0];
 
  2. I have multiple selections for the user to pick, but
 regardless of what
  they choose I want the $max_id variable to be passed to the
 next page. 
 
  3.  Would I go about this by assigning $max_id to a hidden
 field like below?
 
  input type=hidden value=?php echo $max_id; ?
 size=5 
  maxlength=10 name=max_id /
 
  4.  And then to retrieve this value on my next page just get
 it out of
  $_POST['max_id']  ??
 
  Does that all sound correct? 
 
 basically yes
 but if you want the id of the row you just inserted, using
 mysql_insert_id() is better because if another insert is
 happening at
 the same time, select max() may give you incorrect result
 
 greets
 Zoltán Németh
 
 

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



Re: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 16.55-kor Dwayne Heronimo ezt írta:
 Dear all,
 
 hmm.. sorry the $previewstext thing was a typo in my mail.
 
 But yes it is working but it will only display the first record of the 
 recordset. I have like a list for items with short text in a page and of 
 course made a query to make the database variables available. Which where 
 the variable $row_show_cat['text']; comes from.
 
 This is why I thought that i may have to rewrite it into a function to 
 display the $row_show_cat['text']; in a repeated reagion.
 
 
 I have rewritten my function:
 
 ?php
  function previewString($showcatvar) {
 
  $minitxt = $showcatvar;
  $len = strlen($minitxt);
 
  if ($len  235)
  {
   $len = 235;
  }
  else
  {
   $len = $len;
  }
 
  $newstring = substr($minitxt,0,$len);
 
  $previewtext = $newstring;
 
  $previewtext = $whowcatvar;

what is the meaning of the above line???
you are giving an undefined value (default NULL) to $previewtext, just
after you gave it the right value
delete that line and you might be well

greets
Zoltán Németh

 
  return $previewtext;
 }
 ?
 
 And to to show it later in the page:
 ?php echo previewString($row_show_cat['text']); ?
 but this still won't anywould display anything. :S
 
 Please let me know.
 
 Tijnema ! [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
  On 3/23/07, Dwayne Heronimo [EMAIL PROTECTED] wrote:
  Dear All,
 
  I am very new to programming. I want to make a preview text that would
  display only a part of the text that is a text field in a database.
 
  //Begin Make preview string
 
   $minitxt = $row_show_cat['text'];
   $len = strlen($minitxt);
 
   if ($len  235)
   {
   $len = 235;
   }
   else
   {
   $len = $len;
   }
 
   $newstring = substr($minitxt,0,$len);
 
   $previewtext = $newstring;
 
  //End Make preview string
 
  But if I want to display this somewhere in the page it will only display 
  the
  first record of at every text column row ?php echo $previewstext ?
 
  Althought I am very new to php and programming. I thought maybe I should
  rewrite it into a function. But my function won't work.
 
 
  function previewString($showcatvar) {
 
   $minitxt = $showcatvar;
   $len = strlen($minitxt);
 
   if ($len  235)
   {
   $len = 235;
   }
   else
   {
   $len = $len;
   }
 
   $newstring = substr($minitxt,0,$len);
 
   $previewtext = $newstring;
 
   $previewtext = $whowcatvar;
 
  }
 
 
  and to display it in the page:
 
  ?php echo  previewString($row_show_cat['text']) ?
 
  IT displays notthing. But I think I am doing somthing wrong. I am 
  assigning
  the wrong variables to the $row_show_cat['text']) ???
 
  Please let me know
 
  I'm currently not sure why your first piece of code isn't working, but
  the second is quite simple. You aren't returning any variable in your
  function, and so it won't output anything. Add the following:
  return $previewtext;
  Just before the }
 
  Then it will return something, but i think not what you wanted to :(
 
  Tijnema
 
  --
  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] Random Unique ID

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 15.13-kor tedd ezt írta:
 At 9:15 AM +0100 3/23/07, Németh Zoltán wrote:
 2007. 03. 22, csütörtök keltezéssel 12.58-kor tedd ezt írta:
   At 4:53 PM +0100 3/22/07, Németh Zoltán wrote:
   2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
   
  As for efficiency, that's probably not 
 even worth mentioning in this case.
   
   why not? you would use 2 sql queries while I would use one most of the
   time and 2 in case of already reserved ID - that is almost twice as much
   processor time
   that may count much if the routine is used frequently
 
   Go ahead, try it, and tell me how much time it cost.
 
   From experience, there are things one can spend
   their time optimizing and there are other things
   that one should be able to see that aren't worth
   pursing.
 
   I've been wrong before, but you're open to 
 prove me wrong again, if you like.
 
 okay, I've got up earlier and made a little benchmark. The result
 suprised me, and proved you right. ;)
 
 Németh:
 
 Thanks for trying, but I said what I did because 
 I knew from experience that these types of 
 actions are blinding fast and getting faster all 
 the time.
 
 I'm not suggesting to dispense with looking for 
 less operations, but sometimes the effort doesn't 
 exceed other benefits in readability, easier 
 logic, simpler code, and time spent developing 
 code. We have been rather slow to realize changes 
 the speed and memory of hardware.
 
 For example, we recently had a discussion on the 
 difference between using ? as compared to 
 ?php and the additional text was mentioned as 
 a concern. When in fact, if is of no noticeable 
 or significant concern at all. It's like 
 discussing a grain of sand on the beach.
 
 Not that you did this, but sometimes it's best to 
 figure out what's important and what's not before 
 making it an issue.

yeah, you're right again :)
(however my first name is still Zoltán instead of Németh ;) )

that's what I did now. I figured out it's not important. thanks for
inspiring me to do that :)

greets
Zoltán Németh

 
 Cheers,
 
 tedd
 
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 

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



Re: [PHP] preview string with strlen PHP (help)

2007-03-23 Thread Németh Zoltán
2007. 03. 23, péntek keltezéssel 17.30-kor Dwayne Heronimo ezt írta:
 YES this works thank nemeth:

your welcome but please call me Zoltán ;)
(my first name is Zoltán. in Hungary we write names the opposite order
than anywhere else ;) so that's why my mailbox is set to display 'Németh
Zoltán' but I sign my mails as 'Zoltán Németh' showing that my first
name is Zoltán and last name is Németh :) )

greets
Zoltán Németh

 
 ?php
  function previewString($showcatvar) {
 
  $minitxt = $showcatvar;
  $len = strlen($minitxt);
 
  if ($len  235)
  {
   $len = 235;
  }
  else
  {
   $len = $len;
  }
 
  $newstring = substr($minitxt,0,$len);
 
  $previewtext = $newstring;
 
  return $previewtext;
 }
 ?
 
 and to display it:
 
 ?php echo  previewString($row_show_cat['text']); ?
 
 cheers
 
 Dwayne
 
 
 
 
 Nmeth Zoltn [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
  2007. 03. 23, pntek keltezssel 16.55-kor Dwayne Heronimo ezt rta:
  Dear all,
 
  hmm.. sorry the $previewstext thing was a typo in my mail.
 
  But yes it is working but it will only display the first record of the
  recordset. I have like a list for items with short text in a page and of
  course made a query to make the database variables available. Which where
  the variable $row_show_cat['text']; comes from.
 
  This is why I thought that i may have to rewrite it into a function to
  display the $row_show_cat['text']; in a repeated reagion.
 
 
  I have rewritten my function:
 
  ?php
   function previewString($showcatvar) {
 
   $minitxt = $showcatvar;
   $len = strlen($minitxt);
 
   if ($len  235)
   {
$len = 235;
   }
   else
   {
$len = $len;
   }
 
   $newstring = substr($minitxt,0,$len);
 
   $previewtext = $newstring;
 
   $previewtext = $whowcatvar;
 
  what is the meaning of the above line???
  you are giving an undefined value (default NULL) to $previewtext, just
  after you gave it the right value
  delete that line and you might be well
 
  greets
  Zoltn Nmeth
 
 
   return $previewtext;
  }
  ?
 
  And to to show it later in the page:
  ?php echo previewString($row_show_cat['text']); ?
  but this still won't anywould display anything. :S
 
  Please let me know.
 
  Tijnema ! [EMAIL PROTECTED] wrote in message
  news:[EMAIL PROTECTED]
   On 3/23/07, Dwayne Heronimo [EMAIL PROTECTED] wrote:
   Dear All,
  
   I am very new to programming. I want to make a preview text that would
   display only a part of the text that is a text field in a database.
  
   //Begin Make preview string
  
$minitxt = $row_show_cat['text'];
$len = strlen($minitxt);
  
if ($len  235)
{
$len = 235;
}
else
{
$len = $len;
}
  
$newstring = substr($minitxt,0,$len);
  
$previewtext = $newstring;
  
   //End Make preview string
  
   But if I want to display this somewhere in the page it will only 
   display
   the
   first record of at every text column row ?php echo $previewstext ?
  
   Althought I am very new to php and programming. I thought maybe I 
   should
   rewrite it into a function. But my function won't work.
  
  
   function previewString($showcatvar) {
  
$minitxt = $showcatvar;
$len = strlen($minitxt);
  
if ($len  235)
{
$len = 235;
}
else
{
$len = $len;
}
  
$newstring = substr($minitxt,0,$len);
  
$previewtext = $newstring;
  
$previewtext = $whowcatvar;
  
   }
  
  
   and to display it in the page:
  
   ?php echo  previewString($row_show_cat['text']) ?
  
   IT displays notthing. But I think I am doing somthing wrong. I am
   assigning
   the wrong variables to the $row_show_cat['text']) ???
  
   Please let me know
  
   I'm currently not sure why your first piece of code isn't working, but
   the second is quite simple. You aren't returning any variable in your
   function, and so it won't output anything. Add the following:
   return $previewtext;
   Just before the }
  
   Then it will return something, but i think not what you wanted to :(
  
   Tijnema
  
   --
   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] image uploading/resizing best practices in PHP

2007-03-22 Thread Németh Zoltán
2007. 03. 22, csütörtök keltezéssel 12.48-kor Dwayne Heronimo ezt írta:
 thx for the input. I was afraid that it would be option 1 because it is more 
 complex.

why would resizing and then storing it be more complex than resizing and
then displaying it?

greets
Zoltán Németh

 I will start googling. ;)
 
 Thx
 
 Shafiq Rehman [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
  Option one is much better.
 
  -- 
  Shafiq Rehman (ZCE)
  http://phpgurru.com | http://shafiq.pk
 
  On 3/22/07, Tijnema ! [EMAIL PROTECTED] wrote:
 
  On 3/22/07, Dwayne Heronimo [EMAIL PROTECTED] wrote:
   Dear All,
  
   I would like to make a script to upload a jpg filewith php to a server;
  then
   make a thumb; save if for later use. And store the path to the image in
  a
   database to display it later. But what is the best practice to do this
  on a
   relatively low traffic website?
  
   I dont know where to begin but I have 2 appoaches:
  
   1. To make a script to upload the image and resize this on the fly and
  store
   only the thumb image somewhere for later use. While also to store the
  image
   path in de database for later retrieval.
 
  The best way i think if you have enough space on the server to store the
  thumb.
 
  
   2. to make a script to only upload the image as is and then insert the
  image
   path in the database for later use. And upon displaying the image to 
   use
   like a nondistructive img 
   scr=resizer.php?imgfile=image.jpgwidth=250
   border=0 resizer to display the image in the desired dimentions.
  This one is worser then the first one, because everytime you request
  the thumb would cost some CPU power. This isn't a lot, but if you are
  gonna process 1000s thumbs a time, it will really make difference in
  performance.
 
  
   Which one would be the best practice now a days for a relative low
  traffic
   site?
   I really have no idean how to build this but I have a good approach I
  maybe
   could start searching for something more specific.
  
   Thanks for your help,
  
   Dwayne
  
  You should have a look at the image functions of
  PHP(www.php.net/image). Creating the thumbs is the hardest part. The
  upload part should be no problem with a little bit of google :)
  Or you might want to google for a full working scripts, i saw them 
  around.
 
  Tijnema
 
 
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
  
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
  
 

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



Re: [PHP] Random Unique ID

2007-03-22 Thread Németh Zoltán
2007. 03. 22, csütörtök keltezéssel 11.24-kor tedd ezt írta:
 At 11:18 AM -0600 3/21/07, [EMAIL PROTECTED] wrote:
 Hello,
 I want to add a random unique ID to a Mysql table.  Collisions
 are unlikely but possible so to handle those cases I'd like to
 regenerate the random ID until there is no collision and only
 then add my row.  Any suggestions for a newbie as to the right
 way to go about doing this?
 Best,
 Craig
 
 Craig:
 
 Simple.
 
 Generate a random unique ID via whatever method you want. However, 
 before using, search your dB to see if it's already in use. If it is, 
 then generate another one and repeat.

it's probably more efficient to try to insert with the generated ID at
once, and repeat only if it fails.
if the ID generation method is good enough, repeat will be needed only
extremely rarely

greets
Zoltán Németh

 
 Cheers,
 
 tedd
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 

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



Re: [PHP] Random Unique ID

2007-03-22 Thread Németh Zoltán
2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
 At 4:28 PM +0100 3/22/07, Németh Zoltán wrote:
 2007. 03. 22, csütörtök keltezéssel 11.24-kor tedd ezt írta:
   At 11:18 AM -0600 3/21/07, [EMAIL PROTECTED] wrote:
   Hello,
   I want to add a random unique ID to a Mysql table.  Collisions
   are unlikely but possible so to handle those cases I'd like to
   regenerate the random ID until there is no collision and only
   then add my row.  Any suggestions for a newbie as to the right
   way to go about doing this?
   Best,
   Craig
 
   Craig:
 
   Simple.
 
   Generate a random unique ID via whatever method you want. However,
   before using, search your dB to see if it's already in use. If it is,
   then generate another one and repeat.
 
 it's probably more efficient to try to insert with the generated ID at
 once, and repeat only if it fails.
 if the ID generation method is good enough, repeat will be needed only
 extremely rarely
 
 greets
 Zoltán Németh
 
 
 I like to write code that avoids failure if 
 possible rather than writing something that I 
 know can fail and then dealing with resultant 
 errors. Just differences in perspectives.

that's a matter of taste, which can not be argued ;)

 
 As for efficiency, that's probably not even worth mentioning in this case.

why not? you would use 2 sql queries while I would use one most of the
time and 2 in case of already reserved ID - that is almost twice as much
processor time
that may count much if the routine is used frequently

greets
Zoltán Németh

 
 Cheers,
 
 tedd
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 

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



Re: [PHP] Random Unique ID

2007-03-22 Thread Németh Zoltán
2007. 03. 22, csütörtök keltezéssel 12.58-kor tedd ezt írta:
 At 4:53 PM +0100 3/22/07, Németh Zoltán wrote:
 2007. 03. 22, csütörtök keltezéssel 11.42-kor tedd ezt írta:
 
As for efficiency, that's probably not even worth mentioning in this 
  case.
 
 why not? you would use 2 sql queries while I would use one most of the
 time and 2 in case of already reserved ID - that is almost twice as much
 processor time
 that may count much if the routine is used frequently
 
 Go ahead, try it, and tell me how much time it cost.

it would be an interesting benchmark, timing it on some 10 runs or
like that, if I'll have some time I promise I'll do it :)

 
 From experience, there are things one can spend 
 their time optimizing and there are other things 
 that one should be able to see that aren't worth 
 pursing.

yes, it's true. as for the current thing, I do not have experience or
benchmarks, so you may be right that it does not worth the energy. I
said what I said out of logic, which says that 2 queries are slower than
1 query ;)

 
 I've been wrong before, but you're open to prove me wrong again, if you like.

when I'll have some free time (probably not in the next couple of
weeks...) I think I'll try to benchmark it - and we'll see whether the
difference is worth mentioning or not :)

but if anyone has (or you have) existing benchmarks please show me, I'm
interested in it

greets
Zoltán Németh

 
 Cheers,
 
 tedd
 -- 
 ---
 http://sperling.com  http://ancientstones.com  http://earthstones.com
 

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



RE: [PHP] Problem with MySQL

2007-03-21 Thread Németh Zoltán
2007. 03. 21, szerda keltezéssel 00.04-kor Richard Lynch ezt írta:
 On Tue, March 20, 2007 11:08 am, Ford, Mike wrote:
  what do you want with that '@' here?
  that operator can be used to suppress error messages when calling
  functions but not when using a variable
 
 This is most definitely way wrong.
 
  What complete tosh!  @ is a unary operator, so can be applied to any
  expression.
 
  Proof:
 
?php
  echo no @ --, $HTTP_GET_VARS['bogus'], br /\n;
  echo with @ --, @$HTTP_GET_VARS['bogus'], br /\n;
?
 
  Result:
 
no @ --
Warning: Undefined index: bogus in
  c:\www-lco\scripts_etc\lco\php\test.php on line 18
 
with @ --
 
 
  Also:
 
?php
  $a = 123;
  echo no @ --, $a/0, br /\n;
  echo with @ --, @($a/0), br /\n;
?
 
  Result:
 
no @ --
Warning: Division by zero in c:\www-lco\scripts_etc\lco\php\test.php
  on line 19
 
with @ --
 
 
  Not that I'm necessarily advocating this as a technique, but let's not
  spread disinformation!
 
 While it has now been proven that @ is more than a function
 error-suppressant, I suspect it may technically be a Language
 Construct rather than a simple unary operator...
 
 Not that I can come up with anything yet to prove it, as all my
 examples so far were total syntax errors...
 
 Although I did find an interesting anomoly...
 
 What would you expect this to output?
 ?php @ ?
 
 Hint:
 I figured it would apply the @ to no expression at all and do nothing.
 I was wrong.
 
 I suppose I could try to read PHP source and figure all this out
 someday...

actually I tried it and the output suprised me also
it was
Parse error: syntax error, unexpected ';'
in /var/www/tests/kukactest1.php on line 1

although I tried it with the unary operator !
?php ! ?
that produces the same output

so this behaviour is probably the way operators behave...
but it is really interesting ;)

greets
Zoltán Németh

 

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



Re: [PHP] Flash animation without install Flash!

2007-03-21 Thread Németh Zoltán
2007. 03. 21, szerda keltezéssel 09.58-kor Helder Lopes ezt írta:
 Hi people,
 
 Because the problems with virus in internet the people dont install activex
 controls.
 My question is:
 
 How to put a flash in the website without asking the person to install
 activex control??

I think there is no way to do that

greets
Zoltán Németh

 
 /Helder Lopes

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



Re: [PHP] read only texbox to html with php

2007-03-21 Thread Németh Zoltán
2007. 03. 21, szerda keltezéssel 11.51-kor Ross ezt írta:
 I have a readonly textbox that gets mailed as a newsletter. The text is a 
 standard covering letter. The problem is when I try and convert it to html 
 it doesn't work  It is inserted into a variable via a form textarea 
 $mail_text.

what do you mean by converting to html?
if it is just plain text what do you want to do with it? enclose it
within p tags, etc? or what?
and what do you mean by doesn't work?

greets
Zoltán Németh

 
  available on the web site a 
 href=http://www.myurl.org;http://www.myurl.org/a so you can see who is 
 doing.
 
 I tried this
 
 htmlentities((stripslashes($mail_text)));
 
 
 Any ideas?
 
 R.
 

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



Re: [PHP] PHP mail() problem

2007-03-20 Thread Németh Zoltán
2007. 03. 20, kedd keltezéssel 10.54-kor Delta Storm ezt írta:
 Hi,
 
 I'm having problem with character encoding in PHP mail functions.
 
 CODE:
 $headers.= Content-Type: text/html; charset=iso-8859-1;
   $headers .= MIME-Version: 1.0 ;
   $headers .= Content-Transfer-Encoding: 8bit.$eol.$eol;
   $headers .=Content-Type: multipart/alternative; 
 boundary=0-92766976-1174383938=:29106;
   $to = [EMAIL PROTECTED];
   $subject = $_POST['cat'];
   $body = $_POST['text'];

you should check those values first before putting them into mail().
they can contain spammer tricks like putting newlines in the subject and
then cc header lines or something similar

   if (mail($to, $subject, $body, $headers))
   {
   echo('pMessage successfully sent!/pbr /a 
 href=showarticle.php?cid=5id=3Povratak/a');
   }
   else
   {
   echo('pMessage delivery failed.../pbr /a 
 href=showarticle.php?cid=5id=3Povratak/a');
   }
 
 Im receiving mail as you see using yahoo.com. It all works except it 
 doesn't show croatian letters... I also tried with encoding utf-8, same 
 thing...
 ČĆŽŠĐ

what is the charset of the webpage displaying the form which triggers
this function? it must be set to the same value as the email otherwise
your email sending function won't receive the croatian letters at all,
so it cannot send them too...

hope that helps
Zoltán Németh

 
 Please help, thank you very much!
 

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



Re: [PHP] Problem with MySQL

2007-03-20 Thread Németh Zoltán
2007. 03. 20, kedd keltezéssel 15.09-kor Pavel Kaznarskiy ezt írta:
 Hello !
 I have problem with access in mysql
 
 it is my code:
 html
 headtitleSQL Query Sender/title/head
 body
 ?php
 $host=;
 $user=;
 $password=;
 /* Section that executes query */
 if(@$_GET['form'] == yes)

what do you want with that '@' here?
that operator can be used to suppress error messages when calling
functions but not when using a variable

 {
 mysql_connect($host,$user,$password);
 mysql_select_db($_POST['database']);
 $query = stripSlashes($_POST['query']);

you should take care of sql injection, check those $_POST values first!

 $result = mysql_query($query);
 echo Database Selected: b{$_POST['database']}/bbr
 Query: b$query/bh3Results/h3hr;
 if($result == 0)

if you want to check for errors, you should use
if ($result === FALSE)

 echo bError .mysql_errno().: .mysql_error().
 /b;
 elseif (@mysql_num_rows($result) == 0)
 echo(bQuery completed. No results returned.
 /bbr);
 else
 {
 echo table border='1'
 thead
 tr;
 for($i = 0;$i  mysql_num_fields($result);$i++)
 {
 echo th.mysql_field_name($result,$i).
 /th;
 }
 echo  /tr
 /thead
 tbody;
 for ($i = 0; $i  mysql_num_rows($result); $i++)
 {
 echo tr;
 $row = mysql_fetch_row($result);
 for($j = 0;$jmysql_num_fields($result);$j++)
 {
 echo(td . $row[$j] . /td);
 }
 echo /tr;
 }
 echo /tbody
 /table;
 } //end else
 echo 
 hrbr
 form action=\{$_SERVER['PHP_SELF']}\ method=\POST\

putting $_SERVER['PHP_SELF'] here might also be a security risk
read this:
http://blog.phpdoc.info/archives/13-XSS-Woes.html

 input type='hidden' name='query' value='$query'
 input type='hidden' name='database'
 value={$_POST['database']}
 input type='submit' name=\queryButton\
 value=\New Query\
 input type='submit' name=\queryButton\
 value=\Edit Query\
 /form;
 unset($form);
 exit();
 } // endif form=yes
 /* Section that requests user input of query */
 @$query=stripSlashes($_POST['query']);
 if (@$_POST['queryButton'] != Edit Query)
 {
 $query =  ;
 }
 ?
 form action=?php echo $_SERVER['PHP_SELF'] ??form=yes
 method=POST
 table
 tr
 td align=rightbType in database name/b/td
 tdinput type=text name=database
 value=?php echo @$_POST['database'] ? /td
 /tr
 tr
 td align=right valign=top
 bType in SQL query/b/td
 tdtextarea name=query cols=60
 rows=10?php echo $query ?/textarea
 /td
 /tr
 tr
 td colspan=2 align=centerinput type=submit
 value=Submit Query/td
 /tr
 /table
 /form
 /body/html
 
 when i'm trying to execute it. such message appears:
 Warning: mysql_connect(): Access denied for user 'ODBC'@'localhost' (using 
 password: NO) in z:\home\localhost\www\2.php on line 11
 
 Warning: mysql_select_db(): Access denied for user 'ODBC'@'localhost' (using 
 password: NO) in z:\home\localhost\www\2.php on line 12
 
 Warning: mysql_select_db(): A link to the server could not be established in 
 z:\home\localhost\www\2.php on line 12
 
 Warning: mysql_query(): Access denied for user 'ODBC'@'localhost' (using 
 password: NO) in z:\home\localhost\www\2.php on line 14
 
 Warning: mysql_query(): A link to the server could not be established in 
 z:\home\localhost\www\2.php on line 14
 Database Selected: i
 
 what does it' mean?

these errors mean that your mysql user 'ODBC' has no password, while you
are providing a password when connecting.
it is not recommended to have a user without password, so you should
first give him a password with the mysql command SET PASSWORD or
something

greets
Zoltán Németh

 
 -- 
 Best regards,
  Pavelmailto:[EMAIL PROTECTED]
 

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



RE: [PHP] Problem with MySQL

2007-03-20 Thread Németh Zoltán
2007. 03. 20, kedd keltezéssel 16.08-kor Ford, Mike ezt írta:
 On 20 March 2007 13:26, Németh Zoltán wrote:
 
  2007. 03. 20, kedd keltezéssel 15.09-kor Pavel Kaznarskiy ezt írta:
   Hello !
   I have problem with access in mysql
   
   it is my code:
   html
   headtitleSQL Query Sender/title/head
   body
   ?php
   $host=;
   $user=;
   $password=;
   /* Section that executes query */
   if(@$_GET['form'] == yes)
  
  what do you want with that '@' here?
  that operator can be used to suppress error messages when calling
  functions but not when using a variable
 
 What complete tosh!  @ is a unary operator, so can be applied to any 
 expression.
 
 Proof:
 
   ?php
 echo no @ --, $HTTP_GET_VARS['bogus'], br /\n;
 echo with @ --, @$HTTP_GET_VARS['bogus'], br /\n;
   ?
 
 Result:
 
   no @ --
   Warning: Undefined index: bogus in c:\www-lco\scripts_etc\lco\php\test.php 
 on line 18
 
   with @ --
 
 
 Also:
 
   ?php
 $a = 123;
 echo no @ --, $a/0, br /\n;
 echo with @ --, @($a/0), br /\n;
   ?
 
 Result:
 
   no @ --
   Warning: Division by zero in c:\www-lco\scripts_etc\lco\php\test.php on 
 line 19
 
   with @ --
 
 
 Not that I'm necessarily advocating this as a technique, but let's not spread 
 disinformation!

okay, sorry for my ignorance ;)

greets
Zoltán Németh

 
 Cheers!
 
 Mike
 
 -
 Mike Ford,  Electronic Information Services Adviser,
 Learning Support Services, Learning  Information Services,
 JG125, James Graham Building, Leeds Metropolitan University,
 Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
 Email: [EMAIL PROTECTED]
 Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 
 
 
 To view the terms under which this email is distributed, please go to 
 http://disclaimer.leedsmet.ac.uk/email.htm

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



Re: [PHP] Re: Question

2007-03-20 Thread Németh Zoltán
2007. 03. 20, kedd keltezéssel 16.31-kor Dan Shirah ezt írta:
 Because in my application it is VERY VERY VERY important that I track the
 specific details for any given user in any given account.  The user data
 changes frequently and I need to be able to track user information changes,
 numbers of accounts they are assigned to etc.
 
 So rather than updating the user information or keeping one user and tying
 them to multiple accounts it is easier to maintain a specific user per
 account for our strict tracking needs.
 
 This way I can view all accounts the user is associated with, track user
 information changes over months/years and provide detailed statsical reports
 to auditors.
 

I'm sure you could do all that stuff with one copy of the user data and
user-account links stored separately...

greets
Zoltán Németh


 
 On 3/20/07, Jim Lucas [EMAIL PROTECTED] wrote:
 
  Dan Shirah wrote:
   I had thought about having the multiple submissions on a single form,
  but
   with the amount of user information that is collected and the variable
   amount of users that may need to be entered this method would not be
  ideal.
   (A single form that you have to scroll down a far way and the potential
  to
   not have enough user inputs is what prevents this method from being
  used)
  
   Each account is unique.  It is possible that the same user could be on
   multiple accounts, therefore the account will be tied to the user each
   time.
  
   No account_id will be duplicated, but the user table can hold the same
  user
   multiple times tied to different accounts.
  Why duplicate data?  Why not do it as suggested?  What do  you mean by
  not ideal ??
 
  
  
   On 3/20/07, Greg Beaver [EMAIL PROTECTED] wrote:
  
   Dan Shirah wrote:
In my database I have two tables.  One table stores all of the
  account
information, the other table stores all of the user information.
   
Table 1
account_id  - is the primary key and is unique to each account
   
Table 2
user_id  - is the primary key and is unique to each user
account_id  - will be set to whatever the account id is in Table 1
   
You are suggesting that when they click Enter another user for this
account that I save the account/user information to the database and
then when the form refreshes have something like:
   
if (!isset($_POST['submit']))
   
to determine if this is a continuance of a multiple user submission?
   
And then I should select the account_id that was just created?  Using
something like:
   
SELECT scope_identity() FROM accounts
   
Or is there a better way to determine the recently created
   account_id so
I can use it for any other user data that is created for this
  account?
  
   Hi Dan,
  
   Yes, there is a better way.  What you have described is probably more
   complex than you need, and requires more clicking by the user than is
   necessary.
  
   First of all, do you allow multiple accounts for the same user?  If so,
   you're going to run into troubles with querying later on with the
   current data schema.  Generally, when I'm working with inter-linking
   data like you describe, I construct it as:
  
   Table 1 account_info:
   account information
   account_id
  
   Table 2 user_info:
   user information
   user_id
  
   Table 3 account_link:
   user_id
   account_id
  
   This way, you never duplicate user information, and it is very easy to
   link or unlink users from accounts.
  
   In the web form, if you allow adding up to 3 users maximum, why not
  just
   put all of the input on a single page?
  
   [html]
   Account information:
  
   Form Field 1: 
   ...
  
   User #1 (required)
  
   Name: _
   ...
  
   User #2 (optional)
  
   Name: _
   ...
  
   User #3 (optional)
  
   Name: _
   ...
   [/html]
  
   In addition, you might consider either using an AJAX-based dropdown, or
   populating a static dropdown with previous users (assuming the list of
   users is short), so that if a previous user is entered into the
  account,
   that name can be used.
  
   In addition, if you have all 3 users on one page, you can validate them
   all at once, check for accidental duplicates (i.e. if a name matches an
   existing user, bring up the form and ask if they intend to create a new
   user, or wish to use the existing one).
  
   There are lots of options.  If you do decide to do a multi-page form,
   with database submit right at the last step, there is an example of how
   I've done this in the code for pear.php.net's election creation
   interface, at
  
  
  http://cvs.php.net/viewvc.cgi/pearweb/public_html/election/new.php?view=markup
  
   .
  
  
   This code makes use of simple php-based templates found in:
  
  
  
  http://cvs.php.net/viewvc.cgi/pearweb/templates/election-new-step1.tpl.php?view=markup
  
  
  
  http://cvs.php.net/viewvc.cgi/pearweb/templates/election-new-step2.tpl.php?view=markup
  
  
  
  

Re: [PHP] logging erros and user access to logs

2007-03-19 Thread Németh Zoltán
2007. 03. 15, csütörtök keltezéssel 16.08-kor Jason Joines ezt írta:
 Richard Lynch wrote:
  On Thu, March 15, 2007 2:47 pm, Jason Joines wrote:
  Richard Lynch wrote:
  On Thu, March 15, 2007 8:25 am, Jason Joines wrote:
  Richard Lynch wrote:
  Get the errors OFF the web page (display_errors OFF) and into the
?php
  error_reporting(E_PARSE);
  ini_set('display_errors','On');
  ini_set('display_startup_errors','On');
  include('mypage.php');
?
  Then when debugging was done, just delete the debug script.
 
  I moved it to a test server and could get it to work but only
  if
  display_errors was set to on in the global php.ini file.  I can't
  do
  that on the production server.  The manual says display_errors can
  be
  overridden in a script.  I used ini_get() to see if the value was
  actually being changed, it was.  However, it still doesn't print
  the
  errors unless the global ini is set.
 
  Any ideas as to why it's not working?
  Put ?php phpinfo();? into the mypage.php and see if its Master
  and
  Local values are different for display_errors.
 
  If they are, then it worked, and you SHOULD see the errors.
 
 
 
  Well they weren't different so I guess it didn't work.  Seems odd
  to
  me that get_ini would show it has having been changed but phpinfo
  doesn't.
  
  Sounds like a bug to me -- They ought to at least agree on what the
  setting is, even if you weren't allowed to change it...
  
  Check the bug reports and file one, I guess:
  http://bugs.php.net
  
 
 
 I thought I might try a modification of your virtual hosts
 suggestion.  Perhaps create a virtual host with the same document root
 as the main virtual host but turn display_errors on globally for the
 debug vhost using phpflag.  First I tried it in a .htaccess file and
 then in my main apache config file, httpd.conf.  Each time resulted in
 the error:
 Invalid command 'phpflag', perhaps mis-spelled or defined by a module
 not included in the server configuration.

you misspelled it, there is no phpflag command actually.
there is php_flag command and php_value command which you can use
in .htaccess files (php_flag for flags which can have On/Off states
only, php_value for others)

hope that helps
Zoltán Németh

 
 I'm starting to think that all of the ini override stuff was
 implemented in a later version of PHP than I'm using.  Haven't figured
 out when it was implemented yet though.
 
 
 Jason
 ===
 

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



Re: [PHP] displaying image from MySQL DB using HTML/PHP

2007-03-19 Thread Németh Zoltán
2007. 03. 14, szerda keltezéssel 19.30-kor Børge Holen ezt írta:
 On Tuesday 13 March 2007 22:09, Tijnema ! wrote:
  On 3/13/07, Bruce Gilbert [EMAIL PROTECTED] wrote:
   On 3/13/07, Tijnema ! [EMAIL PROTECTED] wrote:
So you just need to set the content-type and output
add this to the bottom of the script:
header(Content-Type: .$encodeddata);
echo $title;
   
If i understand you right.
   
Tijnema
  
   Thanks,
  
   I changed the code around some and now have:
   [php]
   ?php
   //check for validity of user
   $db_name=bruceg_mailinglist;
   $table_name =image_holder;
   $connection = @mysql_connect(db_address, uasername, password)
   or die (mysql_error());
   $db = @mysql_select_db($db_name, $connection) or die (mysql_error());
  
   $img = $_REQUEST[img];
  
   $result = @mysql_query(SELECT * FROM image_holder WHERE id= . $img .
   );
  
   if (!$result)
   {
   echo(Error performing query:  . mysql_error() . );
   exit();
   }
   while ( $row = @mysql_fetch_array($result) )
   {
   $imgid = $row[id];
   header(Content-Type: .$encodeddata);
   echo $title;}
  
   ?
   [/php]
  
   and in the HTML
   centerimg src=image.php?id=1 width=200 border=1 alt=/center
  
   but I am getting a MySQL error
   Error performing query: You have an error in your SQL syntax; check
   the manual that corresponds to your MySQL server version for the right
   syntax to use near '' at line 1
  
   --
  
   ::Bruce::
 
  You changed your html code, you have id=1, and in your PHP code you
  are requesting img, so change
  centerimg src=image.php?id=1 width=200 border=1 alt=/center
  to
  centerimg src=image.php?img=1 width=200 border=1 alt=/center
 
  But i must also say, it is NOT safe to input data from ?img= directly
  into your database, someone could do a SQL injection right away with
  this code!.
 
 He's not using image.php to insert. Earlier he mentioned using phpmyadmin to 
 insert the image, that was the way I used too. First learn to display an 
 image, this way its easier to know if any upload script you make up later is 
 working correctly.

evil code can be injected into any sort of sql statement. so it is not
depending on whether he's using the php for insert or not.

greets
Zoltán Németh

 
 
  Then about this piece of code
  while ( $row = @mysql_fetch_array($result) )
  {
  $imgid = $row[id];
  header(Content-Type: .$encodeddata);
  echo $title;
  }
  I hope for you that there's only one item with this id, if not, there
  would come an error again, so a while loop is not needed, and second,
  now you don't define $encodeddata and $title anymore, try this piece
  of code instead of the one above:
 
  $row = @mysql_fetch_array($result);
  header(Content-Type: .row['mimetype']);
  echo $row['filecontents'];
 
  ps. Reply to the full PHP list, not just me...
 
 -- 
 ---
 Børge
 Kennel Arivene 
 http://www.arivene.net
 ---
 

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



Re: [PHP] Parse

2007-03-14 Thread Németh Zoltán
2007. 03. 14, szerda keltezéssel 07.53-kor al phillips ezt írta:
 I keep getting a parse error line x
   when trying view php info()
   Can you help please?

no, if you don't post the exact error message and your code here

btw, it is probably a typo in your code at line x, but we cannot see it
as you didn't show us your code

greets
Zoltán Németh


 
  
 -
 Be a PS3 game guru.
 Get your game face on with the latest PS3 news and previews at Yahoo! Games.

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



Re: [PHP] Using a reentrant form

2007-03-13 Thread Németh Zoltán
2007. 03. 13, kedd keltezéssel 08.19-kor Todd Cary ezt írta:
 To validate a page, I set the form value to the page name the 
 user is on.  Then there is a hidden variable, looped that is 
 set to 1.  By checking looped, I know if the user has 
 re-entered the form so I can do my validation checks.
 
 Is there a disadvantage to this approach?

it is more secure to store that in a session variable instead of a
hidden field

greets
Zoltán Németh

 
 Thank you...
 

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



Re: [PHP] PHP URL issues

2007-03-12 Thread Németh Zoltán
2007. 03. 12, hétfő keltezéssel 05.50-kor Don Don ezt írta:
 I've got the following url rewriting problem.

   on page 1 i've got this

   p a href='page1.php?messageId=$tmpForumuserId=$user_id' See /a/p

is this all within something like an echo statement with  marks?
otherwise the values might not display correctly


   and on page 2 i've got this

   $messageID = $_REQUEST[messageId];
 $userID = $_REQUEST[userId];

why use $_REQUEST? for this $_GET should be okay, and less confusing

hope that helps
Zoltán Németh


   
 when i check to see the values of these variables its says its empty, but 
 when i place my cursor on the link in
 page 1 i can see both variables being show with their values in the browser.  
 But on page 2 i cant get the values
 Something seems wrong perharps ?

   Cheers
 
  
 -
 Now that's room service! Choose from over 150,000 hotels 
 in 45,000 destinations on Yahoo! Travel to find your fit.

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



RE: [PHP] Using array_search I get error

2007-03-12 Thread Németh Zoltán
2007. 03. 12, hétfő keltezéssel 09.21-kor Richard Kurth ezt írta:
  
 -Original Message-
 From: Tijnema ! [mailto:[EMAIL PROTECTED] 
 Sent: Monday, March 12, 2007 1:16 AM
 To: Richard Kurth
 Cc: Stut; php-general@lists.php.net
 Subject: Re: [PHP] Using array_search I get error
 
 On 3/12/07, Richard Kurth [EMAIL PROTECTED] wrote:
 
 
 
  Richard Kurth wrote:
  
  
   -Original Message-
   From: Stut [mailto:[EMAIL PROTECTED]
   Sent: Sunday, March 11, 2007 2:53 PM
   To: Richard Kurth
   Cc: php-general@lists.php.net
   Subject: Re: [PHP] Using array_search I get error
  
   Richard Kurth wrote:
   This array comes from  $_REQUEST of all data submitted
  
   $array='Array ( [id] = 17 [takeaction] = saveCustomFields [notes] 
   =
   -- Feb 4, 2007 @ 9:16 PM --fdsfdsfsdfdsfsfsfds -- Feb 4, 2007 @ 
   9:21 PM --fdfdsfsdffsd -- February 11, 2007, @ 9:31 PM -- This is a 
   tes -- February 14, 2007, @ 10:10 PM -- jhafjhfa afjahfajfhda 
   kasjdaksdhADSKJL [firstname] = NANCY [lastname] = ADKINS  
   [phone2] =
   [address1] = 25 ALWARD CT.
   [address2] = [city] = MARTINSVILLE [State] = AK [other] = [zip] 
   =
   24112 [country] = US [date18] = 03-13-2007 [text19] = test1 
   [text20] = [rating] = 0 [status] = Active )';  when I use 
   array_search to find date18
  
   $key = array_search('date18', $array);  // $key = 1;
  
   I get Wrong datatype for second argument How come the array is 
   wrong datatype isn't a array an array or am I using this wrong
  
   $array is a string, and array_search is expecting an array, so it's
  correct.
   Where did you get that array?
  
   -Stut
  
   This array comes from  $_REQUEST of all data submitted from a form
 
  Yeah, you said that in your first post. What I meant was where did it 
  come from?
 
  What you have there is the output from print_r($_REQUEST). How exactly 
  are you getting that string? Why are you creating it as a literal 
  array rather than using $_REQUEST directly?
 
  What you have there is the output from print_r($_REQUEST). How exactly 
  are you getting that string? Why are you creating it as a literal 
  array rather than using $_REQUEST directly?
 
  -Stut
 
  This is for saving data from custom fields created by the user I don't 
  know what they are named so I can't use $_REQUEST[name] to pull them 
  from the array.
  I am submitting a form to a script that will search thru the array and 
  find the fields that are in there date18 text19 text20 these are user 
  custom fields that I do not know what they are named. I what to 
  compare what is in the array  with a database table and if they match 
  then save the information in the array for that item to the database.
 
 
 Somehow you managed to get an array become a string..., if your are using
 $_REQUEST directly, or a copy of it, then you should have an array.
 I also don't really understand what you are trying to do, as 'date18' is a
 key, not a value, and array_search searches vor values, in this case it
 searches for the value 'date18' and then try's to get the key of that value,
 but date18 is a key, so it would probably return false.
 
 Then how would I search for the Key date18 and once I find it how would I
 get the value of that key.

$array['date18']

  Because even if I change the date18 to it's value
 03-13-2007 I still get the error Wrong datatype for second argument. I have
 also tried print_r(array_keys($array)); and I get The first argument should
 be an array.

first, you should make clear what array you use where
what is the output of var_dump($_REQUEST) ?
and what is the output of var_dump($array) ?
if there is difference between the above two, then there might be some
bug in your code where you create $array from $_REQUEST

hope that helps
Zoltán Németh

 
 
  
 

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



Re: [PHP] FW: looking for two remote functions

2007-03-10 Thread Németh Zoltán
I'm afraid I don't understand what you want. The size of a file is its
size in bytes, that is its size on the disk. So what else?

greets
Zoltán Németh

2007. 03. 10, szombat keltezéssel 06.07-kor Riyadh S. Alshaeiq ezt írta:
 Thank you Mickey, but I have already looked in there and the function posted
 in the notes is working just fine for getting the size on disk which I am
 not interested in..
 
 Riyadh
 
 -Original Message-
 From: Mikey [mailto:[EMAIL PROTECTED] 
 Sent: 9/Mar/2007 2:57 PM
 To: php-general@lists.php.net
 Subject: Re: looking for two remote functions
 
 Riyadh S. Alshaeiq wrote:
  Hello everybody,
  
   I am looking for an HTTP function for getting remote filesizes. Keeping
 in
  mind that I am NOT interested in getting the size on disk figure, I need
  the actual size of the files when downloaded to a local machine. Please
 let
  me know if there are any..
  
  Another thing, I also need a remote function that gets the created date
 and
  last modified separately, if possible..
  
  Best regards
  
   
  
  
 
 Try looking here:
 
 http://uk.php.net/manual/en/function.filesize.php
 
 If the function itself isn't of use to you, look further down in the 
 notes and I am sure you will find something useful.
 
 Mikey
 

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



Re: [PHP] How to verify Folder Existence?

2007-03-09 Thread Németh Zoltán
2007. 03. 9, péntek keltezéssel 16.48-kor Helder Lopes ezt írta:
 Hi people,
 
 how to verify if folder exists in server??

http://hu2.php.net/manual/en/function.is-dir.php

greets
Zoltán Németh

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



Re: [PHP] Javascript and PHP interaction

2007-03-08 Thread Németh Zoltán
2007. 03. 8, csütörtök keltezéssel 09.14-kor Alain Roger ezt írta:
 Hi,
 
 I would like to know if there is a way how PHP code can extract from
 ElementID some property values.
 
 for example, i have the following PHP page :
 
 ?php
 print div class='maindiv' id='id_maindiv'my main div/div;
 $new_Width = somefunction();
 print div class='childdiv' id='id_childdiv'
 style='width:.$new_Width.px;'my child div/div;
 ?
 in my CSS file (which is link to my HTML page), i have :
 
 .maindiv
 {
  width : 300px;
  height : 400px;
  background-color : #EEBBEE;
 }
 .childdiv
 {
  background-color : #BB;
 }
 
 my PHP code should be able :
 - to extract the width of id_maindiv ID (so to get 300px) and to reduce it
 by 50px
 
 the problem is that i tried with Javascript and if the property
 (style:width) is not define DIRECTLY to HTML code (but only in CSS file),
 the javascript is not able to return the value (but only 'undefined').
 So i would like to know if PHP could help me in this way ?

I think you can not do it with PHP.
But you can do it with javascript. you have to read the offsetWidth
property of the object, then set it's style.width like

if (document.getElementById('whatever').offsetWidth  300) {
document.getElementById('whatever').style.width = 300;
}

hope that helps
Zoltán Németh

 
 thanks a lot,
 

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



Re: [PHP] Can i use DateTime Object with an timestamp as reference instead of an formated string.

2007-03-07 Thread Németh Zoltán
2007. 03. 7, szerda keltezéssel 12.58-kor Mathijs ezt írta:
 Hello there,
 
 I Use timestamps for logging etc..
 But i need this timestamp to let is show the right time in different 
 timezones.
 
 Now i wanted to use DateTime object, but it seems it needs a string as 
 reference, so i can't use a timestamp to re-generate that time.
 
 How can i fix this?

I think
http://hu2.php.net/manual/hu/function.strftime.php
should be okay

greets
Zoltán Németh

 
 Thx in advance.
 

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



Re: [PHP] Textarea update problem

2007-03-07 Thread Németh Zoltán
2007. 03. 7, szerda keltezéssel 16.28-kor Delta Storm ezt írta:
 [EMAIL PROTECTED] wrote:
  is there a question here, or are you asking us to write the script for
  you? 
 
- Rick
 
 
   Original Message 

  Date: Wednesday, March 07, 2007 01:54:04 PM +0100
  From: Delta Storm [EMAIL PROTECTED]
  To: php-general@lists.php.net
  Subject: [PHP] Textarea update problem
 
  Hi,
 
  I'd like to thank everybody who have helped me till now. All your
  advices were very helpfull... :)
 
  But I have a problem again
 
  I need to build a script which will have have the following functions:
 
  1.Be able to select 3 columns from a MySQL database(idnetify the
  columns by ID) and put the column contents into 3 textarea objects.
  (for example title,Text1,Text2 each into i textarea).
 
  2.Edit and MySQL update the textarea contents
 
 
  And all in one script.
 
  The script has a $id = $_GET['id'] variable which holds the
  information about the certain table id.
 
  
 
  -- End Original Message --
 
 
 

 This is the script, I have dealt with both problems but when I click on
 the update button (submit button) i get an error msg:
 
 
   Access forbidden!
 
 You don't have permission to access the requested object. It is either
 read-protected or not readable by the server.
 
 If you think this is a server error, please contact the webmaster
 mailto:[EMAIL PROTECTED].
 
 
 Error 403
 
 localhost /
 03/07/07 16:17:37
 Apache/2.2.3 (Win32) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8d
 mod_autoindex_color PHP/5.2.0
 
 
 The user name and pass for the MySQL server are 100% correct.
 
 It reads out the data from the database into the textarea object but
 when I click the update button I get that msg.
 
 Thank you! :)
 
 
 
 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml; lang=hr
 head
 meta http-equiv=Content-Type content=text/html; charset=utf-8
 meta http-equiv=Content-Language content=hr
 titleUPDATE news and article items/title
 link rel=stylesheet type=text/css href=style.css /
 /head
 body
 
 
 ?php
 
 $id = $_GET['id'];
 include(authenticate.php);
 $link = mysql_connect(localhost,$admin,$pass) or die (Could
 not connect to database);
 
 mysql_select_db(europe) or die (Could not select database);
 
 mysql_query(set names utf8);
 $selResult = mysql_query(select title,sText,fText from news where
 id='$id');
 
 if (mysql_num_rows($selResult)  0)
 {
 while ($row = mysql_fetch_array($selResult))
 {

you don't need that if above, as the while loop will not start at all if
there is no rows in the result

 if (!$_POST[submit])
 {
 echo 'table border=0 cellspacing=0 cellpadding=0
 align=center';
 echo tr;
 echo 'td colspan=2';
 echo form action='?php echo
 $_SERVER[PHP_SELF] ?' method=post;
 echo input type=text size=180 name=title
 value= . $row['title'] .;
 echo /td;
 echo /tr;
 echo tr;
 echo td;
 echo h2sText/h2;
 echo 'textarea cols=65 rows=30 name=sText';
 echo $row['sText'];
 echo /textarea;
 echo '/td
 td
 h2fText/h2
 textarea cols=65 rows=30 name=fText ';
 echo $row['fText'];
 echo '/textarea
 /td
 /tr
 tr
 td colspan=2 align=center
 input type=submit value=UPDATE name=submit
 /form
 /td
 /tr
 /table';
 }
 else
 {
 $title = ($_POST['title']);
 $sText = ($_POST['sText']);
 $fText = ($_POST['fText']);

why are you putting those $_POST values in brackets?
it should be
$title = $_POST['title'];

btw, you should check those values before passing them to the database
because of security reasons

 
 $query = update news set title='$title',
 sText='$sText', fText='$fText' where id='$id';
 
 $result = mysql_query($query) or die (could not process
 query : $query . mysql_error());

here you don't need $result I think, you could just use
mysql_query($query) or die (could not process query : $query .
mysql_error());

 
 if ($result)
 {

and you don't have to check for $result, as the die statement would
cause your script to stop executing if there was an error, so if it gets
here you might just print out everything is ok

 echo Data updated succesfully;
 echo 

Re: [PHP] php and javascript error

2007-03-07 Thread Németh Zoltán
2007. 03. 7, szerda keltezéssel 10.59-kor Ed Curtis ezt írta:
 I've just run into this problem this morning
 
 a href=# onclick=javascript:window.open('web_forward.php?address=? 
 echo $web_url; ?agent=? echo $agent; ?real_company_name=? echo 
 $real_company_name; ?', 'Web Site');
 
 This produces an Error on Page in IE 7, but works perfectly in Firefox 
 and Netscape.
 
 I have several other javascript calls on the page where this call 
 resides and all of them work perfectly except for this one. Does this 
 error occur because I'm sending the variables to another script that 
 does some logging then forwards the user to the URL or is it just a IE 
 quirk?
 

I'm almost sure it has nothing to do with php
rather javascript, and maybe microsoft's special javascript
interpretations...

greets
Zoltán Németh

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



Re: [PHP] how to access private property?

2007-03-06 Thread Németh Zoltán
2007. 03. 6, kedd keltezéssel 20.08-kor Nicholas Yim ezt írta:
 Hello Everyone,
 
 [code]
 class MyClass {
   private $prop;
 }
 $obj=new MyClass;
 [/code]
 
 is there anyway to read and write MyClass-prop, except serialize

write methods to do this

class MyClass {
private $prop;

function getProp() {
return $this-prop;
}

function setProp($val) {
$this-prop = $val;
}
}

greets
Zoltán Németh

 
 Best regards, 
   
 Nicholas Yim
 [EMAIL PROTECTED]
 2007-03-06
 

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



Re: [PHP] module and access rights

2007-03-05 Thread Németh Zoltán
2007. 03. 5, hétfő keltezéssel 15.05-kor Alain Roger ezt írta:
 I already started to use SSL, but i do not understand how to keep it
 running.
 
 I mean after user has been authenticated and authorized to go further, all
 next web pages are opened using PHP location(https://...); command.
 however, it does not certify that it can not be faked by just typing into
 browser address bar https://another_webpage.php
 
 for example :
 1.my login page is called index.php and it is accessible only by https. if
 user type http://../index.php, the index.php redirect itself to
 https://.../index.php.
 2. user type logon and password.
 3. application control it with information stored into DB and authorize user
 to go further, so a session is created and user is redirected to
 https://.../welcome.php
 
 what avoid hacker to directly type https://.../welcome.php ?
 how to be sure that it works correctly as in my example ?

you should check the session settings in the beginning of welcome.php
if session is not set correctly redirect to index.php instead

greets
Zoltán Németh

 
 thanks a lot,
 
 Al.
 
 On 3/4/07, Stut [EMAIL PROTECTED] wrote:
 
  Tijnema ! wrote:
   On 3/4/07, Stut [EMAIL PROTECTED] wrote:
  
   Tijnema ! wrote:
Give your server a unique ID, and add that to your check string lets
   say
so you store in your cookie the username and the check string.
   
example
$user = tijnema;
$server_unique_key =
w#$#%#54dfa4vf4w5$2!@@$w#$%23%25%2354dfa4vf4w5$2!@@$
;
$check_string = md5($server_unique_key.$user.$server_unqie_key);
   
and check that each time the user does an action.
  
   How, exactly, is that any more secure than a standard session
  identifier?
  
   While it's good to worry about security, adding pointless activity such
   as this to every request is not going to help. Anything you do is going
   to involve some piece of data being transferred from client to server,
   and can therefore be faked/shared by the client. Get over it.
  
   -Stut
  
   It is ofcourse possible to share it to another client, but when
  combining
   this with the IP address. This means it can only be used in the same
  LAN.
   To get to the point, using this means you cannot simply fake the
   username in
   the cookie, which is possible else. session identifiers can be faked
  too.
 
  As I said in another email, you *cannot* use the IP address for any
  verification without causing usability issues. It is perfectly
  legitimate for sequential requests from any given user to come from
  different IP addresses. The biggest user of systems like this is AOL,
  and that's a fairly large user base you may want to avoid annoying by
  insisting that they login for every other request.
 
  In short, this issue has been discussed to death, not only by the PHP
  community but also by the web community at large. If you're really
  paranoid, use SSL to secure all data transferred, but just accept that
  it's possible that a session may be hijacked. However, unless you're a
  bank, is anyone really going to bother?
 
  -Stut
 
   On 3/4/07, Alain Roger [EMAIL PROTECTED] wrote:
   
Ok, but i would be very glad to know how can i REALLY authenticate
  the
user.
for example, user is logged, so i have in the cookie his login name.
   
how can i be sure that it's the same user and not some hacker who
   hacked
the cookie and the session ?
what should be checked and where those data should be stored ?
   
because i can store in DB the sessionID, and check it to every DB
   request
user does...but a sessionID can be easily fake.
   
So what should I do ?
   
Al.
   
On 3/4/07, Tijnema ! [EMAIL PROTECTED] wrote:

 On 3/4/07, Stut [EMAIL PROTECTED] wrote:
 
  Alain Roger wrote:
   I would like to implement a module access rights in my web
 application.
   Basically after authentication and authorization. Logged user
   has
   a
   particular profile which allow him to have access to some
   part of
 the
  web
   application.
  
   after reading the security guide from *php*sec.org webpage,
  i'm
 confused
   regarding how to store user login and password.
   I mean the encrypted password stored in database is compared
  to
  encrypted
   password that user type.
  
   But where to store login and password once user is logged ?
  
   when i read the security guide it seems that it is not secured
 enough to
   store them in cookies or in sessions data...
   both can be hacked... So what is the best solution ?
  
   i will use those stored data to check if logged user can have
access
 to
  a
   particular part of the web application.
  
   What is your point of view in such domain ?
 
  Ok, once the user has logged in there is no need to store the
 password.
  Simply store the username or other user details (but not the

Re: [PHP] problems with thumbnail image

2007-03-02 Thread Németh Zoltán
2007. 03. 2, péntek keltezéssel 13.56-kor Punit Neb ezt írta:
 hello,
 
 I am a newbie trying to create on the fly thumbnail images on a debian sarge 
 system with PHP Version 4.3.9-1.
 
 The following code is used
 ?
 function thumbnail_img($photo_img_name)
 {
 $percent = 0.5;
  list($width, $height) = getimagesize($photo_img_name);
  $newwidth = $width * $percent;
  $newheight = $height * $percent;
  $thumb = imagecreatetruecolor($newwidth, $newheight);
  $source = imagecreatefrompng($photo_img_name);
  imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, 
 $height);
 return imagepng($thumb);
 }
 
  print 'HTML';
  print 'HEAD';
  print 'META HTTP-EQUIV=Pragma CONTENT=no-cache';
  print 'TITLEImage/TITLE';
  print '/HEAD';
 print 'body';
 //image file name
  $photo_img_name='./photos/1.png';
 //display original image
  print 'IMG SRC='.$photo_img_name.' border=1';
 //thumbnail image
 print 'IMG SRC='.thumbnail_img($photo_img_name).' border=1';
 print '/body';
 print '/html';
 ?
 
 The original image gets displayed correctly. But in place of the thumbnail 
 image i get loads of junk text data. I guess the hmtl tags are all in order 
 as the original image is perfectly displayed.
 
 What have i missed. Any comments, help etc will be appreciated.

either create a filename for the thumbnail and add it to the imagepng()
call as second parameter and reference it in the thumbnail img tag

or put the thumbnail creation in a separate file, say thumbnail.php
then the img tag should be like

echo img src=\thumbnail.php?img= . $photo_img_name . \;

and the thumbnail.php should send out some content-type header e.g.
Content-Type: image/png and then call your function like

echo thumbnail_img($_GET['img']);

hope that helps
Zoltán Németh

 
 regards
 Punit Neb
 

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



Re: Fw: [PHP] Help! I cannot send e-mail to your mail groups

2007-03-02 Thread Németh Zoltán
2007. 03. 2, péntek keltezéssel 13.42-kor Haydar Tuna ezt írta:
 Hello Again,
If I send e-mail to your group, I have an error message below. There 
 aren't any network problems. I try to send mail different places but I get 
 same error message. May be, you can restrict Turkish IP address blocks 
 becuase I haven't see any message from Turkey recently in your mail lists. 
 May be, you can restrict my mail address in your group. I'm writing a book 
 about PHP and I love helping any people about PHP on the world. Can you help 
 me in this issuse? What is the problem? and this problem has been for 2 
 weeks. 2 weeks ago, I could send mail your groups easily.
   I'm looking forward from hear you.
 
 
 Error Message:
 Outlook Express could not post your message.  Subject 'Re: PHP and cron', 
 Account: 'news.php.net', Server: 'news.php.net', Protocol: NNTP, Port: 119, 
 Secure(SSL): No, Socket Error: 10051, Error Number: 0x800CCC0E

hmm I must admit I don't know anything about using NNTP on
news.php.net...
I simply send all mails to php-general@lists.php.net (with SMTP) and no
problem...
I subscribed to the list at http://www.php.net/mailing-lists.php and
sent back a confirmation email and that's all...

greets
Zoltán Németh

 
 
 - Original Message - 
 From: Németh Zoltán [EMAIL PROTECTED]
 To: Haydar Tuna [EMAIL PROTECTED]
 Cc: php-general@lists.php.net
 Sent: Friday, March 02, 2007 12:19 PM
 Subject: Re: [PHP] Help! I cannot send e-mail to your mail groups
 
 
 
 
 
 2007. 03. 2, péntek keltezéssel 09.57-kor Haydar Tuna ezt írta:
  Hello,
  I have been Linux user for 7 years and I have been membership of Linux
  Community group for 3 years in Turkey. As you know, linux users share all 
  of
  experiences and knownledges and I'm writing a book about PHP. I'm a PHP
  professional for this reason I want to help any people on the world but I
  haven't send a message for two days. I got an abuse e-mail two times but
  there isn't any problem my mails that I have send your mail group. I want 
  to
  send e-mail your mail group again, I want to help any people on the world
  again if possible. Can you help me?
  I'm looking forward here you.
 
 
 It seems to me you can send mail to the list, as I have received it ;)
 
 (or maybe I misunderstood your problem?)
 
 greets
 Zoltán Németh
 
 
 

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



[PHP] Re: Audio CAPTCHA

2007-02-28 Thread Németh Zoltán
2007. 02. 27, kedd keltezéssel 14.15-kor tedd ezt írta:
 Németh:

(call me Zoltán please as that's my first name ;) )

 
 As you  know, I'm having more problems with my 
 CAPTCHA experiment, so back to basics. (as my mum 
 used to say No good deed goes unpunished.
 
 I need your review. All you have to do is to test 
 if the following links produce sound as indicated 
 in the browsers you have?
 
 Link one:
 
 http://www.sperling.com/a/a1/index.php
 
 Clicking Zero should produce the sound Zero 
 and leave your browser cold -- it will probably 
 leave it showing a player of some sort.

XP/IE7: opens up windows media player, plays 0.au which says Zero
Linux/Firefox: opens 0.au with /usr/lib/mime/playaudio, sound is only
noise

 
 Link two:
 
 http://www.sperling.com/a/a1/index1.php
 
 Clicking Zero should produce the sound Zero 
 and then bring your browser back to the original 
 page.

XP/IE7: works fine
Linux/Firefox: tells me I have to install some plugin, then redirects to
the original page

 
 Link three:
 
 http://www.sperling.com/a/a1/index2.php
 
 Clicking Zero should produce the sound Zero 
 and then One and then bring your browser back 
 to the original page.

XP/IE7: works fine
Linux/Firefox: redirects ok, but needs plugin as above


it's probably an issue that it needs plugin to play .au files, I am not
an expert in browser audio ;)
if so, please tell me what plugin to install and I can try again with
that

hope that helps
Zoltán Németh

 
 For me, all the above sounds work, except for 
 Opera 9.0 for the Mac -- it works for Link one 
 but does not work for Link two and Link three.
 
 IE 5.2 for the Mac needs a refresh to jump start 
 it. In other words, the very first time for link 
 two and link three I have to do it twice to 
 get it to work.
 
 Take your time -- no rush on this. I just need to 
 know what browsers work and which don't.
 
 Thanks for your help.
 
 tedd

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



Re: [PHP] ID problem

2007-02-28 Thread Németh Zoltán
2007. 02. 28, szerda keltezéssel 10.24-kor Delta Storm ezt írta:
 Hi,
 
 I'm building an CMS system (for practice and experience :)).
 
 And of course like many times before I have encountered a problem.
 
 The problem is:
 
 I have a index.php that takes the news from the database and publishes 
 them. And by the end of every news on index.php I have a link ('a 
 href=showfullnews.php?id=$idShow full news/a')
 
 That leads to a page that has the full news.
 
 At the beginning of showfullnews i have a variable ( $id = $_GET['id']; )
 
 And in index.php I have the following code:
 
 while ($row = mysql_fetch_array($result))
 {
   $id= $row['id'];
 etc...
 }
 
 In the database I have two tables one for a short version of news for 
 index.php and another for fullNews.
 
 In full news the query is: select title,newsFull from fullnews where 
 id='$id';
 
 In the database i'm 100% sure there is a id = 1 in both rows.
 
 I really dont know what is the problem.

ehh, what is the problem? you didn't tell.
I guess that the fullnews page don't display the news correctly, right?
if so, please show us the code of that page

btw, why are you using two tables?
everything could be put in one with fields like title,shorttext,fulltext
and so on...
and then there would be only one id for one article, which could reduce
confusion and eliminate some possible problems

hope that helps
Zoltán Németh

 Thank you very much!
 

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



Re: [PHP] audio CAPTCHA - was Combining sound files

2007-02-27 Thread Németh Zoltán
2007. 02. 26, hétfő keltezéssel 12.06-kor tedd ezt írta:
 Hi:
 
 Dumb error, please try again:
 
 http://www.sperling.com/a/c
 
 Plus, the point is to click the Speak CAPTCHA button and see if it speaks.

XP/IE7: the error message is gone, but button does nothing

Linux/Firefox: speak button redirects through s1.php-s5.php, they all
show the following error (or similar) :

Notice: Undefined index: captcha
in /home/httpd/vhosts/sperling.com/httpdocs/a/c/a.php on line 19

and Firefox tells me I need to install some missing plugin for the
content... (which may be true ;) )

greets
Zoltán Németh

 
 Thanks,
 
 tedd
 
 
 I got the same notice on the top of the page.
 besides that, when clicking the speak captcha button nothing happens
 
 greets
 Zoltán Németh
 
 2007. 02. 26, hétf‘ keltezéssel 08.12-kor benifactor ezt írta:
   tried, and failed.  got this error:
 
   Notice: Undefined variable: captcha in
   /home/httpd/vhosts/sperling.com/httpdocs/a/c/index.php on line 29
 
   and no captcha was displayed.
   - Original Message -
   From: tedd [EMAIL PROTECTED]
   To: php-general@lists.php.net
   Sent: Monday, February 26, 2007 8:04 AM
   Subject: [PHP] audio CAPTCHA - was Combining sound files
 
 
Hi gang:
   
Thanks for all the advice regarding combining sound files. I shall look
into all of it.
   
In the meantime, I am trying a different solution and would appreciate
your review of the technique:
   
http://www.sperling.com/a/c/
   
The point of this experiment is to speak the numbers required for a
CAPTCHA protection scheme.
   
I've had a few blind users report that this works for them, but
considering all the different platforms and talents on this list, I
thought that I would ask Does this work (i.e., speak the numbers) for
you? The numbers to be spoken are printed on the top of this page for
your notice.
   
If you would be so kind, please review, provide me your platform type 
  and
success.
   
Thanks.
   
tedd
   
PS: What does this have to do with php? Well... a good deal of the code 
  is
php and a mix of a bunch of other stuff (we don't live in a vacuum) -- 
  so
please permit me this indulgence.
   
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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



Re: [PHP] PHP shell_exec

2007-02-27 Thread Németh Zoltán
2007. 02. 27, kedd keltezéssel 13.17-kor h ezt írta:
 Hi 
 
 I have been using the shell_exec command to perform several server queries 
 quite succesfully i.e. analysing files systems by gettin ginformation 
 returned by df -kP (shell_exec('df -kP')).  do any of you guts know if it is 
 possible to target a command like this on another server? 
 
 So from server A where I am running a web app, needs to run the 
 shell_exec('df -kP') on server B, which also has php installed, so that i can 
 display the results in my web app on server A.  Hope that makes sense!
 
 Also, how would i fopen a file such as /proc/cpuinfo on Server B from Server 
 A.
 
 Any help greatly appreciated
 
 Regards
 
 Ade

maybe you need ssh2_exec

http://hu.php.net/manual/hu/function.ssh2-exec.php

hope that helps
Zoltán Németh

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



Re: [PHP] RE: [PHP-DB] NOT NULL query

2007-02-26 Thread Németh Zoltán
SELECT * FROM table WHERE NOT ISNULL(field_3)

(in MySQL)

greets
Zoltán Németh

2007. 02. 26, hétfő keltezéssel 15.21-kor Steven Macintyre ezt írta:
 SELECT * FROM table WHERE field_3 IS NOT NULL
 
  -Original Message-
  From: Ron Piggott [mailto:[EMAIL PROTECTED]
  Sent: 26 February 2007 02:56 PM
  To: PHP DB
  Subject: [PHP-DB] NOT NULL query
  
  Is it possible to do a SELECT query where field_3 isn't null?  What
  would the syntax look like?  Ron
 

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



Re: [PHP] audio CAPTCHA - was Combining sound files

2007-02-26 Thread Németh Zoltán
I got the same notice on the top of the page.
besides that, when clicking the speak captcha button nothing happens

greets
Zoltán Németh

2007. 02. 26, hétfő keltezéssel 08.12-kor benifactor ezt írta:
 tried, and failed.  got this error:
 
 Notice: Undefined variable: captcha in 
 /home/httpd/vhosts/sperling.com/httpdocs/a/c/index.php on line 29
 
 and no captcha was displayed.
 - Original Message - 
 From: tedd [EMAIL PROTECTED]
 To: php-general@lists.php.net
 Sent: Monday, February 26, 2007 8:04 AM
 Subject: [PHP] audio CAPTCHA - was Combining sound files
 
 
  Hi gang:
 
  Thanks for all the advice regarding combining sound files. I shall look 
  into all of it.
 
  In the meantime, I am trying a different solution and would appreciate 
  your review of the technique:
 
  http://www.sperling.com/a/c/
 
  The point of this experiment is to speak the numbers required for a 
  CAPTCHA protection scheme.
 
  I've had a few blind users report that this works for them, but 
  considering all the different platforms and talents on this list, I 
  thought that I would ask Does this work (i.e., speak the numbers) for 
  you? The numbers to be spoken are printed on the top of this page for 
  your notice.
 
  If you would be so kind, please review, provide me your platform type and 
  success.
 
  Thanks.
 
  tedd
 
  PS: What does this have to do with php? Well... a good deal of the code is 
  php and a mix of a bunch of other stuff (we don't live in a vacuum) -- so 
  please permit me this indulgence.
 
  -- 
  ---
  http://sperling.com  http://ancientstones.com  http://earthstones.com
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
 

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



Re: [PHP] Multiple Submit

2007-02-26 Thread Németh Zoltán
2007. 02. 26, hétfő keltezéssel 11.23-kor Dan Shirah ezt írta:
 Hello all,
 
 I have a page that has multiple submits on it.  One submit is within my
 javascriptfor form checking, the other submit is a button used to populate
 all customer information if an order ID is entered.
 
 Problem:  I cannot get the two to coincide at the same time.  They both use
 the submit function to send the data to the same page instead of their
 unique individual pages.
 
 Code:  Below are the code snipets.
 
 
 ?php echo ?xml version=\1.0\ encoding=\iso-8859-1\?.; ?
 !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN 
 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;
 html xmlns=http://www.w3.org/1999/xhtml;
 HEAD
 script language=JavaScript
 !--
 
 function closeThis() {
  if (window.confirm(Are you sure you want to cancel the payment request?))
 
   this.window.close();
 }
 
 *function checkForm() {*
 
  // ** START **
   if (inputForm.cc_phone_number.value == ) {
 alert( Please enter a phone number. );
 inputForm.cc_phone_number.focus();
 return;
   }
 
if (inputForm.receipt.value == ) {
 alert( Please select whether or not a receipt was requested. );
 inputForm.phone_number.focus();
 return;
   }
 
   if (inputForm.cc_first_name.value == ) {
 alert( Please enter a first name. );
 inputForm.cc_first_name.focus();
 return;
   }
 
   if (inputForm.cc_last_name.value == ) {
 alert( Please enter a last name. );
 inputForm.cc_last_name.focus();
 return;
   }
 
   if (!(document.inputForm.cc_comments.value ==)) {
   if (document.inputForm.cc_comments.value.length  250)
   {
 alert(The Comments must be less than 250 characters.\nIt is currently 
 + document.inputForm.window_name.value.length +  characters.);
document.inputForm.window_name.focus();
return;
   }
  }
 * document.inputForm.submit();*
 }
 
 //--
 /script
 LINK rel=stylesheet type=text/css href=../../CSS/background.css
 /head
 body
 *form name=inputForm action=save.php method=post
 enctype=multipart/form-data*
 table align=center border=0 cellpadding=0 cellspacing=0
 width=680
  tr
 td height=13 align=center class=tblheadstrongCredit Card
 Information/strong/td
  /tr
 
 *// LOTS OF FORM DATA REMOVED FOR EMAIL LENGTH*
 
 table align=center border=0 cellpadding=0 cellspacing=0
 width=680
 tr
 *This is the other submit that I need to go a page other than the one
 specified in the form*
 *td width=62a href=DeferredPayment3.phpinput type=submit
 name=retrieve value=Retrieve/a/td*
   td width=8/td

AFAIK an input within an a tag will not work ever
why don't you do it the way you do the other submit button? (with
javascript submit();)

greets
Zoltán Németh

 /tr
 /table
 br /
 br /
 table align=center border=0 cellpadding=0 cellspacing=0
 width=680
  tr
 *Call to the javascript checkForm function*
  *td width=64 align=lefta href=javascript:checkForm()
 title=SaveSave/a/td
 * td width=616 align=lefta href=javascript:closeThis()
 title=CloseClose/a/td
  /tr
 /table
 /form
 /body
 /html

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



Re: [PHP] audio CAPTCHA - was Combining sound files

2007-02-26 Thread Németh Zoltán
2007. 02. 26, hétfő keltezéssel 08.26-kor benifactor ezt írta:
 i was just trying again, and entered 406 via keyboard and pressed 
 submit, and it said i was successful, then i pressed back on my browser and 
 no longer had the error. it displayed the captcha at the top of the page 
 where the error was. 
 

yeah, if you enter anything (even incorrect), the captcha gets displayed
instead of the error message.

but the speak captcha button still does nothing

greets
Zoltán Németh

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



Re: [PHP] Option Value

2007-02-23 Thread Németh Zoltán
2007. 02. 23, péntek keltezéssel 10.10-kor Dan Shirah ezt írta:
 On my form I have several drop down menus.  They all work and display the
 corrent values.  However, I would like the initial display of the form to
 show each dropdown as blank.
 
 
 $q_status = SELECT * FROM status_codes ORDER BY status_description;
  $r_status = mssql_query($q_status) or die(mssql_error());
   while ($rec_status = mssql_fetch_assoc($r_status)) $status[] =
 $rec_status;
 
  foreach ($status as $s)
   {
 if ($s['status_code'] == $_POST['status'])
   echo OPTION value=\{$s['status_code']}\
 SELECTED{$s['status_description']}/OPTION\n;
 else
   echo OPTION
 value=\{$s['status_code']}\{$s['status_description']}/OPTION\n;
   }
 
 Any suggestions on how to make my initial display of the field blank without
 having to add a blank row to my table?

echo a blank option before the others

greets
Zoltán Németh

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



Re: [PHP] Problems processing UNIX timestamps in events directory

2007-02-21 Thread Németh Zoltán
2007. 02. 21, szerda keltezéssel 09.33-kor Dave Goodchild ezt írta:
 Thanks all for your input - you're all correct, I don't really need to use
 timestamps as I am only interested in dates so will be reworking the app to
 use dates only. I still need to generate sequences of dates and really don't
 want to deal with DST, so my question is: can I add days to dates without
 converting to timestamp and adding 86400 for example. If I can it will make
 things much simpler. I am talking about doing this dynamically with php
 rather than at database level. Many thanks in advance, I will also start
 googling...
 
 

of course you can

use something like this:

$newdate = date(Y-m-d, mktime(0, 0, 0, $orig_month, $orig_day + 1,
$orig_year));

greets
Zoltán Németh

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



Re: [PHP] New Menu Bar - Can people test it for me?

2007-02-21 Thread Németh Zoltán
works on linux/firefox and xp/ie7

greets
Zoltán Németh

2007. 02. 21, szerda keltezéssel 12.12-kor Scott Gunn ezt írta:
 All,
 
 http://www.thebigspider.co.uk/test/menu.html
 
 I'm going to write some php code which will build this menu from an XML 
 file.
 
 Before I do, I want to know what sort of browser compatibility it has? could 
 you guys test it and let me know if it worked ok and looked like the preview 
 picture?
 
 If your on IE7 or Firefox2 and it works please don't email back as I know 
 these work fine.
 
 Best Regards
 Scott. 
 

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



Re: [PHP] How to call image from mySql to php file

2007-02-21 Thread Németh Zoltán
2007. 02. 21, szerda keltezéssel 06.26-kor Chris Carter ezt írta:
 I have a field in database called logos which has one value
 images/logos/some_logo.jpg
 
 In my php I am trying to call it in my php file as image. With this code.
 
  $sno = $_REQUEST['sno'];
 
 $query=SELECT logos FROM table WHERE sno = '$sno';

be aware of sql injection. check the data before putting it into a
query.
and also, I do not recommend using $_REQUEST, it is better to use
$_POST/$_GET instead

 
 $result=mysql_query($query);
 $num=mysql_numrows($result);

this is

mysql_num_rows($result);

correctly

 
 mysql_close();
 $logos=mysql_result($result,$i,logos);

I recommend mysql_fetch_row or mysql_fetch_assoc instead
http://hu.php.net/manual/en/function.mysql-fetch-row.php
http://hu.php.net/manual/en/function.mysql-fetch-assoc.php

if you have several rows in the result then do something like

while ($row = mysql_fetch_row($result)) {
// here you have a filename in $row[0]
// do whatever you want to do with it, for example:
echo pimg src=\ . $row[0] . \/p;
}

hope that helps
Zoltán Németh

 
 echo 
 div
 p $logos /p



 /div;
 
 ?/div
 
 But getting errors. What is the way to call image in php file from the
 database. I know that this is a very basic question but first time for me. I
 ignored this in the begining but now its right infront of me.
 
 Please advice.
 
 -- 
 View this message in context: 
 http://www.nabble.com/How-to-call-image-from-mySql-to-php-file-tf3267012.html#a9081704
 Sent from the PHP - General mailing list archive at Nabble.com.
 

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



Re: [PHP] Storing compiled code on the server

2007-02-21 Thread Németh Zoltán
2007. 02. 21, szerda keltezéssel 06.52-kor Brian Dunning ezt írta:
 I have a few scripts that I want to protect from the prying eyes of  
 even people with root access to my server. The best suggestion I've  
 heard is to store only the compiled version on the server itself. I  
 have no idea how to do this or how those scripts would be called. Can  
 anyone point me to a good starting place?
 

google for php compile, the second result is a commercial software
doing something like this

greets
Zoltán Németh

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



Re: [PHP] New Menu Bar - Can people test it for me?

2007-02-21 Thread Németh Zoltán
2007. 02. 21, szerda keltezéssel 08.58-kor Chris Ditty ezt írta:
 Works fine on FF/XP
 
 Looks nice btw.
 
 (sorry for the dup post Nemeth)

no problem
however, my first name is Zoltán and last name is Németh ;)
(it is written in the opposite order in Hungary that's why it appears as
Németh Zoltán in my from header)

greets
Zoltán Németh

 
 On 2/21/07, Németh Zoltán [EMAIL PROTECTED] wrote:
  works on linux/firefox and xp/ie7
 
  greets
  Zoltán Németh
 
  2007. 02. 21, szerda keltezéssel 12.12-kor Scott Gunn ezt írta:
   All,
  
   http://www.thebigspider.co.uk/test/menu.html
  
   I'm going to write some php code which will build this menu from an XML
   file.
  
   Before I do, I want to know what sort of browser compatibility it has? 
   could
   you guys test it and let me know if it worked ok and looked like the 
   preview
   picture?
  
   If your on IE7 or Firefox2 and it works please don't email back as I know
   these work fine.
  
   Best Regards
   Scott.
  
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 

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



Re: [PHP] Re: WHERE problem

2007-02-20 Thread Németh Zoltán
2007. 02. 20, kedd keltezéssel 01.33-kor Fergus Gibson ezt írta:
 How about this instead, Mike?
 
 ?php
 // some code
 
 $fortune = mysql_query(SELECT text FROM fortunes ORDER BY RAND() LIMIT 1);
 $fortune = mysql_fetch_row($fortune);
 $fortune = sprintf(
 'span class=quotecycquot;%squot;br /-Omniversalism.com/span',
 $fortune[0]
 );
 
 // some more code
 ?
 
 MySQL is implemented in random code, so it can probably perform this
 operation faster, and this code is much cleaner.  You may want to move
 away from mysql since it's essentially deprecated.  I have switched to
 mysqli and prefer it.
 

a week ago or something like that there was an extensive discussion here
about ORDER BY RAND being slow and inefficient on large tables

read this:
http://www.titov.net/2005/09/21/do-not-use-order-by-rand-or-how-to-get-random-rows-from-table/

greets
Zoltán Németh

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



Re: [PHP] Mozilla/Opera issue

2007-02-20 Thread Németh Zoltán
2007. 02. 20, kedd keltezéssel 21.40-kor Chris Aitken ezt írta:
 Hi All,
 
  
 
 I am clutching at straws here, but I have come across an issue that I don't
 know whether it's a PHP problem in my coding, or HTML, or something entirely
 different but I've never seen this happen before, and this list has always
 helped me out in the past with odd problems.
 
  
 
 I am developing a site at the moment which is causing a very unusual trait
 in both mozilla and opera browsers.
 
  
 
 http://www.reedsandmore.com.au/index2.php
 
  
 
 For example..
 
  
 
 * Click on Clarinet Reeds  More
 * Click on Bb Clarinet Reeds
 * You will see the first page showing the first 12 items (hopefully it
 will)
 * Scroll to the bottom and click on Next
 * Look at the page that gets refreshed... it's the first page again.
 Yet in the URL it shows the URL for page=2
 * Now to actually bring up page 2, you can click on RELOAD, or simply
 click on Next at the bottom of the screen again. This will bring up the
 proper page 2.
 * Now do the same to bring up page 3. Same thing occurs. Page 2 is
 re-displayed, and page 3 will not come up until you click on Next again, or
 click on RELOAD.
 * The same thing happens in reverse back down through the pages.
 
  
 
 If anyone can point me in the right direction of this or if you have come
 across this in the past, please any assistance would be greatly appreciated.
 The code is valid to XHTML 1.0 Transitional as my initial thought was that
 something wasn't valid.
 

I tried it with Firefox on Ubuntu Linux and IE on XP and the problem
appears on both. The link itself points to the correct url. So the
problem should be in your php code. Maybe it has something to do with
sessions, but I cannot tell anything more unless you show your code.

greets
Zoltán Németh

  
 
 Any help will be appreciated.
 
  
 
 
 
 
 
 Regards
 
  
 
 
 Chris Aitken
 The Web Hub Designer and Programmer
 Phone : 02 4648 0808
 Mobile : 0411 132 075
 
  
 
 -
 
  
 
 Making The Web Work The Web Hub
  http://www.thewebhub.com.au/ http://www.thewebhub.com.au/
  mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]
 
  
 
 -
 
  
 
 Confidentiality Statement:  
 This message is intended only for the use of the Addressee and may contain 
 information that is PRIVILEDGED and CONFIDENTIAL.  If you are not the 
 intended recipient, dissemination of this communication is prohibited.  
 If you have received this communication in error, please erase all 
 copies of the message and its attachments and notify us immediately.
 
  
 

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



Re: [PHP] Manual contradiction concerning string access?

2007-02-20 Thread Németh Zoltán
AFAIK the english manual is more up to date, so I would follow that

greets
Zoltán Németh

2007. 02. 20, kedd keltezéssel 17.15-kor Christian Heinrich ezt írta:
 Dear list,
 
 today, I read in a german PHP forum about a problem with accessing an 
 offset of a string.
 
 For example, if you have a variable like
 
 $string = this is my string;
 
 and you want to access the third character at once, I would suggest to use
 
 $string{2}
 
 so this will return the i.
 
 The (german!) manual says about that: 
 (http://de.php.net/manual/de/language.types.string.php#language.types.string.substr)
 
  *Anmerkung: * Für Abwärtskompatibilität können Sie für den selben 
  Zweck immer noch die Array-Klammern verwenden. Diese Syntax wird 
  jedoch seit PHP 4 missbilligt.
 
 (Translation:)
 
  *Note: *For downwards compatibility you may use the array brackets as 
  well. But as of PHP 4, this syntax is deprecated.
 
 The english manual says: (Link: 
 http://de.php.net/manual/en/language.types.string.php#language.types.string.substr
  
 )
 
  *Note: * They may also be accessed using braces like $str{42} for the 
  same purpose. However, using square array-brackets is preferred 
  because the {braces} style is deprecated as of PHP 6.
 
 
 I'm a little bit confused by now. Which style should I pick? I use PHP 4 
 and 5. Is there any other difference?
 
 It would be great if someone could solve that contradiction within the 
 manual, too.
 
 
 Thanks in advance.
 
 
 Sincere regards
 Christian Heinrich
 

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



Re: [PHP] WHERE problem

2007-02-20 Thread Németh Zoltán
2007. 02. 20, kedd keltezéssel 08.17-kor Jim Lucas ezt írta:
 Mike Shanley wrote:
  I'd like to think I understood code a little better than this, but I've 
  got a problem with my WHERE...
  
  I know it's the WHERE because I get a good result when I leave it out. 
  And the random function is also working... I honestly can't figure it 
  out. Thanks in advance for help with this laughable prob.
  ---
  // How many are there?
  
  $result = mysql_query(SELECT count(*) FROM fortunes);
  $max = mysql_result($result, 0);
  
  // Get randomized!... the moderated way...
  
  $randi = mt_rand(1, $max-1);
  $q = SELECT text FROM fortunes WHERE index = '$randi';
  $choose = mysql_query($q);
  $chosen1 = mysql_fetch_array($choose);
 ARRAY???

what's wrong with that?
http://hu.php.net/manual/en/function.mysql-fetch-array.php

and then you can of course refer to it with indexes, both numeric and
associative
I don't see anything problematic with that...

greets
Zoltán Németh

 
  
  // Ready to ship...
  
 Referring to it via an index...  could be the problem
  $fortune = 'span class=quotecycquot;' . $chosen1[0] . 
  'quot;br/-Omniversalism.com/span';
  
  mysql_close();
  
 
 
 -- 
 Enjoy,
 
 Jim Lucas
 
 Different eyes see different things. Different hearts beat on different 
 strings. But there are times for you and me when all such things agree.
 
 - Rush
 

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



Re: [PHP] WHERE problem

2007-02-20 Thread Németh Zoltán
2007. 02. 20, kedd keltezéssel 08.28-kor Jim Lucas ezt írta:
 Németh Zoltán wrote:
  2007. 02. 20, kedd keltezéssel 08.17-kor Jim Lucas ezt írta:
  Mike Shanley wrote:
  I'd like to think I understood code a little better than this, but I've 
  got a problem with my WHERE...
 
  I know it's the WHERE because I get a good result when I leave it out. 
  And the random function is also working... I honestly can't figure it 
  out. Thanks in advance for help with this laughable prob.
  ---
  // How many are there?
 
  $result = mysql_query(SELECT count(*) FROM fortunes);
  $max = mysql_result($result, 0);
 
  // Get randomized!... the moderated way...
 
  $randi = mt_rand(1, $max-1);
  $q = SELECT text FROM fortunes WHERE index = '$randi';
  $choose = mysql_query($q);
  $chosen1 = mysql_fetch_array($choose);
  ARRAY???
  
  what's wrong with that?
  http://hu.php.net/manual/en/function.mysql-fetch-array.php
  
  and then you can of course refer to it with indexes, both numeric and
  associative
  I don't see anything problematic with that...
  
  greets
  Zoltán Németh
  
  // Ready to ship...
 
  Referring to it via an index...  could be the problem
  $fortune = 'span class=quotecycquot;' . $chosen1[0] . 
  'quot;br/-Omniversalism.com/span';
 
  mysql_close();
 
 
  -- 
  Enjoy,
 
  Jim Lucas
 
  Different eyes see different things. Different hearts beat on different 
  strings. But there are times for you and me when all such things agree.
 
  - Rush
 
  
 I would suggest using either assoc or row this way there is no 
 confusion.  Plus it doesn't take as much resources. :)

ok, it's probably better to decide which to use in advance and then
stick to that one... it's always better to plan carefully before coding,
and use the optimal tools needed for the job.
however, I think sometimes everyone starts coding without detailed
plans ;)

greets
Zoltán Németh

 

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



Re: [PHP] Understanding session variables with input field and register_global

2007-02-20 Thread Németh Zoltán
2007. 02. 20, kedd keltezéssel 17.32-kor Otto Wyss ezt írta:
 I've an input field in a form
 
 input name=username type=text ...
 
 and with register_global I can use this field in PHP as variable 
 $username. Yet if I use a session variable
 
 $_SESSION['username'] = 'value'
 
 the variable $username gets the same value.

the manual says ( http://hu.php.net/manual/en/ref.session.php )
If register_globals is enabled, then the global variables and the
$_SESSION entries will automatically reference the same values which
were registered in the prior session instance. However, if the variable
is registered by $_SESSION then the global variable is available since
the next request.

that's why it is the same
I think you should read the value from $_POST and put it into $_SESSION
to change it

hope that helps
Zoltán Németh

  On the other side when I 
 enter a value in the input field, the session variable isn't changed. So 
 how can I set the session variable from the input field after it has 
 changed?

 
 O. Wyss
 

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



Re: [PHP] WHERE problem

2007-02-20 Thread Németh Zoltán
2007. 02. 20, kedd keltezéssel 11.39-kor [EMAIL PROTECTED]
ezt írta:
 Different strokes for different folks...
 
 Might I toss a new recommendation into the mix?
 
 SELECT text FROM fortunes ORDER BY RAND() LIMIT 1;
 

that's not new :)
a couple of people recommended it earlier today/yesterday

this is perfect, but only if the table is not very large.
see
http://www.titov.net/2005/09/21/do-not-use-order-by-rand-or-how-to-get-random-rows-from-table/

greets
Zoltán Németh

 
 
 = = = Original message = = =
 
 N~~meth Zolt~~n wrote:
  2007. 02. 20, kedd keltez~~ssel 08.17-kor Jim Lucas ezt ~~rta:
  Mike Shanley wrote:
  I'd like to think I understood code a little better than this, but I've 
  got a problem with my WHERE...
 
  I know it's the WHERE because I get a good result when I leave it out. 
  And the random function is also working... I honestly can't figure it 
  out. Thanks in advance for help with this laughable prob.
  ---
  // How many are there?
 
  $result = mysql_query(SELECT count(*) FROM fortunes);
  $max = mysql_result($result, 0);
 
  // Get randomized!... the moderated way...
 
  $randi = mt_rand(1, $max-1);
  $q = SELECT text FROM fortunes WHERE index = '$randi';
  $choose = mysql_query($q);
  $chosen1 = mysql_fetch_array($choose);
  ARRAY???
  
  what's wrong with that?
  http://hu.php.net/manual/en/function.mysql-fetch-array.php
  
  and then you can of course refer to it with indexes, both numeric and
  associative
  I don't see anything problematic with that...
  
  greets
  Zolt~~n N~~meth
  
  // Ready to ship...
 
  Referring to it via an index...  could be the problem
  $fortune = 'span class=quotecycquot;' . $chosen1[0] . 
  'quot;br/-Omniversalism.com/span';
 
  mysql_close();
 
 
  -- 
  Enjoy,
 
  Jim Lucas
 
  Different eyes see different things. Different hearts beat on different 
  strings. But there are times for you and me when all such things agree.
 
  - Rush
 
  
 I would suggest using either assoc or row this way there is no 
 confusion.  Plus it doesn't take as much resources. :)
 
 -- 
 Enjoy,
 
 Jim Lucas
 
 Different eyes see different things. Different hearts beat on different 
 strings. But there are times for you and me when all such things agree.
 
 - Rush
 
 
 
 ___
 Sent by ePrompter, the premier email notification software.
 Free download at http://www.ePrompter.com.
 

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



Re: [PHP] Problem Directing the Page with header

2007-02-16 Thread Németh Zoltán
2007. 02. 15, csütörtök keltezéssel 18.41-kor Ashish Rizal ezt írta:
 Hey Jim,
 Thanks for the quick response. I have actually made the whole
 code on same page (login.php) and the functions that i used in
 this code are in functions.php. Now this time it is showing the
 warning :
 Warning: Cannot modify header information - headers already sent
 by (output started at C:\Program
 Files\xampp\htdocs\fselection\login.php:1) in C:\Program
 Files\xampp\htdocs\fselection\login.php on line 19 
 The line 19 is header(Location: http://$host$uri/$extra;);

it says you sent out some output on line 1
what is on line 1? maybe you have a blank line in the beginning of your
php file?

greets
Zoltán Németh

 
  Below is the list of code for login.php.
 The Server i am using is SunOS 5.10. 
 
 ?php
 session_start();
 require_once 'functions.php';
 $UserName = $_POST['UserName'];
 $Password = $_POST['Password'];
 $host = $_SERVER['HTTP_HOST'];
 $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
 $extra = 'adminlogin.php';
 $loc = \http://$host$uri/$extra\;;
 if ($_POST){
 $error = login_check($_POST);
 if (trim ($error)==)
 {
 $accesslevel = accessLevel($UserName);
 ?
 ?php
 if ($accesslevel == admin){
 $_SESSION[userid] = login($_POST);
 header(Location: http://$host$uri/$extra;);
 exit();
 }
 else if ($accesslevel == user) {
 //echo this is user; 
 $_SESSION[userid] = login($_POST);
 header('Location: userlogin.php');
 exit();
 }
 }
 else {
 print Error :$error;
 }
 }
 ?
 BODY
 FORM id=form1 name=loginform  method=post
 TABLE align=center  
 ***Login Form Goes Here **
 nothing php Stuffs on this part
 /body
 
 Thank you again for your time and consideration. 
 

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



Re: [PHP] array_pop() with key-value pair ???

2007-02-16 Thread Németh Zoltán
2007. 02. 16, péntek keltezéssel 10.23-kor Robin Vickery ezt írta:
 On 16/02/07, Eli [EMAIL PROTECTED] wrote:
  Hi,
 
  Why isn't there a function that acts like array_pop() returns a pair of
  key-value rather than the value only ?
 
  Reason is, that in order to pop the key-value pair, you do:
  ?php
  $arr = array('a'=1,'b'=2,'c'=3,'d'=4);
  $arr_keys = array_keys($arr);
  $key = array_pop($arr_keys);
  $value = $arr[$key];
  ?
 
  I benchmarked array_keys() function and it is very slow on big arrays
  since PHP has to build the array.
 
 benchmark this:
 
 end($arr);
 list($key, $value) = each($arr);

array_pop also removes the element from the array so add one more line:
unset($arr[$key]);

greets
Zoltán Németh

 
 -robin
 

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



Re: [PHP] array_pop() with key-value pair ???

2007-02-16 Thread Németh Zoltán
2007. 02. 16, péntek keltezéssel 10.47-kor Robin Vickery ezt írta:
 On 16/02/07, Németh Zoltán [EMAIL PROTECTED] wrote:
  2007. 02. 16, péntek keltezéssel 10.23-kor Robin Vickery ezt írta:
   On 16/02/07, Eli [EMAIL PROTECTED] wrote:
Hi,
   
Why isn't there a function that acts like array_pop() returns a pair of
key-value rather than the value only ?
   
Reason is, that in order to pop the key-value pair, you do:
?php
$arr = array('a'=1,'b'=2,'c'=3,'d'=4);
$arr_keys = array_keys($arr);
$key = array_pop($arr_keys);
$value = $arr[$key];
?
   
I benchmarked array_keys() function and it is very slow on big arrays
since PHP has to build the array.
  
   benchmark this:
  
   end($arr);
   list($key, $value) = each($arr);
 
  array_pop also removes the element from the array so add one more line:
  unset($arr[$key]);
 
 Yeah, but he's not actually popping the last element of $arr, he's
 just using it to get the last key from $arr_keys.

well, sorry, I didn't examine his code just read his original question
saying a function that acts like array_pop()

it's now up to him to decide whether he wants to unset that element or
not :)

greets
Zoltán Németh

 
   -robin
 

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



Re: [PHP] Banner rotation with links

2007-02-14 Thread Németh Zoltán
2007. 02. 14, szerda keltezéssel 08.29-kor Chris Carter ezt írta:
 How can I rotate a banner as well as the link in it within a page using PHP.
 This can be done as a include file php. Anybody please supply some code or a
 link for this.

please go STFW for banner rotation php script

greets
Zoltán Németh

 
 Thanks in advance.
 
 Chris
 -- 
 View this message in context: 
 http://www.nabble.com/Banner-rotation-with-links-tf3228157.html#a8968148
 Sent from the PHP - General mailing list archive at Nabble.com.
 

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



Re: [PHP] [PHP 5.0] save HTML form to .php file

2007-02-12 Thread Németh Zoltán
On h, 2007-02-12 at 21:04 +1100, Chris Henderson wrote:
 My HTML form submits data to a php form and the php form displays it.
 I was wondering if I could save the data in the php form so whoever
 opens it can see the data. At the moment, if I open action.php from
 a different computer or browser I see hi you are 0 years old

you have to store the data somewhere
- a DB
- a separate file
- or even you could rewrite the original action.php file but that
seems very messy to me

greets
Zoltán Németh

 
 Here's my HTML  PHP form -
 
 html
 
 head /head
 
 title Form /title
 
 body
 
 form action=action.php method=post
 p your name: input type=text name=name / /p
 p your age: input type=text name=age / /p
 p input type=submit / /p
 /form
 /body
 /html
 
 PHP form -
 
 hi ?php echo htmlspecialchars($_POST['name']); ?
 you are ?php echo (int)$_POST['age']; ? years old
 
 Thanks.
 

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



Re: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Németh Zoltán
On h, 2007-02-12 at 11:13 +0100, Matthias S. wrote:
 Hi there,
 
 I've got two bloody beginner questions: I've created a form with various
 text input fields. One is to hold a numeric value (age). Upon submission, I
 try to retrieve the value of this field like this:
 
 $age = $_POST['_txtAge'];
 
 later, I use the $age variable to create a message...
 
 $message = Name:  . $name . \n;
 $message .= Email:  .$email . \n;
 $message .= Age:  . $age . \n;
 $message .= Gender:  . $gender . \n;
 $message .= Info:  . $info;
 
  then I send the message:
 
 mail([EMAIL PROTECTED], A Request, $message, _getMailHeaders($name, 
 email));
 
 Now on to my questions:
 $message contains the values of all fields correctly except the age field
 (input of all others are alphabetic, only age has numeric content). Why is
 this?

what do you mean by incorrect? what is the test input you give and what
result do you get?

 
 Secondly, mail sends my message correctly. But the return adresse set in
 _getMailHeaders is not used. Instead, some identification from the server is
 used. Why is that?

it is (if you use sendmail on the server) because sendmail sets reply-to
to the user running it by default. so it gets set to the user the script
runs as (usually www-data or something like that). it can be overridden
by the -f switch I think. like this:

mail($to, $subject, $message, $headers, -f.$frommail);


hope that helps
Zoltán Németh

 
 Here the function _getMailHeaders:
 
 function _getMailHeaders($senderName, $senderAddress) {
 
  ini_set(sendmail_from, $senderAddress);
 
  $headers  = 'MIME-Version: 1.0' . \r\n;
  $headers .= 'Reply-To: ' . $senderName .''. $senderAddress. '' . \r\n;
  $headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n;
  $headers .= 'To: PostOffice [EMAIL PROTECTED]' . \r\n;
  $headers .= 'From: ' . $senderName . '' . $senderAddress . '' . \r\n;
 
  ini_restore(sendmail_from);
  return $headers;
 }
 
 Any help is greatly appreceated.
 
 Matthias
 

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



Re: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Németh Zoltán
On h, 2007-02-12 at 14:16 +0100, Matthias S. wrote:
 hi zoltan,
 
 thanks for your reply. i've tried the -f switch but the only effect it has
 is an error message ;)
 
 Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The fifth
 parameter is disabled in SAFE MODE.

ehh, sorry, I didn't think you use safe mode. If you can not switch it
off, then try to contact your system admin to install a sendmail
alternative which can be configured to read the reply-to header from the
mail headers passed to it by the caller - AFAIK sendmail itself cannot
be configured this way, but I might be wrong

 
 as for the age value:
 it is simply incorrect because it is always empty... input might be for
 example 25, but the var $age contains always an empty string.

well, you should check the field in your form. does it have exactly the
same name? maybe you misspelled it... (don't forget that it is
case-sensitive, so _txtAge is not equal with _txtage for example)

greets
Zoltán Németh

 
 Can you help? I'm a programmer (C++), but have never used PHP before. The
 concepts are clear to me, but I must be missing here something essential.
 
 Thanks again, Matthias
 
 Nmeth Zoltn [EMAIL PROTECTED] schrieb im Newsbeitrag
 news:[EMAIL PROTECTED]
  On h, 2007-02-12 at 11:13 +0100, Matthias S. wrote:
   Hi there,
  
   I've got two bloody beginner questions: I've created a form with various
   text input fields. One is to hold a numeric value (age). Upon
 submission, I
   try to retrieve the value of this field like this:
  
   $age = $_POST['_txtAge'];
  
   later, I use the $age variable to create a message...
  
   $message = Name:  . $name . \n;
   $message .= Email:  .$email . \n;
   $message .= Age:  . $age . \n;
   $message .= Gender:  . $gender . \n;
   $message .= Info:  . $info;
  
    then I send the message:
  
   mail([EMAIL PROTECTED], A Request, $message, _getMailHeaders($name,
 email));
  
   Now on to my questions:
   $message contains the values of all fields correctly except the age
 field
   (input of all others are alphabetic, only age has numeric content). Why
 is
   this?
 
  what do you mean by incorrect? what is the test input you give and what
  result do you get?
 
  
   Secondly, mail sends my message correctly. But the return adresse set in
   _getMailHeaders is not used. Instead, some identification from the
 server is
   used. Why is that?
 
  it is (if you use sendmail on the server) because sendmail sets reply-to
  to the user running it by default. so it gets set to the user the script
  runs as (usually www-data or something like that). it can be overridden
  by the -f switch I think. like this:
 
  mail($to, $subject, $message, $headers, -f.$frommail);
 
 
  hope that helps
  Zoltn Nmeth
 
  
   Here the function _getMailHeaders:
  
   function _getMailHeaders($senderName, $senderAddress) {
  
ini_set(sendmail_from, $senderAddress);
  
$headers  = 'MIME-Version: 1.0' . \r\n;
$headers .= 'Reply-To: ' . $senderName .''. $senderAddress. '' .
 \r\n;
$headers .= 'Content-type: text/html; charset=iso-8859-1' . \r\n;
$headers .= 'To: PostOffice [EMAIL PROTECTED]' . \r\n;
$headers .= 'From: ' . $senderName . '' . $senderAddress . '' .
 \r\n;
  
ini_restore(sendmail_from);
return $headers;
   }
  
   Any help is greatly appreceated.
  
   Matthias
  
 

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



Re: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Németh Zoltán
On h, 2007-02-12 at 14:54 +0100, Matthias S. wrote:
 hi jochem,
 
 thanks. i've tripplechecked on the names, but just in case I miss something
 obvious, I'll post the entire snippets.
 
 +++ HTML form +++
 form action=templates/prokop/submit.php method=post
 input  type=hidden name=_type value=2
 
 div class=FormLabelName span class=translateName/span:/div
 input type=text name=_txtName maxlength=50
 
 div class=FormLabelEmail-Address span class=translateE-Mail
 Adresse/span:/div
 input type=text name=_txtEmail maxlength=50
 
 div class=FormLabelAge span class=translateAlter/span:/div
 input type=text name=txtAge maxlength=50 style=width:70px;

I'm not sure but this ; at the end of the line may cause troubles

the line should be correctly:
input type=text name=txtAge maxlength=50 style=width:70px;

greets
Zoltán Németh

 
 div class=FormLabelGender span
 class=translateGeschlecht/span:/div
 select name=_optGender style=width:150px;
 option value=female selectedfemale | weiblich
 option value=malemale | mnnlich
 /select
 
 div class=FormLabelAnything more to say? span class=translateNoch
 ein Kommentar?/span/div
 textarea name=_txtInfo rows=3/TEXTAREA
 
 div class=SubmitButton
 input type=submit name=_btnSubmit  value=Submit
 /div
 
 br
 /form
 +++
 +++ PHP file +++
 $name = $_POST['_txtName'];
 $email = $_POST['_txtEmail'];
 $age = $_POST['txtAge'];
 $gender = $_POST['_optGender'];
 $info = $_POST['_txtInfo'];
 
 $message = Name:  . $name . \n;
 $message .= Email:  .$email . \n;
 $message .= Age:  . $age . \n;
 $message .= Gender:  . $gender . \n;
 $message .= Info:  . $info;
 try {
 mail([EMAIL PROTECTED], Request, $message, _getMailHeaders($name, email));
 }
 catch(Exception $e)
 {
 ...
 }
 +++
 
 
 Jochem Maas [EMAIL PROTECTED] schrieb im Newsbeitrag
 news:[EMAIL PROTECTED]
  Matthias S. wrote:
   hi zoltan,
  
   thanks for your reply. i've tried the -f switch but the only effect it
 has
   is an error message ;)
  
   Warning: mail() [function.mail]: SAFE MODE Restriction in effect. The
 fifth
   parameter is disabled in SAFE MODE.
 
  which another way of saying 'my hosting env sucks' - but that's besides
 the point.
  (short story: 'safe mode' isn't)
 
  
   as for the age value:
   it is simply incorrect because it is always empty... input might be for
   example 25, but the var $age contains always an empty string.
  
   Can you help? I'm a programmer (C++)
 
  so the concept of debugging code should not be new to you.
  so hello to print_r(), var_dump() and echo - they are your friends.
 
  e.g. stick the following at the top of your script (to start with):
 
  var_dump(
  $_POST['_txtAge'],
  $_POST
  );
 
  my guess is your form element name and post array key are not identical.
 

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



RE: [PHP] Beginner Questions regarding Mail and Forms

2007-02-12 Thread Németh Zoltán
On h, 2007-02-12 at 14:09 +, Edward Kay wrote:
  div class=FormLabelAge span class=translateAlter/span:/div
  input type=text name=txtAge maxlength=50 style=width:70px;
 
 
 There's your problem: name=txtAge. For your PHP script to work you need
 name=_txtAge.

in his last email the OP has the name txtAge in his php script also...

greets
Zoltán Németh

 
 PS: You should also have quotes around the 50 in the maxlength attribute.
 
 Edward
 

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



Re: [PHP] array within array

2007-02-09 Thread Németh Zoltán
On p, 2007-02-09 at 09:24 +0200, Steven Macintyre wrote:
 Hi all,
 
 I have an array ($articles) that contains content in this format
 
 Textbr
 More text
 
 I am currently calling the creation of the array as such;
 
 $articles = split(Section break, $mystring); -- this works
 
 NOW ... I need to split each item in the articles array into its own array
 (newsarray)
 
 I have tried 
 
 Foreach ($articles as $value) {
   $newsarray = split(br, $value);
 }

I'm not sure what you mean by this aint working but if you want all
elements of the $articles array to be arrays created by the split()
call, then try using the following:


foreach ($articles as $key = $value) {
$newsarray = split(br, $value);
$articles[$key] = $newsarray;
}

hope that helps
Zoltán Németh

 
 But this aint working ... 
 
 Can someone offer a better suggestion?
 
 S
 

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



Re: [PHP] array within array

2007-02-09 Thread Németh Zoltán
On p, 2007-02-09 at 10:10 +0100, Németh Zoltán wrote:
 On p, 2007-02-09 at 09:24 +0200, Steven Macintyre wrote:
  Hi all,
  
  I have an array ($articles) that contains content in this format
  
  Textbr
  More text
  
  I am currently calling the creation of the array as such;
  
  $articles = split(Section break, $mystring); -- this works
  
  NOW ... I need to split each item in the articles array into its own array
  (newsarray)
  
  I have tried 
  
  Foreach ($articles as $value) {
  $newsarray = split(br, $value);
  }
 
 I'm not sure what you mean by this aint working but if you want all
 elements of the $articles array to be arrays created by the split()
 call, then try using the following:
 
 
 foreach ($articles as $key = $value) {
   $newsarray = split(br, $value);
   $articles[$key] = $newsarray;

or in one line

$articles[$key] = split(br, $value);

because you don't need to waste system resources on the temporary array
$newsarray at all

greets
Zoltán Németh

 }
 
 hope that helps
 Zoltán Németh
 
  
  But this aint working ... 
  
  Can someone offer a better suggestion?
  
  S
  
 

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



Re: [PHP] Javascript and $_POST

2007-02-08 Thread Németh Zoltán
On cs, 2007-02-08 at 08:14 -0500, Dan Shirah wrote:
 Okay, I edited my page per some suggestions here.  Below is what I now have:
 
 
 script language=JavaScript
 function checkForm() {
 
  // ** START **
   if (inputForm.cc_phone_number.value == ) {
 alert( Please enter a phone number. );
 inputForm.cc_phone_number.focus();
 return;
   }
 
 **Lots of other checks here, just left out for length**
 
document.inputForm.submit();
 }
 
 /script
 title/title
 LINK rel=stylesheet type=text/css href=../../CSS/background.css
 /head
 body
 div align=center h2/h2
h3Submit a New Payment./h3
 /div
 form name=inputForm action=save.php method=post
 enctype=multipart/form-data
 
 **Lots of form data here**
 
 table align=center border=0 cellpadding=0 cellspacing=0
 width=680
  tr
  td width=64 align=lefta href=javascript:checkForm()
 title=SaveSave/a/td
  td width=616 align=lefta href=javascript:closeThis()
 title=CloseClose/a/td
  /tr
 /table
 /form
 /body
 /html
 
 Now when I submit my page it still perfroms all of the javascript checks
 correctly, but once it gets to the document.inputForm.submit(); part it
 returns the following error.
 
 Error: Object doesn't support this property or method.
 Code: 0
 

maybe because you don't have submit button in the form?
try to include something like this
input type=image src=./images/spacer.gif
where spacer.gif is an 1x1 blank image

I remember some similar situation where it helped, but I'm not sure

hope that helps
Zoltán Németh

 
 
 On 2/7/07, Paul Novitski [EMAIL PROTECTED] wrote:
 
  At 2/7/2007 01:34 PM, Dan Shirah wrote:
  I have a form that uses Javascript to validate form field entries, and if
  they are incorrect it returns an error to the user.
  
  After the Javascript processing is complete, it submits the form to my
  save
  page. However it seems that once the processing is complete and it passes
  to
  the save page, none of my $_POST variables are being passed.
 
 
  Of course, all of your form fields need to be inside the same
  form/form tags as your submit button.  The sample HTML you posted
  did not indicate that you'd done this.
 
  Regards,
 
  Paul
  __
 
  Paul Novitski
  Juniper Webcraft Ltd.
  http://juniperwebcraft.com
 
 

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



Re: [PHP] graphical form validation

2007-02-08 Thread Németh Zoltán
On cs, 2007-02-08 at 13:27 +, Ross wrote:
 Does anyone know of a form validation class available that gives
 
 (i) feedback in a graphical way like this (the ticks and crosses)
 
 http://forums.oscommerce.com/index.php?act=Regcoppa_user=0termsread=1coppa_pass=1
 

this is available to registered users only, could you give a sample
which can be seen by anyone?


 
 (ii) Is dynamic..for example I have a checkbox
 do you own a car?. If I tick 'no' nothing happens. If I tick yes two new 
 fields ask for the year and model.

this feature I think can be achieved with javascript not php

greets
Zoltán Németh

 
 I do not mind if this is a paid class or a free but some suggestions would 
 be nice.
 
 
 R. 
 

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



Re: [PHP] Javascript and $_POST

2007-02-08 Thread Németh Zoltán
On cs, 2007-02-08 at 08:41 -0500, Dan Shirah wrote:
 I should not need an actual Button if my link to checkForm() ends with
 document.inputForm.submit(); which tells the form to submit, right?

well, you should be right...
but I remember a year ago or so I had a similar problem and the image
input solved it... but I'm not sure whether it was exactly the same
problem or not, so it might be complete bullshit ;)

greets
Zoltán Németh

 
 On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote: 
 On cs, 2007-02-08 at 08:14 -0500, Dan Shirah wrote:
  Okay, I edited my page per some suggestions here.  Below is
 what I now have: 
 
 
  script language=JavaScript
  function checkForm() {
 
   // ** START **
if (inputForm.cc_phone_number.value == ) {
  alert( Please enter a phone number. ); 
  inputForm.cc_phone_number.focus();
  return;
}
 
  **Lots of other checks here, just left out for
 length**
 
 document.inputForm.submit();
  }
 
  /script
  title/title
  LINK rel=stylesheet type=text/css
 href=../../CSS/background.css
  /head
  body 
  div align=center h2/h2
 h3Submit a New Payment./h3
  /div
  form name=inputForm action=save.php method=post 
  enctype=multipart/form-data
 
  **Lots of form data here**
 
  table align=center border=0 cellpadding=0
 cellspacing=0 
  width=680
   tr
   td width=64 align=lefta
 href=javascript:checkForm()
  title=SaveSave/a/td 
   td width=616 align=lefta
 href=javascript:closeThis()
  title=CloseClose/a/td
   /tr
  /table
  /form 
  /body
  /html
 
  Now when I submit my page it still perfroms all of the
 javascript checks
  correctly, but once it gets to the
 document.inputForm.submit(); part it
  returns the following error. 
 
  Error: Object doesn't support this property or method.
  Code: 0
 
 
 maybe because you don't have submit button in the form?
 try to include something like this
 input type=image src=./images/spacer.gif 
 where spacer.gif is an 1x1 blank image
 
 I remember some similar situation where it helped, but I'm not
 sure
 
 hope that helps
 Zoltán Németh
 
 
 
  On 2/7/07, Paul Novitski [EMAIL PROTECTED] wrote:
  
   At 2/7/2007 01:34 PM, Dan Shirah wrote:
   I have a form that uses Javascript to validate form field
 entries, and if
   they are incorrect it returns an error to the user. 
   
   After the Javascript processing is complete, it submits
 the form to my
   save
   page. However it seems that once the processing is
 complete and it passes
   to 
   the save page, none of my $_POST variables are being
 passed.
  
  
   Of course, all of your form fields need to be inside the
 same
   form/form tags as your submit button.  The sample HTML
 you posted 
   did not indicate that you'd done this.
  
   Regards,
  
   Paul
   __
  
   Paul Novitski
   Juniper Webcraft Ltd. 
   http://juniperwebcraft.com
  
  
 
 

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



Re: [PHP] Javascript and $_POST

2007-02-08 Thread Németh Zoltán
On cs, 2007-02-08 at 08:56 -0500, Dan Shirah wrote:
 Okay, I'll try your spacer solution.   Where do you think I should add
 it?

I put it right before the /form tag, but I think you could put it
anywhere between the form and the /form

greets
Zoltán Németh

 
 On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote: 
 On cs, 2007-02-08 at 08:41 -0500, Dan Shirah wrote:
  I should not need an actual Button if my link to checkForm()
 ends with 
  document.inputForm.submit(); which tells the form to submit,
 right?
 
 well, you should be right...
 but I remember a year ago or so I had a similar problem and
 the image
 input solved it... but I'm not sure whether it was exactly the
 same 
 problem or not, so it might be complete bullshit ;)
 
 greets
 Zoltán Németh
 
 
  On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote:
  On cs, 2007-02-08 at 08:14 -0500, Dan Shirah wrote: 
   Okay, I edited my page per some suggestions
 here.  Below is
  what I now have:
  
  
   script language=JavaScript 
   function checkForm() {
  
// ** START **
 if (inputForm.cc_phone_number.value == ) {
   alert( Please enter a phone number. ); 
   inputForm.cc_phone_number.focus();
   return;
 }
  
   **Lots of other checks here, just left out for
  length** 
  
  document.inputForm.submit();
   }
  
   /script
   title/title
   LINK rel=stylesheet type=text/css 
  href=../../CSS/background.css
   /head
   body
   div align=center h2/h2
  h3Submit a New Payment./h3 
   /div
   form name=inputForm action=save.php
 method=post
   enctype=multipart/form-data
   
   **Lots of form data here**
  
   table align=center border=0 cellpadding=0
  cellspacing=0 
   width=680
tr
td width=64 align=lefta
  href=javascript:checkForm()
   title=SaveSave/a/td
td width=616 align=lefta
  href=javascript:closeThis()
   title=CloseClose/a/td 
/tr
   /table
   /form
   /body
   /html
  
   Now when I submit my page it still perfroms all of
 the 
  javascript checks
   correctly, but once it gets to the
  document.inputForm.submit(); part it
   returns the following error.
  
   Error: Object doesn't support this property or
 method. 
   Code: 0
  
 
  maybe because you don't have submit button in the
 form?
  try to include something like this
  input type=image src=./images/spacer.gif 
  where spacer.gif is an 1x1 blank image
 
  I remember some similar situation where it helped,
 but I'm not
  sure
 
  hope that helps
  Zoltán Németh 
 
  
  
   On 2/7/07, Paul Novitski
 [EMAIL PROTECTED] wrote:
   
At 2/7/2007 01:34 PM, Dan Shirah wrote: 
I have a form that uses Javascript to validate
 form field
  entries, and if
they are incorrect it returns an error to the
 user.
 
After the Javascript processing is complete, it
 submits
  the form to my
save
page. However it seems that once the processing
 is 
  complete and it passes
to
the save page, none of my $_POST variables are
 being
  passed.
   

Of course, all of your form fields need to be
 inside the
  same
form/form tags as your submit button.  The
 sample HTML
  you posted 
did not indicate that you'd done this.
   
Regards

Re: [PHP] Javascript and $_POST

2007-02-08 Thread Németh Zoltán
On cs, 2007-02-08 at 09:09 -0500, Dan Shirah wrote:
 Nope, same result unfortunately.

well, sorry, then my memories were incorrect
maybe I should run a memtest86 on myself ;)

greets
Zoltán Németh

 
 On 2/8/07, Németh Zoltán [EMAIL PROTECTED] wrote: 
 On cs, 2007-02-08 at 08:56 -0500, Dan Shirah wrote:
  Okay, I'll try your spacer solution.   Where do you think I
 should add 
  it?
 
 I put it right before the /form tag, but I think you could
 put it
 anywhere between the form and the /form
 
 greets
 Zoltán Németh
 
 
  On 2/8/07, Németh Zoltán  [EMAIL PROTECTED] wrote:
  On cs, 2007-02-08 at 08:41 -0500, Dan Shirah wrote:
   I should not need an actual Button if my link to
 checkForm() 
  ends with
   document.inputForm.submit(); which tells the form
 to submit,
  right?
 
  well, you should be right...
  but I remember a year ago or so I had a similar
 problem and 
  the image
  input solved it... but I'm not sure whether it was
 exactly the
  same
  problem or not, so it might be complete bullshit ;)
 
  greets 
  Zoltán Németh
 
  
   On 2/8/07, Németh Zoltán [EMAIL PROTECTED]
 wrote:
   On cs, 2007-02-08 at 08:14 -0500, Dan
 Shirah wrote: 
Okay, I edited my page per some
 suggestions
  here.  Below is
   what I now have:
   

script language=JavaScript
function checkForm() {
   
 // ** START ** 
  if (inputForm.cc_phone_number.value ==
 ) {
alert( Please enter a phone
 number. );
inputForm.cc_phone_number.focus ();
return;
  }
   
**Lots of other checks here, just
 left out for
   length** 
   
   document.inputForm.submit();
}
   
/script
title/title
LINK rel=stylesheet type=text/css
   href=../../CSS/background.css 
/head
body
div align=center h2/h2
   h3Submit a New Payment./h3 
/div
form name=inputForm action=save.php
  method=post
enctype=multipart/form-data 
   
**Lots of form data here**
   
table align=center border=0
 cellpadding=0 
   cellspacing=0
width=680
 tr
 td width=64 align=lefta 
   href=javascript:checkForm()
title=SaveSave/a/td
 td width=616 align=lefta 
   href=javascript:closeThis()
title=CloseClose/a/td
 /tr
/table 
/form
/body
/html
   
Now when I submit my page it still
 perfroms all of 
  the
   javascript checks
correctly, but once it gets to the
   document.inputForm.submit(); part it
returns the following error. 
   
Error: Object doesn't support this
 property or
  method.
Code: 0
   
  
   maybe because you don't have submit button
 in the
  form?
   try to include something like this
   input type=image
 src=./images/spacer.gif 
   where spacer.gif is an 1x1 blank image
  
   I remember some similar situation where it
 helped

Re: [PHP] Sorting a multidimensional array

2007-02-08 Thread Németh Zoltán
array_multisort?

http://php.net/manual/en/function.array-multisort.php

hope that helps
Zoltán Németh

On cs, 2007-02-08 at 14:08 +, Dave Goodchild wrote:
 Hi all. I am building an online events directory and as part of the system
 users can search for events by date, category etc.
 
 The logic involved in finding events that match the user-entered dates works
 like so:
 
 1. we create a range of dates from the start and end dates specified by the
 user
 2. we then poll the database for any events that encompass or intersect this
 range (using the start_date and end_date fields from events table).
 3. we then find out the frequency of the event ie weekly, monthly and then
 map out its lifetime.
 4. we then go through those dates, and for any that match a date in the user
 range, the event on that date (ie all it details, name, venue, date, start
 time etc) is added to an array.
 
 ...etc etc
 
 So we eventually have a large multidimensional array whose elements contain
 arrays of events that fall on a specific date.
 
 I am using usort to ensure the events are sorted by date, but I also want to
 sort by time, for instance if there are five events on one day I want to
 sort them by start_time.
 
 Here's an example of how the event array looks:
 
 element [0] contains an array as follows ('date', 'name' venue',
 'start_time', 'category...');
 element [1] contains an array as follows ('date', 'name' venue',
 'start_time', 'category...');
 
 I tried using array_multisort but it didn't seem to do what I wanted. I want
 to sort by date, then start_time if the dates are equivalent.
 
 Any ideas?
 
 

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



Re: [PHP] Login script login

2007-02-02 Thread Németh Zoltán
On p, 2007-02-02 at 12:10 +, Dave Carrera wrote:
 Hi Stut,
 
 I think i have found where i am going wrong.
 
 Its in the comparison login for the db result.
 
 So i select * from jfjfjfjf where custno=$_POST[number]
 
 But now i am getting messed up with if cust no not found then all i get 
 is a blank page but hoping for an error

because you get an empty result set if no match is found
so check it like

if ($row = mysql_fetch_array($result)) {
 // ok, found
} else {
 // not found, error
}

or whatever sql you use

hope that helps
Zoltán Németh

 
 And i dont think i am comparing the db result with the $_POST correctly
 
 Struggling here a bit :-(
 
 Dave C
 
 Stut wrote:
  Dave Carrera wrote:
  Hi All,
 
  Having a grey brain moment here and need some advise on the logic of 
  this, should be simple, login script.
 
  I am checking validity of
 
  customer number
  customer email
  customer password (md5 in mysql)
 
  So i have my form with relevant fields
 
  Now i am getting problems with either sql or how i am handling , and 
  showing, and errors.
 
  I think what i am asking is this
 
  If someone just hits the login button show error All fields must be 
  entered
 
  If customer number dose not excist show relevant error
 
  If customer number ok but email not show error
 
  If customer number ok but email ok but password is not show error
 
  If all is ok set sessions, got this ok, and proceed.
 
  Any help with with this is very much appreciated.
 
  Kind Regards
 
  Dave C
 
  I'm not totally clear what the question was in there. Personally I 
  keep this simple...
 
  ?php
  $_POST['number'] =
  (isset($_POST['number']) ? trim($_POST['number']) : '');
  $_POST['email'] =
  (isset($_POST['email']) ? trim($_POST['email']) : '');
 
  if (empty($_POST['number']) or
  empty($_POST['email']) or
  empty($_POST['password']))
  {
  die('All fields must be entered');
  }
 
  // Find the customer/user/whatever you need from the given details
 
  if (not found)
  {
  die('Unable to locate customer/user/whatever');
  }
 
  // Set up the session here, or however you're tracking the
  // current customer/user/whatever
 
  header('Location: /somewhere_else');
  ?
 
  Hope that helps.
 
  -Stut
 
 

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



Re: [PHP] Year

2007-02-02 Thread Németh Zoltán
On p, 2007-02-02 at 10:11 -0500, Dan Shirah wrote:
 Hello all,
 
 I am trying to populate a dropdown list to contain the current year to 10
 years in the future.  Below is the code I'm using:
 
 ?PHP
   for ($y=0;$y=10;$y++) {
   $years=date http://php.net/date('Y')+$y;
   $short_years=date http://php.net/date('y')+$y;
   echo $short_years;
   echo option value=\$short_years\$years/option;
   }
 ?
 I want the selection value to be 2007, 2008, 2009, 2010  and the $years
 accomplishes this.  Howeverm I want the option value to be the two digit
 year ex. 07, 08, 09, 10...the $short_years semi accomplishes thisinstead
 of getting 07, 08, 08, 10 I get 7, 8, 9, 10...how can I get it to output the
 two year for 07, 08, 09 without it cutting off the zero?

I think it is because when you calculate $short_years it is an integer.
So insert the following before echoing it out:

if ($short_years  10) {$short_years = 0 . $short_years;}

hope that helps
Zoltán Németh

 
 Reagrds,
 
 Dan

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



Re: [PHP] Socket problem plz read.

2007-02-01 Thread Németh Zoltán
On cs, 2007-02-01 at 14:45 +0100, Scripter47 wrote:
 Richard Lynch skrev:
  On Wed, January 31, 2007 9:39 am, Németh Zoltán wrote:
  On sze, 2007-01-31 at 16:26 +0100, Scripter47 wrote:
  I'm making a simple socket server that just receive some data, and
  then
  send some data back again to the client.
 
  EDIT:
  I forgot to tell that i need help!
 
  I have search around for hours now, and the examples are always not
  what
  I needed :(
 
  the program is written in Python, if that helps, and is something
  like this
  this is PHP list. go to Python list with that, I suggest
  
  I believe the OP is asking how to write the PHP to RECEIVE that data
  from the Python script.
  
 That's what I want!
 
 plz help me, with some sample code :)

ok, then you should read (as Richard also said)

http://php.net/sockets

there are examples in there and everything

Zoltán Németh

  Or, possibly, how to implement that same code in PHP.
  
  http://php.net/sockets
  is still my best answer...
  
 
 

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



Re: [PHP] Who uses PHP

2007-02-01 Thread Németh Zoltán
On cs, 2007-02-01 at 10:19 -0500, Eric Gorr wrote:
 On Feb 1, 2007, at 10:06 AM, Jochem Maas wrote:
 
  Eric Gorr wrote:
 
  On Feb 1, 2007, at 9:47 AM, Jochem Maas wrote:
 
  Eric Gorr wrote:
  I've heard some concern expressed that PHP might be more  
  insecure then
  other methods of developing website where security was of prime
  importance. Now, I personally do not believe this, but it would  
  help me
  to convince others if I could point to major sites, where security
  (mostly with respect to the user authentication system) was  
  extremely
  important (financial sites, etc.) and where PHP was the primary
  development platform.
 
  google, yahoo.
 
  For their user authentication system? Session management? Everything?
  Don't suppose there would be any URL (press release, just general  
  info,
  etc.) with that information?
 
  for the rest search Zend.com or your favorite sdearch engine
 
  Thanks.
 
  While zend.com, etc. will tell me who is using PHP, they do not
  generally state exactly how it is being used and, as much as the  
  who, it
  is the how that is important.
 
  ah right - please ignore my post - I wasn't really reading your  
  question properly,
  my apologies
 
 Well, if you do not know the answer to my particular question, I'm  
 curious how might you respond to someone who says:
 
   PHP has to many security issues and should not be used with a  
 user authentication system.
   We should use XXX.

I think security mainly depends on the programmer and not on the
language he uses...

greets
Zoltán Németh

 
 You are not allowed to say 'Well, you're wrong. PHP is as secure as  
 anything else.' without explaining why.
 Or, would you agree with the statement? Is there an 'XXX' that should  
 be used instead of PHP?
 
 Given the limited number of options for maintaining state  
 information, I would be hard pressed to see how any language could be  
 inherently more security or why one could not write PHP code which  
 implemented the same techniques as 'XXX'.
 
 (No, I do not know what 'XXX' might be.)
 

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



Re: [PHP] nested, referenced foreach implicit current array pointer issues

2007-02-01 Thread Németh Zoltán
On cs, 2007-02-01 at 10:53 -0500, Robert Cummings wrote:
 On Thu, 2007-02-01 at 16:42 +0100, Roman Neuhauser wrote:
 
  If PHP was statically typed, global variables would still be a bad
  smell.  They are bad smell in C++ and Java, for example.  It's too easy
  to call getfoo() before you have set up $foo.  The risk grows
  exponentially: as soon as you add another global, $bar, you risk that
  you or someone else will use getfoo() inside initbar(), and getbar()
  inside initfoo() (or getfoo() inside initfoo()).  Of course, it will be
  several function calls deep, and quite probably only happen in a code
  path that's rarly used (such as error handling).
 
 Nopthing wrong with globals as long as they aren't used to punt data
 around from function to function. I find globals quite useful when used
 for configuration. I usually use a double level array. The first index
 is a grouping index such as someProject the second index is the name
 of the property. I could use a database table, but why incur an extra
 query. I could use a class, but why increase complexity, I could use
 functions, but complexity again.

I greatly agree with this. I use config arrays, and put all
initialization which sets up the elements of the config arrays in an
include file which is included everywhere.
And inside functions these config arrays are my only globals (besides
the superglobals of course).

greets
Zoltán Németh

  As for singletons... just use a static
 class method.
 
 ?php
 
 class Foo extends Singleton
 {
 function Foo()
 {
 static $createdAlready = false;
 
 if( $createdAlready )
 {
 die( 'Use Foo::getGlobalInstance() instead.' );
 }
 
 $createdAlready = true;
 }
 
 function getGlobalInstance()
 {
 static $singleton = null;
 
 if( $singleton === null )
 {
 $singleton = new Foo();
 }
 
 return $singleton;
 }
 }
 
 ?
 
 Now how hard was that!?
 
 Cheers,
 Rob.
 -- 
 ..
 | InterJinn Application Framework - http://www.interjinn.com |
 ::
 | An application and templating framework for PHP. Boasting  |
 | a powerful, scalable system for accessing system services  |
 | such as forms, properties, sessions, and caches. InterJinn |
 | also provides an extremely flexible architecture for   |
 | creating re-usable components quickly and easily.  |
 `'
 

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



Re: [PHP] Socket problem plz read.

2007-01-31 Thread Németh Zoltán
On sze, 2007-01-31 at 16:26 +0100, Scripter47 wrote:
 I'm making a simple socket server that just receive some data, and then
 send some data back again to the client.
 
 EDIT:
 I forgot to tell that i need help!
 
 I have search around for hours now, and the examples are always not what
 I needed :(
 
 the program is written in Python, if that helps, and is something like this

this is PHP list. go to Python list with that, I suggest

greets
Zoltán Németh

 code
 # Set the socket parameters
 host = http://localhost/in/sql.php;
 port = 1
 buf = 1
 addr = (host,port)
 
 # Create socket
 UDPSock = socket(AF_INET, SOCK_DGRAM)
 
 # Send messages:
 
 # Loop
 while (1):
   # userinput
   data = raw_input(' ')
   if not data:
   break
   else:
   # Send to the PHP page
   if(UDPSock.sendto(data,addr)):
   print Sending message ',data,'.
 
 # Close socket
 UDPSock.close()
 /code
 
 it is a program that send data by sockets, (not port 80)
 
 It has to a simple solution :)
 
 plz ask for more information.
 
 
 
 
 -- 
_.____  __
   /   _/ ___|__|__/  |_  ___  /  |  \__  \
   \_  \_/ ___\_  __ \  \ \   __\/ __ \_  __ \/   |  |_  //
   /\  \___|  | \/  |  |_   | \  ___/|  | \/^   / //
 /___  /\___  __|  |__|   __/|__|  \___  __|  \   | //
  \/ \/ |__| \/   |__|
 

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



Re: [PHP] php code to upload a url correctly

2007-01-26 Thread Németh Zoltán
On p, 2007-01-26 at 14:10 +, Corden James (RW3) CMMC Manchester
wrote:
 I have a form in which users submit a url. I am having problems as some
 people submit the url in the format http://www.blah.blah.org
 http://www.blah.blah.org/  while others submit in the format
 www.blah.blah.org http://www.blah.blah.org/  I have designed the form
 so that it seems fairly obvious (to me anyway) not to include the
 http:// but people are still doing it (presumably because they are
 copying and pasting from a browser). My form processing script is
 designed to add http:// to the submitted url and place the modified url
 in a database for future use. As you can imagine sometimes I end up with
 urls such as http://http://www.blah.blah.org
 http://http:/www.blah.blah.org  in my database. Hence I need a more
 rigorous form processing script that is capable of first checking if the
 url includes http:// and then processes accordingly. Can anyone point me
 in the right direction for such a script?
 
  
 

You should first check the url and only add http://; at the beginning
if its not there

I do it like

if (substr($url, 0, 4) != http) {$url = http://; . $url;}

in my website, although it is probably not the most elegant solution ;)

hope that helps
Zoltán Németh

 Thanks
 
  
 
 Dr James Corden
 
 Technology Evaluation Manager
 
 TrusTECH, Innovation Unit
 
 1st Floor Postgraduate Centre
 
 Manchester Royal Infirmary
 
 Oxford Road
 
 Manchester 
 
 M13 9WL
 
  
 
 Tel:   0161 276 5782
 
 Fax:  0161 276 5766
 
 E-mail: [EMAIL PROTECTED]
 
 Web: http://www.trustech.org.uk
 
 This email and any files transmitted with it are confidential and solely
 for the use of the intended recipient. It may contain material protected
 by law as a legally privileged document and copyright work. Its content
 should not be disclosed and it should not be given or copied to anyone
 other than the person(s) named or referenced above. If you are not the
 intended recipient or the person responsible for delivering to the
 intended recipient, be advised that you have received this email in
 error and that any use is strictly prohibited. 
 
 If you have received this email in error please notify sender
 immediately on +44 (0161) 276 5782
 
  
 

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



Re: [PHP] php code to upload a url correctly

2007-01-26 Thread Németh Zoltán
On p, 2007-01-26 at 16:46 +0100, Jochem Maas wrote:
 Németh Zoltán wrote:
  On p, 2007-01-26 at 14:10 +, Corden James (RW3) CMMC Manchester
  wrote:
  I have a form in which users submit a url. I am having problems as some
  people submit the url in the format http://www.blah.blah.org
  http://www.blah.blah.org/  while others submit in the format
  www.blah.blah.org http://www.blah.blah.org/  I have designed the form
  so that it seems fairly obvious (to me anyway) not to include the
  http:// but people are still doing it (presumably because they are
  copying and pasting from a browser). My form processing script is
  designed to add http:// to the submitted url and place the modified url
  in a database for future use. As you can imagine sometimes I end up with
  urls such as http://http://www.blah.blah.org
  http://http:/www.blah.blah.org  in my database. Hence I need a more
  rigorous form processing script that is capable of first checking if the
  url includes http:// and then processes accordingly. Can anyone point me
  in the right direction for such a script?
 
   
 
  
  You should first check the url and only add http://; at the beginning
  if its not there
  
  I do it like
  
  if (substr($url, 0, 4) != http) {$url = http://; . $url;}
  
  in my website, although it is probably not the most elegant solution ;)
 
 it will break in the highly unlikely situation that someone uploads a url 
 like:
 
   http.mydomain.com
 
 an also for things like:
 
   ftp://leet.haxordownload.org/
 
 2 alternatives spring to mind:
 
   1. a beasty little regex.
   2. use the output of parse_url().

parse_url is a great idea, I think I will use that in the future

thanks Jochem

greets
Zoltán Németh

 
 the second is by far the better way of doing this, below a couple of
 examples:
 
 ?php
 
 var_dump(
   parse_url(http.mydomain.com/foo.php?id=1),
   parse_url(https://www.foo.org/html.html?arg=a;),
   parse_url(ftp://leet.haxordl.org;)
 );
 
 ?
 
 hopefully the OP has enough brains (I'll assume he does given the 'Dr' title 
 he carries :-)
 to figure out how to use the output to be able to always generate a valid url 
 from whatever
 people are sticking in his form (and/or return a suitable error if someone 
 tries to insert
 some complete rubbish)

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



RE: [PHP] where match question

2007-01-24 Thread Németh Zoltán
On k, 2007-01-23 at 22:49 -0700, Don wrote:
 On k, 2007-01-23 at 00:58 -0800, Jim Lucas wrote:
  Németh Zoltán wrote:
   On k, 2007-01-23 at 19:46 +1100, chris smith wrote:
   On 1/23/07, Németh Zoltán [EMAIL PROTECTED] wrote:
   On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
   Don wrote:
   I have a db field that contains zip codes separated by comas.
  
   I am trying to get php to return all of the rows that contain a
 particular
   zip code.
  
  
  
   $query = SELECT * FROM info WHERE MATCH (partialZIP) AGAINST
 ('$zip');
   try this
  
   $query = SELECT * FROM info WHERE column LIKE '{$zip}';
   I would use
  
   $query = SELECT * FROM info WHERE LOCATE('{$zip}', column)  0;
   And how are you going to index that? That's going to be extremely slow
   as the size of the table grows.
  
   
   well, yes.
   
   better solution is to not store the zip codes in one field with commas,
   but in a separate table which relates to this one. and then you could
   use a query like
   
   $query = SELECT t1.*, t2.* FROM info t1, zips t2 WHERE t1.id=t2.infoid
   AND t2.zip = '{$zip}';
   
   greets
   Zoltán Németh
   
  But, since the op is working with existing data, what is the performance 
  difference between using LIKE or LOCATE?
  
  Pro's vs. Con's
  
  
  
 
 oops I just made a simple performance test and the result showed me that
 LIKE is faster (in my test it was twice as faster than LOCATE)
 
 sorry for my ignorance, I did not know that
 
 greets
 Zoltán Németh
 
 I appreciate all the input. I would definitely like to use a separate table
 for the zips, but I cannot figure out how make the form that stores them
 user friendly each entry can have any number of zips - from many to just
 a few.
 
 Also, the site is in development, so there is no existing data 
 
 I will play with LIKE for the time being.

well if you don't have existing data I strongly recommend putting the
zips into a separate table (and then you can forget LIKE and LOCATE as
well ;) )

you don't have to change the user input part, the user may enter all the
zips separated with commas, you only have to do an explode() on it and
then store the resulting array into the zips table.

http://www.php.net/manual/en/function.explode.php

greets
Zoltán Németh

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



Re: [PHP] Unserialize problem (and or bug)

2007-01-24 Thread Németh Zoltán
On sze, 2007-01-24 at 17:17 +0200, Sancar Saran wrote:
 Hi,
 
 After updating company test server to dotdeb 5.2.0 it star to give memory 
 problems (even 32mb session). I tought it was because of suhosin. And I 
 cannot update that server to vanilla debian php5 package because it was a 
 sarge so today my company gives me another debian etch (like my home pc). I 
 setup latest php 5.2.0.8 for debian etch.
 

sorry for my ignorance but what is the difference between vanilla php5
and php5?

thanks
Zoltán Németh

 Then unserialize gives another problem 
 
 Message: unserialize(): Error at offset 1384 of 3177 bytes
 Code: 8
 Line: 419
 
 My pc uses debian etch and have php 5.1.6-5 my scripts working normally.
 
 Is there any suggestion for handle this ? 
 
 Regards
 
 Sancar
 

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



Re: [PHP] where match question

2007-01-23 Thread Németh Zoltán
On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
 Don wrote:
  I have a db field that contains zip codes separated by comas.
  
  I am trying to get php to return all of the rows that contain a particular
  zip code.
  
   
  
  $query = SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip');
 
 try this
 
 $query = SELECT * FROM info WHERE column LIKE '{$zip}';

I would use

$query = SELECT * FROM info WHERE LOCATE('{$zip}', column)  0;

greets
Zoltán Németh

 
  
  $result = mysql_query($query)
  
  or die (could not connect to db);
  
  $row = mysql_fetch_row($result);
  
   
  
   
  
  this works if there is only one row that contains that zip code.
  
   
  
  If there is more than one row that contains the zip, it returns 0 rows.
  ('It' being MYSQL that returns 0 rows. I checked this by running the query
  directly to the DB)
  
   
  
  Any ideas are very much appreciated.
  
   
  
  Thanks,
  
   
  
  Don
  
   
  
   
  
  
 

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



Re: [PHP] where match question

2007-01-23 Thread Németh Zoltán
On k, 2007-01-23 at 19:46 +1100, chris smith wrote:
 On 1/23/07, Németh Zoltán [EMAIL PROTECTED] wrote:
  On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
   Don wrote:
I have a db field that contains zip codes separated by comas.
   
I am trying to get php to return all of the rows that contain a 
particular
zip code.
   
   
   
$query = SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip');
  
   try this
  
   $query = SELECT * FROM info WHERE column LIKE '{$zip}';
 
  I would use
 
  $query = SELECT * FROM info WHERE LOCATE('{$zip}', column)  0;
 
 And how are you going to index that? That's going to be extremely slow
 as the size of the table grows.
 

well, yes.

better solution is to not store the zip codes in one field with commas,
but in a separate table which relates to this one. and then you could
use a query like

$query = SELECT t1.*, t2.* FROM info t1, zips t2 WHERE t1.id=t2.infoid
AND t2.zip = '{$zip}';

greets
Zoltán Németh

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



Re: [PHP] where match question

2007-01-23 Thread Németh Zoltán
On k, 2007-01-23 at 00:58 -0800, Jim Lucas wrote:
 Németh Zoltán wrote:
  On k, 2007-01-23 at 19:46 +1100, chris smith wrote:
  On 1/23/07, Németh Zoltán [EMAIL PROTECTED] wrote:
  On h, 2007-01-22 at 22:53 -0800, Jim Lucas wrote:
  Don wrote:
  I have a db field that contains zip codes separated by comas.
 
  I am trying to get php to return all of the rows that contain a 
  particular
  zip code.
 
 
 
  $query = SELECT * FROM info WHERE MATCH (partialZIP) AGAINST ('$zip');
  try this
 
  $query = SELECT * FROM info WHERE column LIKE '{$zip}';
  I would use
 
  $query = SELECT * FROM info WHERE LOCATE('{$zip}', column)  0;
  And how are you going to index that? That's going to be extremely slow
  as the size of the table grows.
 
  
  well, yes.
  
  better solution is to not store the zip codes in one field with commas,
  but in a separate table which relates to this one. and then you could
  use a query like
  
  $query = SELECT t1.*, t2.* FROM info t1, zips t2 WHERE t1.id=t2.infoid
  AND t2.zip = '{$zip}';
  
  greets
  Zoltán Németh
  
 But, since the op is working with existing data, what is the performance 
 difference between using LIKE or LOCATE?
 
 Pro's vs. Con's
 
 
 

oops I just made a simple performance test and the result showed me that
LIKE is faster (in my test it was twice as faster than LOCATE)

sorry for my ignorance, I did not know that

greets
Zoltán Németh

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



Re: [PHP] Newbie - help with a foreach

2007-01-22 Thread Németh Zoltán
On v, 2007-01-21 at 01:28 -0800, pub wrote:
 On Jan 18, 2007, at 2:43 AM, Németh Zoltán wrote:
 
  first, do you want to allow several jobs for the same company to be
  
  stored in the DB and appear on the page, right? (if not, then why
  are
  
  you storing them in separate tables?)
  
  
 Yes, I have the name of the company with address etc in the client
 table
 and all the jobs in the job table, so that I can display several
 jobs per client 
  second, you should do it with one query I think
  
  
  something like SELECT t1.*, t2.* FROM client t1, job t2 WHERE
  
  t1.companyId=t2.companyId ORDER BY t1.companyId
  
  
  and then you can do all stuff in one loop
  
  
   while ($aaa = mysql_fetch_array($result))
  
  
  and you don't need that foreach stuff at all (which also seems to be
  
  screwed up...)
  
 
 I am working on my query as you suggested. I have a joint query that
 seems to work except that I get the name of the company twice. Could
 you please help me figure out how to make it echo the company once and
 list all the jobs next to it on the same line and start a new line
 with the next company?
 
 

ehh, I thought you want the jobs on separate lines, sorry.

this can be achieved for example like this:

$prev_cname = ;
while ($aaa = mysql_fetch_array($result,MYSQL_ASSOC))
 {  
  if ($aaa['companyName'] != $prev_cname) {
   echo span class='navCompany'{$aaa['companyName']}/span;
  }
  echo span class='navArrow'   /spanspan class='navText'a
href='single_page_t10.php?art=.$aaa['pix'].'{$aaa['jobType']}/a/span;
  if ($aaa['companyName'] != $prev_cname) {
   echo br/\n;
   $prev_cname = $aaa['companyName'];
  }
} 

hope that helps
Zoltán Németh


   Here is the code I have now:
 
 
 $query = SELECT client.companyName, job.jobType, job.pix, job.info,
 job.url
  FROM client, job
  WHERE client.companyId=job.companyId
  AND client.view='yes'
  order by client.companyName;
 
 
 
 $result = mysql_query($query)  
 or die (Couldn't execute query);
 
while  ($aaa = mysql_fetch_array($result,MYSQL_ASSOC))
{  
echo span class='navCompany'{$aaa['companyName']}/spanspan
 class='navArrow'   /spanspan class='navText'a
 href='single_page_t10.php?art=.$aaa['pix'].'{$aaa['jobType']}/a/spanbr\n;
 } 
 

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



Re: [PHP] Newbie - help with a foreach

2007-01-19 Thread Németh Zoltán
On cs, 2007-01-18 at 20:46 +0100, Jochem Maas wrote:
 Németh Zoltán wrote:
  On cs, 2007-01-18 at 02:04 -0800, pub wrote:
  On Jan 18, 2007, at 2:00 AM, Németh Zoltán wrote:
 
 
 
 ...
 
  maybe you should use a parameter for it, place it into the link in the
  first query loop, get it here and query based on it
  
  like SELECT * FROM job WHERE id={$_GET['job_id']} or whatever
 
 SQL INJECTION WAITING TO HAPPEN.

true, sorry
so check the value first

greets
Zoltán Németh

 
 
 ...
 
 foreach($row as $url)
 {
 $row = mysql_fetch_array($result2,MYSQL_ASSOC);
 if (url={$row['url']})
 
 what is this IF statement supposed to be doing???
 because it will always evaluate to true

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



[PHP] preg_match problem

2007-01-19 Thread Németh Zoltán
Hi all,

I have a simple checking like

if (preg_match(/[\w\x2F]{6,}/,$a))

as I would like to allow all word characters as mentioned at
http://hu2.php.net/manual/hu/reference.pcre.pattern.syntax.php
plus the '/' character, and at least 6 characters.

But it throws

Warning: preg_match(): Unknown modifier ']'

and returns false for abc/de/ggg which string should be okay.
If I omit the \x2F, everything works fine but / characters are not
allowed. Anyone knows what I'm doing wrong? Maybe / characters can not
be put in patterns like this?

Thanks in advance,
Zoltán Németh

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



Re: [PHP] preg_match problem

2007-01-19 Thread Németh Zoltán
On p, 2007-01-19 at 15:39 +, Roman Neuhauser wrote:
 # [EMAIL PROTECTED] / 2007-01-19 15:25:38 +0100:
  Hi all,
  
  I have a simple checking like
  
  if (preg_match(/[\w\x2F]{6,}/,$a))
  
  as I would like to allow all word characters as mentioned at
  http://hu2.php.net/manual/hu/reference.pcre.pattern.syntax.php
  plus the '/' character, and at least 6 characters.
  
  But it throws
  
  Warning: preg_match(): Unknown modifier ']'
  
  and returns false for abc/de/ggg which string should be okay.
  If I omit the \x2F, everything works fine but / characters are not
  allowed. Anyone knows what I'm doing wrong? Maybe / characters can not
  be put in patterns like this?
 
 1. You're making your life harder with those double quotes.  \x2F is
interpolated by PHP, before the PCRE library has a chance to see the
string.
 2. Use a different delimiter and you'll be able to use slash characters
in the pattern freely.
 
preg_match('~[\w/]{6,}~', $a);
 

Thank you very much, it's working fine now.

Zoltán Németh

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



Re: [PHP] Newbie - help with a foreach

2007-01-18 Thread Németh Zoltán
I can't really understand what your problem is, because it seems to me
that the site is working like you want it to work. Or not?

And if there is a problem with the code then please show us the code
somehow, not the resulting webpage

greets
Zoltán Németh

On cs, 2007-01-18 at 01:31 -0800, pub wrote:
 Could someone please help me figure out how to hide the info in the  
 right bottom part of my page unless the corresponding link is  
 selected in the top left.
 
 The company names and job types at the top left need to show at all  
 time. But the corresponding picture at the bottom left and the web  
 address/info at the bottom right should appear only when selected.
 
 I have the same query repeating twice once for the top left part and  
 once for the bottom right part because I can't figure out how else to  
 do it!
 
 Thank you.
 
 http://www.squareinch.net/single_page_t2.php?art=btw_logo.jpg

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



Re: [PHP] Newbie - help with a foreach

2007-01-18 Thread Németh Zoltán
ok, but how could anyone help without seeing your code?

greets
Zoltán Németh

On cs, 2007-01-18 at 01:54 -0800, pub wrote:
 Thank you for your reply.
 
 My problem is that the web addresses on the bottom right show at all  
 times as is instead of appearing only when active or selected on the  
 left top navigation!
 
 Does that make sense?
 
 On Jan 18, 2007, at 1:43 AM, Németh Zoltán wrote:
 
  I can't really understand what your problem is, because it seems to me
  that the site is working like you want it to work. Or not?
 
  And if there is a problem with the code then please show us the code
  somehow, not the resulting webpage
 
  greets
  Zoltán Németh
 
  On cs, 2007-01-18 at 01:31 -0800, pub wrote:
  Could someone please help me figure out how to hide the info in the
  right bottom part of my page unless the corresponding link is
  selected in the top left.
 
  The company names and job types at the top left need to show at all
  time. But the corresponding picture at the bottom left and the web
  address/info at the bottom right should appear only when selected.
 
  I have the same query repeating twice once for the top left part and
  once for the bottom right part because I can't figure out how else to
  do it!
 
  Thank you.
 
  http://www.squareinch.net/single_page_t2.php?art=btw_logo.jpg
 
  -- 
  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] Newbie - help with a foreach

2007-01-18 Thread Németh Zoltán
On cs, 2007-01-18 at 02:04 -0800, pub wrote:
 On Jan 18, 2007, at 2:00 AM, Németh Zoltán wrote:
 
  ok, but how could anyone help without seeing your code?
 
  greets
  Zoltán Németh
 
 Here is the code:
 
 Here is the entire page:
 
 !-- nav/box 1 starts here --
 
 
 
 ?php
include(../include/etc_inc.php);
 
$connection = mysql_connect($host,$user,$password)
   or die (couldn't connect to server);
   
 // connect to database
$db = mysql_select_db($database,$connection)
   or die (Couldn't select database);
 
 // query a from client
$query = SELECT * FROM client
   where status='active' or status='old'
   order by companyName;
   
   $result = mysql_query($query)
   or die (Couldn't execute query);
   
while  ($aaa = mysql_fetch_array($result,MYSQL_ASSOC))
{  
echo span class='navCompany'{$aaa['companyName']}/spanspan  
 class='navArrow'   /span\n;
 
 // query b from job
   $query = SELECT * FROM job
   WHERE companyId='{$aaa['companyId']}';
   $result2 = mysql_query($query)
   or die (Couldn't execute query b);
 
   foreach($aaa as $jobType)
   {
   $bbb = mysql_fetch_array($result2,MYSQL_ASSOC);
   echo span class='navText'a 
 href='single_page_t2.php?art=.$bbb 
 ['pix'].'{$bbb['jobType']}/a/span\n;
 
   }   

first, do you want to allow several jobs for the same company to be
stored in the DB and appear on the page, right? (if not, then why are
you storing them in separate tables?)

second, you should do it with one query I think

something like SELECT t1.*, t2.* FROM client t1, job t2 WHERE
t1.companyId=t2.companyId ORDER BY t1.companyId

and then you can do all stuff in one loop

 while ($aaa = mysql_fetch_array($result))

and you don't need that foreach stuff at all (which also seems to be
screwed up...)


   
 
   echo br;
   }   
   ?
   
 
 
 !-- nav/box 1 ends here --
 
 
 
 /div
 div class=navbox2img src=images/sq_logo_137.gif alt=Square  
 Inch logo width=137 height=137/div
 
 div class=navbox3?php $image = $_GET['art']; ?
   img src=images/?php print ($image) ?  
 alt=Portfolio Item  
 border=0 width=285 height=285/div
 
 
 
 div class=navbox4
 
 
 
 
 !-- info/box 4 starts here --
 ?php
 /* query 1 from client */

and here you should not run the whole query again

you should specifically query the one which should appear

maybe you should use a parameter for it, place it into the link in the
first query loop, get it here and query based on it

like SELECT * FROM job WHERE id={$_GET['job_id']} or whatever

and just echo the data from that record

hope that helps
Zoltán Németh

 

 $query = SELECT * FROM client
   where status='active' or status='old'
   order by companyName;
   
   $result = mysql_query($query)
   or die (Couldn't execute query);
 
 while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
 { 
   
 /* query 2 from job */
 $query = SELECT * FROM job
   WHERE companyId='{$row['companyId']}';
   $result2 = mysql_query($query)
   or die (Couldn't execute query2);
   $url = mysql_query($result2);
   
   foreach($row as $url)
   {
   $row = mysql_fetch_array($result2,MYSQL_ASSOC);
   if (url={$row['url']})
   
   echo span class='navText'a 
 href='{$row['url']}'{$row['web']}/ 
 a/span;   
   }
 
   echo br;
   }
   ?
 
 
 !-- info/box 4 ends here --
 
 
 
 
 
  On cs, 2007-01-18 at 01:54 -0800, pub wrote:
  Thank you for your reply.
 
  My problem is that the web addresses on the bottom right show at all
  times as is instead of appearing only when active or selected on the
  left top navigation!
 
  Does that make sense?
 
  On Jan 18, 2007, at 1:43 AM, Németh Zoltán wrote:
 
  I can't really understand what your problem is, because it seems  
  to me
  that the site is working like you want it to work. Or not?
 
  And if there is a problem with the code then please show us the code
  somehow, not the resulting webpage
 
  greets
  Zoltán Németh
 
  On cs, 2007-01-18 at 01:31 -0800, pub wrote:
  Could someone please help me figure out how to hide the info in the
  right bottom part of my page unless the corresponding link is
  selected in the top left.
 
  The company names and job types at the top left need to show at all
  time. But the corresponding picture at the bottom left and the web

Re: [PHP] Broken compatibility with escaping { in php 5.2

2007-01-18 Thread Németh Zoltán
On cs, 2007-01-18 at 14:19 +0100, Jochem Maas wrote:
 Bogdan Ribic wrote:
  Hi all,
  
  Try this:
  
  $a = '';
  echo \{$a};
  
  from php 4, it outputs {}, from php 5.2 (one that comes with Zend 5.5)
 
 no-one here supports Zend.
 
  it outputs \{}, thus breaking existing scripts.
 
 AFAICT the escaping in that string is wrong - the fact that it did work
 the way you want it to is probably sheer luck.
 
 lastly I ran your tests and determined at the least that the 'break'
 occur *prior* to 5.2. at a guess it probably changed in 5.0, here are my 
 results:
 
 # php -r 'echo php,phpversion(),:\n; $a = ; var_dump(\{$s});'  ;
   php5 -r 'echo php,phpversion(),:\n; $a = ; var_dump(\{$s});'
 
 OUTPUT:
 
 php4.3.10-18:
 string(2) {}
 php5.1.2:
 string(3) \{}
 
  
 
 be pragmatic - fix your script :-)

is this the correct form:

$a = '';
echo \{$a\};

if I want to get {} a result?

(I think it is)

greets
Zoltán Németh

 

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



Re: [PHP] web form data to arrays?

2007-01-17 Thread Németh Zoltán
On sze, 2007-01-17 at 15:23 +0200, William Stokes wrote:
 Hello,
 
 I have a script which retrieves rows from DB and prints them to a user 
 editable form to a web page. I don't know how to print the form objects so 
 that all editable fields are put to arrays for updating them to DB. I have 
 tried to create arrays sarjanID[] etc. but havent got it to work...
 
 Pls. see code below.
 
 Thanks
 -Will
 
 $sql = SELECT * FROM x_kilpailu WHERE omistaja = '$updateid' ORDER BY 
 'sorter' ASC;
 $row = mysql_fetch_row($result);
 $result = mysql_query($sql);
 $num = mysql_num_rows($result);
 $cur = 1;
 while ($num = $cur) {

why don't you use this:

while ($row = mysql_fetch_array($result)) {

and then you can omit $cur, and also you won't need $num

$row = mysql_fetch_array($result);
$id = $row[id];
$nimi = $row[nimi];
$kilpailutyyppi = $row[kilpailutyyppi];
$sarjataulukko = $row[sarjataulukko];
$joukkueitakpl = $row[joukkueitakpl];
$sorter = $row[sorter];
$kilpailut[] = array($id, $nimi, $kilpailutyyppi, $sarjataulukko, 
 $joukkueitakpl, $sorter);  //create arrays here
$cur++;
 }
 
 ..
 
 foreach ($kilpailut as $value) { //print arrays to a web form
if ($value[3] == 1) {
   $staulu = Kyll;
  } elseif ($value[3] == 0) {
   $staulu = Ei;
  }
 
  print input type=\hidden\ name=\sarjanID[ID]\ value 
 =\$value[0]\\n;
  print input type=\text\ name=\sarjanID[nimi]\ size=\20\ 
 maxlength=\20\ value =\$value[1]\\n;
  print select name=\sarjanID[tyyppi]\\n;
  print option selected$value[2]/option\n;
  print optionSarja/option\n;
  print optionCup/option\n;
  print /select\n;
  print select name=\sarjanID[sarjataulukko]\\n;
  print option selected$staulu/option\n;
  print optionKylla;/option\n;
  print optionEi/option\n;
  print /select\n;
  print select name=\sarjanID[joukkueitayht]\\n;
  print option selected$value[4]/option\n;
  for ($i=3; $i=20; $i++ ) {
 print option$i/option\n;
 }
  print /select\n;
  print input type=\text\ name=\sarjanID[sortteri]\ value 
 =\$value[5]\\n;
  print input type=\checkbox\ name=\poista\Poista kilpailubrbr\n;
 } 
 

all input fields go to $_POST/$_GET depending on the form method you
use. so you don't have to create an array in the form itself.
just do it like

select name=\tyyppi\

and then you will have that value in $_POST['tyyppi'] or $_GET['tyyppi']

greets
Zoltán Németh

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



Re: [PHP] web form data to arrays?

2007-01-17 Thread Németh Zoltán
On sze, 2007-01-17 at 16:13 +0200, William Stokes wrote:
 But if the form is printed with foreach don't I need some type of counter? 
 Otherwise the form that is posted will contain only the data of the last 
 iteration of the loop that wrote the original form. right?
 
 -Will
 

so you want to print the same form fields for each iteration on the same
page?

then I would use a method like

echo select name=\record_$count_tyyppi\

which results in

select name=\record_1_tyyppi\ for record 1 and so on

and you can access the values in $_POST/$_GET like

$_POST[record_$count_tyyppi]

greets
Zoltán Németh

 
 Nmeth Zoltn [EMAIL PROTECTED] kirjoitti 
 viestiss:[EMAIL PROTECTED]
  On sze, 2007-01-17 at 15:23 +0200, William Stokes wrote:
  Hello,
 
  I have a script which retrieves rows from DB and prints them to a user
  editable form to a web page. I don't know how to print the form objects 
  so
  that all editable fields are put to arrays for updating them to DB. I 
  have
  tried to create arrays sarjanID[] etc. but havent got it to work...
 
  Pls. see code below.
 
  Thanks
  -Will
 
  $sql = SELECT * FROM x_kilpailu WHERE omistaja = '$updateid' ORDER BY
  'sorter' ASC;
  $row = mysql_fetch_row($result);
  $result = mysql_query($sql);
  $num = mysql_num_rows($result);
  $cur = 1;
  while ($num = $cur) {
 
  why don't you use this:
 
  while ($row = mysql_fetch_array($result)) {
 
  and then you can omit $cur, and also you won't need $num
 
 $row = mysql_fetch_array($result);
 $id = $row[id];
 $nimi = $row[nimi];
 $kilpailutyyppi = $row[kilpailutyyppi];
 $sarjataulukko = $row[sarjataulukko];
 $joukkueitakpl = $row[joukkueitakpl];
 $sorter = $row[sorter];
 $kilpailut[] = array($id, $nimi, $kilpailutyyppi, 
  $sarjataulukko,
  $joukkueitakpl, $sorter);  //create arrays here
 $cur++;
  }
 
  ..
 
  foreach ($kilpailut as $value) { //print arrays to a web form
 if ($value[3] == 1) {
$staulu = Kyll;
   } elseif ($value[3] == 0) {
$staulu = Ei;
   }
 
   print input type=\hidden\ name=\sarjanID[ID]\ value
  =\$value[0]\\n;
   print input type=\text\ name=\sarjanID[nimi]\ size=\20\
  maxlength=\20\ value =\$value[1]\\n;
   print select name=\sarjanID[tyyppi]\\n;
   print option selected$value[2]/option\n;
   print optionSarja/option\n;
   print optionCup/option\n;
   print /select\n;
   print select name=\sarjanID[sarjataulukko]\\n;
   print option selected$staulu/option\n;
   print optionKylla;/option\n;
   print optionEi/option\n;
   print /select\n;
   print select name=\sarjanID[joukkueitayht]\\n;
   print option selected$value[4]/option\n;
   for ($i=3; $i=20; $i++ ) {
  print option$i/option\n;
  }
   print /select\n;
   print input type=\text\ name=\sarjanID[sortteri]\ value
  =\$value[5]\\n;
   print input type=\checkbox\ name=\poista\Poista 
  kilpailubrbr\n;
  }
 
 
  all input fields go to $_POST/$_GET depending on the form method you
  use. so you don't have to create an array in the form itself.
  just do it like
 
  select name=\tyyppi\
 
  and then you will have that value in $_POST['tyyppi'] or $_GET['tyyppi']
 
  greets
  Zoltn Nmeth 
 

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



Re: [PHP] web form data to arrays?

2007-01-17 Thread Németh Zoltán
And how does it work? does it create a sub-array of $_POST?

And is it documented somewhere in the manual?

Greets
Zoltán Németh

On sze, 2007-01-17 at 10:54 -0500, Mike Smith wrote:
 input type=text name=name[]
 
 *note the [].
 
 --
 Mike
 

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



Re: [PHP] Unbuffered Query

2007-01-15 Thread Németh Zoltán
I think mysql_data_seek throws this warning also if there is no data in
the result object at all, so I would check the result before positioning

greets
Zoltán Németh

2007. 01. 12, péntek keltezéssel 23.30-kor Richard Lynch ezt írta:
 I have this process that dumps out database records to static HTML pages.
 
 The basic algorithm goes like:
 
 //Set any un-parented item (a root in the thread) to be its own parent:
 update entry set original_id = entry_id where original_id is null
 
 //collect any dirty entries (changed in db, need to re-publish)
 $dirty = select entry_id from entry where dirty = 1
 
 while (list($entry_id) = mysql_fetch_row($dirty)){
   //find the whole thread:
   $followups = select entry_id, X, Y from entry where original_id =
 $dirty_id
   //there is an ORDER BY which is not relevant
 
   //get some thread metadata from the first row's X field
   list($junk, $X) = mysql_fetch_row($followups);
   //$X is the same for all rows...
   echo h1$X/h1\n;
 
   //reset to row 0
   mysql_data_seek($followups, 0);
   while (list($entry_id, $X, $Y) = mysql_fetch_row($followups)){
 echo p$Y/p\n;
   }
 }
 
 So, how come *SOMETIMES*, seemingly at random, I get:
 
 Warning: mysql_data_seek(): Offset 0 is invalid for MySQL result index
 116 (or the
 query data is unbuffered) in
 /www/acousticdemo.com/web/complaints/publish.cron on
 line 26
 
 Line 26 is, obviously, the mysql_data_seek call above...
 
 I do not *THINK* there is any other process anywhere deleting rows
 from the table -- it should be an ever-growing table...
 
 So is the query data being unbuffered out from under me due to some
 my.cnf setting?...
 
 Or am I just plain wrong, and *something* is deleting from the entry
 table?
 
 I Googled for the error message, and found about a 26,000 web sites
 that are exhibiting this error, rather than the folks discussing this
 error. :-v
 
 The few I was able to weed out were obvious logic errors, which I
 don't think I have.
 
 I've read the mysql_unbuffered_query on php.net and think I understand
 it in respect to mysql_query et al.
 
 I guess I'm looking for reassurance that it's definitely my mistake
 somewhere in the mess I've made, and that I'm looking for a delete
 query, and it's not a subtle bug or feature I'm failing to understand.
 
 :-)
 
 -- 
 Some people have a gift link here.
 Know what I want?
 I want you to buy a CD from some starving artist.
 http://cdbaby.com/browse/from/lynch
 Yeah, I get a buck. So?
 

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



  1   2   >