Re: [PHP] Converting integer type to long

2005-08-02 Thread Torgny Bjers
Wee Keat wrote:

>The problem is, I have not been able to convert PHP's integer/float type
>to long because there is no function that does it. Or is there?
>

The reason why is because there's no real long support in PHP.

But, since you mention a value such as 0.01, you are not looking for a
long, you are looking for a float. So, what you need to do is to
type-cast all the values involved in the making of the variable that
holds the float value.

For instance:
$var = (float)$var1 / (float)$var2;
$query = sprintf('%.2f %s', (float)$var, $string);

I haven't found the exact points where PHP forgets it's a float, but
it's always good to make sure all mathematical operations are performed
on the value as a float by type-casting, otherwise it might lose
information.

Regards,
Torgny

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



[PHP] dl exploit

2005-08-02 Thread Anas Mughal
There was a posting on http://us3.php.net/dl dated July 18th regarding the 
dl exploit problem. Following the advice in the posting, my shared hosting 
service disabled dl on our hosting server. I can't load my custom PHP 
extension anymore.

I am wondering if anyone knows about any active development effort to fix 
this problem. Please let me know.
Thank you very much.


P.S.
Text of the posting on PHP documentation page for dl:

WARNING: enable_dl/dl()
*

There is an exploit circulating currently which takes advantage of dl() to 
inject code into Apache which causes all requests to all virtual hosts to be 
redirected to a page of the attackers choice.

All operators of shared web hosting servers with Apache and PHP should 
disable dl() by setting enable_dl to off otherwise your servers are 
vulnerable to this exploit.

This exploit is generally known as flame.so (the object that is loaded into 
Apache) and flame.php (the php script that loads it).


-- 
Anas Mughal


[PHP] Converting integer type to long

2005-08-02 Thread Wee Keat
Hi All,

I'm facing a little problem here. I'm making a few query using SOAP
protocol (NuSOAP class), that involves sending out an amount (e.g.
0.01), which is accepted in type of [long] in its WSDL, for recording
purpose. Typical call:

[code]
$param = array('rewardSchemeId'=> $tnt_rewardSchemeId,
'accountNumber' => $acountNumber,
'amount'=> $amountIgnoringDecimalPoint) );

$result = $soap->call('recordBooking', $param);
[/code]

The problem is, I have not been able to convert PHP's integer/float type
to long because there is no function that does it. Or is there?

I've tried using settype() and (type) casting, but to no avail. I've
read a user's contribution note in PHP Manual for settype(), and he said:

"It's worth noting that one can neither settype() nor type-cast a
variable as a long.  The workaround for this seems to be to use
pack()."

I've looked at pack() function and tried it but I don't think I'm
getting it right because the instruction is not clear to me ( I don't
have programming background). I've done the following:

$amount = pack('L', $amount);

Please assist. Thanks.




-- 
Wee Keat Chin

Protocol Networks
p: 1300 131 932
e: [EMAIL PROTECTED]
h: www.pn.com.au

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



[PHP] Re: help with a bucle

2005-08-02 Thread sonu gill
Sorry clarification required to my previous answer...

I sort of answered you in a hurry, and I made another assumption that I 
didn't define.

I wanted to clarify that I'm assuming the array is setup as follows
arr[day]=>report.

arr[1]=>45
arr[2]=>56
arr[4]=>78
etc...


$y = 31;

for($x=0; $x < $y; $x++)
{
echo "day ". ($x+1) ." - report " . ((isset($arr[$x+1]))? 
$arr[$x+1]:"0") . "";  //$x+1 is required because you can never have 
day 0
}

""sonu gill"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> From what I gathered you simply want to print all days and the "reporte" 
> field info and if there isn't any then 0.
>
> Assuming you used SQL and retrieved your information from the db into an 
> associated Array
>
> $arr //the results from the DB...
>
> $y = 31;  //Assuming you are working with 31 days...
>
> for($x=0; $x<$y; $x++)
> {
> echo "day ". ($x+1) ." - report " . ((isset($arr[$x+1]))? 
> $arr[$x+1]:"0") . "";  //$x+1 is required because you can never have 
> day 0
> }
>
> hope this helps...
>
> -sonu
>
>
> ""Jesús Alain Rodríguez Santos"" <[EMAIL PROTECTED]> wrote in 
> message 
> news:[EMAIL PROTECTED]
>> Hi, i have in my mysql db one table columm, some think like this:
>>
>> dayreporte
>> ------
>> 145
>> 256
>> 478
>> 689
>> 790
>> etc...
>>
>> How can i print all the value from 'reporte' columm depending the 'day'
>> columm, and if there is not exist a day print 0 value, for example:
>>
>> day 1 - reporte 45
>> day 2 - reporte 56
>> day 3 - 0
>> day 4 - reporte 78
>> day 5 - 0
>> etc...
>>
>> Sorry for my english
>>
>>
>> -- 
>> Este mensaje ha sido analizado por MailScanner
>> en busca de virus y otros contenidos peligrosos,
>> y se considera que está limpio. 

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



[PHP] Re: help with a bucle

2005-08-02 Thread sonu gill
>From what I gathered you simply want to print all days and the "reporte" 
field info and if there isn't any then 0.

Assuming you used SQL and retrieved your information from the db into an 
associated Array

$arr //the results from the DB...

$y = 31;  //Assuming you are working with 31 days...

for($x=0; $x<$y; $x++)
{
echo "day ". ($x+1) ." - report " . ((isset($arr[$x+1]))? 
$arr[$x+1]:"0") . "";  //$x+1 is required because you can never have 
day 0
}

hope this helps...

-sonu


""Jesús Alain Rodríguez Santos"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Hi, i have in my mysql db one table columm, some think like this:
>
> dayreporte
> ------
> 145
> 256
> 478
> 689
> 790
> etc...
>
> How can i print all the value from 'reporte' columm depending the 'day'
> columm, and if there is not exist a day print 0 value, for example:
>
> day 1 - reporte 45
> day 2 - reporte 56
> day 3 - 0
> day 4 - reporte 78
> day 5 - 0
> etc...
>
> Sorry for my english
>
>
> -- 
> Este mensaje ha sido analizado por MailScanner
> en busca de virus y otros contenidos peligrosos,
> y se considera que está limpio. 

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



[PHP] help with a bucle

2005-08-02 Thread Jesús Alain Rodríguez Santos
Hi, i have in my mysql db one table columm, some think like this:

dayreporte
------
145
256
478
689
790
etc...

How can i print all the value from 'reporte' columm depending the 'day'
columm, and if there is not exist a day print 0 value, for example:

day 1 - reporte 45
day 2 - reporte 56
day 3 - 0
day 4 - reporte 78
day 5 - 0
etc...

Sorry for my english


-- 
Este mensaje ha sido analizado por MailScanner
en busca de virus y otros contenidos peligrosos,
y se considera que está limpio.

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



Re: [PHP] array()

2005-08-02 Thread Jochem Maas

Rory Browne wrote:
You're using a lot of negatives. 



nice catch on the double neg Rory :-)




$data = array(); // You should initialise $data to array() for various reasons:
// 1: self_documentation - to anyone who reads your code will be obvious 
// that $data should contain an empty array
// 2: security - if someone goes to 
//  http://yoursite.com/page.php?data[]=something_bad_here and you have 
//  register_globals on(which should be, but not assumed to be, off)






On 8/1/05, Sebastian <[EMAIL PROTECTED]> wrote:


is it always necessary to call array() when you do something like this:

mysql_query("SELECT ");
while($rows .)
{
  $data[] = $rows;
}

if so, why? i have a habit of never calling array() and someone told me
i shouldn't do this.



Someone told you you shouldn't not call array() - in other words you
should call array(). If I'm reading you correctly then the someone is
right. You should not use a variable without initialising it, unless
it comes from a form, in which case you should not use it without
"cleaning" it.






--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005

--
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] Error Suppression with '@'

2005-08-02 Thread Jochem Maas

Justin Burger wrote:

Good Morning,
I was having a discussion with a fellow PHP Developer this morning and he
mentioned that he put's an '@' sign in front of all function calls, and
every time he accesses an array;

I know that this is sloppy, and dangerous, but I don't know exactly what
this exposes him to, can any one give me any real world examples of why
this is bad, so I can relate it to his code?

php.net does not have much information about this. It seems like
suppressing errors, rather then catching them is problematic.


in short what you monkey is doing sucks - if it was a good idea php
would be designed to output or log no errors at all... ever ... funnily
enough that's not they way it's designed.

knowing how to handle errors properly AND doing it is IMHO one of the
main differentiators between amateur and professional programmers -
of course the true wizards among us know when they can break the rules
(e.g. hack up some nasty little script that scratches an itch knowing
full well it 'breaks the rules') :-)

if I were you I would give serious weight to the words of John Nichel
on this matter - he might not admit it but he really knows where his towel
;-)




Thanks Again.

Justin.



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



Re: [PHP] Re: editor in WEB PAGE

