Re: [PHP] php+ ajax

2006-02-21 Thread Kim Christensen
On 2/20/06, David Dorward [EMAIL PROTECTED] wrote:
 Element ids may not contain square brackets in HTML documents.

Get your facts straight, David. Square brackets works fine in HTML
documents as long as you escape the ID when you need to reference them
by JS.

--
Kim Christensen
[EMAIL PROTECTED]

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



Re: [PHP] HOSTNAME Environment variable

2006-02-21 Thread Kim Christensen
On 2/21/06, Ruben Rubio Rey [EMAIL PROTECTED] wrote:
 How to set Hostname environment variable? (It contains the servers
 name, not the servers domain)
 Its a Linux server.

Try the hostname command. Depending on your linux distro, you might
want to edit /etc/hostname manually afterwards to double-check.

--
Kim Christensen
[EMAIL PROTECTED]

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



[PHP] Re: JPG Compression [detached thread]

2006-02-21 Thread Kim Christensen
Julian, remember to send a new message when posting a thread for the
first time, instead of replying to an old one. I'm sure it was a
mistake, but most people won't bother to answer these kind of posts.

On 2/20/06, julian haffegee [EMAIL PROTECTED] wrote:
 Is there a php function that lets you compress the jpg?

http://php.net/manual/en/function.imagejpeg.php

--
Kim Christensen
[EMAIL PROTECTED]

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



Re: [PHP] HOSTNAME Environment variable

2006-02-21 Thread Ruben Rubio Rey

Kim Christensen wrote:


On 2/21/06, Ruben Rubio Rey [EMAIL PROTECTED] wrote:
 


How to set Hostname environment variable? (It contains the servers
name, not the servers domain)
Its a Linux server.
   



Try the hostname command. Depending on your linux distro, you might
want to edit /etc/hostname manually afterwards to double-check.

--
Kim Christensen
[EMAIL PROTECTED]

 

Strange. Its already set (in hostname and echo $HOSTNAME). I have 
realized that is working on version (in my servers) 5.0.5 and its not 
working in 5.0.4 version. Is it an old bug? Im updating, we ll see 


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



Re: [PHP] HOSTNAME Environment variable

2006-02-21 Thread Kim Christensen
On 2/21/06, Ruben Rubio Rey [EMAIL PROTECTED] wrote:
 Strange. Its already set (in hostname and echo $HOSTNAME). I have
 realized that is working on version (in my servers) 5.0.5 and its not
 working in 5.0.4 version. Is it an old bug? Im updating, we ll see 

Have you rebooted your machine since you changed the hostname? I don't
know where PHP/Apache gets the hostname variable from - there are
quite a few places where that variable is stored on a linux system -
but most services reads the /etc/hostname file upon boot, therefor the
need for a restart after changing it.

You might want to check the contents of /proc/sys/kernel/hostname, and
even changing it by issuing:

echo your_hostname  /proc/sys/kernel/hostname

If it still doesn't work, reboot to be sure.

--
Kim Christensen
[EMAIL PROTECTED]

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



Re: [PHP] php+ ajax

2006-02-21 Thread Jochem Maas

Kim Christensen wrote:

On 2/20/06, David Dorward [EMAIL PROTECTED] wrote:


Element ids may not contain square brackets in HTML documents.



Get your facts straight, David. Square brackets works fine in HTML


David has his facts straight, just because something works (for you)
doesn't make it correct (MARQUEE tag anyone?):

quote from=http://www.w3.org/TR/html4/types.html#type-name;
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed
by any number of letters, digits ([0-9]), hyphens (-), underscores (_),
colons (:), and periods (.).
/quote

what I do usually is misuse the square brackets in the name - to get
the arrays in php - and use a different string for the id (one that is
technically) valid for use in javascript.

Kim do the escaped sqaure brackets work in all majors browsers as
far as you know?


documents as long as you escape the ID when you need to reference them
by JS.

--
Kim Christensen
[EMAIL PROTECTED]



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



Re: [PHP] question about foreach and associate array

2006-02-21 Thread Jochem Maas

jonathan wrote:

I have the following construct:

 $arg['textarea']['body']=Hello;


  foreach($arg['textarea'] as $row)
  {
   echo $row['body'].br/;   



$row contains the _string_ 'Hello'.
the thing is you can use array-like notation to
get at the individual chars of a stringe.g:

echo $row[0]; // outputs an 'H'

when you try to grab the char at index position 'body'
in the string 'Hello' the string 'body' is first converted to
an integer to determine what the char offset is. i.e.

echo (int)body;


   echo $arg['textarea']['body'].br/;

  }


I would expect both of them to output Hello but only the second  does. 
The first outputs H. I thought I have done this before. Can  anybody 
tell me why this won't work?


thanks,

jonathan



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



Re: [PHP] php+ ajax

2006-02-21 Thread Kim Christensen
On 2/21/06, Jochem Maas [EMAIL PROTECTED] wrote:
 Kim do the escaped sqaure brackets work in all majors browsers as
 far as you know?

Major browsers as in Firefox and IE for PC/Mac works great, yes -
haven't had the chance to try Opera or Konqueror yet, maybe someone
could shed a light on this?

Sorry for being rude, David - had a bad morning!

--
Kim Christensen
[EMAIL PROTECTED]

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



[PHP] Re: Request for views on ASP/PHP/ASP.NET - please!

2006-02-21 Thread Simon O'Beirne
Gladly :) Due to be finished at the end of march, however results will be 
analysed start/mid march. Will keep you informed!

Simon

Rafael [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
Well, I would like to know what conclusion you got, so if possible let
me know when you have enough data/finished you work.

Simon O'Beirne wrote:
 Hi guys,

 A bit of an odd request.  I'm in my third and final year at university, 
 and
 part of an assignment requires obtaining developers' perspective on web
 languages.

 If anyone has done at least one of the languages in the subject title
 (ASP/ASP.NET/PHP), I would be eternally grateful if you could pop to (and
 also send any other web developers you know to)

 http://www.coralsystemsolutions.co.uk/uni

 Theres a maximum of 14 short questions (depending on answers to the other
 questions), all optional, just fill out as much as you can be bothered 
 with,
 then click submit a few times until its saved.

 Thank you very much in advance!

 Simon
-- 
Atentamente,
J. Rafael Salazar Magaña
Innox - Innovación Inteligente
Tel: +52 (33) 3615 5348 ext. 205 / 01 800 2-SOFTWARE
[EMAIL PROTECTED]
http://www.innox.com.mx 

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



Re: [PHP] php+ ajax

2006-02-21 Thread David Dorward
--- Kim Christensen [EMAIL PROTECTED] wrote:

 On 2/21/06, Jochem Maas [EMAIL PROTECTED]
 wrote:

 Kim do the escaped sqaure brackets work in
 all majors browsers as far as you know?

 Major browsers as in Firefox and IE for PC/Mac
 works great, yes -

Many browsers are amazing at being able to compensate
by errors made by authors, but that shouldn't be taken
as an excuse to not treat the errors as anything other
than something that should be fixed.

You can't test in every browser out there - there are
too many. You can't test in any browser that hasn't be
written yet.

Writing code that ignores the standards is just asking
for maintainance headaches and other troubles down the
line.


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



[PHP] Help with query

2006-02-21 Thread Ing. Tom�s Liendo
Hi I need the students that didn't take an exam. The tables:

exams(id_test, title, desciption, )

results(id_student, id_test, date, qualification...)

I'm using a version of MySQL that doesn't support NOT IN, then I tried in 
this way:

SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE 
results.id_test IS NULL AND id_student=.$user

The query doesn't return anything... What Can I do???

Ahead of time, thank you very much,

Tom.

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



[PHP] Re: Help with query

2006-02-21 Thread Barry

Ing. Tomás Liendo wrote:

Hi I need the students that didn't take an exam. The tables:

exams(id_test, title, desciption, )

results(id_student, id_test, date, qualification...)

I'm using a version of MySQL that doesn't support NOT IN, then I tried in 
this way:


SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE 
results.id_test IS NULL AND id_student=.$user


The query doesn't return anything... What Can I do???

Ahead of time, thank you very much,

Tom.



--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



Re: [PHP] Problem with Square Brackets [was: php+ ajax]

2006-02-21 Thread Jochem Maas

SIDENOTE TO JAY
add to your list of potential book topics?:

knowing when to successfully break the rules.
(i.e. when to not follow the standards)
/SIDENOTE TO JAY

From a php developer point of view there is one
big problem with 'follow the standards' mantra as
far as square brackets go (with regard to use in the
value of name attributes of form fields) ...

namely if you following the standard you can't use
the array translation capability of php with regard to
incoming request variables.

here is a url from a CMS of mine:

/manager.php?e[n]=articlee[kf][ARTICLE_ID]=186e[f][n]=bundlese[f][kf][BUNDLE_ID]=12427e[f][f][n]=bundledartse[f][f][kf][BUNDLE_ID]=12427e[f][f][kf][BUNDLED_ID]=477a=2

it's dynamically generated and uses a nested array structure
to describe a 'path' to whatever entity (or list of entities) is being
requested (list, edit, etc) -- it works, it's flexible and
I wouldn't have a clue where to start refactoring this so that
the square bracket 'magic' is no longer required.

David Dorward wrote:

--- Kim Christensen [EMAIL PROTECTED] wrote:



On 2/21/06, Jochem Maas [EMAIL PROTECTED]
wrote:




Kim do the escaped sqaure brackets work in
all majors browsers as far as you know?




Major browsers as in Firefox and IE for PC/Mac
works great, yes -



Many browsers are amazing at being able to compensate
by errors made by authors, but that shouldn't be taken
as an excuse to not treat the errors as anything other
than something that should be fixed.

You can't test in every browser out there - there are
too many. You can't test in any browser that hasn't be
written yet.

Writing code that ignores the standards is just asking
for maintainance headaches and other troubles down the
line.


__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



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



RE: [PHP] newbie problem

2006-02-21 Thread Jay Blanchard
[snip]
 [snip]
 When working with an HTML file with a form with
 
 form action=somename.php method=post
 
 the somename.php file is served (completely) to my browser as plain
text
 after the 'submit' button is clicked on my machine (MacOS X). On the
 external webhost though everything is processed correctly...
 
 Is this related to some setting that I should change on my localhost?
 [/snip]
 
 Are you working on localhost or the remote server? Have you uploaded
the
 form to the remote server?

I tested them on both the localhost and - after uploading them - on the
remote server. The remote is ok, but the localhost (with PHP 5.1.2) is
the problem.
[/snip]

Have you installed PHP on the localhost and is it running properly?

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



Re: [PHP] Problem with Square Brackets [was: php+ ajax]

2006-02-21 Thread David Dorward
--- Jochem Maas [EMAIL PROTECTED] wrote:
  From a php developer point of view there is one
 big problem with 'follow the standards' mantra as
 far as square brackets go (with regard to use in the
 value of name attributes of form fields) ...

Nope. The names of form controls MAY contain square
brackets, it is the ids that may not (and the name and
id attributes do NOT need to have the same value).

-- 
David Dorward
http://dorward.me.uk/

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



[PHP] Re: Help with query

2006-02-21 Thread Barry

Ing. Tomás Liendo wrote:

Hi I need the students that didn't take an exam. The tables:

exams(id_test, title, desciption, )

results(id_student, id_test, date, qualification...)

I'm using a version of MySQL that doesn't support NOT IN, then I tried in 
this way:


SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE 
results.id_test IS NULL AND id_student=.$user


The query doesn't return anything... What Can I do???

Ahead of time, thank you very much,

Tom.

Sorry last mail got lost lol.

SELECT * FROM results LEFT JOIN exams USING (id_test)
WHERE id_student =.$user;

So you get when the user has a result and applied to it.
If you dont get a result, he wouldn't have done it yet.

(theory)

Barry
--
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

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



Re: [PHP] newbie problem

2006-02-21 Thread tedd

Hi all,

I have a page that lets people upload images - they are then resized 
for use throughout my site.


It all works fine, but I need to reduce the jpg size (without 
reducing image size)


Is there a php function that lets you compress the jpg?

Thanks

Jules


No -- my understanding is that jpg is already compressed -- it's a 
compression routine itself.


tedd
--

http://sperling.com   php code: http://www.weberdev.com/

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



Re: [PHP] Problem with Square Brackets [was: php+ ajax]

2006-02-21 Thread Jochem Maas

David Dorward wrote:

--- Jochem Maas [EMAIL PROTECTED] wrote:


From a php developer point of view there is one
big problem with 'follow the standards' mantra as
far as square brackets go (with regard to use in the
value of name attributes of form fields) ...



Nope. The names of form controls MAY contain square
brackets, it is the ids that may not 


AHA! - I seem to have read the specvs incorrectly - the 'id' attribute
is defined as 'W3C datatype' NAME whereas the 'name' attribute (atleast as
far as the FORM, INPUT  SELECT tags are concerned) is of 'W3C datatype' CDATA.

the CDATA type allow ssquare brackets ofcourse = which means
the php choice of using the square brackets is AOK. :-)

SIDENOTE TO JAY
the 'when to break the rules' idea still stands in theory :-)
/SIDENOTE TO JAY


(and the name and id attributes do NOT need to have the same value).


