Re: [PHP] preg_replace Question

2008-04-04 Thread Per Jessen
Richard Luckhurst wrote:

> e.g $amount = $524.00 however only 4.00 is displayed in the %Amount
> field on the html page. I tried dropping the .00 from $amount to see
> if this might be a length issue and then %Amount was just 4
> Am I doing something obviously wrong here? I have checked the php
> manual and I appear to be using preg_replace correctly.

>From the manual: 

"replacement  may contain references of the form \\n or (since PHP
4.0.4) $n, with the latter form being the preferred one"

If you use $amount ='\$524.00' instead of '$524.00', it'll work. 


/Per Jessen, Zürich


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



[PHP] Dynamic dropdown lists (select)

2008-04-04 Thread Angelo Zanetti
Hi all, 

I am looking at options for creating a dynamic dropdown list.

Ok here is the scenario: 

All values in the dropdown list (select/option field) are coming from the
database.

So there will be 2 dropdown lists. First one say gets (for example) a list
of cars, 

Then once the car is choosen the second list is populated with the list of
models for the car choosen.

I would like to know if its possible to do this without posting as well as
without the use of JS. I have seen js examples where the values are all
stored in arrays.

This is not desireable as I will be getting the values from the the DB using
PHP, unless I can write the JS values to the arrays using PHP? Also not sure
of that.

Is there any other idea or thing I can do? Im thinking maybe AJAX but this
is for a mobile site (WAP/xHTML) site and Im not sure if the functionality
will work on these devices.

Please advise.

Thanks in advance

Angelo

Web: http://www.elemental.co.za 




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



Re: [PHP] Dynamic dropdown lists (select)

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

Angelo Zanetti írta:
Hi all, 


I am looking at options for creating a dynamic dropdown list.

Ok here is the scenario: 


All values in the dropdown list (select/option field) are coming from the
database.

So there will be 2 dropdown lists. First one say gets (for example) a list
of cars, 


Then once the car is choosen the second list is populated with the list of
models for the car choosen.

I would like to know if its possible to do this without posting as well as
without the use of JS. I have seen js examples where the values are all
stored in arrays.



without JS it is not possible, unless you put a submit button next to 
the first select




This is not desireable as I will be getting the values from the the DB using
PHP, unless I can write the JS values to the arrays using PHP? Also not sure
of that.


sure you can generate the JS arrays with php. just echo out the 
necessary js, like:


echo 'var whatever = new Array();';
foreach ($cars as $idx => $car)
echo 'whatever['.$idx.'] = "'.$car->getName().'";';
echo '';



Is there any other idea or thing I can do? Im thinking maybe AJAX but this
is for a mobile site (WAP/xHTML) site and Im not sure if the functionality
will work on these devices.


I would go for ajax, if possible, but I don't know if it works on wap or not

greets,
Zoltán Németh



Please advise.

Thanks in advance

Angelo

Web: http://www.elemental.co.za 








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



Re: [PHP] Dynamic dropdown lists (select)

2008-04-04 Thread Richard Heyes

I would like to know if its possible to do this without posting as well as
without the use of JS.


Realistically, no. You could do it with VBScript, but then you're
restricted to Internet Explorer.


This is not desirable as I will be getting the values from the the DB using
PHP, unless I can write the JS values to the arrays using PHP? Also not sure
of that.


You will have to either generate all possible values for the second
SELECT or accept that a page refresh is necessary.


Is there any other idea or thing I can do? Im thinking maybe AJAX but this


The J in AJAX stands for Javascript.

--
Richard Heyes
Employ me:
http://www.phpguru.org/cv


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



[PHP] How to write simpleXML object to a file

2008-04-04 Thread It Maq
Hi,

I am reading an xml file. After that i modify one
node. IN the xml object that i'm handling it is
modified but not in the original file. Can you tell me
how i can make   the modification to an xml file or
how to write an xml object to a file?

Thank you


  

You rock. That's why Blockbuster's offering you one month of Blockbuster Total 
Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com


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



[Fwd: Re: [PHP] Character set problems]

2008-04-04 Thread Ryan Yagatich
Forwarding back to the list, since I'm one of those evil people that
uses HTML to write email :)

 Original Message 

Robert Cummings wrote:

>> So, based on the headers I'm using, and the myphpAdmin settings, is there 
>> something I'm missing?  I guess I was assuming since the headers are set for 
>> utf-8, and the "MySQL charset = UTF-8 Unicode (utf8)", that everything would 
>> be compatible.
>> 
>
> Do you have this in your php.ini?
>
> default_charset = "utf-8"
>
> Or if you want... the following in a .htaccess or virtual host config:
>
> php_value default_charset utf-8
>
> You can even manually output it from within your PHP code:
>
> header( 'Content-Type: text/html; charset=utf-8' );
>
> Cheers,
> Rob.
>   
This will fix it in PHP, but may not fix it for any .html file that's on
the server -- even with the appropriate meta tags, check apache's
'AddDefaultCharset' setting too.

Regards,
Ryan Yagatich

-- 
Pantek, Inc. - http://www.pantek.com/ - [EMAIL PROTECTED]
+1-877-LINUX-FIX - Expert Open Source Technical Support


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



Re: [PHP] Character set problems

2008-04-04 Thread Rob Gould
mysql_query("SET NAMES utf8"); 

This above line of code fixed my character problems.  Yay!

Was curious though - - - -is there a place somewhere in the cPanel or 
myPHPAdmin on my ISP (www.bluehost.com), where I can just have this happen 
automatically, or do I need to put this in my code everywhere I make a SQL call?



 
On Thursday, April 03, 2008, at 11:14PM, "Robert Cummings" <[EMAIL PROTECTED]> 
wrote:
>
>On Thu, 2008-04-03 at 21:56 -0700, Rob Gould wrote:
>> I'm having a hard time figuring out why my character sets and data look when 
>> when viewed in phpAdmin when browsing the table-columns, but then I go to 
>> show the data on my web-page with PHP, I get garbage-characters where I 
>> should be seeing apostrophs and special foreign-characters.
>> 
>> I copied all the header-data from the phpAdmin pages:
>> 
>> > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
>> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en" dir="ltr">
>> 
>> 
>> 
>> 
>> 
>> where the characters all show up properly, and I've put this on my web-page.
>> 
>> Here's what I know about my database, according to myphpadmin:
>> 
>> >From the phpAdmin settings page:
>> 
>> MySQL charset:  UTF-8 Unicode (utf8)
>> MySQL connection collation:  utf8_unicode_ci
>> 
>> >From the Structure tab for my table:
>> 
>> Type:  MyISAM
>> Collation:  utf8_unicode_ci
>> 
>> 
>> So, based on the headers I'm using, and the myphpAdmin settings, is there 
>> something I'm missing?  I guess I was assuming since the headers are set for 
>> utf-8, and the "MySQL charset = UTF-8 Unicode (utf8)", that everything would 
>> be compatible.
>
>Do you have this in your php.ini?
>
>default_charset = "utf-8"
>
>Or if you want... the following in a .htaccess or virtual host config:
>
>php_value default_charset utf-8
>
>You can even manually output it from within your PHP code:
>
>header( 'Content-Type: text/html; charset=utf-8' );
>
>Cheers,
>Rob.
>-- 
>http://www.interjinn.com
>Application and Templating Framework for PHP
>
>
>

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



Re: [PHP] Dynamic dropdown lists (select)

2008-04-04 Thread Ryan Yagatich
Angelo Zanetti wrote:
> Hi all, 
>
> I am looking at options for creating a dynamic dropdown list.


> Is there any other idea or thing I can do? Im thinking maybe AJAX but this
> is for a mobile site (WAP/xHTML) site and Im not sure if the functionality
> will work on these devices.
>
>   
You're pretty limited to the use of JavaScript here, and even more
limited to what you can do with it. For instance, JS works on the Treo
700p just fine - but when you get to making HTTP requests through JS
(AJAX and related talk goes here) - they refuse to execute. (The 700p
uses Blazer 4.5 web browser):
http://en.wikipedia.org/wiki/Blazer_(web_browser)

If your page is being read mostly by the non-cell phone crowd, use some
JavaScript making HTTP requests to say cars.php?make=x, where cars.php
returns some xml on all possible models of cars from that particular
make, where then your JS sets onreadystatechange and loops through all
returned values and pushes them onto the select list.