2005-08-02 Thread Graham Cossey
> > -Original Message-
> > From: Graham Cossey [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, August 02, 2005 1:12 PM
> > To: php-general@lists.php.net
> > Subject: Re: [PHP] Re: editor in WEB PAGE
> >
> > Sorry to drag this up again, but I'm attempting to set up FCKeditor
> > and am having problems with the File Browser. Has anyone successfully
> > got this running with the PHP connector? If so some hints & tips would
> > be most appreciated.
> >
> > I've set my UserFilePath in config.php (relative to doc root) but the
> > file (image) browser shows no files and claims to be looking at the
> > path '/'. Uploading a file does not give an error but the file does
> > not get uploaded.
> >
> > thanks
> > --
> > Graham
> >

I've been fiddling and found a typo in the config.php's UserFilesPath.
This now allows me to upload files (to the expected directory) but I
still cannot view the files in this directory in the file browser.

-- 
Graham

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



Re: [PHP] parent::construct not reliable working on php5.1 b2/b3

2005-08-02 Thread Jochem Maas

Meno Abels wrote:

it is only a typo in my email i use __construct


ok - I would recommend cut-n-paste for this kind of output
to prevent idiots like me pointing out you typos and to avoid confusion
in general.

the next questions would be:

a, how many parents does the problem class (Link or Links?) have?
b, is Rank the base class?
c, does Rank::__construct() actually exist?
d, does the error also occur with php5.0.x? (as apposed to php5.1beta)

given these questions may seem silly - but I can't see your code from
here :-) so I figured I'd ask anyway!



Meno

2005/8/2, Jochem Maas <[EMAIL PROTECTED]>:


Pawel Bernat wrote:


On Tue, Aug 02, 2005 at 03:42:00PM +0100, Meno Abels wrote:



Hello,

With my application that uses heavily inherent classes, sometimes I


dep class heirarchies can lead to brainfreeze - beware of going to deep :-)



get the following message:
PHP Fatal error:  Call to undefined method Rank::_construtor() in
.../inc/Links.class.php.   It works with php
4.x when I use the old style of constructor calling
$this->(CLASSNAME) . But when working with php 5.2 b2 or b3 in the old
OR the new style, I get the PHP Fatal error from above.
Is there any hints to look at this problem?


Why do you call _construct instead of __construct? And how do you do it?


he seems to be calling _construtor() which although not wrong is not the
method he is looking for (cue voice of Alex Guiness for the second time this 
week :-)

try __construct()

PS - this kind of thing belongs on generals until you are _sure_ it's an
internals problem. IMHO.



Did you read everything at http://php.net/construct (including Note)?
What about php 5.0?








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



Re: [PHP] cannot find the parse error

2005-08-02 Thread Jochem Maas

Miles Thompson wrote:

At 11:45 AM 8/2/2005, John Nichel wrote:


Jochem Maas wrote:


John Nichel wrote:


Jochem Maas wrote:



did you look at line 44??? (actually I found the problem on line 69
when I cut and pasted into a editor - the editor also gave that 
line as the

one with the error in it:






And to think that I used to hate editors that did this at one time.



:-) not sure I follow you completely.
actually the editor (TextPad in this case) didn't do anything nasty - 
it was my mail

app had already done a nice job with wordwrapping :-/



About 6 or so years ago, I couldn't stand things like syntax 
highlighting, and editors that error checked (don't know why, I'm just 
weird that way I guess).  Now, I don't know how I lived without it. 
Guess I've just be assimilated. ;)


--



John,

Which editor does syntax checking?
(In VB I find it a mixed blessing.)


I have Textpad set up with syntax highlighting and I've added an
item to the 'tools' menu that allows me to perform a 'php -l' on the current
file (1 item for php5, and 1 for php4) - but the best integrated syntax checking
(and code analysis) I have found is in the Zend Studio v4 (aka ZDE) - really
a superb tool (although I feel some work could still be done on the 
general/non-php-specifc
 editor functionality to bring up to par with some of the longer-standing/more 
traditional
editors that I have used)





Cheers - Miles



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



Re[2]: [PHP] Error Suppression with '@'

2005-08-02 Thread Richard Davey
Hello Justin,

Tuesday, August 2, 2005, 8:43:09 PM, you wrote:

JB> Does suppressing the error only suppress it from the screen, or
JB> does it ignore the error?
JB> ie: is the error still logged?

It will ignore it totally, it doesn't even make it as far as the log
files - which is why in most cases it's a bad thing to use. When it
comes to the mysql/i functions however I will suppress the error and
use my own error checking to avoid blank pages / unsightly warnings.

Best regards,

Richard Davey
-- 
 http://www.launchcode.co.uk - PHP Development Services
 Zend Certified Engineer
 "I do not fear computers. I fear the lack of them." - Isaac Asimov

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



Re: [PHP] Forming an SQL query

2005-08-02 Thread Jack Jackson

Ah, I had left out the third column the first time! Thanks.

Now I can insert and not create dupes but for some reason it is not 
updating.