that I know - I mentioned that myself in a previous post.





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



Re: [PHP] php+ ajax

2006-02-21 Thread tedd

You can't test in every browser out there - there are
too many. You can't test in any browser that hasn't be
written yet.

Writing code that ignores the standards is just asking
for maintainance headaches and other troubles down the
line.


I have to agree with David on this -- but, future browser's 
compliance to standards with is certainly not guaranteed. M$ is still 
reluctant to comply even today (i.e., Does IE 7 show IDNS correctly?).


However, we have no other direction to lessen maintenance headaches 
other than comply.


tedd
--

http://sperling.com   php code: http://www.weberdev.com/

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



[PHP] [NEWBIE GUIDE] - suggestions for new list members

2006-02-21 Thread Jay Blanchard
=
Please feel free to add more points and updates. 
20050322jb - Note the new location of PHP Editors list.
=

1. If you have any queries/problems about PHP try
http://www.php.net/manual/en first. You can download a copy and use it
offline also. For example, a frequent question is how do I upload files
with PHP?. If you type http://www.php.net/upload into your browser's
address bar you will taken indirectly to the answers. Other searches of this
nature may be more direct.

Please also try http://www.php.net/manual/faq.php for answers to frequently
answered questions about PHP [added by Christophe Chisogne].

2. Try http://www.google.com next. Searching for php YOUR QUERY may fetch
you relevant information within the first 10 results.

3. There is a searchable archive of the mailing list discussion at
http://phparch.com/mailinglists. Many of the common topics are discussed
repeatedly, and you may get answer to your query from the earlier
discussions. 

For example: One of the repeatedly discussed question in the list is Best
PHP editor. Everyone has his/her favourite editor. You can get all the
opinions by going through the list archives. If you want a chosen list try
this link :
http://www.thelinuxconsultancy.co.uk/phpeditors.php [contributed by
Christophe Chisogne].

4. Not sure if PHP is working or you want find out what extensions are
available to you?

Just put the following code into a file with a .php extension and access it
through your webserver:

?php
phpinfo();
? 

If PHP is installed you will see a page with a lot of information on it. If
PHP is not installed (or not working correctly) your browser will try to
download the file. [contributed by Teren and reworded by Chris W Parker]

5. If you are stuck with a script and do not understand what is wrong,
instead of posting the whole script, try doing some research yourself. One
useful trick is to print the variable/sql query using print or echo command
and check
whether you get what you expected. 

After diagnosing the problem, send the details of your efforts (following
steps 1, 2  3) and ask for help.

6. PHP is a server side scripting language. Whatever processing PHP does
takes place BEFORE the output reaches the client. Therefore, it is not
possible to access users' computer related information (OS, screen size etc)
using PHP. Nor can you modify any the user side settings. You need to go for
JavaScript and ask the question in a JavaScript list.

On the other hand, you can access the information that is SENT by the user's
browser when a client requests a page from your server. You can find details
about browser, OS etc as reported by this request. [contributed by Wouter
van Vliet and reworded by Chris W Parker.]

7. Provide a clear descriptive subject line. Avoid general subjects like
Help!!, A Question etc. Especially avoid blank subjects. 

8. When you want to start a new topic, open a new mail composer and enter
the mailing list address php-general@lists.php.net instead of replying to an
existing thread and replacing the subject and body with
your message.

9. It's always a good idea to post back to the list once you've solved your
problem. People usually add [SOLVED] to the subject line of their email when
posting solutions. By posting your solution you're helping
the next person with the same question. [contribued by Chris W Parker]

10. Ask smart questions http://catb.org/~esr/faqs/smart-questions.html
[contributed by Jay Blanchard]

11. Do not send your email to the list with attachments. If you don't have a
place to upload your code, try the many pastebin websites (such as
www.pastebin.com). [contributed by Burhan Khalid]

12. Although the following suggestions have been known to be debatable they
should help you in general internet mailing list 'netiquette';

a. Please do not top post as it is hard to follow. If you are unfamiliar
with the concept it is the posting of the reply ABOVE the thing that is
being replied to.

top-posting
What is a bad idea?

b. Where possible trim your posts so that only relevant portions of the
message are being discussed. Replies that become too lengthy are likely to
be ignored.

Following these guidelines will ensure that you get effective responses from
the list members. Otherwise, your questions might not be answered.

===
Hope you have a good time programming with PHP.
===

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



RE: [PHP] newbie problem [SOLVED]

2006-02-21 Thread Robert Voogdgeert
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

 Have you installed PHP on the localhost and is it running properly?

Jay (and others),


I solved the problem. I need to use

10.0.1.3/somedir/somedir/somefile.html

and not

localhost/somedir/somedir/somefile.html,

something I don't understand (probably because of lack of knowledge of
PHP/Apache. Strange thing is: on both addresses the .html file can be
reached, only the PHP processing doesn't happen...


Thanks for the quick respons,


Robert.

-BEGIN PGP SIGNATURE-
Version: PGP SDK 3.0.3

iQA/AwUBQ/sqZrSl/DgWyrAzEQIFTgCghaiT4qH1HYON2mlTTchRf8+rs1oAoMbV
e9hGQH58UYDYC10d+jXMCKfy
=BqUk
-END PGP SIGNATURE-

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



RE: [PHP] newbie problem [SOLVED]

2006-02-21 Thread Jay Blanchard
[snip]
 Have you installed PHP on the localhost and is it running properly?

Jay (and others),


I solved the problem. I need to use

10.0.1.3/somedir/somedir/somefile.html

and not

localhost/somedir/somedir/somefile.html,

something I don't understand (probably because of lack of knowledge of
PHP/Apache. Strange thing is: on both addresses the .html file can be
reached, only the PHP processing doesn't happen...
[/snip]

You're using the fixed IP of the machine, but you may also be able to use
the generic localhost IP of 127.0.0.1

127.0.0.1/somedir/somedir/somefile.html

You should also have a hosts file somewhere on your machine that you can map
the name 'localhost' to the local IP

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



[PHP] Object lifetime

2006-02-21 Thread roger helgesen

I'v got CLASS 1 and CLASS2.
CLASS1 makes many instanses of CLASS2 and stores them in an array.

Ex.
--
load class definition...
start_session();
html
form typ..
?PHP
$cl1=new CLASS1;

I serialize CLASS1 into a $_SESSION['cla1']
-submit form -

and unsreialize it to same var
$cl1=unserialize($_SESSION['cla1']);

$cl1 is operational with same data as before 'submit form'. I can change 
values of data in $cl1.


I CAN read/print data in the instanses of CLASS2 that $cl1 created 
before 'submit form'.
I CAN NOT change the data in the instanses of CLASS2 that $cl1 created 
before 'submit form'.



mark I'v only serialized CLASS1.

Is this at all possible ??

I'v find it strange since I can use/print the data that is stored in 
CLASS2 before 'submit form'.


regards
Roger Helgesen

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



[PHP] CLASS/Object lifetime

2006-02-21 Thread roger helgesen

 Hi!

I'v got 2 classes. CLASS1 makes a array of instanses of class2.

I need thees classes 2 live for the duration of the session so I 
serialize class1 to a _session var.


I submit the form and the page is reloaded. I unserialize class1 back 2 
same instanse var.

class1 I works. The instanses of class2 almost work.
I can read all data from the class/object, I can run functions off 
class2 BUT I can't change the data in objects og class2.


Is this at all possible.

ps.I do not serialize/unserialize object of CLASS2, these are instanses 
of CLASS1.


regard
Roger Helgesen

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



Re: [PHP] php+ ajax

2006-02-21 Thread David Dorward
--- tedd [EMAIL PROTECTED] wrote:
 I have to agree with David on this -- but, future
 browser's compliance to standards with is certainly 
 not guaranteed.

I find it less trouble to code to standards and then
deal with bugs in browsers, then to code to bugs in
browsers and then deal with more bugs in browsers PLUS
browsers rejecting the code on the basis of it not
meeting the standard. :)

-- 
David Dorward
http://dorward.me.uk/

__
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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



[PHP] Does this If statement make sense?

2006-02-21 Thread Jeff
I'm again working with someone else's code and I have a problem I
believe is in the section below.  The problem is, I can't seem to
understand what the IF conditions are saying here.  The problem I have
is with the second condition.  To me this reads in psudo code:

If( X and (if Y exists, then W otherwise Z))

Does this work?  If so how is it evaluated?

Here is the actual code.
code