After you figure all of this out, write a "cell-phone crowd" version,
that uses a few reloads of various portions of the page to get the
desired affect. (I do believe that Blazer and the like support iframes -
but I'm not 100% sure, so don't quote me on that!)

Since you're in the market for the non-cell phone crowd, and the
cell-phone crowd - now might be a good time to turn on Channel 4 and
watch The IT Crowd...


> Please advise.
>
> Thanks in advance
>
> Angelo
>
> Web: http://www.elemental.co.za 
>
>
>
>   


Regards,
Ryan Yagatich


-- 
Pantek, Inc. - http://www.pantek.com/ - [EMAIL PROTECTED]
+1-877-LINUX-FIX - Expert Open Source Technical Support



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



Re: [PHP] How to write simpleXML object to a file

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

It Maq írta:

Hi,

I am reading an xml file. After that i modify one
node. IN the xml object that i'm handling it is
modified but not in the original file. Can you tell me
how i can make   the modification to an xml file or
how to write an xml object to a file?


$xml->asXML('whatever.xml');

http://hu.php.net/manual/en/function.simplexml-element-asXML.php

greets,
Zoltán Németh



Thank you


  

You rock. That's why Blockbuster's offering you one month of Blockbuster Total Access, No Cost.  
http://tc.deals.yahoo.com/tc/blockbuster/text5.com






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



[PHP] Why my mails are not received by Hotmail users?

2008-04-04 Thread thomas Armstrong
Hi.

I created this script to send emails:
---
$mailFromEmail = "[EMAIL PROTECTED]";
$mailFromName = "MYDOMAIN";
$mailTo = "[EMAIL PROTECTED]";

$mailHeaders =
"From: $mailFromName <$mailFromEmail>\n"
. "Content-Type: text/plain; "
. "charset=UTF-8; format=flowed\n"
. "MIME-Version: 1.0\n"
. "Content-Transfer-Encoding: 8bit\n";

$mailSubject = "Hi! " . date('h:i:s A');
$mailMessage = "Hi,\n\nHow are you?\n" . date('l dS \of F Y h:i:s A') . "\n";

mail($mailTo, $mailSubject, $mailMessage, $mailHeaders);
---

In addition, I've set an SPF policy on my DNS server, and I added this
line to my 'php.ini' file:
---
sendmail_path = /usr/sbin/sendmail -t -i -f [EMAIL PROTECTED]
---
(I've got 'safe_mode=on' on my server)

So Gmail users receive the messages correctly:
---
Delivered-To: [EMAIL PROTECTED]
Received: by 10.100.121.18 with SMTP id t18cs105671anc;
Fri, 4 Apr 2008 06:58:23 -0700 (PDT)
Received: by 10.114.56.1 with SMTP id e1mr1995521waa.52.1207317502773;
Fri, 04 Apr 2008 06:58:22 -0700 (PDT)
Return-Path: <[EMAIL PROTECTED]>
Received: from v2v-3.net ([52.147.120.136])
by mx.google.com with ESMTP id q18si8099195pog.7.2008.04.04.06.58.22;
Fri, 04 Apr 2008 06:58:22 -0700 (PDT)
Received-SPF: pass (google.com: domain of [EMAIL PROTECTED] designates
52.147.120.136 as permitted sender) client-ip=52.147.120.136;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of
[EMAIL PROTECTED] designates 52.147.120.136 as permitted sender)
[EMAIL PROTECTED]
Received: (qmail 21817 invoked by uid 48); 4 Apr 2008 06:58:22 -0700
---

Note the "Return-Path" line and the "Received-SPF" line.

If I change '[EMAIL PROTECTED]' with '[EMAIL PROTECTED]', they don't
receive my emails. What am I doing wrong?

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



Re: [PHP] Why my mails are not received by Hotmail users?

2008-04-04 Thread Ryan Yagatich
thomas Armstrong wrote:
> Hi.
>
> I created this script to send emails:
> ---
> $mailFromEmail = "[EMAIL PROTECTED]";
> $mailFromName = "MYDOMAIN";
> $mailTo = "[EMAIL PROTECTED]";
>
> $mailHeaders =
> "From: $mailFromName <$mailFromEmail>\n"
> . "Content-Type: text/plain; "
> . "charset=UTF-8; format=flowed\n"
> . "MIME-Version: 1.0\n"
> . "Content-Transfer-Encoding: 8bit\n";
>
>   
Hi Thomas.

I really hope that $mailFromEmail/$mailFromName are either set just like
you have them, or are sanitized prior to input -- otherwise, your email
has spammer written all over it!


> $mailSubject = "Hi! " . date('h:i:s A');
> $mailMessage = "Hi,\n\nHow are you?\n" . date('l dS \of F Y h:i:s A') . "\n";
>
>   
Your body looks like spam - with a spam subject. Try sending something
that is a little more non-spammy :)




Regards,
Ryan Yagatich

-- 
Pantek, Inc. - http://www.pantek.com/ - [EMAIL PROTECTED]
+1-877-LINUX-FIX - Expert Open Source Technical Support



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



RES: [PHP] Why my mails are not received by Hotmail users?

2008-04-04 Thread Thiago Pojda
These emails hit even my M$ Outlook  spam filter (which is not very good at
this job)

Try sending something else, as Ryan said.

-Mensagem original-
De: Ryan Yagatich [mailto:[EMAIL PROTECTED] 
Enviada em: sexta-feira, 4 de abril de 2008 11:31
Para: thomas Armstrong
Cc: php-general@lists.php.net
Assunto: Re: [PHP] Why my mails are not received by Hotmail users?

thomas Armstrong wrote:
> Hi.
>
> I created this script to send emails:
> ---
> $mailFromEmail = "[EMAIL PROTECTED]";
> $mailFromName = "MYDOMAIN";
> $mailTo = "[EMAIL PROTECTED]";
>
> $mailHeaders =
> "From: $mailFromName <$mailFromEmail>\n"
> . "Content-Type: text/plain; "
> . "charset=UTF-8; format=flowed\n"
> . "MIME-Version: 1.0\n"
> . "Content-Transfer-Encoding: 8bit\n";
>
>   
Hi Thomas.

I really hope that $mailFromEmail/$mailFromName are either set just like you
have them, or are sanitized prior to input -- 
otherwise, your email has spammer written all over it!


> $mailSubject = "Hi! " . date('h:i:s A'); $mailMessage = "Hi,\n\nHow 
> are you?\n" . date('l dS \of F Y h:i:s A') . "\n";
>
>   
Your body looks like spam - with a spam subject. Try sending 
something that is a little more non-spammy :)




Regards,
Ryan Yagatich

--
Pantek, Inc. - http://www.pantek.com/ - [EMAIL PROTECTED]
+1-877-LINUX-FIX - Expert Open Source Technical Support



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



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



Re: [PHP] Why my mails are not received by Hotmail users?

2008-04-04 Thread Wolf
 thomas Armstrong <[EMAIL PROTECTED]> wrote: 
> Hi.
> 
> I created this script to send emails:
> ---
> $mailFromEmail = "[EMAIL PROTECTED]";
> $mailFromName = "MYDOMAIN";
> $mailTo = "[EMAIL PROTECTED]";
> 
> $mailHeaders =
> "From: $mailFromName <$mailFromEmail>\n"
> . "Content-Type: text/plain; "
> . "charset=UTF-8; format=flowed\n"
> . "MIME-Version: 1.0\n"
> . "Content-Transfer-Encoding: 8bit\n";
> 
> $mailSubject = "Hi! " . date('h:i:s A');
> $mailMessage = "Hi,\n\nHow are you?\n" . date('l dS \of F Y h:i:s A') . "\n";
> 
> mail($mailTo, $mailSubject, $mailMessage, $mailHeaders);
> ---


Yeah, sounds like you have written a spam sender, which the spam blocking of 
hotmail has flagged and trashed for their senders.

Google will probably flag after the 2nd such comes in to their users...

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



[PHP] Multi sessions - IE

2008-04-04 Thread Thiago Pojda
Guys,
 
Some users often open two different sessions in my application by opening a
new browser instance (not "Open in new window" {they all use IE}). 
 
This actually works better than expected, the two sessions are almost
indepedent.
 
The thing is: almost. Sometimes one session displays data from the other one
and things get messed up.
 