Here's the code:


  if ( ($_POST['action'] == 'process') && (!sizeof($message) ) )
  {
  foreach($_POST as $key=>$val)
   {
   //find key/val sets within posts which are both numeric
   if(is_numeric($key) && is_numeric($val))
   {
  $nkey=$key;
  //add these values ( q_id, a_id ) to sql statement
  $qanda[] .= "('1' , '" . $nkey . "' , '" . $val . 
"')";

   }
   //find key/val sets within sub-arrays of $_POST 
which are numeric

   if(is_array($val))
   {
   foreach ($val as $akey=>$aval)
   {
   //add these values ( q_id, a_id ) to sql 
statement
   $qanda[] .= "('1' , '" . $key . "' , '" . 
$aval . "')";

   }
   }
   }

$q_a_sql="INSERT INTO" . $userTable . "(u_id, q_id, a_id )
  VALUES " . (implode(",",$qanda)) . "on duplicate key 
UPDATE a_id = VALUES(a_id);";


  if($q_a_result = mysql_query($q_a_sql))
{
  unset($_SESSION['required_fields']);
  $cat = $_POST['cat']+1;
  include_once(QUESTIONS . 'q.inc');
}


?


Kristen G. Thorson wrote:
How is it your plan "thwarted?"  It looks fine to me, but maybe I'm 
missing something.  The only thing I can think is that you're not 
defining your table keys correctly to correctly use ON DUPLICATE KEY.  
Do you have a key defined for all three columns *together*?


mysql> create table user_answers (u_id int(11) not null, q_id int(11) 
not null, a_id int(11) not null, unique( u_id, q_id, a_id ) );

Query OK 0 rows affected (0.22 sec)

mysql> insert into user_answers (u_id,q_id,a_id) values 
(1,1,1),(1,1,2),(1,2,1),(1,1,1) on duplicate key update a_id=values(a_id);

Query OK, 5 rows affected (0.01 sec)
Records: 4  Duplicates: 1  Warnings: 0

mysql>select * from user_answers;
+--+--+--+
| u_id | q_id | a_id |
+--+--+--+
|1 |1 |1 |
|1 |1 |2 |
|1 |1 |3 |
+--+--+--+
3 rows in set (0.00 sec)



So, three different answers for the same user & same question.  The one 
duplicate did not cause an error because of the ON DUPLICATE KEY.  This 
looks like it's what you're trying to do, so then what's your error?




kgt




Jack Jackson wrote:


Hi,
Thanks to everyone's help, that multipage monster of a form is now 
working properly (yay!).


One problem I have though is that I stick the answers as each page is 
completed into a table. If the user hits the back button, rather than 
adding a new row to the table I'd rather update it if it's there. 
That's fairly straightforward when it's 1:1 questions to answers:


  $q_a_sql='INSERT INTO $userAnswerTable
  ( q_id, a_id )
  VALUES ' . (implode(",",$qanda))
  . ' on duplicate key UPDATE a_id = VALUES(a_id);';

But when it's 1:n, such as with checkboxes, this neat little plan of 
mine is thwarted.


So if I change the userAnswerTable to three columns, u_id, q_id and 
a_id, is there a way I can do all the 1:1 and 1:n in the manner I wish?


TIA,
JJ







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



Re: [PHP] Re: editor in WEB PAGE

2005-08-02 Thread Graham Cossey
Sorry to drag this up again, but I'm attempting to set up FCKeditor
and am having problems with the File Browser. Has anyone successfully
got this running with the PHP connector? If so some hints & tips would
be most appreciated.

I've set my UserFilePath in config.php (relative to doc root) but the
file (image) browser shows no files and claims to be looking at the
path '/'. Uploading a file does not give an error but the file does
not get uploaded.

thanks
-- 
Graham

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



Re: [PHP] Error Suppression with '@'

2005-08-02 Thread Kristen G. Thorson

Example:

I was working on a HORRIBLE piece of code for a cart app.  The original 
programmer had a line like this:


$result = mysql_query( "SELECT * FROM user_logins WHERE 
cookie='".$cookie."'" );


Where $cookie is a session id stored in a cookie (what else? ;).  The 
problem was, he had some faulty code that was not always properly 
setting the cookie.  So then he went and did the following:


$customer_id=mysql_result($result,0,"id");

Problem is, $cookie='' but there are no entries in the user_logins table 
where cookie=''.  So, the query is empty and trying to pull the customer 
ID gave the nice little warning because E_ALL was on:


*Warning*: mysql_result(): Unable to jump to row 0 on MySQL result index 
3 in *cart.php* on line *26*


So customers get confused because of the warning and on top of that they 
have no items in their cart because customer_id is used to look up temp 
carts (and it wasn't set).  He couldn't figure out why it was happening 
and he didn't have logging turned on, so all he had was Billy Bob saying 
"My cart is gone.  There was an error.  I don't know what it was.  I 
didn't write it down."  So then he decided to put an @ in front of the 
offending lines.  Customers no longer get an error.  Excellent.


But wait!  Three months down the road, we have the problem of the 
vanishing carts.  So third-party programmer comes in, turns on logging 
so I can see the stupid errors and figure out what's going on, but 
errors have been repressed!  This is not helpful to anyone, I then have 
to go through and figure out whether it will break something by removing 
those stupid @'s (there were a LOT of them).


The problem wasn't that he was using @, but that he was not properly 
checking for errors, and used @ to suppress bugs he couldn't duplicate 
or couldn't figure out how to fix.  In short, if you don't want the 
customer to see the error, turn of reporting and turn on logging.  
Anyone trying to debug your code three years later will thank you.


my 2c.

kgt








Justin Burger wrote:


Good Morning,
I was having a discussion with a fellow PHP Developer this morning and he
mentioned that he put's an '@' sign in front of all function calls, and
every time he accesses an array;

I know that this is sloppy, and dangerous, but I don't know exactly what
this exposes him to, can any one give me any real world examples of why
this is bad, so I can relate it to his code?

php.net does not have much information about this. It seems like
suppressing errors, rather then catching them is problematic.


Thanks Again.

Justin.

 



Re: [PHP] Regex help

2005-08-02 Thread Dotan Cohen
On 8/2/05, Robin Vickery <[EMAIL PROTECTED]> wrote:
> I don't suppose this is the place for a rant about the futility of
> checking email addresses with a regexp?
> 
>   -robin

Let Richard Lynch tell him. He's good at regex's, and it's HIS email
address that never makes it through!

Dotan Cohen
http://lyricslist.com/lyrics/artist_albums/182/estefan_gloria.php
Estefan, Gloria Song Lyrics

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



Re: [PHP] Error Suppression with '@'

2005-08-02 Thread Justin Burger


Does suppressing the error only suppress it from the screen, or does   
it ignore the error?


ie: is the error still logged?

On Aug 2, 2005, at 12:18 PM, John Nichel wrote:



Justin Burger wrote:



Good Morning,
I was having a discussion with a fellow PHP Developer this morning  
and he
mentioned that he put's an '@' sign in front of all function  
calls, and

every time he accesses an array;
I know that this is sloppy, and dangerous, but I don't know  
exactly what
this exposes him to, can any one give me any real world examples  
of why

this is bad, so I can relate it to his code?
php.net does not have much information about this. It seems like
suppressing errors, rather then catching them is problematic.




I'm going to partially disagree with some of the responses you get  
on this by saying that it doesn't have to be sloppy or a bad idea.   
I use the '@' symbol on _some_ of my function calls (mainly MySQL  
stuff), but only because I have my own error handling system in  
place.  Some will say that if you want to control what is being  
printed to the screen, modify the php.ini file, but I don't fully  
subscribe to that.  In production, I do turn off notices, but  
that's about it.  For me, it boils down to my wanting to control  
the verbatim of the error; ie make the error messages a bit more  
end user friendly.  The reason I don't like suppressing this in the  
ini file is it becomes a pain in the ass to try and debug a  
customer's problem (with the customer on the phone), if no error  
messages are showing on the screen for him/her.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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





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



Re: [PHP] Error Suppression with '@'

2005-08-02 Thread John Nichel

Justin Burger wrote:
Does suppressing the error only suppress it from the screen, or does  it 
ignore the error?


ie: is the error still logged?


Please reply to the list.

I don't know if it still logs the error (assuming you have error logging 
turned on).


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Error Suppression with '@'

2005-08-02 Thread John Nichel

Justin Burger wrote:

Good Morning,
I was having a discussion with a fellow PHP Developer this morning and he
mentioned that he put's an '@' sign in front of all function calls, and
every time he accesses an array;

I know that this is sloppy, and dangerous, but I don't know exactly what
this exposes him to, can any one give me any real world examples of why
this is bad, so I can relate it to his code?

php.net does not have much information about this. It seems like
suppressing errors, rather then catching them is problematic.


I'm going to partially disagree with some of the responses you get on 
this by saying that it doesn't have to be sloppy or a bad idea.  I use 
the '@' symbol on _some_ of my function calls (mainly MySQL stuff), but 
only because I have my own error handling system in place.  Some will 
say that if you want to control what is being printed to the screen, 
modify the php.ini file, but I don't fully subscribe to that.  In 
production, I do turn off notices, but that's about it.  For me, it 
boils down to my wanting to control the verbatim of the error; ie make 
the error messages a bit more end user friendly.  The reason I don't 
like suppressing this in the ini file is it becomes a pain in the ass to 
try and debug a customer's problem (with the customer on the phone), if 
no error messages are showing on the screen for him/her.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] array()

2005-08-02 Thread Rory Browne
You're using a lot of negatives. 



$data = array(); // You should initialise $data to array() for various reasons:
// 1: self_documentation - to anyone who reads your code will be obvious 
// that $data should contain an empty array
// 2: security - if someone goes to 
//  http://yoursite.com/page.php?data[]=something_bad_here and you have 
//  register_globals on(which should be, but not assumed to be, off)





On 8/1/05, Sebastian <[EMAIL PROTECTED]> wrote:
> is it always necessary to call array() when you do something like this:
> 
> mysql_query("SELECT ");
> while($rows .)
> {
>$data[] = $rows;
> }
> 
> if so, why? i have a habit of never calling array() and someone told me
> i shouldn't do this.

Someone told you you shouldn't not call array() - in other words you
should call array(). If I'm reading you correctly then the someone is
right. You should not use a variable without initialising it, unless
it comes from a form, in which case you should not use it without
"cleaning" it.



> 
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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



Re: [PHP] how to mix two arrays into one and sort it by date/time?

2005-08-02 Thread [EMAIL PROTECTED]

Problem solved by mysql query (I thought it would be more tough :) )

my_query("
   (select order_transaction_no, order_date from order_table_1 
where order_date >= '". $date_yesterday ."')

   union
   (select order_transaction_no, order_date from order_table_2 
where order_date >= '". $date_yesterday ."')

   order by order_transaction_no desc, order_date desc
   ", 0);

:)




[EMAIL PROTECTED] wrote:


I have two tables with orders of different type of articles.
order_table_1
order_table | order_transaction_no | order_date | ...
1 | 56982 | 2005-07-29 9:12:34
1 | 97163 | 2005-07-30 8:45:32
1 | 67452 | 2005-07-31 10:56:11

order_table_2
order_table | order_transaction_no | order_date | ...
2 | 36928 | 2005-07-29 11:12:54
2 | 97001 | 2005-07-29 4:45:41
2 | 54549 | 2005-07-31 6:56:28

I have to grab orders from both tables (last 24 hour), put them 
together and then sort them by datetime ordered. Like this:

2 | 97001 | 2005-07-29 4:45:41
1 | 56982 | 2005-07-29 9:12:34
2 | 36928 | 2005-07-29 11:12:54
1 | 97163 | 2005-07-30 8:45:32
2 | 54549 | 2005-07-31 6:56:28
1 | 67452 | 2005-07-31 10:56:11

My idea was to grab first all orders from first table as 
multi-dimensional array

$orders = array(
   array('order_table' => 1, 'order_trans_no' 
=> 56982, 'order_date' => 2005-07-29 9:12:34),
   array('order_table' => 1, 'order_trans_no' 
=> 97163, 'order_date' => 2005-07-30 8:45:32),
   array('order_table' => 1, 'order_trans_no' 
=> 67452, 'order_date' => 2005-07-31 10:56:11)
   array('order_table' => 2, 'order_trans_no' 
=> 36928, 'order_date' => 2005-07-29 11:12:54),
   array('order_table' => 2, 'order_trans_no' 
=> 97001, 'order_date' => 2005-07-29 4:45:41),
   array('order_table' => 2, 'order_trans_no' 
=> 54549, 'order_date' => 2005-07-31 6:56:28)

   )

and then sort the array after order_date - but don't know how :(

I guess the best way would be to make a sql query and sort them while 
grabbing them from db but don't know how to do it either :(


Any help?

Thanks!

-afan



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



Re: [PHP] Java - toString() <-> php - ?

2005-08-02 Thread Adi Zebic

Rory Browne a écrit :

I haven't a monkies what that code(your java) does, and I don't have
time to analyse it(in expensive cybercafe), but you may want to
consider www.php.net/print-r www.php.net/var-dump and
www.php.net/var-export

I think they may do what you want without using the toString method,
which for what you're describing is basicly an ugly hack.

One more thing: Enlighten me: What exactly do you mean by "live
evolution" in your php/java context.


If in php context you have class, say, A:

class A
{

 var $t1;
 var $t2;
 var $t3;

//After, you have object contructor of type A
//we have something like this

function A ($var1, $var2, $var3)
{
$this -> t1 = $var1;
$this -> t2 = $var2;
$this -> t3 = $var3;
}

some other code
}

//than in some other class we have something like this:

class someOtherClass
{
$aConstructor = new A(1,2,3);
//values of t1, t2 and t3 are 1,2 and 3 now
 }

Right? yes.

How you can you do something like this inside of "someOtherClass"

print ($aConstructor);

to finally have some nice output like
Value of t1 is 1;
Value of t2 is 2;
Value of T3 is 3;

or just:

1
2
3

Without creating functions like getValues()

function getValues()
{
print ($this -> t1);
print ($this -> t2);
print ($this -> t3);
}

and after explicit invoke function:

 $aConstructor -> getValues();

So, what I want is
this: print ($aConstructor);

and not this:

$aContructor -> getValues();

Am I clear :-)


ADI

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



Re: [PHP] Error Suppression with '@'

2005-08-02 Thread Matt Darby

Justin Burger wrote:


Good Morning,
I was having a discussion with a fellow PHP Developer this morning and he
mentioned that he put's an '@' sign in front of all function calls, and
every time he accesses an array;

I know that this is sloppy, and dangerous, but I don't know exactly what
this exposes him to, can any one give me any real world examples of why
this is bad, so I can relate it to his code?

php.net does not have much information about this. It seems like
suppressing errors, rather then catching them is problematic.


Thanks Again.

Justin.
 



This is a Bad Idea. A Very Bad Idea actually. If he's just looking to 
hide error output, he should at least edit php.ini
to log to an error file. Otherwise, debugging his code would be 
horrible. The "@" is total slop.


Matt Darby

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



Re: [PHP] Error Suppression with '@'

2005-08-02 Thread Rory Browne
On 8/2/05, Justin Burger <[EMAIL PROTECTED]> wrote:
> Good Morning,
> I was having a discussion with a fellow PHP Developer this morning and he
> mentioned that he put's an '@' sign in front of all function calls, and
> every time he accesses an array;

Any chance of revealing his identity - so that I can make sure that I
don't sub-contract him any work.

> 
> I know that this is sloppy, and dangerous, but I don't know exactly what
> this exposes him to, can any one give me any real world examples of why
> this is bad, so I can relate it to his code?

It's bad in that your system normally gives you an error when you do
something wrong. Sometimes your code can recover from errors, but your
code runs better if the errors aren't there.

In production code, you don't want the errors to show up on screen,
mainly because you don't want to expose the code you are using on your
back end. You fix this by modding the correct parameter in php.ini (
display_errors IIRC )

> 
> php.net does not have much information about this. It seems like
> suppressing errors, rather then catching them is problematic.

PHP displays errors for a reason. It is both egotistic, and foolish to
assume that your code will always be perfect. Errors enlighten you
when your code is not perfect, and give you the opportunity to perfect
it.

You can achieve a similar effect by setting display_errors to the
correct setting.

> 
> 
> Thanks Again.
> 
> Justin.
> 
> --
> 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] Error Suppression with '@'

2005-08-02 Thread Torgny Bjers
Hello Justin,

I would guess that this is mostly performance and memory related. When,
for instance, trying to iterate an array, or a directory with files,
using @ on all function calls, it will attempt to go through the array,
attempting to allocate memory for each item, but when finding it
empty/broken, it leaves the loop and goes on to the next statement in
the code.

>From what I can tell, PHP handles memory efficiently, although I
wouldn't hazard this when deploying a larger site using this type of
approach. Especially if the code inside a larger if..else block was
performed on an object that was created with @function() call, and then
all the consecutive calls to functions operating on that object also
used @. This would take up both CPU time and memory, possibly creating
leaks, based on how efficiently PHP would handle the operations on a
non-existant object.

A rule of thumb is to instead use empty() and is_array() and such
functions to discern if the object you are going to handle indeed is of
the type you wish it to be, that saves you both time and effort when
trying to debug something in the future. The empty() function goes a
long way here, unless dealing with integers, since empty() will return
true if the value is 0, which might not be desireable.

I hope this helps you in your argument against your fellow developer. :]

Regards,
Torgny

Justin Burger wrote:

>Good Morning,
>I was having a discussion with a fellow PHP Developer this morning and he
>mentioned that he put's an '@' sign in front of all function calls, and
>every time he accesses an array;
>
>I know that this is sloppy, and dangerous, but I don't know exactly what
>this exposes him to, can any one give me any real world examples of why
>this is bad, so I can relate it to his code?
>
>php.net does not have much information about this. It seems like
>suppressing errors, rather then catching them is problematic.
>
>
>Thanks Again.
>
>Justin.
>  
>

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



Re: [PHP] AJAX & PHP

2005-08-02 Thread Graham Anderson
Has anyone integrated JPGraph [or another php graph class]  into a 
PHP/AJAX setup ?


I would really like to integrate interactive graphs based upon user 
variables.

Would be fantastic.
Are there any examples out there ?

g

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



Re: [PHP] encrypting urls

2005-08-02 Thread Rory Browne
On 8/2/05, Torgny Bjers <[EMAIL PROTECTED]> wrote:
> Another idea would be to Base64 encode/decode the parameters.

I'm not sure why you sent this to me(and me only). It's not me, but
rather the OP who wants to "encrypt" the url.

> 
> Rory Browne wrote:
> 
> >serialize/unserialize accompanied by some compression/decompression
> >should do the trick. Your output probably won't be any smaller with
> >compresson overhead, but it would be non-obvious. It is also extremely
> >easy to circumvent.
> >
> >On 8/2/05, Sebastian <[EMAIL PROTECTED]> wrote:
> >
> >
> >>i need to mask (hide) some vars in a url so they arent visible to the
> >>user. example, i want a url like this:
> >>
> >>page?id=3&something=12&more=12
> >>
> >>to turn into:
> >>
> >>page?id=3;LyFU;MLFxvy
> >>
> >>so from "LyFU" i can access $something and from "MLFxvy" $more
> >>any ideas how i can do this?
> >>
> >>doesn't have to be 100% secure, just a simple way hide it from the user.
> >>
> >>
> >
> 
>

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



[PHP] how to mix two arrays into one and sort it by date/time?

2005-08-02 Thread [EMAIL PROTECTED]

I have two tables with orders of different type of articles.
order_table_1
order_table | order_transaction_no | order_date | ...
1 | 56982 | 2005-07-29 9:12:34
1 | 97163 | 2005-07-30 8:45:32
1 | 67452 | 2005-07-31 10:56:11

order_table_2
order_table | order_transaction_no | order_date | ...
2 | 36928 | 2005-07-29 11:12:54
2 | 97001 | 2005-07-29 4:45:41
2 | 54549 | 2005-07-31 6:56:28

I have to grab orders from both tables (last 24 hour), put them together 
and then sort them by datetime ordered. Like this:

2 | 97001 | 2005-07-29 4:45:41
1 | 56982 | 2005-07-29 9:12:34
2 | 36928 | 2005-07-29 11:12:54
1 | 97163 | 2005-07-30 8:45:32
2 | 54549 | 2005-07-31 6:56:28
1 | 67452 | 2005-07-31 10:56:11

My idea was to grab first all orders from first table as 
multi-dimensional array

$orders = array(
   array('order_table' => 1, 'order_trans_no' 
=> 56982, 'order_date' => 2005-07-29 9:12:34),
   array('order_table' => 1, 'order_trans_no' 
=> 97163, 'order_date' => 2005-07-30 8:45:32),
   array('order_table' => 1, 'order_trans_no' 
=> 67452, 'order_date' => 2005-07-31 10:56:11)
   array('order_table' => 2, 'order_trans_no' 
=> 36928, 'order_date' => 2005-07-29 11:12:54),
   array('order_table' => 2, 'order_trans_no' 
=> 97001, 'order_date' => 2005-07-29 4:45:41),
   array('order_table' => 2, 'order_trans_no' 
=> 54549, 'order_date' => 2005-07-31 6:56:28)

   )

and then sort the array after order_date - but don't know how :(

I guess the best way would be to make a sql query and sort them while 
grabbing them from db but don't know how to do it either :(


Any help?

Thanks!

-afan

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



[PHP] Error Suppression with '@'

2005-08-02 Thread Justin Burger
Good Morning,
I was having a discussion with a fellow PHP Developer this morning and he
mentioned that he put's an '@' sign in front of all function calls, and
every time he accesses an array;

I know that this is sloppy, and dangerous, but I don't know exactly what
this exposes him to, can any one give me any real world examples of why
this is bad, so I can relate it to his code?

php.net does not have much information about this. It seems like
suppressing errors, rather then catching them is problematic.


Thanks Again.

Justin.

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



[PHP] Re: Sorting in PHP

2005-08-02 Thread Mathieu Dumoulin
Found my problem, i'm runnig php 4.3.11, will update first then i will 
try again.


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



[PHP] Forming an SQL query

2005-08-02 Thread Jack Jackson

Hi,
Thanks to everyone's help, that multipage monster of a form is now 
working properly (yay!).


One problem I have though is that I stick the answers as each page is 
completed into a table. If the user hits the back button, rather than 
adding a new row to the table I'd rather update it if it's there. That's 
fairly straightforward when it's 1:1 questions to answers:


  $q_a_sql='INSERT INTO $userAnswerTable
  ( q_id, a_id )
  VALUES ' . (implode(",",$qanda))
  . ' on duplicate key UPDATE a_id = VALUES(a_id);';

But when it's 1:n, such as with checkboxes, this neat little plan of 
mine is thwarted.


So if I change the userAnswerTable to three columns, u_id, q_id and 
a_id, is there a way I can do all the 1:1 and 1:n in the manner I wish?


TIA,
JJ

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



[PHP] Sorting in PHP