if ($tostaf   ($reply-comment ? $config-send_comment_staf :
$config-send_emailreply_staf)) 
{
$to=array();
 
$vars[ticketurl]=$config-webpath.ticket.php?id=.$ticket-id;
if ($reply-comment) {
$condition= AND followups.employee'$reply-employee';
}

/code 

Thanks,

Jeff

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



RE: [PHP] Does this If statement make sense?

2006-02-21 Thread Jay Blanchard
[snip]
If( X and (if Y exists, then W otherwise Z))

Does this work?  If so how is it evaluated?

Here is the actual code.
code

if ($tostaf   ($reply-comment ? $config-send_comment_staf :
$config-send_emailreply_staf)) 
[/snip]

IF X then IF Y, W
IF X then IF NOT Y, Z

There is no ELSE to support the IF NOT X, if X does not exist then the
evaluation is over.

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



Re: [PHP] CLASS/Object lifetime

2006-02-21 Thread Jochem Maas

roger helgesen wrote:

 Hi!

I'v got 2 classes. CLASS1 makes a array of instanses of class2.

I need thees classes 2 live for the duration of the session so I 
serialize class1 to a _session var.


I submit the form and the page is reloaded. I unserialize class1 back 2 
same instanse var.

class1 I works. The instanses of class2 almost work.
I can read all data from the class/object, I can run functions off 
class2 BUT I can't change the data in objects og class2.


Is this at all possible.

ps.I do not serialize/unserialize object of CLASS2, these are instanses 
of CLASS1.


know this: you must define the class of any object you serialize in the
session array BEFORE you start the session. (unless you want lots of problems)

==

now if you could post some code then we can figure out why your array of CLASS2
objects (inside your unserialized CLASS1 object) do not contain the data they 
should
(namely the data you stuffed in them before serializing the CLASS1 ['parent'] 
object)

deal?



regard
Roger Helgesen



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



Re: [PHP] CLASS/Object lifetime

2006-02-21 Thread roger helgesen

Jochem Maas wrote:

roger helgesen wrote:

 Hi!

I'v got 2 classes. CLASS1 makes a array of instanses of class2.

I need thees classes 2 live for the duration of the session so I 
serialize class1 to a _session var.


I submit the form and the page is reloaded. I unserialize class1 back 
2 same instanse var.

class1 I works. The instanses of class2 almost work.
I can read all data from the class/object, I can run functions off 
class2 BUT I can't change the data in objects og class2.


Is this at all possible.

ps.I do not serialize/unserialize object of CLASS2, these are 
instanses of CLASS1.


know this: you must define the class of any object you serialize in the
session array BEFORE you start the session. (unless you want lots of 
problems)


==

now if you could post some code then we can figure out why your array of 
CLASS2
objects (inside your unserialized CLASS1 object) do not contain the data 
they should
(namely the data you stuffed in them before serializing the CLASS1 
['parent'] object)


deal?



regard
Roger Helgesen

The thing is that the array of CLASS2 do contain the data, but I can't 
change them.


I attach the code.
CLASS1 = sammendragHTML (child of sammendrag)
CLASS2 = gruppe

There is quite a lot of rubbish in the code !

tnx!

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

[PHP] Re: CLASS/Object lifetime - Here is the code

2006-02-21 Thread roger helgesen

roger helgesen wrote:

 Hi!

I'v got 2 classes. CLASS1 makes a array of instanses of class2.

I need thees classes 2 live for the duration of the session so I 
serialize class1 to a _session var.


I submit the form and the page is reloaded. I unserialize class1 back 2 
same instanse var.

class1 I works. The instanses of class2 almost work.
I can read all data from the class/object, I can run functions off 
class2 BUT I can't change the data in objects og class2.


Is this at all possible.

ps.I do not serialize/unserialize object of CLASS2, these are instanses 
of CLASS1.


regard
Roger Helgesen



?PHP
CLASS kontoplan{
var $kontoer=array();
function kontoplan(){
$SQL=SELECT kontonummer,navn,paslag FROM kontoer ORDER BY 
kontonummer;
$SQL=mysql_query($SQL);
$teller=1;
while($konto=mysql_fetch_array($SQL)){
//  echo bvi er naring; $teller gangbr\n;
//			echo 
array(\kontonummer\=$konto[0],\navn\=$konto[1],\paslag\=$konto[2])br\n;
		 
$this-kontoer[$konto[0]]=array(kontonummer=$konto[0],navn=$konto[1],paslag=$konto[2]);

//  $teller++;
}
//	echo   Kontoplan(.count($this-kontoer).) 
-\n;

//  print_r($this-kontoer);

//  foreach($this-kontoer as $konto=$rekke){
//  echo $konto(.count($this-kontoer).)br\n;
//		echo 0=.$rekke['kontonummer']. 1=.$rekke['navn']. 
2=.$rekke['paslag'].br\n;

//  }
}

}
CLASS sammendrag{
var $prosjektnummer;
var $prosjektnavn;
var $kalk_id;
var $hovedposter=array();
var $subposter=array();
var $vinduer=array();
var $dorer=array();
var $porter=array();
var $antall=0;
var $a=0;
var $kplan;
function sammendrag($nummer,$navn){
//  echo h2I sammandrag/h2\n;
$this-prosjektnummer=$nummer;
$this-prosjektnavn=sql_return(SELECT ProsjektNavn 
FROM prosjektnr where ProsjektNummer=$nummer);

$this-kplan=new kontoplan();
		$this-kalk_id=sql_return(SELECT id FROM kalk_opl WHERE 
prosjekt='$this-prosjektnummer');
$SQL=SELECT left(konto,4) AS hkonto,ROUND(SUM(s4)) 
FROM kalkyler WHERE id_kalk='$this-kalk_id' GROUP BY hkonto;

//echo sql=$SQLbr\n;
		$knavn=SELECT kontonummer,navn FROM kontoer WHERE 
right(kontonummer,2)=00;

$knavn=mysql_query($knavn);
$kn=array();
while($k=mysql_fetch_array($knavn)){
//  $k[0]=$k[0].'00';
$kn[$k[0]]=$k[1];
}
mysql_free_result($knavn);
$SQL=mysql_query($SQL);
$tpost=array();
$npost=array();
while($hkonto=mysql_fetch_array($SQL)){
$hkonto[0]=$hkonto[0].'00';
//  echo hkonto0[$hkonto[0]], knr=$knrbr\n;
//  array_unshift($hkonto,$kn[$hkonto[0]]);
$tpost[]=array($hkonto[0],$kn[$hkonto[0]],$hkonto[1]);
}
// Fyller pa med underentrepenorer
		$SQL=SELECT kontonummer,navn FROM kontoer WHERE (kontonummer =45 
AND kontonummer  451000) AND right(kontonummer,2)='00';

$SQL=mysql_query($SQL);
while($hkonto=mysql_fetch_array($SQL)){
$hkonto[2]=0;
array_push($tpost,$hkonto);
}
$this-fyll_poster($tpost);
$this-fyll_vinduer();
$this-lag_hkontoer();
}
function fyll_poster($rekke){
while($post=current($rekke)){
$this-ny_hovedpost($post);
next($rekke);
}

}
function ny_hovedpost($hovedpost){
//  echo Sette 
hovedposter[.$hovedpost[0].]=$hovedpostbr\n;

$this-hovedposter[$hovedpost[0]]=$hovedpost;
$this-antall++;
}
function hpostnavn($post){
//echo hpostnavn=.$this-hovedposter[$post][1].\n;
return $this-hovedposter[$post][1];

}
function lag_hkontoer(){
foreach($this-hovedposter AS $hkonto=$verd){
$hn='t'.$hkonto;
$hnnavn=$hn;
$hn=new gruppe($hkonto,$this,$this-kplan);
$this-subposter[$hnnavn]=$hn;
//  $hn-skriv($this,$hkonto);   
}
}

function skriv_kontoer(){
// Skrive ut alle konto sider
foreach($this-subposter AS $konto){
$konto-skriv($this);
}
}
function fyll_sub_konto($pv){
foreach($this-subposter AS $konto=$kontoen){
//echo 

RE: [PHP] Re: Help with query

2006-02-21 Thread Duffy, Scott E
 SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE 
 results.id_test IS NULL AND id_student=.$user

exams.id_test=results.id_test

results.id_test IS NULL

think those are preventing this from happening.

Wouldn't you want this
Results.id_student IS NULL
Since if the student didn't take the test there would not be a record for it 
and the outer join would add that. Then probably an and for id_test=$var. for a 
specific test.

GL

Scott


-Original Message-
From: Barry [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 21, 2006 7:57 AM
To: php-general@lists.php.net
Subject: [PHP] Re: Help with query

Ing. Tomás Liendo wrote:
 Hi I need the students that didn't take an exam. The tables:
 
 exams(id_test, title, desciption, )
 
 results(id_student, id_test, date, qualification...)
 
 I'm using a version of MySQL that doesn't support NOT IN, then I tried in 
 this way:
 
 SELECT * FROM exams LEFT JOIN results ON exams.id_test=results.id_test WHERE 
 results.id_test IS NULL AND id_student=.$user
 
 The query doesn't return anything... What Can I do???
 
 Ahead of time, thank you very much,
 
 Tom.
Sorry last mail got lost lol.

SELECT * FROM results LEFT JOIN exams USING (id_test)
WHERE id_student =.$user;

So you get when the user has a result and applied to it.
If you dont get a result, he wouldn't have done it yet.

(theory)

Barry
-- 
Smileys rule (cX.x)C --o(^_^o)
Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o)

-- 
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] Reading binary http post

2006-02-21 Thread Dirk Vanden Boer
Hi,

I have a C++ application that posts binary data to a php script that I 
created using libcurl. Everything works fine except when my binary data 
happens to start with the '' symbol. In that case I can't read the http 
post data (isset returns false).

The post argument then looks like data=ÑÚA
Reading the post is done like this:
if (isset($_POST['data'])
Is there a way to fix this problem?

Thanks in advance
Dirk

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



[PHP] How do I output error messages

2006-02-21 Thread Paul Goepfert
Hi all,

I have a web page that I am doing valildation on.  I have figured out
how to at least get the page to load the page content.  What I can't
seem to figure out is how to output the error messages to the screen. 
The validation is being performed on the same page as the form that is
being validated.  The way the page is setup:

if (isset($submit))
{
  //vaildation code
}
else
{
//webpage
}

Thanks for the help,

Paul

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



RE: [PHP] How do I output error messages

2006-02-21 Thread Jay Blanchard
[snip]
if (isset($submit))
{
  //vaildation code
}
else
{
//webpage
}
[/snip]

What is $submit? Is it set ever? The problem probably lies in the fact that
$submit, whatever it is, never gets set.

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



Re: [PHP] Reading binary http post

2006-02-21 Thread Paul Scott
On Tue, 2006-02-21 at 19:40 +0100, Dirk Vanden Boer wrote:
 The post argument then looks like data=A
 Reading the post is done like this:
 if (isset($_POST['data'])
 Is there a way to fix this problem?
 

Have you tried base64_encoding the binary data, then decoding it again
on the PHP side?

--Paul

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



[PHP] Re: Reading binary http post

2006-02-21 Thread Dan Baker
Dirk Vanden Boer [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Hi,

 I have a C++ application that posts binary data to a php script that I 
 created using libcurl. Everything works fine except when my binary data 
 happens to start with the '' symbol. In that case I can't read the http 
 post data (isset returns false).

 The post argument then looks like data=ÑÚA
 Reading the post is done like this:
 if (isset($_POST['data'])
 Is there a way to fix this problem?

A quick-n-dirty method is to prepend a known letter to the data, like an 
A:
data=AÑÚA
Then, ignore the first character of the data, since it is known to be the 
A character.

I would think that if the data contains an  in the middle of the data, 
you may not be getting all the data.
data=ABCxyz=123
$_POST['data'] = ABC
$_POST['xyz'] = 123

DanB

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



Re: [PHP] Reading binary http post

2006-02-21 Thread Dirk Vanden Boer
Thanks for the hint, I'm not doing any encoding at the moment, I'll
try it out tomorrow.

Dirk

On 2/21/06, Paul Scott [EMAIL PROTECTED] wrote:
 On Tue, 2006-02-21 at 19:40 +0100, Dirk Vanden Boer wrote:
  The post argument then looks like data=A
  Reading the post is done like this:
  if (isset($_POST['data'])
  Is there a way to fix this problem?
 

 Have you tried base64_encoding the binary data, then decoding it again
 on the PHP side?

 --Paul



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



RE: [PHP] How do I output error messages

2006-02-21 Thread Jeremy Schreckhise
You could pass your error message back and forth as an HTTP post.

$myMsg = $_GET['error_msg'];
if(isset($myMsg))
{
//print my message
}
else
{
//process as normal
}


-Original Message-
From: Paul Goepfert [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, February 21, 2006 12:53 PM
To: php-general@lists.php.net
Subject: [PHP] How do I output error messages

Hi all,

I have a web page that I am doing valildation on.  I have figured out how to
at least get the page to load the page content.  What I can't seem to figure
out is how to output the error messages to the screen. 
The validation is being performed on the same page as the form that is being
validated.  The way the page is setup:

if (isset($submit))
{
  //vaildation code
}
else
{
//webpage
}

Thanks for the help,

Paul

--
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] novice with hacked email form issue

2006-02-21 Thread cKc Consultants
An email form that uses a simple server side php code to send the variable
values managed to send: 


Content-Type: multipart/alternative; 
 boundary=5c7c7e682d991e8ec1f6825582ea2103
 MIME-Version: 1.0
 Subject: round a rock by way of anchorage
 bcc: [EMAIL PROTECTED]
 
 This is a multi-part message in MIME format.
 
 --5c7c7e682d991e8ec1f6825582ea2103
 Content-Type: text/plain; charset=\us-ascii\
 MIME-Version: 1.0
 Content-Transfer-Encoding: 7bit
 
 system expict th time is
 --5c7c7e682d991e8ec1f6825582ea2103--


This appears between responses to $msg.= and shouldn't be something the
user could see. In order to figure out how to prevent this, I need to know
how it was done. I know I need to validate the email address more closely,
but I'm curious as to what created this. I've found some interesting
articles on the web, but nothing seems to deal with this issue. Pointing me
in the right direction would be appreciated!

TIA!

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



[PHP] Re: CLASS/Object lifetime - more info

2006-02-21 Thread roger helgesen

The function that gives me trouble
-
function fyll_sub_konto($pv){
foreach($this-subposter AS $konto){
$konto-fyll_fra_post($pv);
}
}
-

$this-subposter is the array of CLASS2

function fyll_fra_post($post_vars){
echo (gruppe)class = .get_class($this) .br\n;
$teller=0;
foreach($this-poster AS $post=$verd){
$best=bestilt_.$post;
$avik=avvik_.$post;
$fakt=faktura_.$post;
$this-poster[$post][bestilt]=$post_vars[$best];
$this-poster[$post][avvik]=$post_vars[$avik];
$this-poster[$post][faktura]=$post_vars[$fakt];
}
$this-endret='ja';
$this-sett_sum();
}

If I print the data (after setting the new data) inside 'fyll_fra_post' 
it puts out the new data.
If I do the same from 'fyll_sub_konto' (after foreach) it gives me the 
old data.


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



Re: [PHP] novice with hacked email form issue

2006-02-21 Thread Greg Schnippel
On 2/21/06, cKc Consultants [EMAIL PROTECTED] wrote:
 An email form that uses a simple server side php code to send the variable
 values managed to send:
snip

Try looking for articles on 'email injection'. This is a really good
place to start for a description of the security risk and ways to
patch your code:

http://securephp.damonkohler.com/index.php/Email_Injection

You should also check recent archives on this list, there have been
several threads on this topic that may be of use.

- schnippy

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



Re: [PHP] How do I output error messages

2006-02-21 Thread Richard Lynch
On Tue, February 21, 2006 12:52 pm, Paul Goepfert wrote:

$messages = array();

 if (isset($submit))
 {
   //vaildation code

Each invalid input adds another element to $messages array.
//E.G.:
if (!isset($_REQUEST['name'])) $messages[] = Name is a required
field.;

 }
 else
 {

if (count($messages)){
  echo p class=\error\, implode(br /\n, $messages), /p\n;
}

 //webpage
 }

You still need to take care that the //webpage itself is not made
insensible by the error conditions...

In extreme cases, such as the database being down and there being no
hope of the rest of the page being useful, I sometimes will do:

if (!$connection){
  head(Error); //This prints out masthead/navbar etc
  $messages[] = Unable to access database. Please try later.;
  echo p class=\error\, implode(br /\n, $messages), /p\n;
  foot(); //This closes all HTML tags from head()
  //both head and foot are defined in a single include file,
  //making it trivial to match up HTML open/close tags
}

It's not as slick as some CRM setups, but it's also not as
cumbersome and over-engineered (imho).

DSFDF

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] novice with hacked email form issue

2006-02-21 Thread Cristian MARIN

Good Resource

Greg Schnippel wrote:

On 2/21/06, cKc Consultants [EMAIL PROTECTED] wrote:
  

An email form that uses a simple server side php code to send the variable
values managed to send:


snip

Try looking for articles on 'email injection'. This is a really good
place to start for a description of the security risk and ways to
patch your code:

http://securephp.damonkohler.com/index.php/Email_Injection

You should also check recent archives on this list, there have been
several threads on this topic that may be of use.

- schnippy
  


Re: [PHP] Reading binary http post

2006-02-21 Thread Richard Lynch
You probably should be URL-encoding your data in the first place...
http://php.net/urlencode

?php
$data = whatever funky characters you want:
$data_url = urlencode($data);

//WRONG:
$URL = http://example.com/$data;

//RIGHT:
$URL = http://example.com/$data_url;;

If it's not feasible for your C++ application to replicate urlencode()
then you may be able to get what you want with that http_raw_post_data
stuff.  You'll have to search on php.net for something not unlike raw
post data until you find it, as I don't have the ULR in my head.

But you'd be 100% better off to follow the standards and url-encode
the data in the first place -- Especially if you're ever going to
re-use this code elsewhere, and MOST especially if you ever might want
to hook up YOUR code to another person's server that actually follows
the standards.

On Tue, February 21, 2006 12:40 pm, Dirk Vanden Boer wrote:
 Hi,

 I have a C++ application that posts binary data to a php script that I
 created using libcurl. Everything works fine except when my binary
 data
 happens to start with the '' symbol. In that case I can't read the
 http
 post data (isset returns false).

 The post argument then looks like data=ÑÚA
 Reading the post is done like this:
 if (isset($_POST['data'])
 Is there a way to fix this problem?

 Thanks in advance
 Dirk

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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Parse Error

2006-02-21 Thread Ray Cantwell

Hi all,
I am a noob and super confused right now. I have some really simple code 
and i am getting an error that reads:
*Parse error*: syntax error, unexpected T_VARIABLE in 
*/var/www/mysql_up.php* on line


here is the code:

html
headtitleTest MySQL/title/head
body
!-- mysql_up.php --
?php
$host=localhost
$user=ray
$password=*

mysql_connect($host,$user,$password) ;
$sql=show status;
$result = mysql_query($sql);
if ($result == 0)
  echo bError  . mysql_errno() . : 
. mysql_error() . /b;
else
{
?
!-- Table That Displays the results --
table border=1
 trtdbVariable_name/b/tdtdbValue/b
 /td/tr
 ?php
   for ($i = 0; $i  mysql_num_rows($result); $i++) {
 echo TR;
 $row_array = mysql_fetch_row($result);
 for ($j = 0; $j  mysql_num_fields(result); $j++)
 {/
   echo TD . $row_array[$j] . /td;
 }
 echo /tr;
  }
?
/table
?php } ?
/body/html

I am really confused because i cannot see any obvious errors.
any help would be appreciated.

Ray.





RE: [PHP] Parse Error

2006-02-21 Thread Jay Blanchard
[snip]
I am a noob and super confused right now. I have some really simple code 
and i am getting an error that reads:
*Parse error*: syntax error, unexpected T_VARIABLE in 
*/var/www/mysql_up.php* on line

here is the code:

html
headtitleTest MySQL/title/head
body
!-- mysql_up.php --
?php
$host=localhost
$user=ray
$password=*
[/snip]

Notice anything missing here? Semi-colons at the end of each line.

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



Re: [PHP] Object lifetime

2006-02-21 Thread Richard Lynch
On Tue, February 21, 2006 9:12 am, roger helgesen wrote:
 I'v got CLASS 1 and CLASS2.
 CLASS1 makes many instanses of CLASS2 and stores them in an array.

 Ex.
 --
 load class definition...
 start_session();
 html
 form typ..
 ?PHP
 $cl1=new CLASS1;
 
 I serialize CLASS1 into a $_SESSION['cla1']
 -submit form -

 and unsreialize it to same var
 $cl1=unserialize($_SESSION['cla1']);

 $cl1 is operational with same data as before 'submit form'. I can
 change
 values of data in $cl1.

 I CAN read/print data in the instanses of CLASS2 that $cl1 created
 before 'submit form'.
 I CAN NOT change the data in the instanses of CLASS2 that $cl1 created
 before 'submit form'.


 mark I'v only serialized CLASS1.

 Is this at all possible ??

 I'v find it strange since I can use/print the data that is stored in
 CLASS2 before 'submit form'.

So...

Is the class definition for CLASS2 getting loaded in the after submit
form page?

Or you you expecting it to get __autoload-ed?  Cuz I don't think it
will...

That might explain why you have a read-only instance.

If all else fails, you could walk the array in $cl1 and serialize each
$cl2 individually, I guess...

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Parse Error

2006-02-21 Thread Ray Hauge
On Tuesday 21 February 2006 14:27, Ray Cantwell wrote:
 Hi all,
 I am a noob and super confused right now. I have some really simple code
 and i am getting an error that reads:
 *Parse error*: syntax error, unexpected T_VARIABLE in
 */var/www/mysql_up.php* on line

 here is the code:

 html
 headtitleTest MySQL/title/head
 body
 !-- mysql_up.php --
 ?php
 $host=localhost
 $user=ray
 $password=*

 mysql_connect($host,$user,$password) ;
 $sql=show status;
 $result = mysql_query($sql);
 if ($result == 0)
echo bError  . mysql_errno() . : 
  . mysql_error() . /b;
 else
 {
 ?
 !-- Table That Displays the results --
 table border=1
   trtdbVariable_name/b/tdtdbValue/b
   /td/tr
   ?php
 for ($i = 0; $i  mysql_num_rows($result); $i++) {
   echo TR;
   $row_array = mysql_fetch_row($result);
   for ($j = 0; $j  mysql_num_fields(result); $j++)
   {/
 echo TD . $row_array[$j] . /td;
   }
   echo /tr;
}
  ?
 /table
 ?php } ?
 /body/html

 I am really confused because i cannot see any obvious errors.
 any help would be appreciated.

 Ray.

It looks like you need some semi-colons after assigning values to variables at 
the top of your file.

If that's not the problem, let us know what line number this is happening on.  
It makes it a lot easier to spot the problem ;)

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
http://www.americanstudentloan.com
1.800.575.1099

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



Re: [PHP] Parse Error

2006-02-21 Thread Kevin Waterson
This one time, at band camp, Ray Cantwell [EMAIL PROTECTED] wrote:


 ?php
 $host=localhost
 $user=ray
 $password=*

these need to be terminated with ;

$host = 'localhost';
etc
etc

Kevin

-- 
Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote.

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



Re: [PHP] novice with hacked email form issue

2006-02-21 Thread Richard Lynch
On Tue, February 21, 2006 12:19 pm, cKc Consultants wrote:
 An email form that uses a simple server side php code to send the
 variable
 values managed to send:

Here is a stripped-down version of what happened:

YOUR BAD CODE:

?php if (isset($email)){
  //This next line blindly embeds the user input $email
  //into the headers of an email message.
  //This pretty much turns your server into a spam-factory.
  //Don't do that!
  mail('[EMAIL PROTECTED]', From Web, $message, From:
$email);
} ?
form action=hackable.php method=post
Your Email: input name=emailbr /
Your Message: textarea name=message wrap=virtual cols=20
rows=10/textareabr /
input type=submit name=hack_me value=send us email
/form


Here is a crude script specifically crafted to abuse the above page.
You can assume the spammers are a bit more sophisticated than this.
?php
  $hack_data = Content-Type: multipart/alternate;\r\n...;
  $post_vars = email=$hack_datamessage=hack_me=send+us+email;
  $data_len = strlen($post_vars);
  $socket = fsockopen(http://example.com;, 80);
  fwrite($socket, POST /hackable.php HTTP/1.0\n);
  fwrite($socket, Host: example.com\n);
  fwrite($socket, Content-length: $data_len\n);
  fwrite($socket, $post_vars);
?


 Content-Type: multipart/alternative;
 boundary=5c7c7e682d991e8ec1f6825582ea2103
 MIME-Version: 1.0
 Subject: round a rock by way of anchorage
 bcc: [EMAIL PROTECTED]

 This is a multi-part message in MIME format.

 --5c7c7e682d991e8ec1f6825582ea2103
 Content-Type: text/plain; charset=\us-ascii\
 MIME-Version: 1.0
 Content-Transfer-Encoding: 7bit

 system expict th time is
 --5c7c7e682d991e8ec1f6825582ea2103--


 This appears between responses to $msg.= and shouldn't be something
 the
 user could see. In order to figure out how to prevent this, I need to
 know
 how it was done. I know I need to validate the email address more
 closely,
 but I'm curious as to what created this. I've found some interesting
 articles on the web, but nothing seems to deal with this issue.
 Pointing me
 in the right direction would be appreciated!

Having the above kind of junk in the message body itself is not really
a huge huge problem -- And it's almost impossible to avoid it without
crippling the legitimate input for a message BODY.

Buuut:

An email address, which you are splicing into the HEADERS as the
fourth argument to PHP's http://php.net/mail function should *NOT*
have any kind of crap like this in it.

In fact, if an email contains a newline, you can pretty much assume
the user is a spammer trying to abuse your script to do Evil Things...

Actually, a real user might manage to have a leading/trailing
newline when they paste an email address into a web form.

Amened the preceding statement to:

If an email contains an embedded newline, they are a spammer.

So, to secure your mail() script do this:

$email = trim($_REQUEST['email']);
if (strstr($email, \n)){
  die(spammer);
}
//now it's safe to send the email.

You also should sanitize the input for $subject since that ALSO gets
spliced into the headers of an email.

You could, perhaps, perform additional validation upon $email, looking
for a specific format involving @ and dots and so forth -- but be
warned that you are likely to inadvertantly reject valid email
addresses, and are guaranteed to accept worthless email addresses no
matter how rigorous your validation...

So I personally don't think it's wise to attempt to validate an email
address as syntactically valid email address for a simple form mail.

But then, I've been burned by a BUNCH of web-sites that reject MY
email address as invalid and am biased by that. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Parse Error

2006-02-21 Thread Claudio Corlatti

Hi,
you need to finish every line with ;
$host=localhost ;
$user=ray ;
$password=* ;

Bye


Ray Cantwell wrote:

Hi all,
I am a noob and super confused right now. I have some really simple 
code and i am getting an error that reads:
*Parse error*: syntax error, unexpected T_VARIABLE in 
*/var/www/mysql_up.php* on line


here is the code:

html
headtitleTest MySQL/title/head
body
!-- mysql_up.php --
?php
$host=localhost ;
$user=ray ;
$password=* ;

mysql_connect($host,$user,$password) ;
$sql=show status;
$result = mysql_query($sql);
if ($result == 0)
  echo bError  . mysql_errno() . : 
. mysql_error() . /b;
else
{
?
!-- Table That Displays the results --
table border=1
 trtdbVariable_name/b/tdtdbValue/b
 /td/tr
 ?php
   for ($i = 0; $i  mysql_num_rows($result); $i++) {
 echo TR;
 $row_array = mysql_fetch_row($result);
 for ($j = 0; $j  mysql_num_fields(result); $j++)
 {/
   echo TD . $row_array[$j] . /td;
 }
 echo /tr;
  }
?
/table
?php } ?
/body/html

I am really confused because i cannot see any obvious errors.
any help would be appreciated.

Ray.








Re: [PHP] Parse Error

2006-02-21 Thread Ray

Jay Blanchard wrote:


[snip]
I am a noob and super confused right now. I have some really simple code 
and i am getting an error that reads:
*Parse error*: syntax error, unexpected T_VARIABLE in 
*/var/www/mysql_up.php* on line


here is the code:

html
headtitleTest MySQL/title/head
body
!-- mysql_up.php --
?php
$host=localhost
$user=ray
$password=*
[/snip]

Notice anything missing here? Semi-colons at the end of each line.

 


Thanks. did i say i was a n00b? :-)

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



Re: [PHP] Parse Error

2006-02-21 Thread John Nichel

Ray Cantwell wrote:

Hi all,
I am a noob and super confused right now. I have some really simple code 
and i am getting an error that reads:
*Parse error*: syntax error, unexpected T_VARIABLE in 
*/var/www/mysql_up.php* on line


here is the code:

html
headtitleTest MySQL/title/head
body
!-- mysql_up.php --
?php
$host=localhost
$user=ray
$password=*

snip

Terminate your php lines with a semi-colon ';'

--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
[EMAIL PROTECTED]

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



Re: [PHP] Parse Error

2006-02-21 Thread benifactor

- Original Message - 
From: Ray Cantwell [EMAIL PROTECTED]
To: php-general@lists.php.net
Sent: Tuesday, February 21, 2006 1:27 PM
Subject: [PHP] Parse Error


 Hi all,
 I am a noob and super confused right now. I have some really simple code 
 and i am getting an error that reads:
 *Parse error*: syntax error, unexpected T_VARIABLE in 
 */var/www/mysql_up.php* on line
 
 here is the code:
 
 html
 headtitleTest MySQL/title/head
 body
 !-- mysql_up.php --
 ?php
 $host=localhost
 $user=ray
 $password=*
 
 mysql_connect($host,$user,$password) ;
 $sql=show status;
 $result = mysql_query($sql);
 if ($result == 0)
echo bError  . mysql_errno() . : 
  . mysql_error() . /b;
 else
 {
 ?
 !-- Table That Displays the results --
 table border=1
   trtdbVariable_name/b/tdtdbValue/b
   /td/tr
   ?php
 for ($i = 0; $i  mysql_num_rows($result); $i++) {
   echo TR;
   $row_array = mysql_fetch_row($result);
   for ($j = 0; $j  mysql_num_fields(result); $j++)
   {/
 echo TD . $row_array[$j] . /td;
   }
   echo /tr;
}
  ?
 /table
 ?php } ?
 /body/html
 
 I am really confused because i cannot see any obvious errors.
 any help would be appreciated.
 
 Ray.
 
 
 


you need to add a ; to every  variable you assign... 
you had:
$host=localhost
 $user=ray
 $password=*

it should be:

$host=localhost;
$user=ray;
$password=*;

also i belive a better way to get the result of your query would be

mysql_connect($host, $user, $pass) or die(mysql_error());

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



Re: [PHP] Does this If statement make sense?

2006-02-21 Thread Richard Lynch
On Tue, February 21, 2006 9:55 am, Jeff wrote:
 I'm again working with someone else's code and I have a problem I
 believe is in the section below.  The problem is, I can't seem to
 understand what the IF conditions are saying here.  The problem I
 have
 is with the second condition.  To me this reads in psudo code:

 If( X and (if Y exists, then W otherwise Z))

 Does this work?  If so how is it evaluated?

 Here is the actual code.
 code

 if ($tostaf   ($reply-comment ? $config-send_comment_staf :
 $config-send_emailreply_staf))

Makes sense to me...

If $tostaf is false, the rest of this stuff is irrelevant, and the
whole block can be ignored.

If $tostaf is TRUE, then check $reply-comment.

If $reply-comment is TRUE, check $config-send_comment_staf
If $reply-comment is FALSE, check $config-send_emailreply_staf

The $config-send_XYZ is going to ALSO be evaluated as TRUE/FALSE,
whichever one of the two setting is relevent.

It might be more clear to write it like this:

$config_send = $reply-comment ? $config-send_comment_staf :
$config-send_emailreply_staf;

if ($tostaf  $config_send){
   $to = array();
   ...
}

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] CLI utility

2006-02-21 Thread Ray Cantwell

Hello again,
I was wondering if any of you knew of a good command line utility for 
php5 on linux? The box i write on has no X-windows.

Ray.

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



Re: [PHP] question about foreach and associate array

2006-02-21 Thread Richard Lynch
On Mon, February 20, 2006 8:57 pm, jonathan wrote:
 I have the following construct:

   $arg['textarea']['body']=Hello;


foreach($arg['textarea'] as $row)
{
  echo $row['body'].br/;
  echo $arg['textarea']['body'].br/;

}

 I would expect both of them to output Hello but only the second
 does. The first outputs H. I thought I have done this before. Can
 anybody tell me why this won't work?

It's like this:

foreach($arg['textarea'] as $row) is ALREADY tearing apart the
$arg['textarea'] into pieces.

So $row is Hello

When you print $row['body'], PHP is kinda stuck...

You've got a string, which is really a bunch of individual characters
run together.

You're trying to index it like an array.

So you MUST be trying to get at an individual character.

The index you've given is 'body', and PHP needs that to be a number:
0-H
1-e
2-l
3-l
4-o

The data-type conversion rules of PHP convert 'body' to the number 0.

So you're getting 'H' because you are really doing:
$row = Hello;
echo $row[0];

Maybe what you REALLY wanted was:
//iterate through each 'textarea':
foreach($arg as $row){
  echo $row['body'];
}

Or, perhaps:
foreach($arg['textarea'] as $row){
  echo $row;
}

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Proper OOP Syntax

2006-02-21 Thread Richard Lynch
On Mon, February 20, 2006 5:25 pm, Albert Padley wrote:
 $password = (strlen($this-user_pw)  32) ? md5($this-user_pw) :
 $this-user_pw;

So, if I use a password with more than 32 characters, you're NOT going
to md5() it?!

This is not really the Right Way to do this, imho.

   $sql = sprintf(SELECT COUNT(*) AS test, TeamID FROM %s 
 WHERE
 BINARY login = '%s' AND pw = '%s' AND active = 'y', $this-
  table_name, $this-user, $password);
   }
   $result = mysql_query($sql) or die(mysql_error());

list($text, $TeamID) = mysql_fetch_row($result);

session_start();
$_SESSION['TeamID'] = $TeamID


   if (mysql_result($result, 0, test) == 1) {
   return true;
   } else {
   return false;
   }

 How would I set a session variable for the value of TeamID?


 Thanks.

 Albert Padley

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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Re: regular pattern to match åäö

2006-02-21 Thread Cristian MARIN
Normally the \w in documentation is written that it does this trick 
matching based on the locale that your machine having the pcre installed 
use:


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

 ... A word character is any letter or digit or the underscore 
character, that is, any character which can be part of a Perl word. 
The definition of letters and digits is controlled by PCRE's character 
tables, and may vary if locale-specific matching is taking place. For 
example, in the fr (French) locale, some character codes greater than 
128 are used for accented letters, and these are matched by \w.


These character type sequences can appear both inside and outside 
character classes. They each match one character of the appropriate 
type. If the current matching point is at the end of the subject string, 
all of them fail, since there is no character to match. ...


Therefore your code in this situation will became:
[^\w\s]
Another solution is to get the hex code or the octal code of these special 
characters and put them into your pattern under this form:

[^a-zA-Z\ddd\ddd\ddd-_\s]  where ddd is the octal code

or 


[^a-zA-Z\xhh\xhh\xhh-_\s] where hh is the hex code.


Cristian MARIN - [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

Developer Designers Department
InterAKT Online (www.interaktonline.com http://www.interaktonline.com



Patrick wrote:

im trying to get my regular pattern to allow åäöÅÄÖ but it refuses to,
i have something like this:

[^a-zA-ZåäöÅÄÖ0-9-_ ]

But this dosent seem to work, anyone got any ideas?
  


Re: [PHP] HOSTNAME Environment variable

2006-02-21 Thread Richard Lynch
On Tue, February 21, 2006 1:37 am, Ruben Rubio Rey wrote:
 How to set Hostname environment variable? (It contains the servers
 name, not the servers domain)
 Its a Linux server.

The environment variables come *FROM* the environment into PHP.

If you want them changed, you have to change your environment -- IE,
the environment of the user that PHP runs as (httpd.conf User
setting).

PHP essentially just reports what's in ENV, GET, POST, COOKIE etc.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



[PHP] Re: Reading binary http post

2006-02-21 Thread Cristian MARIN
This is actually not a solution as is not solving Dirk's problem. The 
'A' will make the isset($_POST['data']) to be always true. Another thing 
is that the $_POST['data'] is still not  containing the binary code that 
is expected as the PHP will get the  and will start a new variable


A solution will be the base64_encode() which is the safest way to 
transport binary data over the net.
Another one will be a simple rawurlencode() which is supposed to solve 
exactly this problem and on the server you shouldn't do any decode 
after. However I can't grant you that your binary will correctly survive.





Cristian MARIN - [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

Developer Designers Department
InterAKT Online (www.interaktonline.com http://www.interaktonline.com


Dan Baker wrote:
Dirk Vanden Boer [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
  

Hi,

I have a C++ application that posts binary data to a php script that I 
created using libcurl. Everything works fine except when my binary data 
happens to start with the '' symbol. In that case I can't read the http 
post data (isset returns false).


The post argument then looks like data=ÑÚA
Reading the post is done like this:
if (isset($_POST['data'])
Is there a way to fix this problem?



A quick-n-dirty method is to prepend a known letter to the data, like an 
A:

data=AÑÚA
Then, ignore the first character of the data, since it is known to be the 
A character.


I would think that if the data contains an  in the middle of the data, 
you may not be getting all the data.

data=ABCxyz=123
$_POST['data'] = ABC
$_POST['xyz'] = 123

DanB
  


RE: [PHP] Parse Error

2006-02-21 Thread Emmanuel Job
[snip]
for ($j = 0; $j  mysql_num_fields(result); $j++)
[/snip]

need to change this as well (forgot a $). should be:

for ($j = 0; $j  mysql_num_fields($result); $j++)


-Original Message-
From: John Nichel [mailto:[EMAIL PROTECTED]
Sent: Tuesday, February 21, 2006 1:34 PM
To: php-general@lists.php.net
Subject: Re: [PHP] Parse Error


Ray Cantwell wrote:
 Hi all,
 I am a noob and super confused right now. I have some really simple code 
 and i am getting an error that reads:
 *Parse error*: syntax error, unexpected T_VARIABLE in 
 */var/www/mysql_up.php* on line
 
 here is the code:
 
 html
 headtitleTest MySQL/title/head
 body
 !-- mysql_up.php --
 ?php
 $host=localhost
 $user=ray
 $password=*
snip

Terminate your php lines with a semi-colon ';'

-- 
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
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



[PHP] Re: PHP5.1.2/Apache2/WindowsXP

2006-02-21 Thread Cristian MARIN
Most probably this is a bug that should be first isolated (see what line 
exactly line of your code make the Apache crash). You should report this 
to bugs.php.net.


I had a similar situation and on Windows is quite difficult to report 
such a bug:  http://bugs.php.net/bug.php?id=35940


Cristian MARIN - [EMAIL PROTECTED] 
mailto:[EMAIL PROTECTED]

Developer Designers Department
InterAKT Online (www.interaktonline.com http://www.interaktonline.com


Robert Hicks wrote:
I am trying to use the DB PEAR extension. Every time it tries to 
connect, I get a memory cannot be read error.


I have just setup all this to try out PHP5 so help to a newbie would 
be appreciated.


Robert


Re: [PHP] Reading binary http post

2006-02-21 Thread Dirk Vanden Boer
Thanks for the info, it was really helpfull. One question though, is
it necessary to first encode my data with the base64 algo, or can I
skip that step and immediately urlencode my data?

Dirk

On 2/21/06, Richard Lynch [EMAIL PROTECTED] wrote:
 You probably should be URL-encoding your data in the first place...
 http://php.net/urlencode

 ?php
 $data = whatever funky characters you want:
 $data_url = urlencode($data);

 //WRONG:
 $URL = http://example.com/$data;

 //RIGHT:
 $URL = http://example.com/$data_url;;

 If it's not feasible for your C++ application to replicate urlencode()
 then you may be able to get what you want with that http_raw_post_data
 stuff.  You'll have to search on php.net for something not unlike raw
 post data until you find it, as I don't have the ULR in my head.

 But you'd be 100% better off to follow the standards and url-encode
 the data in the first place -- Especially if you're ever going to
 re-use this code elsewhere, and MOST especially if you ever might want
 to hook up YOUR code to another person's server that actually follows
 the standards.

 On Tue, February 21, 2006 12:40 pm, Dirk Vanden Boer wrote:
  Hi,
 
  I have a C++ application that posts binary data to a php script that I
  created using libcurl. Everything works fine except when my binary
  data
  happens to start with the '' symbol. In that case I can't read the
  http
  post data (isset returns false).
 
  The post argument then looks like data=ÑÚA
  Reading the post is done like this:
  if (isset($_POST['data'])
  Is there a way to fix this problem?
 
  Thanks in advance
  Dirk
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --
 Like Music?
 http://l-i-e.com/artists.htm




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



Re: [PHP] CLI utility

2006-02-21 Thread Richard Lynch
On Tue, February 21, 2006 4:03 pm, Ray Cantwell wrote:
 I was wondering if any of you knew of a good command line utility for
 php5 on linux? The box i write on has no X-windows.

E.  Assuming I understand the question...

lynx is a text-based browser which you can use to surf to pages and
see what they output, kinda sorta.

Not really useful for rich-media sites, but viable for mostly-text sites.

There MIGHT be a curses-based web browser out there...  I mean, in
theory, there could be one, right?

And it might even be able to render vector-based images, I suppose???

You can also run:
php -l script.php
to check for syntax errors before you attempt to surf to it, and catch
the really bone-headed mistakes before you fire up lynx.

None of the above will be real useful for MOST web-sites, but might
fit your needs, and fall strictly within the question asked.

Going farther afield from the original question...

You might also want to use a laptop/desktop/whatever and an SSH client
program such as putty to be able to surf with common browsers in one
window while typing in another.

Cuz you're really not going to be able to develop a modern web-site
without some kind of graphical browser, for 99.99% of web-sites
out there today.

OTOH, if all you are doing is some kind of data-warehousing
web-service type application, you could probably get away with:

telnet localhost 80 | less
GET / HTTP/1.0
Host: localhost


[hit return TWICE] after that last localhost]

I've done that, in a pinch. :-)

Actually, if's VERY useful for figuring out your headers, for checking
output of funky characters, and quite instructive for search engine
optimization, because THAT is what Google sees.

YMMV

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Page validation: Un-wanted PHP session ID added to links????

2006-02-21 Thread Richard Lynch
On Mon, February 20, 2006 2:19 pm, Michael Hulse wrote:
 On Feb 20, 2006, at 12:10 PM, John Nichel wrote:
 It's all in the manual

 Hi, thanks for pointing that out. I guess I should have RTFM first,
 then ask q's second... noob mistake, wont happen again.  :D

 I guess I just do not understand why a session is even being created,
 I
 never started one... I guess I need to read the manual in more detail
 (doing now).

While you should RTFM, in this particular instance, reading the
php.ini file on your two servers, paying particular attention to the
session.* settings will probably be sufficient enlightenment for today
:-)

RTFM tomorrow, though.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] newbie problem

2006-02-21 Thread Richard Lynch
On Mon, February 20, 2006 1:14 pm, Robert Voogdgeert wrote:
 When working with an HTML file with a form with

 form action=somename.php method=post

 the somename.php file is served (completely) to my browser as plain
 text
 after the 'submit' button is clicked on my machine (MacOS X). On the
 external webhost though everything is processed correctly...

 Is this related to some setting that I should change on my localhost?

You'd need to correctly install PHP on your localhost.

You either didn't install PHP at all, or didn't configure Apache
and/or PHP correctly, and PHP is not running when you request
somename.php

Exactly what went wrong is difficult to guess at without more info...

You may want to work on getting a simpler script to work, namely:

?php phpinfo();?

Name this as, say, phpinfo.php and surf to it.

It will be blatantly obvious when it works. :-)

General Principles:
If you think Apache/PHP should be working, examine the Apache
error_log file, and re-start Apache, and examine the output of that
restart of Apache as well.

Odds are good something in all that will tell you what is wrong.

Also search through all of httpd.conf for php and see if it all
seems to make sense and the relevant bits are not commented out.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] Reading binary http post

2006-02-21 Thread Richard Lynch
You'd have to check if URL-encoding supports whatever sort of
characters/data is your input.

I would *THINK* that URL-encoding standard would support binary data
of any kind, and be the correct way to do this, in THEORY.

In PRACTICE, it may be that the implementation of URL-encode would not
correctly handle binary data.

So you might be stuck with base64-encoding as a work-around...

I'm pretty sure that base64-encoding output consists only of:
0123456789ABCDEF and newline and maybe the = sign as a continuation
character?  I may be confusing base64 with something else though...

You could probably get away then, with not urlencoding after you
base64-encode it, as there aren't any characters that are going to get
changed in urlencoding...  But it would be more clean to urlencode()
it, no matter what else you have to do to get the data through
cleanly, as you ARE passing it into a URL.

If your data is really huge or super-over-loaded servers, and you KNOW
that base64 can never generate a character that matters, a comment in
the code to that effect in place of urlencode() would be Nifty Enough.

On Tue, February 21, 2006 4:34 pm, Dirk Vanden Boer wrote:
 Thanks for the info, it was really helpfull. One question though, is
 it necessary to first encode my data with the base64 algo, or can I
 skip that step and immediately urlencode my data?

 Dirk

 On 2/21/06, Richard Lynch [EMAIL PROTECTED] wrote:
 You probably should be URL-encoding your data in the first place...
 http://php.net/urlencode

 ?php
 $data = whatever funky characters you want:
 $data_url = urlencode($data);

 //WRONG:
 $URL = http://example.com/$data;

 //RIGHT:
 $URL = http://example.com/$data_url;;

 If it's not feasible for your C++ application to replicate
 urlencode()
 then you may be able to get what you want with that
 http_raw_post_data
 stuff.  You'll have to search on php.net for something not unlike
 raw
 post data until you find it, as I don't have the ULR in my head.

 But you'd be 100% better off to follow the standards and url-encode
 the data in the first place -- Especially if you're ever going to
 re-use this code elsewhere, and MOST especially if you ever might
 want
 to hook up YOUR code to another person's server that actually
 follows
 the standards.

 On Tue, February 21, 2006 12:40 pm, Dirk Vanden Boer wrote:
  Hi,
 
  I have a C++ application that posts binary data to a php script
 that I
  created using libcurl. Everything works fine except when my binary
  data
  happens to start with the '' symbol. In that case I can't read
 the
  http
  post data (isset returns false).
 
  The post argument then looks like data=ÑÚA
  Reading the post is done like this:
  if (isset($_POST['data'])
  Is there a way to fix this problem?
 
  Thanks in advance
  Dirk
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


 --
 Like Music?
 http://l-i-e.com/artists.htm






-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] need a php multiple/mysql choice quiz

2006-02-21 Thread Richard Lynch
On Mon, February 20, 2006 9:49 am, Ross wrote:
 I am looking for a php/mysql multiple choice quiz. One that saves the
 answers to a database. A basic example I can expand on is all that is
 required.

You may want to expand your search to PHP Poll as it will also have
most of what you need, and may be easier to expand that to include
user ID with response than to deal with the bloat of many
text/quiz/exam packages...

Just an idea.

There are a zillion of both out there, and I have no idea if any of
them are any good.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] PHP generated JavaScript

2006-02-21 Thread Richard Lynch




On Mon, February 20, 2006 1:59 am, Tim Burgan wrote:
 Is is possible to make an external Javascript with PHP.

 Am I doing this correcT?

 ?php

 header(Content-Type: text/javascript);

 $text = Hello World;

 echo alert('.$text.');;

You may need to include the trailing newline on this line...

I certainly would, needed or not.



 ?

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




-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] need a php multiple/mysql choice quiz

2006-02-21 Thread tedd

On Mon, February 20, 2006 9:49 am, Ross wrote:

 I am looking for a php/mysql multiple choice quiz. One that saves the
 answers to a database. A basic example I can expand on is all that is
 required.



Perhaps something like this:

http://www.xn--ovg.com/form/form_mysql.php

Drop me an email and I'll provide the code.

tedd
--

http://sperling.com

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



Re: [PHP] novice with hacked email form issue

2006-02-21 Thread tedd

On 2/21/06, cKc Consultants [EMAIL PROTECTED] wrote:

 An email form that uses a simple server side php code to send the variable
 values managed to send:

snip


Perhaps something here:

http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=%2Bemail+%2BformSubmit1.x=0Submit1.y=0

tedd

--

http://sperling.com

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



Re: [PHP] CLI utility

2006-02-21 Thread Björn Bartels
moin,  richard

nice idea , but i'd rather think according to probability calculation
chance for this to happen converge to 0, doesn't it... ;)

There MIGHT be a curses-based web browser out there... I mean, in
theory, there could be one, right?

And it might even be able to render vector-based images, I suppose???


woh-woh-woh... what is this? never ever thought of such a method...
where can i get
more info about such stuff ? maybe apache-docs, but where? does it even
work with other
protocols/servers, maybe something like 'rtsp' or a db-server :) ?

telnet localhost 80 | less
GET / HTTP/1.0
Host: localhost


Oh...  errr...  sorry... but, those abbrivations... can't get used to
them... is there a glosary or such
alike to find somewhere?
YMMV

cheers

Björn Bartels
-Development/IT-Services-

--
dbusiness.de gmbh
digital business  printing gmbh

Greifswalder Str. 152
D-10409 Berlin

Fon: [0.30] 4.21.19.95
Fax: [0.30] 4.21.19.74

www.dbusiness.de
[EMAIL PROTECTED]
ftp://dbusiness.dyndns.org

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

Re: [PHP] Working with a config file

2006-02-21 Thread Curt Zirzow
On Mon, Feb 20, 2006 at 05:21:51PM -0500, Benjamin Adams wrote:
 I'm trying to parse a config file, example of the config is:
 [fred]
 id=8782
 section=s1
 years=4
 download1=mirror1
 ...

I'd say http://php.net/parse-ini-file is your best option.

Curt.
-- 
cat .signature: No such file or directory

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



[PHP] __call() and interfaces

2006-02-21 Thread Mike Pfaff

Hello World :)

I need to write a class that implements a predefined interface. In my 
class all(or most) methods will use the same code. At first i thought 
the ideal solution would be to handle this by defining the magic 
__call() method in my class, but PHP then complains about the interface 
not being completely implemented. (Is there no way to tell PHP that the 
methods are handled by __call()?)


Options i see right now:
a) Just omit implements SomeInterface and PHP will stop complaining. 
This would be suboptimal as i want my class to officially conform to 
the standardized API which is defined in the interface.
b) Implement all methods and just copy-paste the code. I find this 
rather ugly and it's a hassle to maintain. Is there a better solution 
than copy-paste(Keep in mind that the methods vary in argument types, 
argument counts and return value types)?


Somehow neither a) nor b) seems the right way to do what i want, so i 
would be glad to hear your opinions on this. I would also be interested 
what the best solution would be from a performance point of view.


Regards,
Mike

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



Re: [PHP] Re: CLASS/Object lifetime - more info

2006-02-21 Thread Jochem Maas

REFERENCES.

the object you get back is a copy (foreach has the same
effect as creating a new variable as in the example below).

... see below ...

notice the use of the  symbol (and the 'refcount' values).
(there is loads of info out there on references/php4/objects
out there that explain it better than me.) - see what happens
when you start removing ''s.

or you could try php5 and forget about 'object hell'. :-)