Does anyone know how to fix this? Add a hidden PHPSESSID field in every form
(instead of cookies) would solve my problem or is this a server-side thing?
 
Thanks!
 

Atenciosamente,


  www.softpartech.com.br


Thiago Henrique Pojda
Desenvolvimento Web
+55 41 3033-7676
[EMAIL PROTECTED]
Excelência em Softwares Financeiros

 


Re: [PHP] Multi sessions - IE

2008-04-04 Thread Ryan Yagatich
Thiago Pojda wrote:

> Does anyone know how to fix this? Add a hidden PHPSESSID field in every form
> (instead of cookies) would solve my problem or is this a server-side thing?
>  
>   
you mean like session.use_trans_sid in php.ini?


Regards,
Ryan Yagatich

-- 
Pantek, Inc. - http://www.pantek.com/ - [EMAIL PROTECTED]
+1-877-LINUX-FIX - Expert Open Source Technical Support



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



[PHP] using php to backup mysql database?

2008-04-04 Thread paragasu
anyone know how to backup a mysql database using PHP?
i want to write one php function to allow admin to download the mysql
database backup (mysqldump maybe?) ..
and how to restore the database backup from web based admin?

i am using a shared server and the php scripts executed under the
www-data user..


thank you..


[PHP] exec return values

2008-04-04 Thread Philip Thompson
Is there a set list of return values/error codes returned by exec? I  
am running this command on a windows box and getting the following  
error:


exec ("net use /delete i: /y", $output, $ret);
print_r ($output);// Array()
echo "Return: $ret";  // Return: 2

I tested this statement with the mapped drive (i:) created and without  
it. I get the same result. Now this exec statement is just one  
example, but are there generic return values or is it based solely on  
the command being sent to exec?


I have RTFM (hopefully well enough) and STFW, but have not been  
fruitful in my searches. =/


Thanks,
~Philip

"Personally, most of my web applications do not have to factor 13.7  
billion years of space drift in to the calculations, so PHP's rand  
function has been great for me..." ~S. Johnson



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



Re: [PHP] using php to backup mysql database?

2008-04-04 Thread paragasu
i know phpmyadmin..
the points is, i am writing an application.
i want the admin of the website i wrote, to be able to do backup/restore
from the main administration area.

this admin do not have access to phpmyadmin.


Re: [PHP] using php to backup mysql database?

2008-04-04 Thread Robert Cummings

On Fri, 2008-04-04 at 23:40 +0800, paragasu wrote:
> i know phpmyadmin..
> the points is, i am writing an application.
> i want the admin of the website i wrote, to be able to do backup/restore
> from the main administration area.
> 
> this admin do not have access to phpmyadmin.

If you know phpmyadmin then why are you asking us for the solution when
the solution is already in phpmyadmin's source code? ;)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] LDAP in php

2008-04-04 Thread Nathan Nobbe
On Thu, Apr 3, 2008 at 4:10 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
wrote:

> Nathan Nobbe schrieb:
> > and its a little more
> > complicated to map to sql than one might initially suspect
> > http://www.openldap.org/doc/admin24/intro.html#LDAP%20vs%20RDBMS
>
> Yes, that's why I decided to try a php LDAP read-only (for Thunderbird)
> "implementation" - I could not see how I can map the LDAP to our SQL (which
> implements object-relational mapping defined in XML text files and could not
> be done without the php logic).


unfortunately, i dont think youll be able to escape this. suppose
thunderbird asks your php app a question in ldap; suppose it wants to
authenticate a user (one of the most prominent uses of ldap).  so it will be
giving you something (roughly) like

cn=someDude,dc=urDomain,dc=com

(also, somewhere in there ldap would specify this is a bind request and hand
you a password [but this is just a simple example for illustration]).

lets assume you have a simple user table in your database (again grossly
simplified)

create table USER (
  id integer not null auto_increment,
  name varchar(50) not null,
  password varchar(25) not null,
  primary key(id)
)

so you would turn around and do something like

function authUser($cn, $pass) {
  $qry = "SELECT password FROM USER WHERE name = '$cn'";
  $resultSet = doQuery ...
  if($resultSet['password'] == $pass) { return true; } else { return false;
}
}

which means you will be mapping ldap queries to sql queries; ergo, 'you cant
escape a mapping of some sort if your data is in a relational database and
your trying to get it in the hands of ldap'

setting up an ldap server like openldap involves mapping your relational
database schema to one of the openldap directory structure (which is
descended [roughly i believe] from x509 back in the day).  its kind of a
pain in the ass, especially if youre new to it (trust me on this one ;))
but you won't have to know anything about the ldap protocol.  imho this
would be far easier and it would have the advantage that you wouldnt be
reinventing the wheel so to speak.  this is a common practice that many
people have done and would be able to help you w/ whereas building a
'read-only' ldap server in php is something i dont think many, if any have
ever done.. youre likely to have your hands full w/ that and be mostly on
your own...

but it would be cool if you got it working ;)

if i were you i would consider building a custom backend for openldap,
perhaps a shell one, that turned around and called php.
http://www.openldap.org/doc/admin24/backends.html#Perl/Shell

or perhaps just doing w/e it takes to get the sql backend working; i however
found it quite vexing and to boot its marked as experimental..  but still
you wouldnt have to write your own server.  openldap would esentially be
speaking ldap for you and giving you something somewhat deluded to work w/
on the backend.

good luck,

-nathan


RES: [PHP] Multi sessions - IE