2005-08-02 Thread Mathieu Dumoulin
Hi, i need to sort data using ksort. Its complex data out from a 
database (and no i can't sort it using the database sadly). I can change 
my code to reflect a new way of sorting but only to some extent, im limited.


Now from the data i build an array of the things i need to display, 
using the names of the hockey players i create a list that is supposed 
to be sorted, look at the result, you'll see that accents are not sorted 
althought my var_dump(setlocale(...)) returns that the french locale 
(string(5) "fr_CA") has been chosen. Is there anything wrong? can i 
change my code to fix this problem and how, cause all my tries point to 
nothing.


(Btw i tried all the installed locales to no avail.)

Balodis  Devon1985-06-11Baie-Comeau AF *Joueur
Balogh  Sébastien1987-01-17Baie-Comeau AF   Joueur
Blais  Alexandre1986-06-23Baie-Comeau AFJoueur
Blouin  Sébastien1987-03-04Baie-Comeau MAJ  Joueur
Bossé  Simon1900-01-01Baie-Comeau AF *Joueur
Bouchard  François1988-04-26Baie-Comeau MAJ   Joueur
Boudreault  Stéphane1986-01-16Baie-Comeau AF  Joueur
Boulianne  Yannick1987-10-19Baie-Comeau AF   Joueur
Bradley  Adam1985-09-18Baie-Comeau AF *Joueur
Breault  Benjamin1988-02-21Baie-Comeau MAJ Joueur
Brodeur  Benoît1987-03-07Baie-Comeau AF Joueur
Bédard  Mikaël1987-12-13Baie-Comeau AF Joueur
Bélanger  Maxime1986-03-03Baie-Comeau MAJ Joueur
Bérubé  Mathieu1986-10-01Baie-Comeau AF Joueur

(In case you didn't notice, the last 3 lines are the problem, they 
should be right after the 3 first lines (after the a's))




//$teamdata gathered higher up in the code
$tmp_players = list_get_players($mysql_link, $_SESSION['team_list'],
$_GET['sys_date'],
$_SESSION['histo_directdata']);

//Sort it alpha cause its not done right now
foreach($tmp_players as $player){
	$players[0][$player['register_file']['info_lname'].'-'.$player['register_file']['info_fname'].'-'.$player['register_file']['info_mname'].'-'.$player['register_file']['info_datenais']] 
= $player;

}

unset($tmpplayers, $player);
var_dump(setlocale(LC_ALL, array('fr_CA', 'fr_CA.iso88591',
'fr_CA.utf8')));
ksort($players[0], SORT_LOCALE_STRING);

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



Re: [PHP] Regular expression help

2005-08-02 Thread John Nichel

David Christensen wrote:

I just plain suck at regex, so I was hoping to get some hints from you
regex experts out there.  I'm sure it's been done a thousand times, but
I can't seem to find what I'm looking for with a simple google search:

$phone could be "1234567890" OR
$phone could be "123-456-7890" OR
$phone could be "(123) 456 7890 OR
$phone could have other unexpected characters in it, even control
characters.

So what I'm desiring to do is run some type of regex on $phone and only
return the integers and assign the cleaned string back to $phone.  I
thought I knew how to do this, but it's not working.

Thanks for your guidance.



If all you want is the digits

$phone = preg_replace ( "/\D/", "", $phone );

Same as

/[^0-9]/

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Sessions Issue

2005-08-02 Thread Jason Motes




We built a box about 7 months or so ago using the SuSE 9.1 cd's,
straight install from the CDs. While I've read that sessions are turned
on by default, when we try to call on the sessions functions (like with
phpOpenChat or start_session()) we get calls to undefined function
errors. This is leading me to belive that sessions are disabled for some
reason. I need to enable the sessions so I have a few questions

1) Can I do this without recompiling?



Don't know - Don't have SuSE




In YaST, goto install/remove software and do a search on php.
Is php4-session installed??

I am running SuSE 9.1 and sessions work fine for me.

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



[PHP] Regular expression help

2005-08-02 Thread David Christensen
I just plain suck at regex, so I was hoping to get some hints from you
regex experts out there.  I'm sure it's been done a thousand times, but
I can't seem to find what I'm looking for with a simple google search:

$phone could be "1234567890" OR
$phone could be "123-456-7890" OR
$phone could be "(123) 456 7890 OR
$phone could have other unexpected characters in it, even control
characters.

So what I'm desiring to do is run some type of regex on $phone and only
return the integers and assign the cleaned string back to $phone.  I
thought I knew how to do this, but it's not working.

Thanks for your guidance.

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



Re: [PHP] encrypting urls

2005-08-02 Thread Rory Browne
serialize/unserialize accompanied by some compression/decompression
should do the trick. Your output probably won't be any smaller with
compresson overhead, but it would be non-obvious. It is also extremely
easy to circumvent.

On 8/2/05, Sebastian <[EMAIL PROTECTED]> wrote:
> i need to mask (hide) some vars in a url so they arent visible to the
> user. example, i want a url like this:
> 
> page?id=3&something=12&more=12
> 
> to turn into:
> 
> page?id=3;LyFU;MLFxvy
> 
> so from "LyFU" i can access $something and from "MLFxvy" $more
> any ideas how i can do this?
> 
> doesn't have to be 100% secure, just a simple way hide it from the user.
> 
> 
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005
> 
> --
> 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] Running a PHP script everyday

2005-08-02 Thread Rory Browne
On 8/1/05, Jay Blanchard <[EMAIL PROTECTED]> wrote:
> [snip]
> What is the "-q" for?  I can't find any documentation on it.  If I do
> a "php -h" or "man php", it is not listed.  I am running php 5.0.3 on
> RHEL ES 4
> [/snip]
> 
> It means 'quiet'...in other words do not send anything to standard out.

I'm open to correction but I think that normal output will still
appear. It's only headers like Content-type, or Location, etc that the
-q suppresses.

echo's printf's and ?> this  
> --
> 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] Sessions Issue

2005-08-02 Thread Rory Browne
On 7/29/05, Tom Ray [Lists] <[EMAIL PROTECTED]> wrote:
> We built a box about 7 months or so ago using the SuSE 9.1 cd's,
> straight install from the CDs. While I've read that sessions are turned
> on by default, when we try to call on the sessions functions (like with
> phpOpenChat or start_session()) we get calls to undefined function
> errors. This is leading me to belive that sessions are disabled for some
> reason. I need to enable the sessions so I have a few questions
> 
> 1) Can I do this without recompiling?

Don't know - Don't have SuSE

> 2) If I can't, how do I recompile this since I used the SuSE cds?

Head to www.php.net and hit the downloads section. 

unArchive the source, and type ./configure --help to get a list of the
compilabel extensions. Once you're done, you can ./configure
--with-this --without-that --enable this-thing --disable-that-thing

The compile instructions(a file called INSTALL AFAIR) and the PHP
manual are among the best docs I've ever seen.

> 
> It's SuSE 9.1 running Php 4.3.4 with APache 2.0.49
> 
> any help would be great!
> 
> Thanks!
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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



Re: [PHP] varibles defination

2005-08-02 Thread Rory Browne
There are two ways of accomplishing what I think you're trying to acomplish.

These ways are known as the right way and the wrong way. 

the right way results in an array like

$func = array(0 => 0, 1 => 1, 2 => 2 ...)

The wrong way results in a set of variables like you described 

$func1 = 0
$func2 = 1
$func3 = 2
$func4 = 3
$func5 = 4

If you want to do it the wrong way, you can 

for($i = 1; $i < 5 ++$i){
  $varname = "func" . $i;
  $$varname = $i;
}

Personally I reckon you should do it the right way as Jim outlines.

On 8/2/05, Jim Moseby <[EMAIL PROTECTED]> wrote:
> > If I want to define and display a set of varibles, for example :
> > $func1 = 0
> > $func2 = 1
> > $func3 = 2
> > $func4 = 3
> > $func5 = 4
> >
> > How can we define and display the varibles by using for loop
> > function ?
> 
>  for ($x=0;$x<10;$x++){
>  $func[$x]=$x;
> }
> print_r($func);
> ?>
> 
> This uses an array, so, in this case, your variables would be referenced as
> $func[0]..$func[9].
> 
> JM
> 
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
>

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



Re: [PHP] Java - toString() <-> php - ?

2005-08-02 Thread Rory Browne
I haven't a monkies what that code(your java) does, and I don't have
time to analyse it(in expensive cybercafe), but you may want to
consider www.php.net/print-r www.php.net/var-dump and
www.php.net/var-export

I think they may do what you want without using the toString method,
which for what you're describing is basicly an ugly hack.

One more thing: Enlighten me: What exactly do you mean by "live
evolution" in your php/java context.

On 8/2/05, Adi Zebic <[EMAIL PROTECTED]> wrote:
> To print "state" of object in Java I can define toString() function and
> then I can do something like this:
> 
> Java exemple:
> *
> import java.io.*;
> import java.util.*;
> 
> public class ReadTextFromFile
> {
>private static String line;
>private static String Fable = new String ("");
>private static String NomFable;
>private static int cptLine = 0;
>private static int nbrPersonnes = 0;
>private static String nomPersonnes = new String ("");
>private static ArrayList AListe = new ArrayList(nbrPersonnes);
> 
> //**
> public String toString()
> {
>return getClass().getName()
>+ " [ Nom de la fable: "+  NomFable
>+ "  <==>  Nombre de personnes dans dialogue: " + nbrPersonnes
>+ " ] "
>;
> }
> ***
> 
> Is there similar kind of function in php that help us to print the state
> of object in his "life evolution"?
> 
> Thanks
> 
> 
> ADI
> 
> --
> 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] XSL custom xmlns/urn in PHP5 for callbacks

2005-08-02 Thread Torgny Bjers
Hello,

I recently started working with PHP5 after having spent quite some time
with C#.NET (at work), and I was wondering if there's a way to create a
custom callback namespace for XSL in PHP5? The example below should
illustrate what I need:


http://www.w3.org/1999/XSL/Transform";
xmlns:myapp.library="urn:myapp.library"
exclude-result-prefixes="myapp.library">









Hope someone can help here. If not possible, I can always use the
standard PHP function/class::method callbacks, but it would be nice to
have custom xmlns so that I could add several different libraries.