roger helgesen wrote:

The function that gives me trouble
-
function fyll_sub_konto($pv){
foreach($this-subposter AS $konto){
$konto-fyll_fra_post($pv);
}


class Test
{
var $number;
var $subposter;

function Test($n = 0) { $this-number = $n; }

function sqar() { if (is_numeric($this-number)) { $this-number *= 
$this-number; } return $this; }
function doit() { echo strval($this-number),\n; }
function make() {   
static $c = 1;
$t = new Test($c++);
$s = $t; // watch what happens when you remove the '' (php4 only)
$s-sqar();
$this-subposter[] = $t-sqar();
}
function goan() {   
$cnt = count($this-subposter);
$this-doit();
for($i=0;$i$cnt;$i++) {
// watch what happens when you remove the '' (php4 only)
$tmp = $this-subposter[$i];
$tmp-sqar();
$this-subposter[$i]-doit();
}
}
}

$t = new Test(infinity); $i = 0;
while($i++  5) $t-make();
$t-goan();



}
-

$this-subposter is the array of CLASS2

function fyll_fra_post($post_vars){
echo (gruppe)class = .get_class($this) .br\n;
$teller=0;
foreach($this-poster AS $post=$verd){
$best=bestilt_.$post;
$avik=avvik_.$post;
$fakt=faktura_.$post;
$this-poster[$post][bestilt]=$post_vars[$best];
$this-poster[$post][avvik]=$post_vars[$avik];
$this-poster[$post][faktura]=$post_vars[$fakt];
}
$this-endret='ja';
$this-sett_sum();
}