2008-04-04 Thread Thiago Pojda
De: Ryan Yagatich [mailto:[EMAIL PROTECTED] 


 you mean like session.use_trans_sid in php.ini?


Never heard of it, just RTFM'ed and it looks like the solution.

I'll be trying it and reply with the results. Thanks!


Thiago


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



Re: [PHP] everything as classes

2008-04-04 Thread robert

Hi
After spending yesterday afternoon I cleaned up my code and simplified  
in many places. I really like the idea to use Static class for "single  
use" database operations. Thank you very much to you that responded  
with comments.


-robert


On Apr 3, 2008, at 11:23 AM, Richard Heyes wrote:
Along the lines of a previous post "How to get a code review", I am  
curious if it is overkill to create everything in classes.


Everything, yes. Sometimes all you need is a quick and not so dirty  
function. Though saying that, OO is generally thought of as the way  
to go.


> For example,
a movie website where there is a class for the movie datatype,  
class for getting/adding/deleting/updating movie's data to the  
database, and class for displaying the data. (Of course there are  
classes for  general functionality like sql database connection  
etc.) For listing movies alone there are at least 4 different  
inheritance classes for chronological, alphabetic, category and  
keyword. Anyway this is how I coded something similar but for Flash/ 
Actionscript site but I'm not sure about a PHP site. I appreciate  
your comments.


Based on what you've described I would go with the following classes:

Movie

This class would handle fetching the movies data, updating it and/or  
deleting it. Or you could have a static Movie method for deleting  
one, eg Movie::Delete($id). Could also have a static Add() method  
which creates a movie and returns a movie object.


DB Connection

There are plenty of database classes around (not least my own PEAR  
replica - http://www.phpguru.org/article.php/121). Others include  
MDB2, PDO, ADODB etc.


Movie Listing(s) (abstract?)
|
+- By name (alphabetical
+- By category
+- By keyword
+- By date (chronological)

Here you'd have the code to show listings. With common code on the  
parent movie listings class and with specific code on the  
appropriate child class.


--
Richard Heyes
Employ me:
http://www.phpguru.org/cv



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



Re: [PHP] Character set problems

2008-04-04 Thread viraj
in most php apps, they use a separate database connection class. just
locate the function where it does mysql_select_db(), you can place the
line right after it selects the db. this will set name for each
connection, so no need to specifically set name every time you execute
a query.

or if you have access to my.cnf, add.. "init-connect='SET NAMES utf8'"
under the [mysqld] section.

happy utf8ing


~viraj

On Fri, Apr 4, 2008 at 3:32 PM, Rob Gould <[EMAIL PROTECTED]> wrote:
> mysql_query("SET NAMES utf8");
>
>  This above line of code fixed my character problems.  Yay!
>
>  Was curious though - - - -is there a place somewhere in the cPanel or 
> myPHPAdmin on my ISP (www.bluehost.com), where I can just have this happen 
> automatically, or do I need to put this in my code everywhere I make a SQL 
> call?
>
>
>
>
>
>
>  On Thursday, April 03, 2008, at 11:14PM, "Robert Cummings" <[EMAIL 
> PROTECTED]> wrote:
>  >
>  >On Thu, 2008-04-03 at 21:56 -0700, Rob Gould wrote:
>  >> I'm having a hard time figuring out why my character sets and data look 
> when when viewed in phpAdmin when browsing the table-columns, but then I go 
> to show the data on my web-page with PHP, I get garbage-characters where I 
> should be seeing apostrophs and special foreign-characters.
>  >>
>  >> I copied all the header-data from the phpAdmin pages:
>  >>
>  >>   >> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
>  >> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en" 
> dir="ltr">
>  >> 
>  >>
>  >> 
>  >>
>  >>
>  >> where the characters all show up properly, and I've put this on my 
> web-page.
>  >>
>  >> Here's what I know about my database, according to myphpadmin:
>  >>
>  >> >From the phpAdmin settings page:
>  >>
>  >> MySQL charset:  UTF-8 Unicode (utf8)
>  >> MySQL connection collation:  utf8_unicode_ci
>  >>
>  >> >From the Structure tab for my table:
>  >>
>  >> Type:  MyISAM
>  >> Collation:  utf8_unicode_ci
>  >>
>  >>
>  >> So, based on the headers I'm using, and the myphpAdmin settings, is there 
> something I'm missing?  I guess I was assuming since the headers are set for 
> utf-8, and the "MySQL charset = UTF-8 Unicode (utf8)", that everything would 
> be compatible.
>  >
>  >Do you have this in your php.ini?
>  >
>  >default_charset = "utf-8"
>  >
>  >Or if you want... the following in a .htaccess or virtual host config:
>  >
>  >php_value default_charset utf-8
>  >
>  >You can even manually output it from within your PHP code:
>  >
>  >header( 'Content-Type: text/html; charset=utf-8' );
>  >
>  >Cheers,
>  >Rob.
>  >--
>  >http://www.interjinn.com
>  >Application and Templating Framework for PHP
>  >
>  >
>  >
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RES: [PHP] Multi sessions - IE

2008-04-04 Thread Thiago Pojda
De: Ryan Yagatich [mailto:[EMAIL PROTECTED] 

you mean like session.use_trans_sid in php.ini?


How does this thing work anyway? As far as I read, it adds the session id to
every (default behavior) href and a hidden field in forms, right?

I *think* it just does that when you have cookies disabled. But I've
disabled my cookies and I can't pass the login screen. 

And also I did not see anything out of the ordinary in my forms :/

Am I missing something? I'm under PHP 4.3.4 (yeah, old)


Thanks,
Thiago


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



Re: [PHP] using php to backup mysql database?

2008-04-04 Thread Daniel Brown
On Fri, Apr 4, 2008 at 11:27 AM, paragasu <[EMAIL PROTECTED]> wrote:
> anyone know how to backup a mysql database using PHP?
>  i want to write one php function to allow admin to download the mysql
>  database backup (mysqldump maybe?) ..
>  and how to restore the database backup from web based admin?
>
>  i am using a shared server and the php scripts executed under the
>  www-data user..

If you have shell access and/or can run system() calls from PHP
(and presuming it's a *NIX-like system), you could try something like
this:


./mysql_'.$stamp.'sql',$ret,$err);
// Handle $ret and $err as you'd like, if you want.

exec('tar -cf mysql_'.$stamp.'.tar mysql_'.$stamp.'.sql',$ret,$err);
// Handle $ret and $err as you'd like, if you want.

exec('gzip -9 mysql_'.$stamp.'.tar',$ret,$err);
// Handle $ret and $err as you'd like, if you want.

echo "Download MySQL Backup";
?>

Doing any sanity, extension, or even concatenation of commands to
a single line is up to you.

-- 

Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Multi sessions - IE

2008-04-04 Thread Daniel Brown
On Fri, Apr 4, 2008 at 2:37 PM, Thiago Pojda
<[EMAIL PROTECTED]> wrote:
> De: Ryan Yagatich [mailto:[EMAIL PROTECTED]
>  
>
> you mean like session.use_trans_sid in php.ini?
>  
>
>  How does this thing work anyway? As far as I read, it adds the session id to
>  every (default behavior) href and a hidden field in forms, right?

http://www.domain.com/script.php?".session_name()."=".session_id();
?>

-- 

Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



RES: [PHP] Multi sessions - IE

2008-04-04 Thread Thiago Pojda
De: Daniel Brown [mailto:[EMAIL PROTECTED] 

On Fri, Apr 4, 2008 at 2:37 PM, Thiago Pojda 
<[EMAIL PROTECTED]> wrote:
> De: Ryan Yagatich [mailto:[EMAIL PROTECTED]  
>
> you mean like session.use_trans_sid in php.ini?
>  
>
>  How does this thing work anyway? As far as I read, it adds the 
> session id to  every (default behavior) href and a hidden 
field in forms, right?

http://www.domain.com/script.php?".session_name()."=".session_id();
?>



I think it was supposed to add those stuff automagically...?

Not quite sure I understood. I found litle doc on that setting, most results
are people telling to not use it :)


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



Re: [PHP] exec return values

2008-04-04 Thread Daniel Brown
On Fri, Apr 4, 2008 at 11:34 AM, Philip Thompson <[EMAIL PROTECTED]> wrote:
> Is there a set list of return values/error codes returned by exec? I am
> running this command on a windows box and getting the following error:
>
>  exec ("net use /delete i: /y", $output, $ret);
>  print_r ($output);// Array()
>  echo "Return: $ret";  // Return: 2

The third parameter ($ret) isn't defined by the exec() function,
but rather by the program called in the first parameter.  I'm not
certain if Windows has a[n easy] way to redirect STDERR to STDOUT, but
if it does, try that.  For example:

&1',$ret,$err);
print_r($ret);
echo "Return: ".$err."\n";
?>

-- 

Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Multi sessions - IE

2008-04-04 Thread Daniel Brown
On Fri, Apr 4, 2008 at 2:57 PM, Thiago Pojda
<[EMAIL PROTECTED]> wrote:
>> De: Daniel Brown [mailto:[EMAIL PROTECTED]
>>
>>  > echo
>>  "http://www.domain.com/script.php?".session_name()."=".session_id();
>>  ?>
>
>  I think it was supposed to add those stuff automagically...?
>
>  Not quite sure I understood. I found litle doc on that setting, most results
>  are people telling to not use it :)

Probably because of the fear of session hijacking and spoofing.
The thing is, a handwritten cookie is just as effective for that, by
changing the PHPSESSID (or equivalent).  In any case, a 32-byte
hexadecimal hash should be sufficient security for most sessions.

-- 

Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Dynamic dropdown lists (select)

2008-04-04 Thread Daniel Brown
On Fri, Apr 4, 2008 at 9:33 AM, Ryan Yagatich <[EMAIL PROTECTED]> wrote:
> Angelo Zanetti wrote:
>  > Hi all,
>  >
>  > I am looking at options for creating a dynamic dropdown list.
>  
>
>
>  > Is there any other idea or thing I can do? Im thinking maybe AJAX but this
>  > is for a mobile site (WAP/xHTML) site and Im not sure if the functionality
>  > will work on these devices.
>  >
>  >
>  You're pretty limited to the use of JavaScript here, and even more
>  limited to what you can do with it. For instance, JS works on the Treo
>  700p just fine - but when you get to making HTTP requests through JS
>  (AJAX and related talk goes here) - they refuse to execute. (The 700p
>  uses Blazer 4.5 web browser):
>  http://en.wikipedia.org/wiki/Blazer_(web_browser)

For posterity's sake (and an FYI), I'll point out that Internet
Exploder on the Treo 700wx does have a JavaScript parsing engine, but
does *not* handle AJAX very well at all.

I know this comes as a big surprise that a Microsoft product is
lacking when compared to another.

-- 

Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



RES: [PHP] Multi sessions - IE

2008-04-04 Thread Thiago Pojda
De: Daniel Brown [mailto:[EMAIL PROTECTED] 
Probably because of the fear of session hijacking and spoofing.
The thing is, a handwritten cookie is just as effective for 
that, by changing the PHPSESSID (or equivalent).  In any case, 
a 32-byte hexadecimal hash should be sufficient security for 
most sessions.




Yes, that's what they say. 

But anyway, adding that setting did not change a thing and I still can't see
my sessid anywhere in my code.

What will happen if I do it manually? Add the sessionid in a hidden input
field in every form (I don't feel like doing it, but if I have to...) will
do it?

Sorry to be asking too much, but I can't seem to be able to test it and the
docs are very poor for this.


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



Re: [PHP] Multi sessions - IE

2008-04-04 Thread Nitsan Bin-Nun
*im really sorry for interupting*

The session.use_trans_sid setting automaticly adds


> sid=**(32-chars-sess-id)**
>
to the url's of the website,
it should solve your problem
try to use it if you have an access to php.ini
otherwise, my suggestion is to forward a compiled (coded or something like
that) version of the id in all the links, urls, and requests manualy.
you can also write the user ip and/or agent and/or system and/or other crap
like that, and give each of them a unique id that forward within the links -
in this way you can build up a login system that does NOT require
sessions/cookies, all you have to do is that after the login completed, you
should forward an compiled string that contains some crap like a md5 of the
user and pass with some salt and check the string at each page (its can get
hijacked quickly but this is out of discussion).

sorry for going out of the topic

i wrote that without any attention so im sorry for anything that will misled
you on the wrong direction,
hope it helps,

Nitsan


On 04/04/2008, Thiago Pojda <[EMAIL PROTECTED]> wrote:
>
> De: Daniel Brown [mailto:[EMAIL PROTECTED]
>Probably because of the fear of session hijacking and spoofing.
> The thing is, a handwritten cookie is just as effective for
> that, by changing the PHPSESSID (or equivalent).  In any case,
> a 32-byte hexadecimal hash should be sufficient security for
> most sessions.
>
> 
>
>
> Yes, that's what they say.
>
> But anyway, adding that setting did not change a thing and I still can't
> see
> my sessid anywhere in my code.
>
> What will happen if I do it manually? Add the sessionid in a hidden input
> field in every form (I don't feel like doing it, but if I have to...) will
> do it?
>
> Sorry to be asking too much, but I can't seem to be able to test it and
> the
> docs are very poor for this.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Multi sessions - IE

2008-04-04 Thread Daniel Brown
On Fri, Apr 4, 2008 at 3:48 PM, Thiago Pojda
<[EMAIL PROTECTED]> wrote:
> De: Daniel Brown [mailto:[EMAIL PROTECTED]
>
> Probably because of the fear of session hijacking and spoofing.
>  The thing is, a handwritten cookie is just as effective for
>  that, by changing the PHPSESSID (or equivalent).  In any case,
>  a 32-byte hexadecimal hash should be sufficient security for
>  most sessions.
>
>  
>
>
>  Yes, that's what they say.
>
>  But anyway, adding that setting did not change a thing and I still can't see
>  my sessid anywhere in my code.
>
>  What will happen if I do it manually? Add the sessionid in a hidden input
>  field in every form (I don't feel like doing it, but if I have to...) will
>  do it?
>
>  Sorry to be asking too much, but I can't seem to be able to test it and the
>  docs are very poor for this.

It's quite alright.

PHP won't add it on automatically, you have to specify when and
where to do it.

-- 

Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



[PHP] Posting Summary for Week Ending 4 April, 2008: php-general@lists.php.net

2008-04-04 Thread PostTrack [Dan Brown]

Posting Summary for PHP-General List
Week Ending: Friday, 4 April, 2008

Messages| Bytes  | Sender
++--
295 (100%)  393216 (100%)   EVERYONE
26 (8.8%)  27525   (7%)Daniel Brown 
15 (5.1%)  16368   (4.2%)  Robert Cummings 
13 (4.4%)  10983   (2.8%)  Colin Guthrie 
13 (4.4%)  18635   (4.7%)  Richard Lynch 
10 (3.4%)  33529   (8.5%)  Zoltán Németh 
10 (3.4%)  16718   (4.3%)  admin at buskirkgraphics dot com
10 (3.4%)  18067   (4.6%)  Casey 
9  (3.1%)  12275   (3.1%)  Nathan Nobbe 
7  (2.4%)  5785(1.5%)  tedd 
7  (2.4%)  6596(1.7%)  Thiago Pojda 
6  (2%)12972   (3.3%)  Jim Lucas 
6  (2%)6093(1.5%)  Richard Heyes 
6  (2%)4767(1.2%)  Stut 
5  (1.7%)  4535(1.2%)  Wolf 
5  (1.7%)  3031(0.8%)  Per Jessen 
5  (1.7%)  4593(1.2%)  Ryan Panning 
4  (1.4%)  2584(0.7%)  paragasu 
4  (1.4%)  4393(1.1%)  Andrew Ballard 
4  (1.4%)  4058(1%)Chris 
4  (1.4%)  2666(0.7%)  Micky Hulse 
4  (1.4%)  4924(1.3%)  Adam Jacob Muller 
4  (1.4%)  6353(1.6%)  pobox at verysmall dot org 

4  (1.4%)  4517(1.1%)  Ryan Yagatich 
4  (1.4%)  7983(2%)Lamp Lists 
4  (1.4%)  4325(1.1%)  Ed W 
4  (1.4%)  5550(1.4%)  Manuel Lemos 
3  (1%)2863(0.7%)  Aschwin Wesselius 
3  (1%)2192(0.6%)  David Jourard 
3  (1%)5929(1.5%)  Test User 
3  (1%)5394(1.4%)  Larry Garfield 
3  (1%)1804(0.5%)  Ray Hauge 
3  (1%)1226(0.3%)  Bill 
2  (0.7%)  3602(0.9%)  Rob Gould 
2  (0.7%)  618 (0.2%)  Kevin Waterson 
2  (0.7%)  1294(0.3%)  mike 
2  (0.7%)  2577(0.7%)  Shawn McKenzie 
2  (0.7%)  2905(0.7%)  Shelley 
2  (0.7%)  2448(0.6%)  Jason Pruim 
2  (0.7%)  1860(0.5%)  Eric Butera 
2  (0.7%)  1706(0.4%)  kvigor 
2  (0.7%)  3789(1%)edwardspl at ita dot org dot mo
2  (0.7%)  2980(0.8%)  robert 
2  (0.7%)  2830(0.7%)  Alain Roger 
2  (0.7%)  2949(0.7%)  Joey 
2  (0.7%)  1548(0.4%)  kingzones at gmail dot com
2  (0.7%)  1815(0.5%)  Paul Scott 
2  (0.7%)  3551(0.9%)  steve 
2  (0.7%)  423 (0.1%)  Ali Reza Sajedi 
2  (0.7%)  1897(0.5%)  Hamar Gábor 
2  (0.7%)  3350(0.9%)  jeffry s 
1  (0.3%)  1070(0.3%)  Angelo Zanetti 
1  (0.3%)  1477(0.4%)  jwynacht 
1  (0.3%)  1491(0.4%)  Lamonte 
1  (0.3%)  2975(0.8%)  Constance dot Kan 
1  (0.3%)  3320(0.8%)  Jack Sasportas 
1  (0.3%)  1573(0.4%)  Sn!per 
1  (0.3%)  613 (0.2%)  Ilya Dyoshin 
1  (0.3%)  2966(0.8%)  Winiecki Beutel 
1  (0.3%)  319 (0.1%)  
1  (0.3%)  484 (0.1%)  Michael Horowitz 
1  (0.3%)  378 (0.1%)  Damian Hischier 
1  (0.3%)  695 (0.2%)  Kyle Baczynski 
1  (0.3%)  1254(0.3%)  Jon Wynacht 
1  (0.3%)  609 (0.2%)  It Maq 
1  (0.3%)  9558(2.4%)  PostTrack [Dan Brown] 

1  (0.3%)  1956(0.5%)  thomas Armstrong 
1  (0.3%)  913 (0.2%)  Philip Thompson 
1  (0.3%)  1234(0.3%)  Richard Luckhurst 
1  (0.3%)  3038(0.8%)  viraj 
1  (0.3%)  2799(0.7%)  Greg Bowser 
1  (0.3%)  2182(0.6%)  Nitsan Bin-Nun 
1  (0.3%)  559 (0.1%)  micky at ambiguism dot com
1  (0.3%)  720 (0.2%)  Kyle B 
1  (0.3%)  2636(0.7%)  Sangamesh B 
1  (0.3%)  888 (0.2%)  
1  (0.3%)  347 (0.1%)  Christoph Boget 
1  (0.3%)  253 (0.1%)  Christoph Boget 
1  (0.3%)  2999(0.8%)  Daniels

Re: [PHP] Multi sessions - IE

2008-04-04 Thread Daniel Brown
On Fri, Apr 4, 2008 at 3:58 PM, Nitsan Bin-Nun <[EMAIL PROTECTED]> wrote:
> *im really sorry for interupting*
>
>  The session.use_trans_sid setting automaticly adds
>
>
>  > sid=**(32-chars-sess-id)**
>  >
>  to the url's of the website,
>  it should solve your problem
>  try to use it if you have an access to php.ini

That's correct.  I should've been a bit clearer in the message I
just sent.  It will automatically append it to a URL but it won't
rewrite the code so that it's in forms, et cetera.

>
>  sorry for going out of the topic

You're still very much on-topic!  ;-)

-- 

Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



Re: [PHP] Dynamic dropdown lists (select)

2008-04-04 Thread Nathan Nobbe
On Fri, Apr 4, 2008 at 1:11 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:

> On Fri, Apr 4, 2008 at 9:33 AM, Ryan Yagatich <[EMAIL PROTECTED]>
> wrote:
> > Angelo Zanetti wrote:
> >  > Hi all,
> >  >
> >  > I am looking at options for creating a dynamic dropdown list.
> >  
> >
> >
> >  > Is there any other idea or thing I can do? Im thinking maybe AJAX but
> this
> >  > is for a mobile site (WAP/xHTML) site and Im not sure if the
> functionality
> >  > will work on these devices.
> >  >
> >  >
> >  You're pretty limited to the use of JavaScript here, and even more
> >  limited to what you can do with it. For instance, JS works on the Treo
> >  700p just fine - but when you get to making HTTP requests through JS
> >  (AJAX and related talk goes here) - they refuse to execute. (The 700p
> >  uses Blazer 4.5 web browser):
> >  
> > http://en.wikipedia.org/wiki/Blazer_(web_browser)
>
> For posterity's sake (and an FYI), I'll point out that Internet
> Exploder on the Treo 700wx does have a JavaScript parsing engine, but
> does *not* handle AJAX very well at all.
>
>I know this comes as a big surprise that a Microsoft product is
> lacking when compared to another.


im not a fan of this technique on full-blown web browsers, but in this case
it sounds like a workaround is called for.  you could just handle the
onchange event on the the select element and submit the form to the server
for a full page refresh.
eg.







you may also consider embedding the form in an iframe to enhance
performance, tho im no expert on the mobile front :D

-nathan


Re: [PHP] Dynamic dropdown lists (select)

2008-04-04 Thread Nitsan Bin-Nun
After reading the rest of the conversation, I think the best solution is the
next thing:
First, if I got this correct, you can extract the makes select-element from
the mysql using a query? if so, then extract it and host is in a temp
variable.
The next thing is writing down a js code, that contains an array of models
for each make. Personally, I'd use a 2 dimension array, the first dimension
for the make id/name and the second for the model id/name.
The 2 dimm. array you write with something like


> echo 'var whatever = new Array();';
> foreach ($cars as $idx => $car)
>echo 'whatever['.$idx.'] = "'.$car->getName().'";';
> echo '';


as Zoltan said.
Then you have just simplefied it to a JS based script, i think this is the
best way you will figure out which does NOT contains AJAX, only static JS ;)

HTH,
Nitsan

On 04/04/2008, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
>
> On Fri, Apr 4, 2008 at 1:11 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:
>
> > On Fri, Apr 4, 2008 at 9:33 AM, Ryan Yagatich <[EMAIL PROTECTED]>
> > wrote:
> > > Angelo Zanetti wrote:
> > >  > Hi all,
> > >  >
> > >  > I am looking at options for creating a dynamic dropdown list.
> > >  
> > >
> > >
> > >  > Is there any other idea or thing I can do? Im thinking maybe AJAX
> but
> > this
> > >  > is for a mobile site (WAP/xHTML) site and Im not sure if the
> > functionality
> > >  > will work on these devices.
> > >  >
> > >  >
> > >  You're pretty limited to the use of JavaScript here, and even more
> > >  limited to what you can do with it. For instance, JS works on the
> Treo
> > >  700p just fine - but when you get to making HTTP requests through JS
> > >  (AJAX and related talk goes here) - they refuse to execute. (The 700p
> > >  uses Blazer 4.5 web browser):
> > >  http://en.wikipedia.org/wiki/Blazer_(web_browser)<
> http://en.wikipedia.org/wiki/Blazer_%28web_browser%29>
> >
> > For posterity's sake (and an FYI), I'll point out that Internet
> > Exploder on the Treo 700wx does have a JavaScript parsing engine, but
> > does *not* handle AJAX very well at all.
> >
> >I know this comes as a big surprise that a Microsoft product is
> > lacking when compared to another.
>
>
> im not a fan of this technique on full-blown web browsers, but in this
> case
> it sounds like a workaround is called for.  you could just handle the
> onchange event on the the select element and submit the form to the server
> for a full page refresh.
> eg.
>
> 
> 
> 
> 
> 
>
> you may also consider embedding the form in an iframe to enhance
> performance, tho im no expert on the mobile front :D
>
> -nathan
>


RES: [PHP] Multi sessions - IE

2008-04-04 Thread Thiago Pojda
-Mensagem original-
De: Nitsan Bin-Nun [mailto:[EMAIL PROTECTED] 


The session.use_trans_sid setting automaticly adds

> sid=**(32-chars-sess-id)**
>
to the url's of the website,
it should solve your problem


ME -> I added "session.use_trans_sid = 1" to the beggining of my php.ini
file and I don't see that sid parameter in any $_GET value.

ME -> Nothing has changed, nothing. :/

ME -> Will I have to use url_rewrite()? Is that what Daniel was talking
about?

try to use it if you have an access to php.ini otherwise, my suggestion is
to forward a compiled (coded or something like
that)  you should 
forward an compiled string that contains some crap like a md5 
of the user and pass with some salt and check the string at 
each page (its can get hijacked quickly but this is out of discussion).

ME -> That sounds good, but too much effort to rebuild all hrefs. The system
is quite big for that.


sorry for going out of the topic

i wrote that without any attention so im sorry for anything 
that will misled you on the wrong direction, hope it helps,

Nitsan

ME-> That was not OT, and quite good to know :)


Thanks,
Thiago

{As of now, I'm only going to top post :)}

On 04/04/2008, Thiago Pojda <[EMAIL PROTECTED]> wrote:
>
> De: Daniel Brown [mailto:[EMAIL PROTECTED]
>Probably because of the fear of session hijacking and spoofing.
> The thing is, a handwritten cookie is just as effective for that, by 
> changing the PHPSESSID (or equivalent).  In any case, a 32-byte 
> hexadecimal hash should be sufficient security for most sessions.
>
> 
>
>
> Yes, that's what they say.
>
> But anyway, adding that setting did not change a thing and I still 
> can't see my sessid anywhere in my code.
>
> What will happen if I do it manually? Add the sessionid in a hidden 
> input field in every form (I don't feel like doing it, but if I have 
> to...) will do it?
>
> Sorry to be asking too much, but I can't seem to be able to test it 
> and the docs are very poor for this.
>
>
> --
> PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
> http://www.php.net/unsub.php
>
>


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



Re: [PHP] Dynamic dropdown lists (select)

2008-04-04 Thread Nathan Nobbe
On Fri, Apr 4, 2008 at 2:19 PM, Nitsan Bin-Nun <[EMAIL PROTECTED]> wrote:

> After reading the rest of the conversation, I think the best solution is
> the next thing:
> First, if I got this correct, you can extract the makes select-element
> from the mysql using a query? if so, then extract it and host is in a temp
> variable.
> The next thing is writing down a js code, that contains an array of models
> for each make. Personally, I'd use a 2 dimension array, the first dimension
> for the make id/name and the second for the model id/name.
> The 2 dimm. array you write with something like
>
>
> > echo 'var whatever = new Array();';
> > foreach ($cars as $idx => $car)
> >echo 'whatever['.$idx.'] = "'.$car->getName().'";';
> > echo '';
>
>
> as Zoltan said.
> Then you have just simplefied it to a JS based script, i think this is the
> best way you will figure out which does NOT contains AJAX, only static JS ;)
>

you have to be careful with this approach.  sending too much data to the
client can kill performance; im guessing this is even more sensitive in the
context of mobile client.  just use careful judgement (and testing ! ;)) ;
if there are a couple dozen entries total, probly this route is acceptable.
if there are several hundred

-nathan


Re: [PHP] Multi sessions - IE

2008-04-04 Thread Nitsan Bin-Nun
Usually my system are templates and OOP based, so if you change the main
function that handles the links...
btw I dont know if you thought about this, in order to deny any kind of
session fixation and X/CSRF (cross site forgeries) you better write down
some $_GET forwarded token system ;)

CSRF - a situation when 2 tabs / ie windows are open, and for instance, one
of them is a shopping guide blog, and the other one is a shopping website,
in case that the addition of items to the shopping card is validated by
session, you can just call (with iframe and something like that) at the blog
website to the adding form and submit the request, the item will be added
cause of the active session at the next tab ;) the solution for this is
using tokens (ask and ill explain).

On 04/04/2008, Thiago Pojda <[EMAIL PROTECTED]> wrote:
>
> -Mensagem original-
> De: Nitsan Bin-Nun [mailto:[EMAIL PROTECTED]
>
> 
> The session.use_trans_sid setting automaticly adds
>
> > sid=**(32-chars-sess-id)**
> >
> to the url's of the website,
> it should solve your problem
>
> 
> ME -> I added "session.use_trans_sid = 1" to the beggining of my php.ini
> file and I don't see that sid parameter in any $_GET value.
>
> ME -> Nothing has changed, nothing. :/
>
> ME -> Will I have to use url_rewrite()? Is that what Daniel was talking
> about?
>
> try to use it if you have an access to php.ini otherwise, my suggestion is
> to forward a compiled (coded or something like
> that)  you should
> forward an compiled string that contains some crap like a md5
> of the user and pass with some salt and check the string at
> each page (its can get hijacked quickly but this is out of discussion).
>
> ME -> That sounds good, but too much effort to rebuild all hrefs. The
> system
> is quite big for that.
>
>
> sorry for going out of the topic
>
> i wrote that without any attention so im sorry for anything
> that will misled you on the wrong direction, hope it helps,
>
> Nitsan
>
> ME-> That was not OT, and quite good to know :)
>
>
> Thanks,
> Thiago
>
> {As of now, I'm only going to top post :)}
>
> On 04/04/2008, Thiago Pojda <[EMAIL PROTECTED]> wrote:
> >
> > De: Daniel Brown [mailto:[EMAIL PROTECTED]
> >Probably because of the fear of session hijacking and spoofing.
> > The thing is, a handwritten cookie is just as effective for that, by
> > changing the PHPSESSID (or equivalent).  In any case, a 32-byte
> > hexadecimal hash should be sufficient security for most sessions.
> >
> > 
> >
> >
> > Yes, that's what they say.
> >
> > But anyway, adding that setting did not change a thing and I still
> > can't see my sessid anywhere in my code.
> >
> > What will happen if I do it manually? Add the sessionid in a hidden
> > input field in every form (I don't feel like doing it, but if I have
> > to...) will do it?
> >
> > Sorry to be asking too much, but I can't seem to be able to test it
> > and the docs are very poor for this.
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
> > http://www.php.net/unsub.php
> >
> >
>
>


[PHP] PostTrack Updates

2008-04-04 Thread Daniel Brown
Some changes take effect with the PostTrack metrics system with
this week (will show up in next week's report).  There's one bug fix
and a new feature added, in which some of you may be really
interested.

CHANGELOG
Fixed a bug that would (seemingly random) split a user's post
recording over multiple entries. (See this week's report: Zoltan
Nemeth for example)
Added a new CodeCount feature.  Explained below.

The CodeCount feature will, from now on, track the amount of
[pseudo]code everyone posts to the list.  However, for a variety of
reasons (including enforcing Good Coding Practices[tm], there will be
some rules:

* short_open_tags code will not be counted.  It must begin
with  things won't count.
* All code must be properly closed as well as opened.  Thus,
.
* You can include multiple blocks of code, and all will be tallied.  So:

 and 

 will both be counted.

Some notes that should be obvious:
* HTML won't be counted unless included in an echo/print
construct or a HEREDOC/NOWDOC (when used).  Only the code between the
 tags will be counted.
* The CodeCount procedure *does* count comments as code.  This
can be changed if there's enough desire.
* CodeCount *will not* differentiate between "Good" and "Bad"
code.  If you forget a semicolon, it'll still count.

-- 

Ask me about:
Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
and shared hosting starting @ $2.50/mo.
Unmanaged, managed, and fully-managed!

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



[PHP] How to jump to line number in large file

2008-04-04 Thread Steve McGill
Hello,

I have code where it is appropriate for me to jump to certain lines in a 
text file and edit that particular line. I need to keep a record of the byte 
position of every line so that I can fseek to it.

I need to do in-line editing so I don't want to write the entire file out 
again etc. I don't want to read the entire file into memory using file(). 
Finally each line has an unpredicatable line length as it is generated by a 
3rd party program so I can't do some maths to work out the correct byte 
position.

 I am using code like this to keep a record of all the byte positions:

$line_positions = array(1=>0);
$line_number = 2;
while(!feof($handle)) {
  fseek($handle, 1, SEEK_CUR); // or fseek($handle, $pos)
  $t = fgetc($handle);
  if($t == "\n") {
$line_positions[$line_number] = $pos + 1;
$line_number++;
  }
  $pos++;
}

This behaves fine with smaller textfiles but not very well with 100Mb files, 
etc.

I've commented out assigning the array in the loop and that doesn't really 
help, it seems it's the fseek fgetc etc which takes forever.

Can anybody point me in the right direction? Editplus opens up the 100Mb 
file in a couple of seconds and can then jump to a line number 
instantaneously, whereas my code takes a couple of minutes to loop through 
the file. I'm assuming this isn't the difference between PHP & C but rather 
that I'm doing something stupid :-)

Many thanks in advance for your time,

Steve




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



Re: [PHP] How to jump to line number in large file

2008-04-04 Thread Greg Bowser
 fseek($handle, 1, SEEK_CUR); // or fseek($handle, $pos)
  $t = fgetc($handle);

This probably won't help you, but given a quick glance, it looks like you're
incrementing the file pointer by 2 positions on each iteration of your while
loop. The fgetc() function returns the character at the current position and
increments the file pointer by 1.

I haven't tried this, but perhaps using strpos would be faster? Use strpos
to seek to find the first "\n", then use the offset parameter to seek to the
second, and so on, until strpos() returns false.

--GREG


Re: [PHP] using php to backup mysql database?

2008-04-04 Thread paragasu
On Sat, Apr 5, 2008 at 2:42 AM, Daniel Brown <[EMAIL PROTECTED]> wrote:

> On Fri, Apr 4, 2008 at 11:27 AM, paragasu <[EMAIL PROTECTED]> wrote:
> > anyone know how to backup a mysql database using PHP?
> >  i want to write one php function to allow admin to download the mysql
> >  database backup (mysqldump maybe?) ..
> >  and how to restore the database backup from web based admin?
> >
> >  i am using a shared server and the php scripts executed under the
> >  www-data user..
>
> If you have shell access and/or can run system() calls from PHP
> (and presuming it's a *NIX-like system), you could try something like
> this:
>
>  // mysql-backup.php
>
> $database = "your-db-name";
> $username = "your-db-username";
> $password = "your-db-password";
> $stamp = time();
>
> ignore_user_abort(1); // Continue no matter what.
>
> exec('mysqldump -u '.$username.' -p'.$password.' '.$database.' >
> ./mysql_'.$stamp.'sql',$ret,$err);
> // Handle $ret and $err as you'd like, if you want.
>
> exec('tar -cf mysql_'.$stamp.'.tar mysql_'.$stamp.'.sql',$ret,$err);
> // Handle $ret and $err as you'd like, if you want.
>
> exec('gzip -9 mysql_'.$stamp.'.tar',$ret,$err);
> // Handle $ret and $err as you'd like, if you want.
>
> echo "Download MySQL Backup";
> ?>
>
>Doing any sanity, extension, or even concatenation of commands to
> a single line is up to you.
>
> --
> 
> Ask me about:
> Dedicated servers starting @ $59.99/mo., VPS starting @ $19.99/mo.,
> and shared hosting starting @ $2.50/mo.
> Unmanaged, managed, and fully-managed!
>

thank you.. that is the answer i am looking for :)


Re: [PHP] PostTrack Updates

2008-04-04 Thread Robert Cummings


 Some changes take effect with the PostTrack metrics\n" ?>
 system with this week (will show up in next week's\n" ?>
 report). There's one bug fix and a new feature added,
\n" ?>
 in which some of you may be really interested.\n" ?>
\n" ?>
 CHANGELOG\n" ?>

 Fixed a bug that would (seemingly random)\n" ?>
 split a user's post recording over multiple entries.\n" ?>
 (See this week's report: Zoltan Nemeth for example)\n" ?>
 Added a new CodeCount feature.  Explained\n" ?>
 below.\n" ?>
\n" ?>
 The CodeCount feature will, from now on, track\n" ?>
 the amount of [pseudo]code everyone posts to the\n" ?>
 list. However, for a variety of reasons (including\n" ?>
 enforcing Good Coding Practices[tm], there will be\n" ?>
 some rules:\n" ?>
\n" ?>
 * short_open_tags code will not be counted.\n" ?>
   It must begin with 
things won't count.\n" ?>
 * All code must be properly closed as well as
\n" ?>
   opened. Thus, .\n" ?>
 * You can include multiple blocks of code,\n" ?>
   and all will be tallied. So:\n" ?>
 
 // Block one\n" ?>
 ?>\n" ?>
  and \n" ?>
 
 // Block two\n" ?>
 ?>\n" ?>
  will both be counted.\n" ?>
\n" ?>
 Some notes that should be obvious:\n" ?>
 * HTML won't be counted unless included in an
\n" ?>
   echo/print construct or a HEREDOC/NOWDOC\n" ?>
   (when used). Only the code between the\n" ?>
tags will be counted.\n" ?>
 * The CodeCount procedure *does* count\n" ?>
   comments as code. This can be changed if\n" ?>
   there's enough desire.\n" ?>
 * CodeCount *will not* differentiate between\n" ?>
   \"Good\" and \"Bad\" code. If you forget a\n" ?>
   semicolon, it'll still count.\n" ?>
\n" ?>
 --\n" ?>
 \n" ?>
 Ask me about:\n" ?>
 Dedicated servers starting @ \$59.99/mo., VPS\n" ?>
 starting @ \$19.99/mo., and shared hosting starting @
\n" ?>
 \$2.50/mo. Unmanaged, managed, and fully-managed!\n" ?>

I don't know about anyone else, but I am absolutely stoked about this
development!

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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



Re: [PHP] PostTrack Updates

2008-04-04 Thread Jim Lucas

Robert Cummings wrote:


 Some changes take effect with the PostTrack metrics\n" ?>
 system with this week (will show up in next week's\n" ?>
 report). There's one bug fix and a new feature added,
\n" ?>
 in which some of you may be really interested.\n" ?>
\n" ?>
 CHANGELOG\n" ?>

 Fixed a bug that would (seemingly random)\n" ?>
 split a user's post recording over multiple entries.\n" ?>
 (See this week's report: Zoltan Nemeth for example)\n" ?>
 Added a new CodeCount feature.  Explained\n" ?>
 below.\n" ?>
\n" ?>
 The CodeCount feature will, from now on, track\n" ?>
 the amount of [pseudo]code everyone posts to the\n" ?>
 list. However, for a variety of reasons (including\n" ?>
 enforcing Good Coding Practices[tm], there will be\n" ?>
 some rules:\n" ?>
\n" ?>
 * short_open_tags code will not be counted.\n" ?>
   It must begin with 
things won't count.\n" ?>
 * All code must be properly closed as well as
\n" ?>
   opened. Thus, .\n" ?>
 * You can include multiple blocks of code,\n" ?>
   and all will be tallied. So:\n" ?>
 
 // Block one\n" ?>
 ?>\n" ?>
  and \n" ?>
 
 // Block two\n" ?>
 ?>\n" ?>
  will both be counted.\n" ?>
\n" ?>
 Some notes that should be obvious:\n" ?>
 * HTML won't be counted unless included in an
\n" ?>
   echo/print construct or a HEREDOC/NOWDOC\n" ?>
   (when used). Only the code between the\n" ?>
tags will be counted.\n" ?>
 * The CodeCount procedure *does* count\n" ?>
   comments as code. This can be changed if\n" ?>
   there's enough desire.\n" ?>
 * CodeCount *will not* differentiate between\n" ?>
   \"Good\" and \"Bad\" code. If you forget a\n" ?>
   semicolon, it'll still count.\n" ?>
\n" ?>
 --\n" ?>
 \n" ?>
 Ask me about:\n" ?>
 Dedicated servers starting @ \$59.99/mo., VPS\n" ?>
 starting @ \$19.99/mo., and shared hosting starting @
\n" ?>
 \$2.50/mo. Unmanaged, managed, and fully-managed!\n" ?>

I don't know about anyone else, but I am absolutely stoked about this
development!

Cheers,
Rob.


wait you forgot the semi-colon...  ah, that's right, he said grammar 
mistakes were not counted...


:)

Who else

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



Re: [PHP] PostTrack Updates

2008-04-04 Thread Robert Cummings

On Fri, 2008-04-04 at 22:39 -0700, Jim Lucas wrote:
> Robert Cummings wrote:
> > 
> >  Some changes take effect with the PostTrack metrics\n" ?>
> >  system with this week (will show up in next week's\n" ?>
> >  report). There's one bug fix and a new feature added,
> > \n" ?>
> >  in which some of you may be really interested.\n" ?>
> > \n" ?>
> >  CHANGELOG\n" ?>
> > 
> >  Fixed a bug that would (seemingly random)\n" ?>
> >  split a user's post recording over multiple entries.\n" ?>
> >  (See this week's report: Zoltan Nemeth for example)\n" ?>
> >  Added a new CodeCount feature.  Explained\n" ?>
> >  below.\n" ?>
> > \n" ?>
> >  The CodeCount feature will, from now on, track\n" ?>
> >  the amount of [pseudo]code everyone posts to the\n" ?>
> >  list. However, for a variety of reasons (including\n" ?>
> >  enforcing Good Coding Practices[tm], there will be\n" ?>
> >  some rules:\n" ?>
> > \n" ?>
> >  * short_open_tags code will not be counted.\n" ?>
> >It must begin with 
> > things won't count.\n" ?>
> >  * All code must be properly closed as well as
> > \n" ?>
> >opened. Thus,  > by ?>.\n" ?>
> >  * You can include multiple blocks of code,\n" ?>
> >and all will be tallied. So:\n" ?>
> >  
> >  // Block one\n" ?>
> >  ?>\n" ?>
> >   and \n" ?>
> >  
> >  // Block two\n" ?>
> >  ?>\n" ?>
> >   will both be counted.\n" ?>
> > \n" ?>
> >  Some notes that should be obvious:\n" ?>
> >  * HTML won't be counted unless included in an
> > \n" ?>
> >echo/print construct or a HEREDOC/NOWDOC\n" ?>
> >(when used). Only the code between the\n" ?>
> > tags will be counted.\n" ?>
> >  * The CodeCount procedure *does* count\n" ?>
> >comments as code. This can be changed if\n" ?>
> >there's enough desire.\n" ?>
> >  * CodeCount *will not* differentiate between\n" ?>
> >\"Good\" and \"Bad\" code. If you forget a\n" ?>
> >semicolon, it'll still count.\n" ?>
> > \n" ?>
> >  --\n" ?>
> >  \n" ?>
> >  Ask me about:\n" ?>
> >  Dedicated servers starting @ \$59.99/mo., VPS\n" ?>
> >  starting @ \$19.99/mo., and shared hosting starting @
> > \n" ?>
> >  \$2.50/mo. Unmanaged, managed, and fully-managed!\n" ?>
> > 
> > I don't know about anyone else, but I am absolutely stoked about this
> > development!
> > 
> > Cheers,
> > Rob.
> 
> wait you forgot the semi-colon...  ah, that's right, he said grammar 
> mistakes were not counted...

Perfectly valid to omit the last semi-colon when closing a PHP block.

> :)

;)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


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