Warm Regards,
Torgny

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



RE: [PHP] How to determine if a script instance is already runnin g?

2005-08-02 Thread Jim Moseby
> -Original Message-
> From: Matt [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 02, 2005 10:45 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] How to determine if a script instance is already
> running?
> 
> 
> Perhaps "svscan" and its associated "daemontools" programs could be
> used to monitor the script instead of relying on cron.
> 
> http://cr.yp.to/daemontools.html
> 
> On 8/2/05, André Medeiros <[EMAIL PROTECTED]> wrote:
> > On Tue, 2005-08-02 at 15:09 +0100, Stut wrote:
> > > André Medeiros wrote:
> > > > Do like some services do:
> > > >
> > > > 1) Check if script.pid exists
> > > > 2) If it doesn't
> > > > 2.1) Write the process's PID onto the file
> > > > (http://pt.php.net/manual/en/function.getmypid.php)
> > > > 3) If it does
> > > > 3.1) Die gracefully :)
> > >
> > > Personally I'd extend that slightly to have the process 
> touch the PID
> > > file every so often and to check that it's been touched 
> recently when it
> > > starts up. Alternatively use the ps shell command to check that a
> > > process with that PID is still running, but that tends to 
> be less reliable.
> > >
> > > If the process does decide to continue in spite of the 
> PID file existing
> > > it should issue a a shell kill command to kill that PID 
> in case it's
> > > hung or a zombie.
> > >
> > > -Stut
> > 
> > Excelent point!

Thanks to all who replied.  I'll let the list know how it works out.

JM

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



RE: [PHP] varibles defination

2005-08-02 Thread Jim Moseby
> If I want to define and display a set of varibles, for example :
> $func1 = 0
> $func2 = 1
> $func3 = 2
> $func4 = 3
> $func5 = 4
> 
> How can we define and display the varibles by using for loop 
> function ?



This uses an array, so, in this case, your variables would be referenced as
$func[0]..$func[9].

JM

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



Re: [PHP] cannot find the parse error

2005-08-02 Thread John Nichel

Miles Thompson wrote:


John,

Which editor does syntax checking?
(In VB I find it a mixed blessing.)



I personally use the Zend editor, but I'm pretty sure there are a few 
more out there (like ActiveState's IDE I think).


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] parent::construct not reliable working on php5.1 b2/b3

2005-08-02 Thread Meno Abels
it is only a typo in my email i use __construct

Meno

2005/8/2, Jochem Maas <[EMAIL PROTECTED]>:
> Pawel Bernat wrote:
> > On Tue, Aug 02, 2005 at 03:42:00PM +0100, Meno Abels wrote:
> >
> >>Hello,
> >>
> >>With my application that uses heavily inherent classes, sometimes I
> 
> dep class heirarchies can lead to brainfreeze - beware of going to deep 
> :-)
> 
> >>get the following message:
> >>PHP Fatal error:  Call to undefined method Rank::_construtor() in
> >>.../inc/Links.class.php.   It works with php
> >>4.x when I use the old style of constructor calling
> >>$this->(CLASSNAME) . But when working with php 5.2 b2 or b3 in the old
> >>OR the new style, I get the PHP Fatal error from above.
> >>Is there any hints to look at this problem?
> >
> > Why do you call _construct instead of __construct? And how do you do it?
> 
> he seems to be calling _construtor() which although not wrong is not the
> method he is looking for (cue voice of Alex Guiness for the second time this 
> week :-)
> 
> try __construct()
> 
> PS - this kind of thing belongs on generals until you are _sure_ it's an
> internals problem. IMHO.
> 
> > Did you read everything at http://php.net/construct (including Note)?
> > What about php 5.0?
> >
> 
>

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



Re: [PHP] parent::construct not reliable working on php5.1 b2/b3

2005-08-02 Thread Jochem Maas

Pawel Bernat wrote:

On Tue, Aug 02, 2005 at 03:42:00PM +0100, Meno Abels wrote:


Hello,

With my application that uses heavily inherent classes, sometimes I


dep class heirarchies can lead to brainfreeze - beware of going to deep :-)


get the following message:
PHP Fatal error:  Call to undefined method Rank::_construtor() in
.../inc/Links.class.php.   It works with php
4.x when I use the old style of constructor calling 
$this->(CLASSNAME) . But when working with php 5.2 b2 or b3 in the old

OR the new style, I get the PHP Fatal error from above.
Is there any hints to look at this problem?


Why do you call _construct instead of __construct? And how do you do it?


he seems to be calling _construtor() which although not wrong is not the
method he is looking for (cue voice of Alex Guiness for the second time this 
week :-)

try __construct()

PS - this kind of thing belongs on generals until you are _sure_ it's an
internals problem. IMHO.


Did you read everything at http://php.net/construct (including Note)?
What about php 5.0?



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



Re: [PHP] cannot find the parse error

2005-08-02 Thread Miles Thompson

At 11:45 AM 8/2/2005, John Nichel wrote:

Jochem Maas wrote:

John Nichel wrote:


Jochem Maas wrote:



did you look at line 44??? (actually I found the problem on line 69
when I cut and pasted into a editor - the editor also gave that line as the
one with the error in it:





And to think that I used to hate editors that did this at one time.


:-) not sure I follow you completely.
actually the editor (TextPad in this case) didn't do anything nasty - it 
was my mail

app had already done a nice job with wordwrapping :-/


About 6 or so years ago, I couldn't stand things like syntax highlighting, 
and editors that error checked (don't know why, I'm just weird that way I 
guess).  Now, I don't know how I lived without it. Guess I've just be 
assimilated. ;)


--


John,

Which editor does syntax checking?
(In VB I find it a mixed blessing.)

Cheers - Miles

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



Re: [PHP] cannot find the parse error

2005-08-02 Thread John Nichel

Jochem Maas wrote:

John Nichel wrote:


Jochem Maas wrote:



did you look at line 44??? (actually I found the problem on line 69
when I cut and pasted into a editor - the editor also gave that line 
as the

one with the error in it:





And to think that I used to hate editors that did this at one time.



:-) not sure I follow you completely.

actually the editor (TextPad in this case) didn't do anything nasty - it 
was my mail

app had already done a nice job with wordwrapping :-/


About 6 or so years ago, I couldn't stand things like syntax 
highlighting, and editors that error checked (don't know why, I'm just 
weird that way I guess).  Now, I don't know how I lived without it. 
Guess I've just be assimilated. ;)


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] How to determine if a script instance is already running?

2005-08-02 Thread Matt
Perhaps "svscan" and its associated "daemontools" programs could be
used to monitor the script instead of relying on cron.

http://cr.yp.to/daemontools.html

On 8/2/05, André Medeiros <[EMAIL PROTECTED]> wrote:
> On Tue, 2005-08-02 at 15:09 +0100, Stut wrote:
> > André Medeiros wrote:
> > > Do like some services do:
> > >
> > > 1) Check if script.pid exists
> > > 2) If it doesn't
> > > 2.1) Write the process's PID onto the file
> > > (http://pt.php.net/manual/en/function.getmypid.php)
> > > 3) If it does
> > > 3.1) Die gracefully :)
> >
> > Personally I'd extend that slightly to have the process touch the PID
> > file every so often and to check that it's been touched recently when it
> > starts up. Alternatively use the ps shell command to check that a
> > process with that PID is still running, but that tends to be less reliable.
> >
> > If the process does decide to continue in spite of the PID file existing
> > it should issue a a shell kill command to kill that PID in case it's
> > hung or a zombie.
> >
> > -Stut
> 
> Excelent point!
> 
> --
> 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] varibles defination

2005-08-02 Thread edwardspl
Dear You,

If I want to define and display a set of varibles, for example :
$func1 = 0
$func2 = 1
$func3 = 2
$func4 = 3
$func5 = 4

How can we define and display the varibles by using for loop function ?

Edward.

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



Re: [PHP] cannot find the parse error

2005-08-02 Thread Jochem Maas

John Nichel wrote:

Jochem Maas wrote:



did you look at line 44??? (actually I found the problem on line 69
when I cut and pasted into a editor - the editor also gave that line 
as the

one with the error in it:




And to think that I used to hate editors that did this at one time.


:-) not sure I follow you completely.

actually the editor (TextPad in this case) didn't do anything nasty - it was my 
mail
app had already done a nice job with wordwrapping :-/





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



Re: [PHP] Regex help

2005-08-02 Thread Robin Vickery
On 8/2/05, Chris Boget <[EMAIL PROTECTED]> wrote:
> I'm trying to validate an email address and for the life of me I
> cannot figure out why the following regex is not working:
>
>   $email = "[EMAIL PROTECTED]";
>   $regex =
> "^([a-zA-Z0-9_\.\-\']+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-\']+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