If I print the data (after setting the new data) inside 'fyll_fra_post' 
it puts out the new data.
If I do the same from 'fyll_sub_konto' (after foreach) it gives me the 
old data.




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



Re: [PHP] __call() and interfaces

2006-02-21 Thread David Tulloh
I find __call() to be a nasty solution, particularily from a
self-documenting code point of view.  I personally only use call when
the function names are defined at run time; as you clearly know the
function names, I would be implementing them as normal functions.

If there is a lot of repeated code, implement the repeated code in a
private function.  Each of your methods then does it's own unique thing,
calling the private function for the common processing.  This way you
don't have any copy-paste code, you implement your Interface and your
code is easy to read, understand and maintain.


David

Mike Pfaff wrote:
 Hello World :)
 
 I need to write a class that implements a predefined interface. In my
 class all(or most) methods will use the same code. At first i thought
 the ideal solution would be to handle this by defining the magic
 __call() method in my class, but PHP then complains about the interface
 not being completely implemented. (Is there no way to tell PHP that the
 methods are handled by __call()?)
 
 Options i see right now:
 a) Just omit implements SomeInterface and PHP will stop complaining.
 This would be suboptimal as i want my class to officially conform to
 the standardized API which is defined in the interface.
 b) Implement all methods and just copy-paste the code. I find this
 rather ugly and it's a hassle to maintain. Is there a better solution
 than copy-paste(Keep in mind that the methods vary in argument types,
 argument counts and return value types)?
 
 Somehow neither a) nor b) seems the right way to do what i want, so i
 would be glad to hear your opinions on this. I would also be interested
 what the best solution would be from a performance point of view.
 
 Regards,
 Mike
 

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



[PHP] Script updating secondary server

2006-02-21 Thread Peter Lauri
Hi,

I have one server in USA and one server in Thailand. The server in USA is
the one containing the updated information. The Thai server will be a copy
of the USA server.

I want to write a PHP script that does this for me:
1. Once a day copies the files on the USA server to the Thai server and put
them in the web folder
2. Once a day copy the database in USA (dump) and then empty the Thai
database and insert the USA content (inserts)

Maybe PHP is not the right way? Do you know any code that already do this
(PHP)? I would like to do this in PHP, because I am in the learning process
of this great language.

Best regards,

Peter Lauri
Managing Director
DWS Asia
Mobile: +66 (0) 4 703 4033
Office: +66 (0) 2 974 3384
Fax: +66 (0) 2 974 2038
[EMAIL PROTECTED]
www.dwsasia.com


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

Re: [PHP] Reading binary http post

2006-02-21 Thread Curt Zirzow
On Tue, Feb 21, 2006 at 04:58:01PM -0600, Richard Lynch wrote:
 You'd have to check if URL-encoding supports whatever sort of
 characters/data is your input.
 
 I would *THINK* that URL-encoding standard would support binary data
 of any kind, and be the correct way to do this, in THEORY.
 
 In PRACTICE, it may be that the implementation of URL-encode would not
 correctly handle binary data.
 
 So you might be stuck with base64-encoding as a work-around...
 
 I'm pretty sure that base64-encoding output consists only of:
 0123456789ABCDEF and newline and maybe the = sign as a continuation
 character?  I may be confusing base64 with something else though...

Yeah you are correct. There usually 2 =='s at the end of base64
encoded as well, so urlencode should be used without a doubt on top
of base64.

Of course, the best solution would be to do a file upload of the
binary data instead.  If file upload is used, there wont be any of
this need  to mess around with all this base64 encoding/decoding
and url encoding stuff, it is already taken care of.

Curt.
-- 
cat .signature: No such file or directory

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



Re: [PHP] Script updating secondary server

2006-02-21 Thread Chris