[a-zA-Z0-9\-\']

You don't escape hyphens like that in a character class. Put it at the
end of the list of characters like this:

[a-zA-Z0-9'-]

Then it'll match your test address. 

If you're trying to find out why a regexp isn't working, try
simplifying your test cases until it works. For example:

$email = "[EMAIL PROTECTED]"; // doesn't work
$email = "[EMAIL PROTECTED]";  // doesn't work
$email = "[EMAIL PROTECTED]";   // doesn't work
$email = "[EMAIL PROTECTED]";   // works!

I don't suppose this is the place for a rant about the futility of
checking email addresses with a regexp?

  -robin

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



Re: [PHP] How to determine if a script instance is already running?

2005-08-02 Thread André Medeiros
On Tue, 2005-08-02 at 15:09 +0100, Stut wrote:
> André Medeiros wrote:
> > Do like some services do:
> > 
> > 1) Check if script.pid exists
> > 2) If it doesn't
> > 2.1) Write the process's PID onto the file
> > (http://pt.php.net/manual/en/function.getmypid.php)
> > 3) If it does
> > 3.1) Die gracefully :)
> 
> Personally I'd extend that slightly to have the process touch the PID 
> file every so often and to check that it's been touched recently when it 
> starts up. Alternatively use the ps shell command to check that a 
> process with that PID is still running, but that tends to be less reliable.
> 
> If the process does decide to continue in spite of the PID file existing 
> it should issue a a shell kill command to kill that PID in case it's 
> hung or a zombie.
> 
> -Stut

Excelent point!

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



Re: [PHP] cannot find the parse error

2005-08-02 Thread John Nichel

Jochem Maas wrote:


did you look at line 44??? (actually I found the problem on line 69
when I cut and pasted into a editor - the editor also gave that line as the
one with the error in it:



And to think that I used to hate editors that did this at one time.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] regarding form submission and option pull down menu

2005-08-02 Thread John Nichel

Bruce Gilbert wrote:

a few more questions about the submission process for a form with
option choices.

say I am using :



  selected="selected">Purchase
value="construct_home">Construct Home

  Refinance - No Cash
  Refinance - Cash
Out



is it better to use a name for value (the same as the selection
choice) or a number 1,2,3 etc? (or does it matter).


Doesn't matter.  You're the one processing it on the back end, so 
whatever works for you.



and for the return info what's the difference between:



and without the isset?


In your above example, nothing, other than it will issue a notice for an 
undefined variable if you have error reporting set that high.  However 
it's a good practice to check if something exists (and has the data you 
expect) before you process that data.


--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] cannot find the parse error

2005-08-02 Thread John Nichel

Bruce Gilbert wrote:


  





--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] How to determine if a script instance is already running?

2005-08-02 Thread Stut

André Medeiros wrote:

Do like some services do:

1) Check if script.pid exists
2) If it doesn't
2.1) Write the process's PID onto the file
(http://pt.php.net/manual/en/function.getmypid.php)
3) If it does
3.1) Die gracefully :)


Personally I'd extend that slightly to have the process touch the PID 
file every so often and to check that it's been touched recently when it 
starts up. Alternatively use the ps shell command to check that a 
process with that PID is still running, but that tends to be less reliable.


If the process does decide to continue in spite of the PID file existing 
it should issue a a shell kill command to kill that PID in case it's 
hung or a zombie.


-Stut

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



Re: [PHP] regarding form submission and option pull down menu

2005-08-02 Thread Jochem Maas

Bruce Gilbert wrote:

a few more questions about the submission process for a form with
option choices.

say I am using :



  selected="selected">Purchase
value="construct_home">Construct Home

  Refinance - No Cash
  Refinance - Cash
Out



is it better to use a name for value (the same as the selection
choice) or a number 1,2,3 etc? (or does it matter).


it's your data - you decide - personally IDGAF. just make sure you santize
your incoming data whatever form you expect it in.



and for the return info what's the difference between:



and without the isset?


do you know what an if statement is?
have you looked at the manual page for isset()?
do you know what a E_NOTICE is?

the short answer is:  difference is 1 line of code,
the longer answer is: read some more of the manual and learn about
error checking (the most simple form being to simply check that a variable
exists before trying to use it.)



thanks!








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



Re: [PHP] cannot find the parse error

2005-08-02 Thread Jochem Maas

Bruce Gilbert wrote:

I am getting the following parsing error and don't see it off hand.

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in
/hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form.php on
line 44


did you look at line 44??? (actually I found the problem on line 69
when I cut and pasted into a editor - the editor also gave that line as the
one with the error in it:


DON'T DO THIS:



DO THIS, INSTEAD:




you can figure out which line it is yourself.



here is all of the code:

if anyone has any clues please let me know!

the URL is:http://www.inspired-evolution.com/Contact_Form.php
PHP info is at http://www.inspired-evolution.com/info.php

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
http://www.w3.org/1999/xhtml"; xml:lang="en-US"
lang="en-US" dir="ltr">


Inspired Evolution :: Contact












 Skip
over navigation
  
  

  
  
   


  About
Me
  Skill set
  Hire
Me
  Portfolio
  Contact
  Résumé
  Blog
  
RSS



  
  
   


Home
  > > Contact

  
  Contact

  

Additional Information
Request



* First Name: 






* Last Name:






* Company: 





* Phone: 





* e-mail: 





* re-enter e-mail: 






 URL:

 



 Best way to reach:





 Best time to contact:









Send me a detailed
message specifying what you wish to accomplish with your web
site.






END_FORM;
if ($_POST['op']!='ds') { 
// they need to see the form

echo "$form_block";
} else if ($_POST["op"]  == "ds")  {
// check value of $_POST['firstname']
if ($_POST['firstname'] == " ")  {
$name_err = 'Please enter your first
name!< /br>';
$send = "no" ;
}
// check value of $POST['email']
if ($_POST ['email'] == " ")  {
$email_err ='Please enter your email
address!';
$send="no";
}
if ($send != "no") {
//it's ok to send, so build the mail
$msg = "E-mail sent from www site\n";
$msg .="Sender's first name:{$_POST['firstname']}\n";
$msg .="Sender's last name:{$_POST['lastname']}\n";
$msg .="Company name:{$_POST['company']}\n";
$msg .="Senders Phone number:{$_POST['phone']}\n";
$msg .="Senders email address:{$_POST['email']}\n";
$msg .="Senders email address (re-typed):{$_POST['email2']}\n";
$msg .="URL :{$_POST['URL']}\n";
$msg .="Contact_Preference: {$_POST['Contact_Preference']}\n";
$msg .="Contact_Time {$_POST['Contact_Time']}\n";
$msg .="Message:{$_POST['message']}\n\n";
$to ="[EMAIL PROTECTED]";
$subject ="There has been a disturbance in the force";
$mailheaders .="From: My Web Site
\n";
$mailheaders .="Reply-To: {$_POST['email']}\n";
//send the mail
mail ($to, $subject, $msg, $mailheaders);
//display information to user
  echo "Hola, $firstname!.
We have received your request for additional information, and will
respond shortly.
Thanks for visiting inspired-evolution.com and have a wonderful day!
Regards,
Inspired Evolution";
 
} else if ($send =="no") {

//print error messages
echo "$name_err";
echo "$email_err";
echo "$message_err";
echo "$form_block";
}
}
?>
  * indicates a required field.
  
  
  


 
  Inspired-Evolution - Web Site: Design, Development, 
Marketing for Raleigh/Durham, Chapel Hill, Cary North Carolina.

  
  
  
   
  






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



[PHP] regarding form submission and option pull down menu

2005-08-02 Thread Bruce Gilbert
a few more questions about the submission process for a form with
option choices.

say I am using :



Purchase
  Construct Home
  Refinance - No Cash
  Refinance - Cash
Out



is it better to use a name for value (the same as the selection
choice) or a number 1,2,3 etc? (or does it matter).

and for the return info what's the difference between:



and without the isset?

thanks!






-- 
::Bruce::

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



Re: [PHP] How to determine if a script instance is already running?

2005-08-02 Thread André Medeiros
On Tue, 2005-08-02 at 09:49 -0400, Jim Moseby wrote:
> I have a command line script that needs to run continuously, and so I plan
> to have cron execute it every so often.  I want to have the script first
> check to see if another instance is already running and, if so, die().
> 
> Now, I know I can exec the process list and parse through the output, but is
> there and easier, faster, cooler, sexier, better way?  :o)
> 
> JM
> 

Do like some services do:

1) Check if script.pid exists
2) If it doesn't
2.1) Write the process's PID onto the file
(http://pt.php.net/manual/en/function.getmypid.php)
3) If it does
3.1) Die gracefully :)

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



[PHP] How to determine if a script instance is already running?

2005-08-02 Thread Jim Moseby
I have a command line script that needs to run continuously, and so I plan
to have cron execute it every so often.  I want to have the script first
check to see if another instance is already running and, if so, die().

Now, I know I can exec the process list and parse through the output, but is
there and easier, faster, cooler, sexier, better way?  :o)

JM

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



[PHP] cannot find the parse error

2005-08-02 Thread Bruce Gilbert
I am getting the following parsing error and don't see it off hand.

Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
expecting T_STRING or T_VARIABLE or T_NUM_STRING in
/hsphere/local/home/bruceg/inspired-evolution.com/Contact_Form.php on
line 44

here is all of the code:

if anyone has any clues please let me know!

the URL is:http://www.inspired-evolution.com/Contact_Form.php
PHP info is at http://www.inspired-evolution.com/info.php

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
http://www.w3.org/1999/xhtml"; xml:lang="en-US"
lang="en-US" dir="ltr">


Inspired Evolution :: Contact












 Skip
over navigation
  
  

  
  
   

  About
Me
  Skill set
  Hire
Me
  Portfolio
  Contact
  Résumé
  Blog
  RSS

  
  
   

Home
  > > Contact

  
  Contact
  

Additional Information
Request



* First Name: 






* Last Name:






* Company: 





* Phone: 





* e-mail: 





* re-enter e-mail: 






 URL:

 



 Best way to reach:





 Best time to contact:









Send me a detailed
message specifying what you wish to accomplish with your web
site.