I have one server in USA and one server in Thailand. The server in USA is
the one containing the updated information. The Thai server will be a copy
of the USA server.

I want to write a PHP script that does this for me:
1. Once a day copies the files on the USA server to the Thai server and put
them in the web folder
2. Once a day copy the database in USA (dump) and then empty the Thai
database and insert the USA content (inserts)

Maybe PHP is not the right way? Do you know any code that already do this
(PHP)? I would like to do this in PHP, because I am in the learning process
of this great language.


To be honest you're better off using tools other than php.

rsync will copy files quite efficiently (http://rsync.samba.org) and 
will only copy *changed files* - so a copy each day won't take much time 
at all.


On the US server, make sure you place a database dump before the sync 
starts.


From the Thai server, initiate the sync.

When the copy is finished, import the database dump.

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



Re: [PHP] CLI utility

2006-02-21 Thread Curt Zirzow
 
Just a raw (manual) way to talk to a server.  You just need to
understand the way a HTTP request is sent to a server
(http://w3c.org/). Or if you know how to comminicate with what ever
protocol you use manually.

The reason to really do it with db-server  would be to test
to see if is actually running, for example for mysql:

  telnet localhost 3306
  5.0.15-standard�q9i$t=tR,|;P_l%lu']~^CConnection closed by foreign host.

or  smtp
  telnet localhost 25
  220 bagend.shire ESMTP Exim 4.54 Tue, 21 Feb 2006 20:01:16 -0800
  helo localhost
  250 bagend.shire Hello localhost.shire [::1]
  ...

or  pop3
  telnet localhost 110
  Trying 127.0.0.1...
  telnet: connect to address 127.0.0.1: Connection refused
  telnet: Unable to connect to remote host

oh yeah, i dont run a pop server :)

 
 woh-woh-woh... what is this? never ever thought of such a method...
 where can i get
 more info about such stuff ? maybe apache-docs, but where? does it even
 work with other
 protocols/servers, maybe something like 'rtsp' or a db-server :) ?
 
 telnet localhost 80 | less
 GET / HTTP/1.0
 Host: localhost
 

I usually use google's 'define:YMMV'


 Oh...  errr...  sorry... but, those abbrivations... can't get used to
 them... is there a glosary or such
 alike to find somewhere?
 YMMV


Curt.
-- 
cat .signature: No such file or directory

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



Re: [PHP] Script updating secondary server

2006-02-21 Thread Curt Zirzow
On Wed, Feb 22, 2006 at 01:02:29PM +1100, Chris wrote:
 
 
 I want to write a PHP script that does this for me:
 1. Once a day copies the files on the USA server to the Thai server and put
 them in the web folder
 2. Once a day copy the database in USA (dump) and then empty the Thai
 database and insert the USA content (inserts)
 
 Maybe PHP is not the right way? Do you know any code that already do this
 (PHP)? I would like to do this in PHP, because I am in the learning process
 of this great language.
 
 To be honest you're better off using tools other than php.
 
 rsync will copy files quite efficiently (http://rsync.samba.org) and 
 will only copy *changed files* - so a copy each day won't take much time 
 at all.

Not to mention they'd be copy securely and may be sent compressed
as well.

Curt.
-- 
cat .signature: No such file or directory

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



Re: [PHP] How do I output error messages

2006-02-21 Thread Paul Goepfert
$submit is soppose to be set when the user submits the web form for
validation.  I am not sure but is there soppose to be a $submit =
input type=submit name=submit value=submit statement?

Paul

On 2/21/06, Jay Blanchard [EMAIL PROTECTED] wrote:
 [snip]
 if (isset($submit))
 {
   //vaildation code
 }
 else
 {
 //webpage
 }
 [/snip]

 What is $submit? Is it set ever? The problem probably lies in the fact that
 $submit, whatever it is, never gets set.


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



[PHP] Special Chars on Form to Image (GD), not displaying properly.

2006-02-21 Thread Louie Miranda
Im having a trouble displaying special characters like #, + on GD (Jpeg) -
Image. When i typed in on the form +88 it only shows 88 and the + sign is
missing.

My code:
 ?php
..
$line_1_1 = urldecode($_GET[line_1_1]);
..
// display my text from $line_1_1
imagettftext($background, 13, 0, $new, 65, $black,
includes/resources/$fonts, $line_1_1);
..
?

I made a couple of tests and found this variables.

 The data that will be pass: +88and#
Data from the url (address box): line_1_1=%2B88and%23
Image displayed: 88and - only missing + and #

What could i be missing?

--
Louie Miranda ([EMAIL PROTECTED])
http://www.axishift.com

//JSM-W


Re: [PHP] Special Chars on Form to Image (GD), not displaying properly.

2006-02-21 Thread Curt Zirzow
On Wed, Feb 22, 2006 at 12:38:19PM +0800, Louie Miranda wrote:
 Im having a trouble displaying special characters like #, + on GD (Jpeg) -
 Image. When i typed in on the form +88 it only shows 88 and the + sign is
 missing.
 
 My code:
  ?php
 ..
 $line_1_1 = urldecode($_GET[line_1_1]);

You dont want to urldecode() the $_GET vars. PHP already does this
step.

See what happens with:

  var_dump(urldecode($_GET['line_1_1']));
  var_dump($_GET['line_1_1']);

 ...
 I made a couple of tests and found this variables.
 
  The data that will be pass: +88and#
 Data from the url (address box): line_1_1=%2B88and%23
 Image displayed: 88and - only missing + and #
 
 What could i be missing?

Well if you dont use the urldecode() as mentioned above, the only
reasons i can think of (assuming + will display properly now):

  - The font doesn't have a definition for #
  - The area isn't big enough so # is getting truncated.

Curt.
-- 
cat .signature: No such file or directory

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



Re: [PHP] Special Chars on Form to Image (GD), not displaying properly.

2006-02-21 Thread Louie Miranda
Please read below..

 Im having a trouble displaying special characters like #, + on GD (Jpeg) -
  Image. When i typed in on the form +88 it only shows 88 and the + sign
 is
  missing.
 
  My code:
   ?php
  ..
  $line_1_1 = urldecode($_GET[line_1_1]);

 You dont want to urldecode() the $_GET vars. PHP already does this
 step.

 See what happens with:

   var_dump(urldecode($_GET['line_1_1']));
   var_dump($_GET['line_1_1']);


I tested this not on a GD/Image, but on a plain form and plain var_dump.
The results:

string(1)  
string(1) +

 So, now if i even make a urldecode it also disappers. I think the problem
is when i typed in + on the user input via form. The url converts it
to %2B which
i think is a space. Because as for my example (seen thru the url):

+88and#
When displayed on an image becomes..
 88and

Now, if i made this

+88+and#
It displays..
 88 and#

It converts + to space. Now, how could i filter this properly?

 ...
  I made a couple of tests and found this variables.
 
   The data that will be pass: +88and#
  Data from the url (address box): line_1_1=%2B88and%23
  Image displayed: 88and - only missing + and #
 
  What could i be missing?

 Well if you dont use the urldecode() as mentioned above, the only
 reasons i can think of (assuming + will display properly now):

   - The font doesn't have a definition for #
   - The area isn't big enough so # is getting truncated.


The font is verdana and the image is just normal for its size.

Now, i did this test.

imagettftextalign($background, 8, 0, 385, 120, $black,
includes/resources/$fonts, +88+and#$line_1_1, $alignment='R');

This one displays +88+and# properly on the GD image. I only get problems
when displaying it from form to php gd.

What could i be missing? :(

--
Louie Miranda ([EMAIL PROTECTED])
http://www.axishift.com

//JSM-W


[PHP] array variables with or without quotes

2006-02-21 Thread 2dogs
I recently encountered a situation where I had to retrieve data from a MYSQL 
database table with a field named include. My code looked like this:

$content_result = mysql_query('SELECT * FROM calander') or 
die(mysql_error());
$content_row = mysql_fetch_array($content_result);
if ($content_row[include])
{go do something;}

When I tried to run this, PHP treated the word  -include- as a control 
structure rather than an index name. Understandable. So, I put it in single 
quotes  ('include') to see what would happen and it works fine. But I don't 
understand why!

What is the difference between $content_row [include] and 
$content_row['include']? I have been unable to resolve this question in the 
php manual, I need enlightenment.

2dogs 

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



[PHP] Nested Set Model or modified preorder tree traversal

2006-02-21 Thread Daevid Vincent
I've been searching the web for the past few hours trying to find a simple
drop-in class or functions to implement Nested Set Model or modified
preorder tree traversal.

I've found several tutorials and related links:

  http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
  http://www.sitepoint.com/article/hierarchical-data-database
 
http://www.zend.com/zend/tut/tutorial-ferrara2.php?article=tutorial-ferrara2
id=3453open=1anc=0view=1
  http://simon.incutio.com/archive/2003/06/19/storingTrees
  http://istherelifeafter.com/joecelko.html
  http://www.codeproject.com/cs/database/Trees_in_SQL_databases.asp

I even found some outdated PEAR DB_NestedSet class from 2003 that seemed way
to overly complicated. And some other PHP4_Mysql3MPTTA class on PHP Classes
that was equally complicated and written for ancient PHP4 and mySQL 3!!

Hasn't anyone else done this before (recently)? 
Did everyone just write their own code every time?
Anyone have some easy to use code that allows for:
Add, delete, update/rename, select, show tree, bread crumb display, etc.

I use PHP 5.0.5 and mySQL 5.0.18, so ideally it would take advantage of all
the optimizations and bells  whistles of those more modern versions.

TIA.

D.Vin

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



Re: [PHP] array variables with or without quotes

2006-02-21 Thread Chris
When I tried to run this, PHP treated the word  -include- as a control 
structure rather than an index name. Understandable. So, I put it in single 
quotes  ('include') to see what would happen and it works fine. But I don't 
understand why!


What is the difference between $content_row [include] and 
$content_row['include']? I have been unable to resolve this question in the 
php manual, I need enlightenment.


Without quotes it could be constant or defined variable:

define('variable', 'blah blah blah');

so then I can just use:

?php
define('variable', 'blah blah blah');
echo variable;
?

will print out:

blah blah blah

So in your case, it's checking for a defined variable called 'include' 
which doesn't exist (and prints out a warning/notice).


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



[PHP] Why does it stop working?

2006-02-21 Thread pine oil
I've used the following counter for some time, but I don't seem to
have it work now after I have moved the directory of the files.

They used to be in /var/www/html, but moved to /home/webroot/test.

Do you think the relocation of the files has something to do with my problem?

-- index.php
--
html
head
meta http-equiv=Content-Type content=text/html; charset=UTF-8
titleThe Counter/title
/head
body
p
strongfont size=2 face=Arial, Helvetica, sans-serif
color=#CCPage visits:/font/strongbr /
img src=counter.php / /p
/body
/html
-- counter.php
---
?
include(counter_config.php);
$cn = implode(,file(counter.txt));
$cn++;
$fp = fopen(counter.txt,w+);
fwrite($fp,$cn);
fclose($fp);

$des = imagecreatetruecolor($counter_width,$counter_font_size);

$bgcol = HEX2RGB($counter_background);
$tcol = HEX2RGB($counter_color);
$bg = imagecolorallocate($des,$bgcol[0],$bgcol[1],$bgcol[2]);
$fc = imagecolorallocate($des,$tcol[0],$tcol[1],$tcol[2]);
imagecolortransparent($des,$bg);
$font = fonts/$counter_font.ttf;
$tt = $counter_numbers  - strlen($cn)-1;
$ts = 0;
while($ts = $tt)
{
$cn = '0'.$cn;
$ts++;
}
imagettftext($des, $counter_font_size, 0, 0, $counter_font_size, $fc,
$font, $cn);

header(Content-type: image/gif);
imagegif($des);

function HEX2RGB($color){
$color = str_replace(#,,$color);
 $color_array = array();
 $hex_color = strtoupper($color);
 for($i = 0; $i  6; $i++){
  $hex = substr($hex_color,$i,1);
  switch($hex){
   case A: $num = 10; break;
   case B: $num = 11; break;
   case C: $num = 12; break;
   case D: $num = 13; break;
   case E: $num = 14; break;
   case F: $num = 15; break;
   default: $num = $hex; break;
  }
  array_push($color_array,$num);
 }
 $R = (($color_array[0] * 16) + $color_array[1]);
 $G = (($color_array[2] * 16) + $color_array[3]);
 $B = (($color_array[4] * 16) + $color_array[5]);
 return array($R,$G,$B);
 unset($color_array,$hex,$R,$G,$B);
}
?
--- counter_config.php
---
?
//counter_config.php  Source
// Width in pixels of your counter
$counter_width = 100;
// Number of digits you want to display in the counter. Zeros will be
automaticly included
$counter_numbers = 6;
// Font size in pixels
$counter_font_size = 13;
// Font of your digits
$counter_font = 'arial';
// Color of your counter
$counter_color = '#FF6600';
// Color of the background. Usualy it should be the same with the
color  of the place where will be placed
$counter_background = '#FF';
// Trasparent bacground counter true = yes false = no
$counter_transparent = true;
?
 counter.txt ---
572

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



Re: [PHP] Nested Set Model or modified preorder tree traversal

2006-02-21 Thread Chris
Hasn't anyone else done this before (recently)? 
Did everyone just write their own code every time?

Anyone have some easy to use code that allows for:
Add, delete, update/rename, select, show tree, bread crumb display, etc.

I use PHP 5.0.5 and mySQL 5.0.18, so ideally it would take advantage of all
the optimizations and bells  whistles of those more modern versions.


The php or mysql version doesn't matter, it's more to do with how you 
structure your database.


Instead of your id/parentid relationship the way I did it was you create 
a 'node' with this information in it.


So:

select categoryid, node, categoryname from all_categories;
 categoryid |   node   | categoryname
+--+--
  9 | 0009 | Parent
 10 | 0010 | Another Parent
 11 | 00090011 | Sub Cat
 13 | 00100013 | Sub Cat 2
 12 | 00100012 | Sub Cat 3

catid '11' is a subcategory of '9'.
catid '13' is a subcat of '10'.

You'll need to pad each node out to a certain length so you don't get 
overlaps (in my case I used 4 giving me  categories at each level). 
The longer each node is the more categories you can have at each level 
but the smaller number of categories you have altogether.


Don't forget mysql  other databases only let you index up to 255 
characters of a text field (in my case I used a varchar(200) for the 
node field), so while you could in theory have infinite levels it's not 
really practical (unless you use full text indexing).



Inserting is easy - you get the parent that you're inserting under and 
add your padded node on the end of it giving you the full path.



Deleting is easy as well - to delete a category and all subcategories:

delete from all_categories where node like '0009%';


Moving things around is harder..


If you need more info let me know.

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



Re: [PHP] Special Chars on Form to Image (GD), not displaying properly.

2006-02-21 Thread Curt Zirzow
On Wed, Feb 22, 2006 at 01:12:00PM +0800, Louie Miranda wrote:
 Please read below..
 
  Im having a trouble displaying special characters like #, + on GD (Jpeg) -
   Image. When i typed in on the form +88 it only shows 88 and the + sign
  is
   missing.
  
   My code:
?php
   ..
   $line_1_1 = urldecode($_GET[line_1_1]);
 
  You dont want to urldecode() the $_GET vars. PHP already does this
  step.
 
  See what happens with:
 
var_dump(urldecode($_GET['line_1_1']));
var_dump($_GET['line_1_1']);
 
 
 I tested this not on a GD/Image, but on a plain form and plain var_dump.
 The results:
 
 string(1)  
 string(1) +
 
  So, now if i even make a urldecode it also disappers. I think the problem
 is when i typed in + on the user input via form. The url converts it
 to %2B which
 i think is a space. Because as for my example (seen thru the url):
 
 +88and#
 When displayed on an image becomes..
  88and
 
 Now, if i made this
 
 +88+and#
 It displays..
  88 and#

this is where i think your confused, the problem with your original
code is you are ending up urldecoding things twice thus thinking
that %2B == a space.

consider:
  echo urlencode(' '); # '+'
  echo urlencode('+'); # '%2B'

  echo urldecode(' ');   # ' '
  echo urldecode('+');   # ' '
  echo urldecode('%2B'); # '+'

if your url is:
  http://server.com/?foo=%2B88an%23

then in php if you do:
  echo $_GET['foo'];

you will get '+88and#'

if your url is:
  http://server.com/?foo=+88and#

then in php if you do:
  echo $_GET['foo'];

you will get: ' 88and'

 
 It converts + to space. Now, how could i filter this properly?

Now given what I said and you have a form defined as:
form method=GET
  input name=foo
/form

And you type in the box '+88and#' the url that is submited should
be:
  http://server.com/?foo=%2B88and%23

Then:
  echo $_GET['foo']; # '+88and#'
 
Or if you type: ' 88and#' the url should be:

  http://server.com/?foo=+88and%23

  or possibly (not to confuse things more)

  http://server.com/?foo=%2088and%23

Then:
  echo $_GET['foo']; # ' 88and#'


Now, the only way that # could seem to disappear is if you have your
form setup like:
form method=GET action=#
  input name=foo
/form

And you type: '+88and',  The url will look like:
  http://server.com/?foo=%2B88and#

thus:
  echo $_GET['foo']; # '+88and'

or if you type ' 88and', the url will look like:
  http://server.com/?foo=+88and#

thus:
  echo $_GET['foo']; # ' 88and'


Curt.
-- 
cat .signature: No such file or directory

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



Re: [PHP] Why does it stop working?

2006-02-21 Thread Chris

pine oil wrote:

I've used the following counter for some time, but I don't seem to
have it work now after I have moved the directory of the files.

They used to be in /var/www/html, but moved to /home/webroot/test.

Do you think the relocation of the files has something to do with my problem?


It could be a permissions thing (it can't read/write the counter.txt file).

If you could narrow down what's going wrong a bit it'd help.

View the counter only in your browser - does that give an error?

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



Re: [PHP] Why does it stop working?

2006-02-21 Thread pine oil
On 2/22/06, Chris [EMAIL PROTECTED] wrote:
 pine oil wrote:
  I've used the following counter for some time, but I don't seem to
  have it work now after I have moved the directory of the files.
 
  They used to be in /var/www/html, but moved to /home/webroot/test.
 
  Do you think the relocation of the files has something to do with my 
  problem?

 It could be a permissions thing (it can't read/write the counter.txt file).

 If you could narrow down what's going wrong a bit it'd help.

 View the counter only in your browser - does that give an error?

I changed the permission to read/write for the owner and group. That
did not help.

I am sorry I don't know how to view the counter in my browswer. The
counter did not show if I open the index.php when I access the page
through the apache server.

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



Re: [PHP] Why does it stop working?

2006-02-21 Thread Chris

pine oil wrote:

On 2/22/06, Chris [EMAIL PROTECTED] wrote:


pine oil wrote:


I've used the following counter for some time, but I don't seem to
have it work now after I have moved the directory of the files.

They used to be in /var/www/html, but moved to /home/webroot/test.

Do you think the relocation of the files has something to do with my problem?


It could be a permissions thing (it can't read/write the counter.txt file).

If you could narrow down what's going wrong a bit it'd help.

View the counter only in your browser - does that give an error?



I changed the permission to read/write for the owner and group. That
did not help.

I am sorry I don't know how to view the counter in my browswer. The
counter did not show if I open the index.php when I access the page
through the apache server.


img src=counter.php /

Instead of going to index.php, go to counter.php

That will run just the counter script and (hopefully) show an error.

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



Re: [PHP] Nested Set Model or modified preorder tree traversal

2006-02-21 Thread Curt Zirzow
On Tue, Feb 21, 2006 at 09:38:53PM -0800, Daevid Vincent wrote:
 I've been searching the web for the past few hours trying to find a simple
 drop-in class or functions to implement Nested Set Model or modified
 preorder tree traversal.

I actually fell in love of this method of doing trees when I
discovered it about a year ago, when researching a fast way to do
a parent child retrieval.

 
 I've found several tutorials and related links:
 
   http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
   http://www.sitepoint.com/article/hierarchical-data-database
  
 http://www.zend.com/zend/tut/tutorial-ferrara2.php?article=tutorial-ferrara2
 id=3453open=1anc=0view=1
   http://simon.incutio.com/archive/2003/06/19/storingTrees
   http://istherelifeafter.com/joecelko.html
   http://www.codeproject.com/cs/database/Trees_in_SQL_databases.asp

oh i have to add some of these to my list, i didn't have a couple
of them.

 
 I even found some outdated PEAR DB_NestedSet class from 2003 that seemed way
 to overly complicated. And some other PHP4_Mysql3MPTTA class on PHP Classes
 that was equally complicated and written for ancient PHP4 and mySQL 3!!

yeah, i kind of got that feeling with the PEAR class as well, i
think it was designed that way to be as flexible as possible. I'm
not familiar with the other class, i tend to avoid anything from
PHP Classes.

 
 Hasn't anyone else done this before (recently)? 
 Did everyone just write their own code every time?
 Anyone have some easy to use code that allows for:
 Add, delete, update/rename, select, show tree, bread crumb display, etc.

It would be nice to have a tool to manage the functionality. There
will always be the issue with any common tool that is built for
this purpose is how do you relate the table that defines the nested
with the table that actually holds the data.

I believe that why the PEAR and other classes you came across
seemed to be overly complicated.  I have found that it is easier to
write my own management (as awful as that sounds) for the job at
hand.

 
 I use PHP 5.0.5 and mySQL 5.0.18, so ideally it would take advantage of all
 the optimizations and bells  whistles of those more modern versions.

5.0.5? you mentioned that php4 is ancient, 5.0.5 is more ancient
than php4.. infact 5.0.x is rather dead.

PHP 4.4.2 - Released Jan 13 2006
php 5.1.2 - Released Jan 12 2006
PHP 5.0.5 - Released Sept 6 2005

I wouldn't expect any more releases of 5.0.x version.


Curt.
-- 
cat .signature: No such file or directory

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



Re: [PHP] Why does it stop working?

2006-02-21 Thread Curt Zirzow

On Tue, Feb 21, 2006 at 11:54:53PM -0600, pine oil wrote:
 I've used the following counter for some time, but I don't seem to
 have it work now after I have moved the directory of the files.

... 
 $cn = implode(,file(counter.txt));
 $cn++;
 $fp = fopen(counter.txt,w+);
 fwrite($fp,$cn);
 fclose($fp);

hmm.. i didn't think these raw counter like things were used
anymore.

Have you considered not even worrying about showing how many people
have viewed the page?

Curt.
-- 
cat .signature: No such file or directory

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



Re: [PHP] Re: CLASS/Object lifetime - more info

2006-02-21 Thread Roger Helgesen

ain't that the other way around ?

$var1=$var2 ($var1 is a copy of $var2)
$var1= $var2 ($var1 is a reference to $var2)
$var1='Test'
echo $var2  (outputs Test)

roger
Jochem Maas wrote:

REFERENCES.

the object you get back is a copy (foreach has the same
effect as creating a new variable as in the example below).

... see below ...

notice the use of the  symbol (and the 'refcount' values).
(there is loads of info out there on references/php4/objects
out there that explain it better than me.) - see what happens
when you start removing ''s.

or you could try php5 and forget about 'object hell'. :-)

roger helgesen wrote:

The function that gives me trouble
-
function fyll_sub_konto($pv){
foreach($this-subposter AS $konto){
$konto-fyll_fra_post($pv);
}


class Test
{
var $number;
var $subposter;

function Test($n = 0) { $this-number = $n; }

function sqar() { if (is_numeric($this-number)) { $this-number *= 
$this-number; } return $this; }

function doit() { echo strval($this-number),\n; }
function make() {   
static $c = 1;
$t = new Test($c++);   
$s = $t; // watch what happens when you remove the '' (php4 only)

$s-sqar();
$this-subposter[] = $t-sqar();
}
function goan() {   
$cnt = count($this-subposter);

$this-doit();
for($i=0;$i$cnt;$i++) {
// watch what happens when you remove the '' (php4 only)
$tmp = $this-subposter[$i];
$tmp-sqar();
$this-subposter[$i]-doit();
}
}
}

$t = new Test(infinity); $i = 0;
while($i++  5) $t-make();
$t-goan();



}
-

$this-subposter is the array of CLASS2

function fyll_fra_post($post_vars){
echo (gruppe)class = .get_class($this) .br\n;
$teller=0;
foreach($this-poster AS $post=$verd){
$best=bestilt_.$post;
$avik=avvik_.$post;
$fakt=faktura_.$post;
$this-poster[$post][bestilt]=$post_vars[$best];
$this-poster[$post][avvik]=$post_vars[$avik];
$this-poster[$post][faktura]=$post_vars[$fakt];
}
$this-endret='ja';
$this-sett_sum();
}

If I print the data (after setting the new data) inside 
'fyll_fra_post' it puts out the new data.
If I do the same from 'fyll_sub_konto' (after foreach) it gives me 
the old data.






--
mvh
Roger Helgesen
Helgesen Tekniske-bygg AS
56193410
[EMAIL PROTECTED] 


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



Re: [PHP] Why does it stop working?

2006-02-21 Thread Sameer N Ingole

Curt Zirzow wrote:

On Tue, Feb 21, 2006 at 11:54:53PM -0600, pine oil wrote:

I've used the following counter for some time, but I don't seem to
have it work now after I have moved the directory of the files.
This seems to be Apache problem than PHP problem. Are you sure your 
Apache can process PHP pages in your home directory? Check that first.


May be you should see if page with just phpinfo() function executes 
properly if kept in your home directory.


Regards,

--
Sameer N. Ingole
Blog: http://weblogic.noroot.org/
---
Better to light one candle than to curse the darkness.

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



[PHP] Problem with mail() on Debian

2006-02-21 Thread George Pitcher
Hi,

I am in the process of moving from Windows (NT/XP) to Linux. I'm starting
with a new small application which I have working on my Windows XP laptop.

On my Linux box, I have php.ini saying:

sendmail_path /usr/sbin/sendmail

That 'sendmail' is a symbolic link to exim4 in the same directory. I can
send mail using exim4 from the command line, but not using PHP. I couldn't
find anything in the manual or on Google that helps me solve the problem.

Can anyone give me a clue where to look to solve this problem?

Cheers

George, in Oxford

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



  1   2   >