END_FORM;
if ($_POST['op']!='ds') { 
// they need to see the form
echo "$form_block";
} else if ($_POST["op"]  == "ds")  {
// check value of $_POST['firstname']
if ($_POST['firstname'] == " ")  {
$name_err = 'Please enter your first
name!< /br>';
$send = "no" ;
}
// check value of $POST['email']
if ($_POST ['email'] == " ")  {
$email_err ='Please enter your email
address!';
$send="no";
}
if ($send != "no") {
//it's ok to send, so build the mail
$msg = "E-mail sent from www site\n";
$msg .="Sender's first name:{$_POST['firstname']}\n";
$msg .="Sender's last name:{$_POST['lastname']}\n";
$msg .="Company name:{$_POST['company']}\n";
$msg .="Senders Phone number:{$_POST['phone']}\n";
$msg .="Senders email address:{$_POST['email']}\n";
$msg .="Senders email address (re-typed):{$_POST['email2']}\n";
$msg .="URL :{$_POST['URL']}\n";
$msg .="Contact_Preference: {$_POST['Contact_Preference']}\n";
$msg .="Contact_Time {$_POST['Contact_Time']}\n";
$msg .="Message:{$_POST['message']}\n\n";
$to ="[EMAIL PROTECTED]";
$subject ="There has been a disturbance in the force";
$mailheaders .="From: My Web Site
\n";
$mailheaders .="Reply-To: {$_POST['email']}\n";
//send the mail
mail ($to, $subject, $msg, $mailheaders);
//display information to user
  echo "Hola, $firstname!.
We have received your request for additional information, and will
respond shortly.
Thanks for visiting inspired-evolution.com and have a wonderful day!
Regards,
Inspired Evolution";
 
} else if ($send =="no") {
//print error messages
echo "$name_err";
echo "$email_err";
echo "$message_err";
echo "$form_block";
}
}
?>
  * indicates a required field.
  
  
  


 
  Inspired-Evolution - Web Site: Design, Development, 
Marketing for Raleigh/Durham, Chapel Hill, Cary North Carolina.
  
  
  
   
  




-- 
::Bruce::

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



[PHP] Regex help

2005-08-02 Thread Chris Boget

I'm trying to validate an email address and for the life of me I
cannot figure out why the following regex is not working:



 $email = "[EMAIL PROTECTED]";
$regex = "^([a-zA-Z0-9_\.\-\']+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-\']+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$";

 if( ereg( $regex, $email )) {
   echo 'Good email address';

 } else {
   echo 'Bad email address';

 }



Does anyone have any ideas?

thnx,
Chris 


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



Re: [PHP] PHP form not working

2005-08-02 Thread hope


u can also work out like this:


$email_err ="Please enter your email address!/span>/>";


$message_err = "Please enter a message!";



this wil also work perfectly alrite.

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



[PHP] encrypting urls

2005-08-02 Thread Sebastian
i need to mask (hide) some vars in a url so they arent visible to the 
user. example, i want a url like this:


page?id=3&something=12&more=12

to turn into:

page?id=3;LyFU;MLFxvy

so from "LyFU" i can access $something and from "MLFxvy" $more
any ideas how i can do this?

doesn't have to be 100% secure, just a simple way hide it from the user.


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.9.7/60 - Release Date: 7/28/2005

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



Re: [PHP] Re: error checking a null array

2005-08-02 Thread Jochem Maas

Jack Jackson wrote:

I can only swear this to the entire list:

Before I come here for help, each time, I echo and var_dump and print_r 
until, yes, I need a doctor.


I did say give it a rest when you start bleeding ;-)



So by the time I come here, it's not laziness or lack of looking in the 
manual, it's head-swirling confusion infused with incompetence and a 
complete lack of programming experience at any time before April of this 


addictive isn't it :-) and cheaper that drugs - unless you buy Apple(tm) ;-)

year which leads me to come back again and again with relatively foolish 
questions.


questions are only foolish when you are not willing to look for the answer
yourself - (I am Jack's Raging Bile Duct)




My problem before, for example: In my error check function, I placed the 
include file (to return to the form) *within* the foreach loop, and then 
I wondered why it only ran through once.


D'oh.



it's donut time :-)

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



Re: [PHP] returning info. from a form selection

2005-08-02 Thread Mark Rees
> >
> > can anyone give me an idea on how to return info. from a forl
> > pulldown menu
> >
> > and return that to an email address.
> >
>
> A most basic question begs a most basic answer:
>
>  if (!$_POST['submit']){ // Display form
> ?>
> 
> 
> Dropdown Value to Email
> 
> 
>
> 
> 
>   Purchase
>   Construct Home
>   
> 
> 
> 
>
>  }else{ // Mail form results
> if(mail('[EMAIL PROTECTED]','Dropdown
results',$_POST['loan_process'])){
>   echo 'Mail sent!';}
> else {
>   echo 'Mail NOT sent!';}

Even more basic, no php required (but not suitable for internet use as it
relies on your browser knowing what to do with a mailto link:

 
 
 Dropdown Value to Email
 
 
  mailto:[EMAIL PROTECTED]>
 
   Purchase
   Construct Home
   
 
 
 

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



Re: [PHP] Java - toString() <-> php - ?

2005-08-02 Thread Jochem Maas

Adi Zebic wrote:
To print "state" of object in Java I can define toString() function and 
then I can do something like this:


Java exemple:
*
import java.io.*;
import java.util.*;

public class ReadTextFromFile
{
private static String line;
private static String Fable = new String ("");
private static String NomFable;
private static int cptLine = 0;
private static int nbrPersonnes = 0;
private static String nomPersonnes = new String ("");
private static ArrayList AListe = new ArrayList(nbrPersonnes);

//** 


public String toString()
{
return getClass().getName()
+ " [ Nom de la fable: "+  NomFable
+ "  <==>  Nombre de personnes dans dialogue: " + nbrPersonnes
+ " ] "
;
}
*** 



Is there similar kind of function in php that help us to print the state 
of object in his "life evolution"?


there is but it's use is limited and currently AFAIR it only works on 
internally defined
classes the method is called __toString() - from what I have read and 
played with it (not
recently though) the fucntionality is _bit_ 'halfbaked' - as in the internals 
guys are still
pondering how to imnplement this as nicely as possible.

an example:



the problem with implementing this is the fact that php is dynamically typed - 
and it
autocasts types all over the place - very handy BUT it makes a __toString() 
[magic] method
very hard to implement in a way that is obvious to the people using it (try 
playing around with
the SimpleXML extension to see how it can warp your brain! well it makes my 
head spin anyway :-)

but don't take my word for it - try it yourself, oh and also take a dive into 
the [php]internals mailing
list archives - lots has been discussed about this function AFAIR.



Thanks


ADI



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



[PHP] Re: Sessions Issue

2005-08-02 Thread kalinga
did you check the output of "phpinfo()"? 

if you did not made modifications or manual configurations,
the session support should be on in defalt.


~viraj.

On 8/1/05, Burhan Khalid <[EMAIL PROTECTED]> wrote:
> 
> On Jul 29, 2005, at 8:07 PM, Tom Ray [Lists] wrote:
> 
> > We built a box about 7 months or so ago using the SuSE 9.1 cd's,  
> > straight install from the CDs. While I've read that sessions are  
> > turned on by default, when we try to call on the sessions functions  
> > (like with phpOpenChat or start_session()) we get calls to  
> > undefined function errors. This is leading me to belive that  
> > sessions are disabled for some reason. I need to enable the  
> > sessions so I have a few questions
> >
> > 1) Can I do this without recompiling?
> > 2) If I can't, how do I recompile this since I used the SuSE cds?
> >
> > It's SuSE 9.1 running Php 4.3.4 with APache 2.0.49
> 
> I don't *think* there is a separate module/rpm for sessions, so you  
> are off to a recompile job.
> 
> While you are it, upgrade your PHP to the latest stable version.  
> 4.3.4 is quite old.  Maybe there is a new package for SuSE that does  
> it? (not really familiar with SuSE).
> 
> -- 
> 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] array()

2005-08-02 Thread Jochem Maas

Edward Vermillion wrote:

Sebastian wrote:


is it always necessary to call array() when you do something like this:

mysql_query("SELECT ");
while($rows .)
{
   $data[] = $rows;
}

if so, why? i have a habit of never calling array() and someone told 
me i shouldn't do this.



If that's your first use of $data then it's not necessary, but it's very 
highly recommended to do something like:


DITTO! :-)



$data = array();


the someone who told you don't is wrong - by setting $data to an array()
explicitly just before you use it you we be sure $data contains exactly what 
yuou think
it should when your while loop (in this case) completes...

imagine you came back to a script containing this code and you added a similiar
query loop above also using the var $data!

don't worry about the difference in performance (whether you initialize the var 
to
an array() or not) - you can't even measure it in any valid way.



mysql_query("SELECT ");
while($rows .)
{
   $data[] = $rows;
}



you might even consider that it is not always worth looping just to create
a $data array - often you can process/output/whatever each $row as you 
encounter it...

imagine what happens if your query returns a million records, your script could 
process
each $row 1 by 1 (granted it would take quite a while!) but trying to fill a 
$data array
would almost definitely cause your script to die due to memory exhaustion. 
(either a php limit
or a system limit)

That way you _know_ that $data is "clean" before you start doing 
anything with it.


It's always a good idea to set any variables you're using to some value, 
either "", array(), 0, or some default value, before you use them to 
help keep the "bad guys" out of your scripts.




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