Re: [PHP] Ajax please....

2006-04-07 Thread Carlin Bingham
Just use PHP to do it.

To check if an account with that username exsists just use the
mysql_num_rows function and a 'die' statement.


Then use SQL/PHP code to log the information in a database and just echo
the success text at the bottom of your code.


Simple.



On 3:21:47 am 08/04/2006 "Ryan A" <[EMAIL PROTECTED]> wrote:
> Hey,
>
> Just been googleing and trying out different AJAX frameworks..:
> From PEAR HTML_AJAX
> Gauva
> My-Bic
> AjaxAC
> and quite a few moreand it happened, I confused myself :-(
>
> For some reason HTML_AJAX is not working on my local machine (windows
> based, I am getting runtime errors with the examples) and it seems
> quite bulky. I have even tried the YAHOO one, which Rasmus suggested
> to another guy some time back (found it
> after looking in the archives) unfortunatly could not find much
> documentation that I could understand...
>
> Hopefully after reading about my requirment(s) someone can suggest
> something thats really simple (or really well
> documented with examples)
>
> Requirements:
> Write little or no JS
> When i submit the form, it should simply call my script and print out
> the answer inbetween the DIV tags
>
>
> This is what i want to use it for:
> Client comes to site, wants to make an account, I check if the
> username he entered is not already in use, if already in use I print
> out a failute message in red on the screen if not in usei make
> his account and print out a success text or redirect him to a success
> page. THATS IT, nothing too fancy.
>
> Thanks in advance.
>
> Cheers,
> Ryan
>
> --
> 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] headers already sent.

2006-04-07 Thread Chris

Comment inline:

P. Guethlein wrote:

(Know enough to be dangerous beginner...)

Routine for a web login asked user name and password.

User Name is entered correctly.

Password is Incorrect.

Next Try.

User Name is enter correctly.

Password is Entered Correctly.

PHP notifies me on the html output that I am logged in.  However, an 
error is appearing in text above the html output.  It states


Warning: Cannot modify header information - headers already sent by 
(output started at D:\webpages\\users.inc:11) in 
D:\webpages\\web\loginfunctions.php on line 26


Users.inc is

==


This gap right here, it's outputting a carriage return and/or linefeed. 
headers get sent on the first character of output being sent.


===

Line 26 from the loginfunctions.php file is

//now redirect the user to whatever page they wanted.
header('Location: index.php?href='.$link);

==

I can anticipate what the problem is with the notification that PHP 
gives me with the headers already output.  However, it says 'headers 
already sent by users.inc', huh?


Suggestions of where to look on this bug is appreciated!

-Pete



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



Re: [PHP] PHP Book Recommendation

2006-04-07 Thread Pablo L. de Miranda
Man,
Anothers good books:
- PHP|Architect's Guide to PHP Design Patterns, ISBN: 0973589825
- PHP 5 Objects, Patterns, and Practice, ISBN: 0973589825


On 4/8/06, Jim Lucas <[EMAIL PROTECTED]> wrote:
> Paul Goepfert wrote:
> > Hi all,
> >
> > Can anyone tell me a good php book to buy.  I already have Web
> > Database Applications with PHP & MySQL by O'Reilly.
> >
> > Thanks,
> > Paul
> >
> >
> Professional PHP5 by WROX
>
> --
> 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] microtime questions

2006-04-07 Thread Joe Wollard
Tedd,

I think Brad was just making some observations, he wasn't trying to be rude.
When he said that "the time differentials are too be expected." I think he
was just answering the question of why the exact same FOR loop could
possibly take different amounts of time to execute under the same conditions
in the script; not necessarily why it was providing negative values.

On your original issue, were you able to make use of the example function on
http://php.net/microtime? The documentation there along with what I posted
should hopefully clear things up for you as to why microtime() is reliable,
and that it doesn't return a pure float that should be used in equations. It
seems as though you knew that, but as I said before the way that you're
using microtime() is not valid with the version of PHP your host is using.

Please let us know if you'd like more clarification on this. There are a lot
of people on this list, so someone will have the answer that you need. ;-)

- Joe

On 4/7/06, tedd <[EMAIL PROTECTED]> wrote:
>
> -B
>
> At 12:51 PM -0400 4/7/06, Brad Bonkoski wrote:
> >How is the CPU not in question?  Does this script run on air?
>
> I did not say that. I said that it was not MY CPU that was involved
> and it isn't.
>
> >It may not be YOUR CPU, but it is still a CPU bound by the sceduling
> >algorithm of the Operating System, so the time differentials are too
> >be expected.
>
> Negative times are expected? Incorrect times are expected? What's the
> point of microtime if you can't reply on it?
>
> Please explain.
>
> tedd
>
> --- previous ---
>
> >-B
> >
> >tedd wrote:
> >
> >>At 12:24 PM -0400 4/7/06, Brad Bonkoski wrote:
> >>
> >>>Interesting...
> >>>as for your first question...
> >>>Know that PHP/Apache does not have free reign to your CPU, so the
> >>>times could be different based on the scheduling going on in the
> >>>OS kernel.
> >>>
> >>>As for the second one...
> >>>No idea why you would get a negative number, I just copied and ran
> >>>from the command line and did not encounter 1 negative time for
> >>>about 30 runs
> >>>
> >>>Do you get negative times if you run it from the command line as well?
> >>>-B
> >>>
> RE:
> 
> http://www.xn--ovg.com/microtime.php
> 
> >>
> >>Brad:
> >>
> >>Thanks for looking.
> >>
> >>My questions are with regard to what happens on the site, not via
> >>my command line. As such, my command line and my CPU are not
> >>involved.
> >>
> >>Can you answer the questions as they pertain to the site in question?
> >>
> >>Thanks.
> >>
> >>tedd
>
>
> --
>
> 
> http://sperling.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] headers already sent.

2006-04-07 Thread P. Guethlein

(Know enough to be dangerous beginner...)

Routine for a web login asked user name and password.

User Name is entered correctly.

Password is Incorrect.

Next Try.

User Name is enter correctly.

Password is Entered Correctly.

PHP notifies me on the html output that I am logged in.  However, an 
error is appearing in text above the html output.  It states


Warning: Cannot modify header information - headers already sent by 
(output started at D:\webpages\\users.inc:11) in 
D:\webpages\\web\loginfunctions.php on line 26


Users.inc is

==



===

Line 26 from the loginfunctions.php file is

//now redirect the user to whatever page they wanted.
header('Location: index.php?href='.$link);

==

I can anticipate what the problem is with the notification that PHP 
gives me with the headers already output.  However, it says 'headers 
already sent by users.inc', huh?


Suggestions of where to look on this bug is appreciated!

-Pete

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



Re: [PHP] Ajax please....

2006-04-07 Thread tedd

At 2:21 AM +0200 4/8/06, Ryan A wrote:

This is what i want to use it for:
Client comes to site, wants to make an account, I check if the username he
entered is not already in use, if already in use I print out a failute
message in red on the screen if not in usei make his account and print
out a success text or redirect him to a success page.
THATS IT, nothing too fancy.


Ryan:

Unless you want something more, you don't need ajax for that. All of 
that can be done in php.


Why do you think you need ajax?

tedd
--

http://sperling.com

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



Re: [PHP] PHP Book Recommendation

2006-04-07 Thread Jim Lucas

Paul Goepfert wrote:

Hi all,

Can anyone tell me a good php book to buy.  I already have Web
Database Applications with PHP & MySQL by O'Reilly.

Thanks,
Paul

  

Professional PHP5 by WROX

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



Re: [PHP] Ajax please....

2006-04-07 Thread Rasmus Lerdorf

Ryan A wrote:

Just been googleing and trying out different AJAX frameworks..:

From PEAR HTML_AJAX

Gauva
My-Bic
AjaxAC
and quite a few moreand it happened, I confused myself :-(

For some reason HTML_AJAX is not working on my local machine (windows based,
I am getting runtime errors with the examples) and it seems quite
bulky. I have even tried the YAHOO one, which Rasmus suggested to another
guy some time back (found it
after looking in the archives) unfortunatly could not find much
documentation that I could understand...


It's really not hard.  Remember my 30s AJAX post a while back?  Well, 
here is a revised version using the Yahoo! library.  You can try it on 
this slide:


  http://talks.php.net/show/yul/14

There are basically 3 parts to any AJAX app.  The initial HTML that the 
user first loads up.  In this case it is:


 
   Location: 
 

So, just a form with a single text field where the user can enter a 
location.  Easy enough so far.  When the user hits enter the action line 
there says to call the sendform() Javascript function and pass it the 
strings 'yajax.php' and 'main'.  'yajax.php' is the name of the script 
to post to and 'main' is the name of the form that contains the data to 
post.


Ok, now to the second part, the Javascript portion that implements this 
sendform() function using the Yahoo libs.  You could have this in a 
separate .js file, but to keep it simple I have just put it into the 
same file in the head section:


 
 
 

 

This might look a bit complex, but the first part just includes the 
Yahoo stuff.  YAHOO.js and connection.js which are part of the ZIP file 
you can get from here: http://developer.yahoo.com/yui/downloads/yui.zip
Next we have the callback function that will be called when we receive 
data back from the server.  This does an eval() which is simple, but if 
you don't trust your source you might want to use 
http://www.json.org/js.html instead.  After parsing the returned json we 
create an IMG tag, set some attributes on it and append it to the 
document body.  And finally the sendform function is a simple 2-liner 
that goes and fetches the form data from the passed in formName followed 
by the asynchronous backend request to the server.


The final part is the really easy part.  The server-side PHP part.

  $src = 
"http://api.local.yahoo.com/MapsService/V1/mapImage?appid=YahooDemo";;

  $src.= "&location=".urlencode($_GET['loc']).
 "&output=php&image_width=300&image_height=300&zoom=7";
  header("Content-type: application/x-json");
  echo json_encode(unserialize(file_get_contents($src)));
  exit;
}
?>

This makes a call to the Yahoo! map image api to get a map tile for the 
location the user entered and it returns the image url json-encoded. 
You will need the pecl/json extension installed do this encoding or 
failing that there is a PEAR JSON as well.


You are not going to be able to avoid writing a little bit of Javascript 
if you are going to do asynchronous backend requests (AJAX).  You need 
to send the request somehow from Javascript and you need to read the 
response in Javascript.  On the other hand, it is mostly just DOM 
manipulation so if you know DOM in PHP it isn't hard to pick up.


-Rasmus

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



[PHP] Re: mail() and exim

2006-04-07 Thread Manuel Lemos
Hello,

on 04/08/2006 12:11 AM Webmaster said the following:
> I'm not sure if this is the right list to ask this on or not
> 
> Here's the situation... my php scripts were generating emails as
> expected.  I was shocked when they told me that exim was not responding
> to requests on port 25 and had to be restarted.  So, PHP communicates
> with exim internally and doesn't have the need for ports as far as PHP
> generated emails go?  Can anyone describe how this communication takes
> place between PHP and exim (or any mail server for that matter)??  Is
> this why exim would not send my emails via thunderbird but would send
> them via PHP???

You are a bit confused, but that is a normal confusion. You do not need
an SMTP server to send messages. The role of the SMTP server is to
receive messages, not to send them. What sends messages is an MTA (Mail
Transfer Agent). Some SMTP servers are attached to MTA, so they can
receive messages to be resent to their final recipients.

PHP under Unix/Linux calls the sendmail program. Every Unix/Linux MTA
emulates sendmail, including exim. The sendmail program just attempts to
resend the message or queue it for later delivery attempt.

Thunderbird and other mail clients could use sendmail to deliver
messages if they were running on the same machine, but they do not
support it.

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



[PHP] mail() and exim

2006-04-07 Thread Webmaster

Hello,

I'm not sure if this is the right list to ask this on or not

Here's the situation... my php scripts were generating emails as 
expected.  I was shocked when they told me that exim was not responding 
to requests on port 25 and had to be restarted.  So, PHP communicates 
with exim internally and doesn't have the need for ports as far as PHP 
generated emails go?  Can anyone describe how this communication takes 
place between PHP and exim (or any mail server for that matter)??  Is 
this why exim would not send my emails via thunderbird but would send 
them via PHP???


Thanks!

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



Re: [PHP] Handling Large Select Boxes

2006-04-07 Thread Brad Ciszewski
Perhaps try implementing some AJAX on the page. Therefore, once the page has
loaded, the select tag is populated with different options, without actually
lagging the page.


""Jay Blanchard"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
[snip]
I have a form for user interaction and part of it is a select box with a

large number of options from a database ~12K options.
Currently I have a function which queries the DB to get fresh data and
loads the HTML (Y) into a string, so the DB is
only hit once,
but the page still takes a while to load.

Anyone else have any experience with something like this, or any other
helpful suggestions for making the page load time a little less
cumbersome?
[/snip]

If you are loading 12000 entries into a select box then that is way too
much. The gods of usability frown on you. Is there no way to make the
data selection slimmer?

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



[PHP] Re: Ajax please....

2006-04-07 Thread Manuel Lemos
Hello,

on 04/07/2006 09:21 PM Ryan A said the following:
> For some reason HTML_AJAX is not working on my local machine (windows based,
> I am getting runtime errors with the examples) and it seems quite

If that is XMLHttpRequest based, that is not surprising. Under IE6,
XMLHttpRequest objects are implemented by ActiveX objects, and for
security reasons Microsoft disabled ActiveX support by default since the
latest service packs.

Bjoern Schotte of ThinkPHP has warned about that in the past:

http://blog.thinkphp.de/archives/43-AJAX-redesign-your-PHP-applications.html

The problem is that XMLHttpRequest is the new new thing that many are
overexcited to use, as if it is the only or the best solution for
performing browser server interaction without page reload.

The truth is that XMLHttpRequest is very problematic and inviable in
many situations, not only due to ActiveX being disabled.

Even IFrame is a much better solution than using XMLHttpRequest for most
purposes people want to use AJAX, as you read below in this post:

http://www.phpclasses.org/blog/post/51-PHPClasses-20-Beta-AJAX-XMLHttpRequest-x-IFrame.html



> Hopefully after reading about my requirment(s) someone can suggest something
> thats really simple (or really well
> documented with examples)
> 
> Requirements:
> Write little or no JS
> When i submit the form, it should simply call my script and print out the
> answer inbetween the DIV tags

You may want to try this forms generation class. It comes with an AJAX
form submit plug-in that does exactly what you want: it generates the
necessary Javascript for you but you do not need to write a single line
of Javascript.

With a few lines of PHP you can instruct the class to generate a
response that can execute different types of actions, like adding or
replacing HTML parts of the page, like you want.


> This is what i want to use it for:
> Client comes to site, wants to make an account, I check if the username he
> entered is not already in use, if already in use I print out a failute
> message in red on the screen if not in usei make his account and print
> out a success text or redirect him to a success page.

With that class, it is very easy to achieve that. Here you can see an
example of that in action. It is not really a subscription page, but it
is a login page that shows similar browser server interaction:

http://www.phpclasses.org/login.html/v/2

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



Re: [PHP] Problem with require_once

2006-04-07 Thread chris smith
On 4/8/06, Pablo L. de Miranda <[EMAIL PROTECTED]> wrote:
> I has modified my code to this, notice wich all directories that I
> refer is in the root of application:
>
> // File Controller.php in directory controller:
> $file = '../util/ClassUtil.php';
> echo $file.'';
> include $file;
> $service = ClassUtil::loadClass('service.FormularioService');
> $service->helloWorld();
>
> // File ClassUtil.php in diretory util:
> class ClassUtil {
>
> function __construct() {
> echo 'Construindo objecto';
> }
>
> static public function loadClass($class) {
> $str = explode('.',$class) ;
> $className = $str[count($str) - 1];
>
> $obj = null;
>
> $exist = false;
> $scriptName = $_SERVER['SCRIPT_NAME'];
> $paths = explode('/', $scriptName);
> $url = 'http://'.$_SERVER['HTTP_HOST'];
> $appDir = $_SERVER['DOCUMENT_ROOT'];
>
> $class = str_replace(".", "/", $class);
> $path = "";
> for ($i = 0; $i < count($paths) - 1; $i ++) {
> $path .= '/'.$paths[$i];
> echo 'AppDir: '.$appDir.$path.'';
>
> $c = $appDir.$path.'/'.$class.'.php';
>
> while (strstr($c, '//'))
> $c = str_replace('//', '/', $c);
>
> echo 'Carregando classe: '.$c.'';
> if (file_exists($c)) {
> echo 'Carregando a URL: 
> '.$url.$path.'/'.$class.'.php';
> include $url.$path.'/'.$class.'.php';
> $exist = true;
> return new $className;
> }
>
> }
> if (!$exist)
> echo 'ERRO: O ARQUIVO NAO EXISTE!...';
> }
> }
>
> // File FormularioService.php in directory service:
> class FormularioService {
>
> public function helloWorld() {
> echo 'Hello World.';
> }
> }
> $serv = new FormularioService;
> $serv->helloWorld();
>
> And my output in the browser is that:
> ../util/ClassUtil.php
>
> argv: Array
> argc: 1
> AppDir: /var/www//
> Carregando classe: /var/www/service/FormularioService.php
>
> AppDir: /var/www///egressos
> Carregando classe: /var/www/egressos/service/FormularioService.php
> Carregando a URL: http://localhost//egressos/service/FormularioService.php
> Hello World.
>
> Fatal error: Class 'FormularioService' not found in
> /home/pldm/projetos/egressos/src/util/ClassUtil.php on line 44

What's in this file?

/var/www/egressos/service/FormularioService.php


(Always CC the list).

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] Creating a Photo Album

2006-04-07 Thread Paul Goepfert
updating by user click for now.  I might change that in the future to
update by interval.

Paul

On 4/7/06, tedd <[EMAIL PROTECTED]> wrote:
> At 12:13 AM -0700 4/7/06, Paul Goepfert wrote:
> >Hi all,
> >
> >I am postilng pictures up on a website.  So far I have a picture per
> >page. This will get not be very efficient as time goes on.  Is there
> >anyway that I can have one page with only the image updating?  Can
> >this be done in PHP.  If it can would someone explain it to me.  The
> >only thing I k.now how to do well in PHP is mysql queries and data
> >validatlion.
> >
> >Thanks,
> >Paul
>
> Paul:
>
> Updating how? By a time interval, by a user click, or what?
>
> tedd
> --
> 
> http://sperling.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] microtime questions

2006-04-07 Thread tedd

-B

At 12:51 PM -0400 4/7/06, Brad Bonkoski wrote:

How is the CPU not in question?  Does this script run on air?


I did not say that. I said that it was not MY CPU that was involved 
and it isn't.


It may not be YOUR CPU, but it is still a CPU bound by the sceduling 
algorithm of the Operating System, so the time differentials are too 
be expected.


Negative times are expected? Incorrect times are expected? What's the 
point of microtime if you can't reply on it?


Please explain.

tedd

--- previous ---


-B

tedd wrote:


At 12:24 PM -0400 4/7/06, Brad Bonkoski wrote:


Interesting...
as for your first question...
Know that PHP/Apache does not have free reign to your CPU, so the 
times could be different based on the scheduling going on in the 
OS kernel.


As for the second one...
No idea why you would get a negative number, I just copied and ran 
from the command line and did not encounter 1 negative time for 
about 30 runs


Do you get negative times if you run it from the command line as well?
-B


RE:

http://www.xn--ovg.com/microtime.php



Brad:

Thanks for looking.

My questions are with regard to what happens on the site, not via 
my command line. As such, my command line and my CPU are not 
involved.


Can you answer the questions as they pertain to the site in question?

Thanks.

tedd



--

http://sperling.com

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



Re: [PHP] Re: make global variables accessible to functions?

2006-04-07 Thread tedd

At 12:35 PM -0500 4/7/06, Bing Du wrote:

Thanks for the response.


 That way is secure and has nothing to do with register_globals ;)



Good.  That's what I wanted to hear.  I know by default some pre-defined
global variables can be accessed through $GLOBALS.  If I don't want end
users to add their own user defined variables in the superglobal area, how
should I do that?


 What you can do too is this:

 


Yeah, I know it works this way.  The reason I don't go this way is I have
quite a few variables that need to be passed to the function, it's not
feasible to pass all them as funtion parameters.

Bing


Bing:

Then pass them as an array by reference.

I seldom use Globals.

tedd
--

http://sperling.com

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



[PHP] Ajax please....

2006-04-07 Thread Ryan A
Hey,

Just been googleing and trying out different AJAX frameworks..:
>From PEAR HTML_AJAX
Gauva
My-Bic
AjaxAC
and quite a few moreand it happened, I confused myself :-(

For some reason HTML_AJAX is not working on my local machine (windows based,
I am getting runtime errors with the examples) and it seems quite
bulky. I have even tried the YAHOO one, which Rasmus suggested to another
guy some time back (found it
after looking in the archives) unfortunatly could not find much
documentation that I could understand...

Hopefully after reading about my requirment(s) someone can suggest something
thats really simple (or really well
documented with examples)

Requirements:
Write little or no JS
When i submit the form, it should simply call my script and print out the
answer inbetween the DIV tags


This is what i want to use it for:
Client comes to site, wants to make an account, I check if the username he
entered is not already in use, if already in use I print out a failute
message in red on the screen if not in usei make his account and print
out a success text or redirect him to a success page.
THATS IT, nothing too fancy.

Thanks in advance.

Cheers,
Ryan

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



Re: [PHP] IF or SWITCH (asinine?)

2006-04-07 Thread Ray Hauge
On Friday 07 April 2006 16:41, tedd wrote:
> Note, it's not actually required to have a variable to be evaluated
> for each case statement. Each case statement stands on it's own
> independent from the evaluation.
>
> This has always worked for me in other languages and I am assuming
> that it works the same in php.
>
> Does anyone disagree or will correct me?
>
> HTH's.
>
> tedd

You are right.  It does work that way.  My opinion just differs in that I 
think ELSEIF works better in that situation than SWITCH, and SWITCH is better 
for a single value comparison than ELSEIF.

I think that by now people will have been able to form their own conclusions 
as to which style they prefer, and either is probably more readable than 
putting everyone all on one line :-P

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
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] int to string

2006-04-07 Thread tedd

At 10:50 PM -0400 4/6/06, sgsweb wrote:

Hi Tanner,

Here's a completely working piece of code that I got from my hosting 
company.  This looks like it does exactly what you want to do.  I am 
also including the output in the bottom of this e-mail.



sunil.

Was that for php 5? I couldn't get it to run under 4.

tedd
--

http://sperling.com

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



Re: [PHP] IF or SWITCH (asinine?)

2006-04-07 Thread tedd

Anyways, I think this debate is pretty much pointless now, you've
clarified your point of view (sort of) and I'll just run with the final
though that you limit your use of switch to case where elseif would be
needed... and to clarify on my part once more, I did not call that
asinine.

Cheers,
Rob.


Rob:

Okay.

Please accept my public apology for our misunderstanding.

tedd
--

http://sperling.com

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



Re: [PHP] Problem with require_once

2006-04-07 Thread chris smith
On 4/8/06, Pablo L. de Miranda <[EMAIL PROTECTED]> wrote:
> Hey Guys,
> I have the code below:
>
> $file = $_SERVER['HTTP_REFERER'].'util/ClassUtil.php';
> echo $file.'';
> require_once($file);
>
> $service = ClassUtil::loadClass('service.FormularioService');
>
> And the output in browser:
>
> http://localhost/egressos/util/ClassUtil.php
>
> Fatal error: Class 'ClassUtil' not found in
> /home/pldm/projetos/egressos/src/controller/Controller.php on line 27

This is a different file - is it included by
$_SERVER['HTTP_REFERER'].'util/ClassUtil.php' ?

PS - Relyig on the referrer for something like this is extremely dangerous.

--
Postgresql & php tutorials
http://www.designmagick.com/

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



Re: [PHP] IF or SWITCH (asinine?)

2006-04-07 Thread tedd

 > Personally, as I said before, I use if/else for two conditions and

 switch for three or more. Your mileage may vary, but it's truly a

 > matter of choice and is not one of asinine methodology.



 > tedd




I think that's a fairly good methodology to follow.  I usually do that...
except when I run into a huge list of multiple conditions for each
possibility (TRUE && FALSE OR FALSE && TRUE) etc.  To me IF/ELSEIF is easier
to ready in that case,


The true && false scenarios require me to work up a truth table, for 
I have great difficulty figuring that out in my head.



and SWITCH is a LOT easier to read if you have one
variable and have a CASE for each possibility of that variable.


I believe (until someone informs me otherwise) that your statement 
above is a common misconception of the switch conditional -- you 
don't need a single variable to evaluate. Case in point, try this 
(taken from your own code).


$who_cares = 1;
switch ($who_cares)
{
case $numFFELP > 1 && count($FFELP_Lenders) > 1 && $numFFELP == $numTotal:
$retVal = array(TRUE, 'A');
break;

case $numFFELP > 0 && $enumFFELP > 0 && count($FFELP_Lenders) > 1 &&
$enumFFELP + $numFFELP == $numTotal:
$retVal = array(TRUE, 'A');
break;
}

Note, it's not actually required to have a variable to be evaluated 
for each case statement. Each case statement stands on it's own 
independent from the evaluation.


This has always worked for me in other languages and I am assuming 
that it works the same in php.


Does anyone disagree or will correct me?

HTH's.

tedd

--

http://sperling.com

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



Re: [PHP] Zend Certification

2006-04-07 Thread Anthony Ettinger
if it's job related, you may even get your co. to pay for it.

On 4/7/06, Jad madi <[EMAIL PROTECTED]> wrote:
>
> in my case the salary increment is more valuable than the $400
>
>
>
> On Sat, 2006-04-08 at 00:24 +0200, Rory Browne wrote:
> > My info may be dated but AFAIK the exam is $200 - so what if you have
> > to take one one month and another the next? That (assuming PHP5 was
> > the same price) would still only be $400. I don't want to sound petty,
> > but what's another $200 for a second certification - having both will
> > give you that long_time_user status.
> >
> > On 4/7/06, Jad madi <[EMAIL PROTECTED]> wrote:
> > If taking the exam now makes different to you then go for it,
> > actually I
> > scheduled the exam 29 April bluntly just for the sake of
> > salary
> > increment heh
> >
> >
> >
> > On Fri, 2006-04-07 at 14:33 -0700, Ray Hauge wrote:
> > > Hello All,
> > >
> > > I've been thinking about taking the ZCE test.  I want to,
> > but I also want it
> > > to be current for as long as possible.  Should I wait for it
> > to be revised
> > > for PHP5, or are they even going to update it?  I just don't
> > want to end up
> > > taking it and then a few months later have it be "outdated"
> > because it was
> > > for PHP4, and not PHP5.
> > >
> > > Thanks,
> > > --
> > > Ray Hauge
> > > Programmer/Systems Administrator
> > > American Student Loan Services
> > > www.americanstudentloan.com
> > > 1.800.575.1099
> > >
> >
> > --
> > 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
>
>
>


--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html


Re: [PHP] Problem with require_once

2006-04-07 Thread Anthony Ettinger
can you do a dump of what $file is?

Seems the path is incorrect.

On 4/7/06, Pablo L. de Miranda <[EMAIL PROTECTED]> wrote:
>
> Hey Guys,
> I have the code below:
>
> $file = $_SERVER['HTTP_REFERER'].'util/ClassUtil.php';
> echo $file.'';
> require_once($file);
>
> $service = ClassUtil::loadClass('service.FormularioService');
>
> And the output in browser:
>
> http://localhost/egressos/util/ClassUtil.php
>
> Fatal error: Class 'ClassUtil' not found in
> /home/pldm/projetos/egressos/src/controller/Controller.php on line 27
>
> But, the file that I pass to require_once exist in the server...
> If someone know the problem, please sende a answer...
>
> Thank you,
>
> Pablo
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html


Re: [PHP] xsl / xslt in php 4+

2006-04-07 Thread Anthony Ettinger
My ISP has php5 with all the xml goodies installed, I'm not sure if that's
typical or not, php5 is still relatively new for shared hosting providers to
rollout. My previous ISP only has php 4.



On 4/7/06, jonathan <[EMAIL PROTECTED]> wrote:
>
> I'm working on a piece of an application that we'd like to distribute
> to other sites. Basically, it would be a REST application where the
> client would transform the xml into html. I'd like to xsl for the
> transformation but was curious about how prevelant xsl is installed
> in a shared hosting environment. Is this  a bad assumption? I'm
> pretty sure that both amazon uses a REST interface with the client
> transforming on the browser. What would be alternatives that could be
> achieved in a shared hosting environment?
>
> -j
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>


--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html


Re: [PHP] how to kill session id without closing the window?

2006-04-07 Thread tedd

At 9:19 PM +0200 4/6/06, [EMAIL PROTECTED] wrote:

Hi to all,

session_start();
$_SESSION['sessid'] = session_id;

echo $_SESSION['sessid']; will show e.g. 699e506bd42ea402985dce24a0ef9

After:

unset($_SESSION['sessid']);

$_SESSION['sessid'] = session_id();

I'm getting the same SID again.

I tried with session_unregister() and session_destroy() but same result.

How can I create new, other sesssion id (after I, for example, click on
'Log Out' button) without closing window?

Thanks for any help.



Look up:

http://www.weberdev.com/session_regenerate_id

HTH's

tedd


--

http://sperling.com

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



Re: [PHP] Help with a complex scenario

2006-04-07 Thread tedd

At 4:59 PM -0400 4/7/06, Robert Fitzpatrick wrote:

I have an order table that we are trying to figure out a way to find the
best (cheapest) scenario to sending to vendors to fill the orders. Let's
say we have 10 parts ordered, if we split that amongst vendors, even
paying a higher shipping cost in some cases can be cheaper. We can send
2 of those parts from this vendor and 3 from another and so on. We have
an ID, price, ship price and vendor to consider that is retrieved via
the api with each vendor. Does anyone have experience in trying to find
all the scenario possibilities?

--
Robert


Yeah, every time I buy something on eBay -- it's a pretty simple 
problem, don't you think?


tedd
--

http://sperling.com

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



Re: [PHP] getimagesize()

2006-04-07 Thread tedd

At 9:14 AM -0500 4/7/06, Ed Curtis wrote:

 Can you call getimagesize() multiple times in one script? I'm trying to
use it multiple times but it only seems to work in the first loop I call
it in. I read something in the docs about it cacheing the results and
didn't know if this has something to do with it.

 I also tried creating an array out of the results I get from it but it
will only output the size values when it's building the array, never when
I try to loop back through it and output the values.

Thanks,

Ed


Ed:

Have you tried flush?

http://www.weberdev.com/flush

or

http://www.weberdev.com/ob_flush

I haven't used that before, but that's where I would start.

HTH's.

tedd
--

http://sperling.com

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



Re: [PHP] Creating a Photo Album

2006-04-07 Thread tedd

At 12:13 AM -0700 4/7/06, Paul Goepfert wrote:

Hi all,

I am postilng pictures up on a website.  So far I have a picture per
page. This will get not be very efficient as time goes on.  Is there
anyway that I can have one page with only the image updating?  Can
this be done in PHP.  If it can would someone explain it to me.  The
only thing I k.now how to do well in PHP is mysql queries and data
validatlion.

Thanks,
Paul


Paul:

Updating how? By a time interval, by a user click, or what?

tedd
--

http://sperling.com

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



Re: [PHP] Argument passed by reference?

2006-04-07 Thread tedd

At 1:52 PM -0500 4/6/06, Chris Boget wrote:
The way I understand it, pass by reference in php is determined in 
the function definition and not the function call. Something like:


You used to be able to pass by reference at run time.  But I see that is
no longer allowed... :|  So I guess that makes my question moot.

Thanks for your help.

thnx,
Chris


Chris:

Please forgive my ignorance, but when did that happen?

tedd
--

http://sperling.com

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



Re: [PHP] Argument passed by reference?

2006-04-07 Thread tedd

At 1:24 PM -0500 4/6/06, Chris Boget wrote:
Is there a way to test to see if a function argument was passed by 
reference instead of by value?


thnx,
Chris


Chris:

As I am sure you know, passing by reference is simply passing the 
memory address of the variable to a function instead of it's value. 
If the receiving function does something to the variable at that 
address, then the value at that address is changed. You can test this 
by simply checking the value before and after it's returned from the 
function.


For example, the following just passes the memory address of variable 
$a to a function. After which, the function alters the variable at 
that memory address, but doe not return a value. But, echoing the 
variable after the function call shows that the variable has indeed 
been altered.


");
ref(&$a);
echo("$a");
?>




HTH's

tedd

--

http://sperling.com

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



Re: [PHP] Re: Parsing variables within string variables

2006-04-07 Thread Paul Novitski

At 02:41 PM 4/7/2006, David Clough wrote:

I have to parse the string 'Hello $foo' as it comes from the
database: I don't get to construct it.

I did hold out more hope for the eval function, but it seems to me that
this is for PHP code in a database, not to evaluate variables.



David, please try the eval() route: it will do what you want.  You 
say, "this is for PHP code in a database, not to evaluate variables," 
but evaluating variables is absolutely part of PHP code 
processing!  Eval() will operate on "$x = 4;" just as easily as on 
"Hello $foo."


You should not use eval() frivolously because it presents a potential 
vulnerability in your code.  You may wish to ensure that the database 
text it operates on is first cleansed of any other PHP syntax -- 
similarly to the way we should all ensure that any incoming data is 
clean before we process it and incorporate it into our scripts.


Here's an example of variaible evaluation:
___

$bar = "cat";
$foo = "Hello \$bar.";

echo $foo;
RESULT: Hello $bar.

By escaping the $, I have made it a literal character in the text, 
the same as if I'd read "Hello $bar" from a database.

___

eval("echo \"$foo\";");
RESULT: Hello cat.

This is equivalent to scripting:
echo "$foo";
I'm using eval() to execute the echo command and interpret the PHP 
variable $foo.

___

eval("\$dog = \$bar;");
echo "dog = " . $dog;

RESULT: dog = cat

Here I'm using eval() to set one PHP variable equal to another.
___

You can't simply write:
eval("\$bar;");
or
$x = eval($foo);

because everything inside the eval() parentheses needs to be a 
complete PHP statement.  The eval() function itself doesn't return 
the value of an evaluated expression.  To capture the value of an 
expression, you must evaluate a complete statement that sets a 
variable equal to the expression as above.

___

Clear as mud?

Regards,
Paul 


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



[PHP] xsl / xslt in php 4+

2006-04-07 Thread jonathan
I'm working on a piece of an application that we'd like to distribute  
to other sites. Basically, it would be a REST application where the  
client would transform the xml into html. I'd like to xsl for the  
transformation but was curious about how prevelant xsl is installed  
in a shared hosting environment. Is this  a bad assumption? I'm  
pretty sure that both amazon uses a REST interface with the client  
transforming on the browser. What would be alternatives that could be  
achieved in a shared hosting environment?


-j

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



Re: [PHP] Zend Certification

2006-04-07 Thread Jad madi
in my case the salary increment is more valuable than the $400 



On Sat, 2006-04-08 at 00:24 +0200, Rory Browne wrote:
> My info may be dated but AFAIK the exam is $200 - so what if you have
> to take one one month and another the next? That (assuming PHP5 was
> the same price) would still only be $400. I don't want to sound petty,
> but what's another $200 for a second certification - having both will
> give you that long_time_user status. 
> 
> On 4/7/06, Jad madi <[EMAIL PROTECTED]> wrote:
> If taking the exam now makes different to you then go for it,
> actually I
> scheduled the exam 29 April bluntly just for the sake of
> salary
> increment heh
> 
> 
> 
> On Fri, 2006-04-07 at 14:33 -0700, Ray Hauge wrote: 
> > Hello All,
> >
> > I've been thinking about taking the ZCE test.  I want to,
> but I also want it
> > to be current for as long as possible.  Should I wait for it
> to be revised
> > for PHP5, or are they even going to update it?  I just don't
> want to end up 
> > taking it and then a few months later have it be "outdated"
> because it was
> > for PHP4, and not PHP5.
> >
> > Thanks,
> > --
> > Ray Hauge
> > Programmer/Systems Administrator
> > American Student Loan Services
> > www.americanstudentloan.com
> > 1.800.575.1099
> >
> 
> --
> 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] Problem with require_once

2006-04-07 Thread Pablo L. de Miranda
Hey Guys,
I have the code below:

$file = $_SERVER['HTTP_REFERER'].'util/ClassUtil.php';
echo $file.'';
require_once($file);

$service = ClassUtil::loadClass('service.FormularioService');

And the output in browser:

http://localhost/egressos/util/ClassUtil.php

Fatal error: Class 'ClassUtil' not found in
/home/pldm/projetos/egressos/src/controller/Controller.php on line 27

But, the file that I pass to require_once exist in the server...
If someone know the problem, please sende a answer...

Thank you,

Pablo

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



Re: [PHP] Zend Certification

2006-04-07 Thread Ray Hauge
On Friday 07 April 2006 15:24, Rory Browne wrote:
> having both will give you that long_time_user status.

Good point.  Thanks :)

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
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] Zend Certification

2006-04-07 Thread Rory Browne
My info may be dated but AFAIK the exam is $200 - so what if you have to
take one one month and another the next? That (assuming PHP5 was the same
price) would still only be $400. I don't want to sound petty, but what's
another $200 for a second certification - having both will give you that
long_time_user status.

On 4/7/06, Jad madi <[EMAIL PROTECTED]> wrote:
>
> If taking the exam now makes different to you then go for it, actually I
> scheduled the exam 29 April bluntly just for the sake of salary
> increment heh
>
>
>
> On Fri, 2006-04-07 at 14:33 -0700, Ray Hauge wrote:
> > Hello All,
> >
> > I've been thinking about taking the ZCE test.  I want to, but I also
> want it
> > to be current for as long as possible.  Should I wait for it to be
> revised
> > for PHP5, or are they even going to update it?  I just don't want to end
> up
> > taking it and then a few months later have it be "outdated" because it
> was
> > for PHP4, and not PHP5.
> >
> > Thanks,
> > --
> > Ray Hauge
> > Programmer/Systems Administrator
> > American Student Loan Services
> > 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] Zend Certification

2006-04-07 Thread Jad madi
If taking the exam now makes different to you then go for it, actually I
scheduled the exam 29 April bluntly just for the sake of salary
increment heh



On Fri, 2006-04-07 at 14:33 -0700, Ray Hauge wrote:
> Hello All,
> 
> I've been thinking about taking the ZCE test.  I want to, but I also want it 
> to be current for as long as possible.  Should I wait for it to be revised 
> for PHP5, or are they even going to update it?  I just don't want to end up 
> taking it and then a few months later have it be "outdated" because it was 
> for PHP4, and not PHP5.
> 
> Thanks,
> -- 
> Ray Hauge
> Programmer/Systems Administrator
> American Student Loan Services
> 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] Parsing variables within string variables

2006-04-07 Thread David Clough
Dear Paul,

this is exactly the problem: the string including the dollar sign comes 
from the database.

The problem I have is that the echo statement parses the $bar reference, 
but not the $foo reference within it.

So

   echo $bar

generates

   Hello $foo

which is better than 

   $bar

but doesn't get as far as

   Hello cat

What I think I need is to send the results of the first echo to a second 
echo for parsing. Is there some way of doing that?

Thanks for any help...

   David.

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Paul Novitski) wrote:

> I wrote:
> >You need to EVALUATE the string coming from the database:
> >
> >Assuming that $sDataField contains the string 'Hello $foo':
> >
> > $foo = "cat";
> > $sText = eval($sDataField);
> >
> >RESULT: $sText = "Hello cat"
> >
> >http://php.net/eval
> 
> 
> I was assuming that you meant that the string "Hello $foo" -- 
> including the dollar sign -- came from the database.
> 
> If $foo exists as a native PHP variable, I'd want to see your actual 
> code to tell why it's not being properly evaluated by the parser.
> 
> Sometimes you need to use curly braces to help the PHP interpreter 
> differentiate a variable from the surrounding text:
> 
>  $bar = "Hello ${foo}amaran";
> 
> If you escape the dollar sign, the variable won't be evaluated:
> 
>  $bar = "Hello \$foo";
>  RESULT: "Hello $foo"
> 
> Paul

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



[PHP] Re: Parsing variables within string variables

2006-04-07 Thread David Clough
Thanks for all these responses, but unless I'm missing something none of 
them work for what I need. Quotes are irrelevant: with the string "Hello 
$foo" in $bar

   echo "$bar"
   echo $bar

both produce
   
   Hello $foo

and

   echo '$bar'

produces
   
   $bar

I can't use any of the answers like

   'Hello'.$foo

because I have to parse the string 'Hello $foo' as it comes from the 
database: I don't get to construct it.

I did hold out more hope for the eval function, but it seems to me that 
this is for PHP code in a database, not to evaluate variables.

If anyone else can provide the silver bullet, I will be very grateful.

   David.

In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (David Clough) wrote:

> I've been bashing my head against the wall on this, and would be glad of 
> help to stop. 
> 
> I have a variable containing a string that contains the names of 
> variables, and want to output the variable with the variables it 
> contains evaluated. E.g. 
> 
>$foo contains 'cat'
>$bar contains 'Hello $foo'
> 
> and I want to output $bar as 
> 
>Hello cat
> 
> The problem is that if I use
> 
>echo $bar
> 
> I just get
> 
>Hello $foo
> 
> Note that $bar is loaded from a database query, so I can't control its 
> contents: I just have to parse it.
> 
> Any help appreciated.
> 
> David.

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



[PHP] Zend Certification

2006-04-07 Thread Ray Hauge
Hello All,

I've been thinking about taking the ZCE test.  I want to, but I also want it 
to be current for as long as possible.  Should I wait for it to be revised 
for PHP5, or are they even going to update it?  I just don't want to end up 
taking it and then a few months later have it be "outdated" because it was 
for PHP4, and not PHP5.

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

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



[PHP] Help with a complex scenario

2006-04-07 Thread Robert Fitzpatrick
I have an order table that we are trying to figure out a way to find the
best (cheapest) scenario to sending to vendors to fill the orders. Let's
say we have 10 parts ordered, if we split that amongst vendors, even
paying a higher shipping cost in some cases can be cheaper. We can send
2 of those parts from this vendor and 3 from another and so on. We have
an ID, price, ship price and vendor to consider that is retrieved via
the api with each vendor. Does anyone have experience in trying to find
all the scenario possibilities?

-- 
Robert

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



Re: [PHP] Parse Error on SQL Insert

2006-04-07 Thread Joe Henry
On Friday 07 April 2006 1:56 pm, Chrome wrote:
> Backticks (`) encapsulate table or database names
>
> I was thinking maybe if the array references were encapsulated in curly
> braces {}:
>
> $_POST['model'] to {$_POST['model']}
>
> Of course if the field in the DB isn't numeric this would be
> '{$_POST['model']}'
>
> Dan
>
> ---
> http://chrome.me.uk
>
>
> -Original Message-
> From: Joe Henry [mailto:[EMAIL PROTECTED]
> Sent: 07 April 2006 20:53
> To: php-general@lists.php.net; [EMAIL PROTECTED]
> Subject: Re: [PHP] Parse Error on SQL Insert
>
> On Friday 07 April 2006 1:37 pm, Tom Chubb wrote:
> > $insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,
>
> Not sure if this is your problem, but those look like backticks around year
> instead of single quotes. Should there even be quotes there?
>
> HTH
> --
> Joe Henry
> www.celebrityaccess.com
> [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
> __ NOD32 1.1475 (20060406) Information __
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com

Good to know. Thanks.

-- 
Joe Henry
www.celebrityaccess.com
[EMAIL PROTECTED]

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



Re: [PHP] Parse Error on SQL Insert

2006-04-07 Thread Satyam

Mi vote goes to the curly braces

The error is given by php, not by SQL

When exploding variables within double quotes it is hard for php to 
distinguish when a variable end unless it is a simple variable like $foo. 
When it is an array element and even worst, when it is an element of a 
multidimensional array, php cannot assert when it is over  (really, it is 
not a bug, try to figure out how to do it and you'll see it is not easy) so 
you tell php by enclosing the whole variable in curly braces.


Which it says so in the manual

Satyam
- Original Message - 
From: "Chrome" <[EMAIL PROTECTED]>
To: "'Joe Henry'" <[EMAIL PROTECTED]>; ; 
<[EMAIL PROTECTED]>

Sent: Friday, April 07, 2006 9:56 PM
Subject: RE: [PHP] Parse Error on SQL Insert



Backticks (`) encapsulate table or database names

I was thinking maybe if the array references were encapsulated in curly
braces {}:

$_POST['model'] to {$_POST['model']}

Of course if the field in the DB isn't numeric this would be
'{$_POST['model']}'

Dan

---
http://chrome.me.uk


-Original Message-
From: Joe Henry [mailto:[EMAIL PROTECTED]
Sent: 07 April 2006 20:53
To: php-general@lists.php.net; [EMAIL PROTECTED]
Subject: Re: [PHP] Parse Error on SQL Insert

On Friday 07 April 2006 1:37 pm, Tom Chubb wrote:

$insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,


Not sure if this is your problem, but those look like backticks around 
year

instead of single quotes. Should there even be quotes there?

HTH
--
Joe Henry
www.celebrityaccess.com
[EMAIL PROTECTED]

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


__ NOD32 1.1475 (20060406) Information __

This message was checked by NOD32 antivirus system.
http://www.eset.com

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




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



Re: [PHP] Parse Error on SQL Insert

2006-04-07 Thread Ray Hauge
On Friday 07 April 2006 12:56, Chrome wrote:
> Of course if the field in the DB isn't numeric this would be
> '{$_POST['model']}'
>
> Dan

That's what I was thinking.  Even if data is a number, I still generally put 
quotes around it to make sure I don't have an issue.

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
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 on SQL Insert

2006-04-07 Thread John Nichel

Tom Chubb wrote:

Complete code...



  $insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,
image2, image3, forsale) VALUES ($_POST['model'], $_POST['year'],
$_POST['details'], $_POST['price'], $_FILE['image']['name'][0],
$_FILE['image']['name'][1], $_FILE['image']['name'][2], $_POST['forsale'])";



Looks like a problem with your input data.  Escape it.  You should be 
escaping it anyway, and not putting raw user input into your db.



The reason for the single quotes around the year is something to do with
Dreamweaver's insert wizard.


"year" is a special word in MySQL.  The back ticks are to let MySQL know 
that it's a column name.  Without the back ticks, MySQL will 'guess', 
but that can cause problems...best to just back tick all the column 
names anyway.


--
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 on SQL Insert

2006-04-07 Thread Brad Bonkoski
thanks for the clarification, I guess the other solution would be to 
avoid using names with special meaning for column names...

-B

Ray Hauge wrote:


On Friday 07 April 2006 12:53, Joe Henry wrote:
 


On Friday 07 April 2006 1:37 pm, Tom Chubb wrote:
   


$insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,
 


Not sure if this is your problem, but those look like backticks around year
instead of single quotes. Should there even be quotes there?

HTH
--
Joe Henry
www.celebrityaccess.com
[EMAIL PROTECTED]
   



The backticks should be fine.  They tell MySQL that you mean the column "year" 
of the table "cars" and not the MySQL special word "year" which can be used 
in date calculations.  The same thing would apply if you wanted a column 
named "create".


I would agree with John on the POST data.  Make sure you at least run 
mysql_real_escape_string().


 



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



RE: [PHP] Parse Error on SQL Insert

2006-04-07 Thread Chrome
Backticks (`) encapsulate table or database names

I was thinking maybe if the array references were encapsulated in curly
braces {}:

$_POST['model'] to {$_POST['model']}

Of course if the field in the DB isn't numeric this would be
'{$_POST['model']}'

Dan
 
---
http://chrome.me.uk
 

-Original Message-
From: Joe Henry [mailto:[EMAIL PROTECTED] 
Sent: 07 April 2006 20:53
To: php-general@lists.php.net; [EMAIL PROTECTED]
Subject: Re: [PHP] Parse Error on SQL Insert

On Friday 07 April 2006 1:37 pm, Tom Chubb wrote:
> $insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,

Not sure if this is your problem, but those look like backticks around year 
instead of single quotes. Should there even be quotes there?

HTH
-- 
Joe Henry
www.celebrityaccess.com
[EMAIL PROTECTED]

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


__ NOD32 1.1475 (20060406) Information __

This message was checked by NOD32 antivirus system.
http://www.eset.com

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



Re: [PHP] Parse Error on SQL Insert

2006-04-07 Thread Ray Hauge
On Friday 07 April 2006 12:53, Joe Henry wrote:
> On Friday 07 April 2006 1:37 pm, Tom Chubb wrote:
> > $insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,
>
> Not sure if this is your problem, but those look like backticks around year
> instead of single quotes. Should there even be quotes there?
>
> HTH
> --
> Joe Henry
> www.celebrityaccess.com
> [EMAIL PROTECTED]

The backticks should be fine.  They tell MySQL that you mean the column "year" 
of the table "cars" and not the MySQL special word "year" which can be used 
in date calculations.  The same thing would apply if you wanted a column 
named "create".

I would agree with John on the POST data.  Make sure you at least run 
mysql_real_escape_string().

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
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 on SQL Insert

2006-04-07 Thread Tom Chubb
Complete code...



http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
http://www.w3.org/1999/xhtml";>


Untitled Document




  

  Model:
  


  Year:
  


  Details:



  Price:
  
  


  Image1:
  


  Image2:
  


  Image3:
  


  Forsale:
  


   
  

  
  

 





The reason for the single quotes around the year is something to do with
Dreamweaver's insert wizard.



On 07/04/06, Brad Bonkoski <[EMAIL PROTECTED]> wrote:
>
> why do you have single quotes around year?
> -B
>
> Tom Chubb wrote:
>
> >I'm working on an insert record page with a multiple file upload script
> of
> >which I understand the fundamentals.
> >However, on submission I am getting the following error:
> >
> >Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE,
> expecting
> >T_STRING or T_VARIABLE or T_NUM_STRING in
> >C:\apache2triad\htdocs\damotors\admin\insertnew.php on line 34
> >
> >Where line 34 is...
> >
> >$insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,
> >image2, image3, forsale) VALUES ($_POST['model'], $_POST['year'],
> >$_POST['details'], $_POST['price'], $_FILE['image']['name'][0],
> >$_FILE['image']['name'][1], $_FILE['image']['name'][2],
> $_POST['forsale'])";
> >
> >
> >For info, the HTML for the form is as follows:
> >
> >
> >  Image1:
> >  
> >
> >
> >  Image2:
> >  
> >
> >
> >  Image3:
> >  
> >
> >
> >I've been slaving away for an hour and it's probably something really
> >obvious but I'd really appreciate it if someone could point it out to me
> >please?
> >Previously I was getting an "image1 cannot be null" error which I
> couldn't
> >work out either. That's gone, but I still can't work out what's going on.
> >
> >Many thanks,
> >
> >Tom
> >
> >
> >
> >--
> >Tom Chubb
> >[EMAIL PROTECTED]
> >07915 053312
> >
> >
> >
>
>


--
Tom Chubb
[EMAIL PROTECTED]
07915 053312


Re: [PHP] Parse Error on SQL Insert

2006-04-07 Thread Joe Henry
On Friday 07 April 2006 1:37 pm, Tom Chubb wrote:
> $insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,

Not sure if this is your problem, but those look like backticks around year 
instead of single quotes. Should there even be quotes there?

HTH
-- 
Joe Henry
www.celebrityaccess.com
[EMAIL PROTECTED]

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



Re: [PHP] Parse Error on SQL Insert

2006-04-07 Thread Brad Bonkoski

why do you have single quotes around year?
-B

Tom Chubb wrote:


I'm working on an insert record page with a multiple file upload script of
which I understand the fundamentals.
However, on submission I am getting the following error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
C:\apache2triad\htdocs\damotors\admin\insertnew.php on line 34

Where line 34 is...

$insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,
image2, image3, forsale) VALUES ($_POST['model'], $_POST['year'],
$_POST['details'], $_POST['price'], $_FILE['image']['name'][0],
$_FILE['image']['name'][1], $_FILE['image']['name'][2], $_POST['forsale'])";


For info, the HTML for the form is as follows:

   
 Image1:
 
   
   
 Image2:
 
   
   
 Image3:
 
   

I've been slaving away for an hour and it's probably something really
obvious but I'd really appreciate it if someone could point it out to me
please?
Previously I was getting an "image1 cannot be null" error which I couldn't
work out either. That's gone, but I still can't work out what's going on.

Many thanks,

Tom



--
Tom Chubb
[EMAIL PROTECTED]
07915 053312

 



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



Re: [PHP] Parse Error on SQL Insert

2006-04-07 Thread John Nichel

Tom Chubb wrote:

I'm working on an insert record page with a multiple file upload script of
which I understand the fundamentals.
However, on submission I am getting the following error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
C:\apache2triad\htdocs\damotors\admin\insertnew.php on line 34

Where line 34 is...

$insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,
image2, image3, forsale) VALUES ($_POST['model'], $_POST['year'],
$_POST['details'], $_POST['price'], $_FILE['image']['name'][0],
$_FILE['image']['name'][1], $_FILE['image']['name'][2], $_POST['forsale'])";



I've been slaving away for an hour and it's probably something really
obvious but I'd really appreciate it if someone could point it out to me
please?
Previously I was getting an "image1 cannot be null" error which I couldn't
work out either. That's gone, but I still can't work out what's going on.



Without seeing more code (the error is probably above line 34), I can 
only guess that the problem is with your posted data.  Escape your data 
before you insert it into a db.


--
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] Parse Error on SQL Insert

2006-04-07 Thread Tom Chubb
I'm working on an insert record page with a multiple file upload script of
which I understand the fundamentals.
However, on submission I am getting the following error:

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting
T_STRING or T_VARIABLE or T_NUM_STRING in
C:\apache2triad\htdocs\damotors\admin\insertnew.php on line 34

Where line 34 is...

$insertSQL = "INSERT INTO cars (model, `year`, details, price, image1,
image2, image3, forsale) VALUES ($_POST['model'], $_POST['year'],
$_POST['details'], $_POST['price'], $_FILE['image']['name'][0],
$_FILE['image']['name'][1], $_FILE['image']['name'][2], $_POST['forsale'])";


For info, the HTML for the form is as follows:


  Image1:
  


  Image2:
  


  Image3:
  


I've been slaving away for an hour and it's probably something really
obvious but I'd really appreciate it if someone could point it out to me
please?
Previously I was getting an "image1 cannot be null" error which I couldn't
work out either. That's gone, but I still can't work out what's going on.

Many thanks,

Tom



--
Tom Chubb
[EMAIL PROTECTED]
07915 053312


RE: [PHP] code obfuscating

2006-04-07 Thread Jay Blanchard
[snip]
>[snip]
>Am seeking for a solution to obfuscate php code on the server side, so
>if i decide to sell php closed source applications, i can encode the
>source code.
>
>Thanks for your help
>[/snip]
>
>No problem, we are always glad to answer questions. You're welcome.
>
>

Hey Jay,

Better add to that.  Bring the light down slowly as the pouring rain 
ascends - critical.
[/snip]

Friday afternoons, when I am left to tend the shop after an 80 hour
week.

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



RE: [PHP] code obfuscating

2006-04-07 Thread Miles Thompson

At 04:05 PM 4/7/2006, you wrote:


[snip]
Am seeking for a solution to obfuscate php code on the server side, so
if i decide to sell php closed source applications, i can encode the
source code.

Thanks for your help
[/snip]

No problem, we are always glad to answer questions. You're welcome.




Hey Jay,

Better add to that.  Bring the light down slowly as the pouring rain 
ascends - critical.


Miles



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.385 / Virus Database: 268.3.5/303 - Release Date: 4/6/2006

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



Re: [PHP] Completing forms offline with PHP/MySQL

2006-04-07 Thread Miles Thompson

At 01:06 PM 4/7/2006, Kevin Davies - Bonhurst Consulting wrote:


Hi,

Apologies if this is the wrong place for this question, but I'm sure there
are some experts out there who might be able to point me in the right
direction... :)

I'm doing some work at the moment where remote teams can submit reports
through to our database when connected over the internet to our server.
However, I've been asked to look in the possibility of the teams completing
the form offline, and uploading when they have access to a connection.

It looks like I might be able offer something like Microsoft InfoPath forms
(better recommendations?) to generate an XML file, and then use a PHP file
to upload the file into the database. Additionally, I could also do with
this process uploading a number of other files (e.g. images, text files) to
the server.

Does anyone have any experience in this area, and would be able to recommend
a solution?

Thanks in advance for your help...

Kevin



PHP-GTK+
GTK+ front end, laid out using wGlade (which creates an XML-like file with 
a .glade extension), and of course, PHP for all of your logic.


Works

Miles 



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.1.385 / Virus Database: 268.3.5/303 - Release Date: 4/6/2006

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



RE: [PHP] code obfuscating

2006-04-07 Thread Jay Blanchard
[snip]
Am seeking for a solution to obfuscate php code on the server side, so
if i decide to sell php closed source applications, i can encode the
source code.

Thanks for your help
[/snip]

No problem, we are always glad to answer questions. You're welcome.





















Did you google?

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



RE: [PHP] PHP Book Recommendation

2006-04-07 Thread Jay Blanchard
[snip]
Can anyone tell me a good php book to buy.  I already have Web
Database Applications with PHP & MySQL by O'Reilly.
[/snip]

Core PHP.

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



[PHP] code obfuscating

2006-04-07 Thread Zouari Fourat
Hello,
Am seeking for a solution to obfuscate php code on the server side, so
if i decide to sell php closed source applications, i can encode the
source code.

Thanks for your help

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



[PHP] PHP Book Recommendation

2006-04-07 Thread Paul Goepfert
Hi all,

Can anyone tell me a good php book to buy.  I already have Web
Database Applications with PHP & MySQL by O'Reilly.

Thanks,
Paul

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



[PHP] Re: Here is a silly question

2006-04-07 Thread Michelle Konzack
Am 2006-04-03 11:58:39, schrieb Wolf:
> I tend to stick "/nav/header.php" in for my includes, since I control
> the server.
> 
> As long as the site translates root to the main directory of your
> website and not somewhere else, you can always have your links be
> "/menu.php" as server-speak "/" means rootme.
> 
> I also use "/" in my href links in my menus and such so that no matter
> where the script is called from, it always works.

But he is talking about includes,
which mean NOT THE WEB-ROOT but the OS-ROOT.

Greetings
Michelle Konzack


-- 
Linux-User #280138 with the Linux Counter, http://counter.li.org/
# Debian GNU/Linux Consultant #
Michelle Konzack   Apt. 917  ICQ #328449886
   50, rue de Soultz MSM LinuxMichi
0033/3/8845235667100 Strasbourg/France   IRC #Debian (irc.icq.com)

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



Re: [PHP] IF or SWITCH (asinine?)

2006-04-07 Thread Robert Cummings
On Fri, 2006-04-07 at 11:57, tedd wrote:
> Ray said:
> 
> >I'm pretty sure he's ONLY talking about IF/ELSEIF and not IF in general.
> >That's what I got from the message.  Correct me if I'm wrong.
> 
> Of course, you're absolutely right -- I said specifically IF/ELSEIF. 
> My objection is not with the IF statement, of course I use that. In 
> fact, I use if/else for two choices and switch for three or more.
> 
> I find it interesting that some programmers, who have to be exact 
> with their syntax, can't read a simple statement containing proper 
> syntax without misreading it.

Everyone is fallible, don't pretend you are not. When I realized my
misunderstanding I made it public and requested clarification. Either
way, I wasn't the only one to make the mistake as John Nichel also
assumed you included the if structure in your diatribe. Undoubtedly
others perceived similar.

> Rob said:
> 
> >I think I may have read too much into your previous post. Are you saying
> >specifically that you never use the elseif construct or any of the if,
> >elseif, else constructs? If the latter then I think your methodology is
> >somewhat asinine since I'm sure 99% of the programmers out there would
> >view code consisting entirely of switches in place of ifs with a huge
> >grain of WTF :)

> You read too much? No, the case is that you didn't read enough -- or 

No I read ALL of it. See, you're being unclear again, what you mean to
say above is that I didn't absorb the full meaning.

> you didn't comprehend what I wrote. I said that I NEVER use the 

Yes there we go, I didn't FULLY comprehend what you wrote.

> IF/ELSEIF construct. I did not say that I don't use IF/ELSE (forgive 

So does that mean you DO use IF/ELSEIF/ELSE? I mean come on, I can only
assume you do since you don't attach the ELSE to your list. What? I'm
supposed to read your mind? Oh sorry, I bow to your authority.

> my double negative). Don't be what you called my methodology.

If you understood what I wrote you would see I didn't call your
methodology asinine, I called restrictive use of switch in place of if,
if/elseif, if/else, if/elseif/else asinine. Oh wait, maybe I'm
misunderstanding you again and you don't just restrict to elseif usage.
Dammit, you've muddied the water again.

> As for what the 99% of programmers out there -- Locus ab auctoritate 
> est infirmissimus.

"The argument from authority is the weakest." *Wh* Who's the
authority btw? You? I mean, you've got 30 years on me. I'm not sure why
you're weakening your stance, but whatever works best I guess.

> Also would you care to provide proof for your statistics?

Right off the top of my head. Thank you, thank you very much. It was not
meant as a definitive statistic, it was meant as a comment on the
unlikelyhood of anyone naturally subscribing to replacement of the
complete set of if/elseif/else permutations with switch statements.

Anyways, I think this debate is pretty much pointless now, you've
clarified your point of view (sort of) and I'll just run with the final
though that you limit your use of switch to case where elseif would be
needed... and to clarify on my part once more, I did not call that
asinine.

Cheers,
Rob.
-- 
..
| InterJinn Application Framework - http://www.interjinn.com |
::
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for   |
| creating re-usable components quickly and easily.  |
`'

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



Re: [PHP] Creating a Photo Album

2006-04-07 Thread Jason S. Motes

Jay Blanchard wrote:

[snip]
I am postilng pictures up on a website.  So far I have a picture per
page. This will get not be very efficient as time goes on.  Is there
anyway that I can have one page with only the image updating?  Can
this be done in PHP.  If it can would someone explain it to me.  The
only thing I k.now how to do well in PHP is mysql queries and data
validatlion.
[/snip]




I would look at coppermine to see how they do it.

http://coppermine-gallery.net/index.php


--
Jason S. Motes
php at imotes.com
www.imotes.com

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



Re: [PHP] Parsing variables within string variables

2006-04-07 Thread Dave Goodchild
Use double quotes/

On 07/04/06, David Clough <[EMAIL PROTECTED]> wrote:
>
> I've been bashing my head against the wall on this, and would be glad of
> help to stop.
>
> I have a variable containing a string that contains the names of
> variables, and want to output the variable with the variables it
> contains evaluated. E.g.
>
>$foo contains 'cat'
>$bar contains 'Hello $foo'
>
> and I want to output $bar as
>
>Hello cat
>
> The problem is that if I use
>
>echo $bar
>
> I just get
>
>Hello $foo
>
> Note that $bar is loaded from a database query, so I can't control its
> contents: I just have to parse it.
>
> Any help appreciated.
>
> David.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
http://www.web-buddha.co.uk
dynamic web programming from Reigate, Surrey UK

look out for e-karma, our new venture, coming soon!


Re: [PHP] IF or SWITCH (asinine?)

2006-04-07 Thread Ray Hauge
On Friday 07 April 2006 08:57, tedd wrote:
>
> Personally, as I said before, I use if/else for two conditions and
> switch for three or more. Your mileage may vary, but it's truly a
> matter of choice and is not one of asinine methodology.
>
> Thanks to all who replied.
>
> tedd
>
> --
> ---
>- http://sperling.com

I think that's a fairly good methodology to follow.  I usually do that... 
except when I run into a huge list of multiple conditions for each 
possibility (TRUE && FALSE OR FALSE && TRUE) etc.  To me IF/ELSEIF is easier 
to ready in that case, and SWITCH is a LOT easier to read if you have one 
variable and have a CASE for each possibility of that variable.  Just my 
opinion of course :)

I guess when it came down to it I just had to stick with what works for me.  I 
cleaned up a lot of the totals and counting, so it's MUCH easier to read 
now :)

To imitate Tedd...

Thanks to all who replied

-- 
Ray Hauge
Programmer/Systems Administrator
American Student Loan Services
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] how to run 'periodic'

2006-04-07 Thread Joe Wollard
Frank,

It sounds like you need to run this as a job through crond. I'm not sure
what the OSX version is (maybe they have a port of crond?) but you could set
that up to execute the specific code, as root, whenever you want. As far as
I can think, and maybe Chris Shifflet can confirm/deny this, you shouldn't
be running into any additional security issues by executing the script as
root - As long as it's running through the CLI version of PHP. Just make
sure it's only executable by root and then root should be the only one
allowed to create that mammoth ;-)

- Joe

On 4/6/06, Frank Arensmeier <[EMAIL PROTECTED]> wrote:
>
> Hi.
>
> I have written a script which outputs a rather large ZIP file ( 200
> MB ) by collecting a large amount of PDF files and html pages. When
> the script is done, the available amount of free memory has decreased
> by about 20 - 30%. Running 'periodic' on my machine ( Apple Xserve G5
> with Mac OS 10.4 server) restores the available memory to a more
> proper size.
>
> The question is: how can I execute 'periodic daily|weekly|monthly'
> from my script? Is this possible at all? I know that 'periodic' needs
> root. And all PHP code is executed as www user which doesn't have
> root privileges. Would I compromise my servers security when granting
> root privileges to a script that executes 'periodic' (which could be
> called from the script that outputs the ZIP archive)?
>
> thanks
> /frank
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] microtime questions

2006-04-07 Thread Joe Wollard
I just realized that I could check your version, and it appears that we've
found the problem. You're running PHP 4.3.10, so I'd suggest using the non
PHP5 work around on php.net's site.

Cheers!
- Joe


On 4/7/06, Joe Wollard <[EMAIL PROTECTED]> wrote:
>
> Tedd,
>
> The only way that I can even think of this as being possible is if you
> call microtime() instead of microtime(true). The former will return 'msec
> sec' separated by a space which can produce a negative number because you've
> essentially got two different types of measurements there. IMHO PHP should
> probably throw out an error when two strings are used in a mathematical way
> - in this case (without the TRUE arg) here is a possible equation that could
> be evaluated.
>
>   0.15290800 1144430717
> - 0.86641600 1144430716
>
> PHP evaluates this to -0.713508 (or 0.15290800 - 0.86641600) It's negative
> because we're not talking about msecs from the same second - it ignores the
> seconds and only pays attention to the microseconds. So if you're using
> microtime(true) how can this happen on your machine? Well, off the top of my
> head I think you should verify that your machine (or your hosting service)
> is running PHP5 || >. IF not, and error reporting is turned off, then you'll
> get a negative number from time to time since the seconds are being ignored.
>
>
> http://php.net/microtime has an example of how to emulate microtime(true)
> on PHP < 5
>
> Hope that helps!
> -Joe
>
>
> On 4/7/06, Brad Bonkoski <[EMAIL PROTECTED]> wrote:
> >
> > How is the CPU not in question?  Does this script run on air?
> > It may not be YOUR CPU, but it is still a CPU bound by the sceduling
> > algorithm of the Operating System, so the time differentials are too be
> > expected.
> > -B
> >
> > tedd wrote:
> >
> > > At 12:24 PM -0400 4/7/06, Brad Bonkoski wrote:
> > >
> > >> Interesting...
> > >> as for your first question...
> > >> Know that PHP/Apache does not have free reign to your CPU, so the
> > >> times could be different based on the scheduling going on in the OS
> > >> kernel.
> > >>
> > >> As for the second one...
> > >> No idea why you would get a negative number, I just copied and ran
> > >> from the command line and did not encounter 1 negative time for about
> > >> 30 runs
> > >>
> > >> Do you get negative times if you run it from the command line as
> > well?
> > >> -B
> > >>
> > >>> RE:
> > >>>
> > >>> http://www.xn--ovg.com/microtime.php
> > >>>
> > >
> > > Brad:
> > >
> > > Thanks for looking.
> > >
> > > My questions are with regard to what happens on the site, not via my
> > > command line. As such, my command line and my CPU are not involved.
> > >
> > > Can you answer the questions as they pertain to the site in question?
> > >
> > > Thanks.
> > >
> > > tedd
> > >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>


Re: [PHP] microtime questions

2006-04-07 Thread Joe Wollard
Tedd,

The only way that I can even think of this as being possible is if you call
microtime() instead of microtime(true). The former will return 'msec sec'
separated by a space which can produce a negative number because you've
essentially got two different types of measurements there. IMHO PHP should
probably throw out an error when two strings are used in a mathematical way
- in this case (without the TRUE arg) here is a possible equation that could
be evaluated.

  0.15290800 1144430717
- 0.86641600 1144430716

PHP evaluates this to -0.713508 (or 0.15290800 - 0.86641600) It's negative
because we're not talking about msecs from the same second - it ignores the
seconds and only pays attention to the microseconds. So if you're using
microtime(true) how can this happen on your machine? Well, off the top of my
head I think you should verify that your machine (or your hosting service)
is running PHP5 || >. IF not, and error reporting is turned off, then you'll
get a negative number from time to time since the seconds are being ignored.

http://php.net/microtime has an example of how to emulate microtime(true) on
PHP < 5

Hope that helps!
-Joe

On 4/7/06, Brad Bonkoski <[EMAIL PROTECTED]> wrote:
>
> How is the CPU not in question?  Does this script run on air?
> It may not be YOUR CPU, but it is still a CPU bound by the sceduling
> algorithm of the Operating System, so the time differentials are too be
> expected.
> -B
>
> tedd wrote:
>
> > At 12:24 PM -0400 4/7/06, Brad Bonkoski wrote:
> >
> >> Interesting...
> >> as for your first question...
> >> Know that PHP/Apache does not have free reign to your CPU, so the
> >> times could be different based on the scheduling going on in the OS
> >> kernel.
> >>
> >> As for the second one...
> >> No idea why you would get a negative number, I just copied and ran
> >> from the command line and did not encounter 1 negative time for about
> >> 30 runs
> >>
> >> Do you get negative times if you run it from the command line as well?
> >> -B
> >>
> >>> RE:
> >>>
> >>> http://www.xn--ovg.com/microtime.php
> >>>
> >
> > Brad:
> >
> > Thanks for looking.
> >
> > My questions are with regard to what happens on the site, not via my
> > command line. As such, my command line and my CPU are not involved.
> >
> > Can you answer the questions as they pertain to the site in question?
> >
> > Thanks.
> >
> > tedd
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP] Re: make global variables accessible to functions?

2006-04-07 Thread Bing Du
Thanks for the response.

> That way is secure and has nothing to do with register_globals ;)
>

Good.  That's what I wanted to hear.  I know by default some pre-defined
global variables can be accessed through $GLOBALS.  If I don't want end
users to add their own user defined variables in the superglobal area, how
should I do that?

> What you can do too is this:
>
>  function foo($a) {
> echo "a is $a";
> }
> ?>

Yeah, I know it works this way.  The reason I don't go this way is I have
quite a few variables that need to be passed to the function, it's not
feasible to pass all them as funtion parameters.

Bing

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



Re: [PHP] Parsing variables within string variables

2006-04-07 Thread Paul Novitski

I wrote:

You need to EVALUATE the string coming from the database:

Assuming that $sDataField contains the string 'Hello $foo':

$foo = "cat";
$sText = eval($sDataField);

RESULT: $sText = "Hello cat"

http://php.net/eval



I was assuming that you meant that the string "Hello $foo" -- 
including the dollar sign -- came from the database.


If $foo exists as a native PHP variable, I'd want to see your actual 
code to tell why it's not being properly evaluated by the parser.


Sometimes you need to use curly braces to help the PHP interpreter 
differentiate a variable from the surrounding text:


$bar = "Hello ${foo}amaran";

If you escape the dollar sign, the variable won't be evaluated:

$bar = "Hello \$foo";
RESULT: "Hello $foo"

Paul 


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



Re: [PHP] Parsing variables within string variables

2006-04-07 Thread Paul Novitski

At 09:37 AM 4/7/2006, David Clough wrote:

I have a variable containing a string that contains the names of
variables, and want to output the variable with the variables it
contains evaluated. E.g.

   $foo contains 'cat'
   $bar contains 'Hello $foo'

and I want to output $bar as

   Hello cat

The problem is that if I use

   echo $bar

I just get

   Hello $foo

Note that $bar is loaded from a database query, so I can't control its
contents: I just have to parse it.



David,

You need to EVALUATE the string coming from the database:

Assuming that $sDataField contains the string 'Hello $foo':

$foo = "cat";
$sText = eval($sDataField);

RESULT: $sText = "Hello cat"

http://php.net/eval

Paul 


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



RE: [PHP] Parsing variables within string variables

2006-04-07 Thread Chrome
Or change the quote style to double (")

Just another option

Dan

(If I'm right this time... I really can't afford 88AUD/hr... :) )
---
http://chrome.me.uk
 

-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED] 
Sent: 07 April 2006 18:12
To: David Clough; php-general@lists.php.net
Subject: RE: [PHP] Parsing variables within string variables

[snip]

I have a variable containing a string that contains the names of 
variables, and want to output the variable with the variables it 
contains evaluated. E.g. 

   $foo contains 'cat'
   $bar contains 'Hello $foo'

and I want to output $bar as 

   Hello cat

The problem is that if I use

   echo $bar

I just get

   Hello $foo
[/snip]

$bar = 'Hello' . $foo;

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


__ NOD32 1.1475 (20060406) Information __

This message was checked by NOD32 antivirus system.
http://www.eset.com

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



RE: [PHP] Parsing variables within string variables

2006-04-07 Thread Jay Blanchard
[snip]

I have a variable containing a string that contains the names of 
variables, and want to output the variable with the variables it 
contains evaluated. E.g. 

   $foo contains 'cat'
   $bar contains 'Hello $foo'

and I want to output $bar as 

   Hello cat

The problem is that if I use

   echo $bar

I just get

   Hello $foo
[/snip]

$bar = 'Hello' . $foo;

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



RE: [PHP] Parsing variables within string variables

2006-04-07 Thread Kevin Davies - Bonhurst Consulting
David,

Is this what you're looking for?

$bar = 'Hello '.$bar

HTH,

Kevin


-Original Message-
From: David Clough [mailto:[EMAIL PROTECTED] 
Sent: 07 April 2006 17:37
To: php-general@lists.php.net
Subject: [PHP] Parsing variables within string variables

I've been bashing my head against the wall on this, and would be glad of 
help to stop. 

I have a variable containing a string that contains the names of 
variables, and want to output the variable with the variables it 
contains evaluated. E.g. 

   $foo contains 'cat'
   $bar contains 'Hello $foo'

and I want to output $bar as 

   Hello cat

The problem is that if I use

   echo $bar

I just get

   Hello $foo

Note that $bar is loaded from a database query, so I can't control its 
contents: I just have to parse it.

Any help appreciated.

David.

-- 
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] microtime questions

2006-04-07 Thread Brad Bonkoski

How is the CPU not in question?  Does this script run on air?
It may not be YOUR CPU, but it is still a CPU bound by the sceduling 
algorithm of the Operating System, so the time differentials are too be 
expected.

-B

tedd wrote:


At 12:24 PM -0400 4/7/06, Brad Bonkoski wrote:


Interesting...
as for your first question...
Know that PHP/Apache does not have free reign to your CPU, so the 
times could be different based on the scheduling going on in the OS 
kernel.


As for the second one...
No idea why you would get a negative number, I just copied and ran 
from the command line and did not encounter 1 negative time for about 
30 runs


Do you get negative times if you run it from the command line as well?
-B


RE:

http://www.xn--ovg.com/microtime.php



Brad:

Thanks for looking.

My questions are with regard to what happens on the site, not via my 
command line. As such, my command line and my CPU are not involved.


Can you answer the questions as they pertain to the site in question?

Thanks.

tedd



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



Re: [PHP] microtime questions

2006-04-07 Thread tedd

At 12:24 PM -0400 4/7/06, Brad Bonkoski wrote:

Interesting...
as for your first question...
Know that PHP/Apache does not have free reign to your CPU, so the 
times could be different based on the scheduling going on in the OS 
kernel.


As for the second one...
No idea why you would get a negative number, I just copied and ran 
from the command line and did not encounter 1 negative time for 
about 30 runs


Do you get negative times if you run it from the command line as well?
-B


RE:

http://www.xn--ovg.com/microtime.php



Brad:

Thanks for looking.

My questions are with regard to what happens on the site, not via my 
command line. As such, my command line and my CPU are not involved.


Can you answer the questions as they pertain to the site in question?

Thanks.

tedd

--

http://sperling.com

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



Re: [PHP] Completing forms offline with PHP/MySQL

2006-04-07 Thread Brad Bonkoski

If your users are using Windows, then something like
http://www.hypervisual.com/winbinder/
might be good on the user side, as you can bundle the PHP binary and 
everything else needed into one executable (with some work of course)
And then they can create a file formatted to your specifications to 
upload sometime later.


Or you can use some other UI like QT to create the XML document on the 
client side which would be cross-platform.


The only way to re-use what you have in an offline web environment would 
be like Jay said to install the required software on the client's / 
user's computers, and is that really something that is maintainable?


The key question: is the additional work required really beneficial? 


Jay Blanchard wrote:


[snip]
Apologies if this is the wrong place for this question, but I'm sure
there
are some experts out there who might be able to point me in the right
direction... :)

I'm doing some work at the moment where remote teams can submit reports
through to our database when connected over the internet to our server.
However, I've been asked to look in the possibility of the teams
completing
the form offline, and uploading when they have access to a connection.

It looks like I might be able offer something like Microsoft InfoPath
forms
(better recommendations?) to generate an XML file, and then use a PHP
file
to upload the file into the database. Additionally, I could also do with
this process uploading a number of other files (e.g. images, text files)
to
the server. 


Does anyone have any experience in this area, and would be able to
recommend
a solution?
[/snip]

The first part: completing a web-based form offline would mean having
some way to process the result 'locally', so how would you do that? You
don't want to install copies of Apache & PHP on each machine and have
those services run each time the machine starts, so how would you get a
form to save the necessary data client side? I searched offline forms on
Google and came up with several third party solutions, YMMV.

The second part: making the network aware that a machine has connected
to it and performing the proper steps or make the machine aware that it
has connected to the network and have it initiate the process. Of course
this could be taken care of by the user by having them click something.

 



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



RE: [PHP] Completing forms offline with PHP/MySQL

2006-04-07 Thread Jay Blanchard
[snip]
Apologies if this is the wrong place for this question, but I'm sure
there
are some experts out there who might be able to point me in the right
direction... :)

I'm doing some work at the moment where remote teams can submit reports
through to our database when connected over the internet to our server.
However, I've been asked to look in the possibility of the teams
completing
the form offline, and uploading when they have access to a connection.

It looks like I might be able offer something like Microsoft InfoPath
forms
(better recommendations?) to generate an XML file, and then use a PHP
file
to upload the file into the database. Additionally, I could also do with
this process uploading a number of other files (e.g. images, text files)
to
the server. 

Does anyone have any experience in this area, and would be able to
recommend
a solution?
[/snip]

The first part: completing a web-based form offline would mean having
some way to process the result 'locally', so how would you do that? You
don't want to install copies of Apache & PHP on each machine and have
those services run each time the machine starts, so how would you get a
form to save the necessary data client side? I searched offline forms on
Google and came up with several third party solutions, YMMV.

The second part: making the network aware that a machine has connected
to it and performing the proper steps or make the machine aware that it
has connected to the network and have it initiate the process. Of course
this could be taken care of by the user by having them click something.

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



Re: [PHP] microtime questions

2006-04-07 Thread Brad Bonkoski

Interesting...
as for your first question...
Know that PHP/Apache does not have free reign to your CPU, so the times 
could be different based on the scheduling going on in the OS kernel.


As for the second one...
No idea why you would get a negative number, I just copied and ran from 
the command line and did not encounter 1 negative time for about 30 runs


Do you get negative times if you run it from the command line as well?
-B

tedd wrote:


Hi gang:

I'm getting elapsed time results I can't believe.

Would anyone care to check out:

http://www.xn--ovg.com/microtime.php

And answer a couple questions posted there?

Thanks.

tedd


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



Re: [PHP] Handling Large Select Boxes

2006-04-07 Thread Manuel Lemos
Hello,

on 04/07/2006 01:06 PM Brad Bonkoski said the following:
> Good point...
> Maybe the gods of usability can kick the user's in the butt to get them
> to clean up the data!
> Previously they used a free text field, which is why the problem is as
> bad as it is currently
> 
> All the data has to be available, so the only other option I can think
> of is to select 1 letter and then have Javascript populate the
> sub-select box...
> unless someone has any other ideas?

You may want to use this forms generation class that comes with a linked
select input plug-in .

You can link an unlimited number of select inputs  making one show a
sub-set of the options depending on the value selected in the previous
select.

The good part is that it can retrieve the options of each select from
static arrays or dynamically a database via AJAX. This means that when
you change the value of one select the new set of options of the
dependent select are loaded without page refresh.

Despite it can use AJAX, you do not have to learn a single line of
Javascript. All is achieved with PHP code. The plug-in takes care of any
Javascript generation.

It supports MySQL databases directly or any other database using
Metabase or PEAR::MDB2 API.

Here is a live example of the static array mode.

http://www.phpclasses.org/browse/view/html/file/9879/name/test_linked_select_page.html

There are examples of the dynamic mode in the class page.

http://www.phpclasses.org/formsgeneration

-- 

Regards,
Manuel Lemos

Metastorage - Data object relational mapping layer generator
http://www.metastorage.net/

PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/

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



[PHP] microtime questions

2006-04-07 Thread tedd

Hi gang:

I'm getting elapsed time results I can't believe.

Would anyone care to check out:

http://www.xn--ovg.com/microtime.php

And answer a couple questions posted there?

Thanks.

tedd
--

http://sperling.com

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



Re: [PHP] Handling Large Select Boxes

2006-04-07 Thread Paul Novitski

At 08:51 AM 4/7/2006, Brad Bonkoski wrote:
I have a form for user interaction and part of it is a select box 
with a large number of options from a database ~12K options.
Currently I have a function which queries the DB to get fresh data 
and loads the HTML (Y) into a string, so 
the DB is only hit once,

but the page still takes a while to load.
Anyone else have any experience with something like this, or any 
other helpful suggestions for making the page load time a little 
less cumbersome?



Brad,

If the data and the application permit, you can split the list into a 
series of nested lists and let the user drill down to the desired 
item.  (If it's a multiple-selection menu, this could get 
tricky.)  If the user can select from one or more category menus to 
get to the finest granularity of detail, they will have multiple 
steps to perform but the wait-time on each step will be far less than 
downloading a 12,000-option list, and therefore the user's perception 
of wait-time will be less.


There are serious usability issues with very long lists -- for 
example, the scrollbar button on the list control can become so small 
that it's difficult to grab, and paging down a few hundred times 
isn't fun.  You can help ameliorate this by ordering the options 
alphabetically so the user can at least jump to the desired initial 
letter.  Even so, 12,000 / 26 is still 461, a huge number of options 
to have to scroll through.


Here's one example of a drill-down in which all the category menus 
remain on the screen:

http://www.dandemutande.org/ResourceGuide/

Paul 


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



[PHP] Completing forms offline with PHP/MySQL

2006-04-07 Thread Kevin Davies - Bonhurst Consulting
Hi,

Apologies if this is the wrong place for this question, but I'm sure there
are some experts out there who might be able to point me in the right
direction... :)

I'm doing some work at the moment where remote teams can submit reports
through to our database when connected over the internet to our server.
However, I've been asked to look in the possibility of the teams completing
the form offline, and uploading when they have access to a connection.

It looks like I might be able offer something like Microsoft InfoPath forms
(better recommendations?) to generate an XML file, and then use a PHP file
to upload the file into the database. Additionally, I could also do with
this process uploading a number of other files (e.g. images, text files) to
the server. 

Does anyone have any experience in this area, and would be able to recommend
a solution?

Thanks in advance for your help...

Kevin

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



Re: [PHP] Handling Large Select Boxes

2006-04-07 Thread Brad Bonkoski

Good point...
Maybe the gods of usability can kick the user's in the butt to get them 
to clean up the data!
Previously they used a free text field, which is why the problem is as 
bad as it is currently


All the data has to be available, so the only other option I can think 
of is to select 1 letter and then have Javascript populate the 
sub-select box...

unless someone has any other ideas?

-B

Jay Blanchard wrote:


[snip]
I have a form for user interaction and part of it is a select box with a

large number of options from a database ~12K options.
Currently I have a function which queries the DB to get fresh data and 
loads the HTML (Y) into a string, so the DB is 
only hit once,
but the page still takes a while to load. 

Anyone else have any experience with something like this, or any other 
helpful suggestions for making the page load time a little less

cumbersome?
[/snip]

If you are loading 12000 entries into a select box then that is way too
much. The gods of usability frown on you. Is there no way to make the
data selection slimmer?

 



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



Re: [PHP] IF or SWITCH (asinine?)

2006-04-07 Thread tedd

Ray said:


I'm pretty sure he's ONLY talking about IF/ELSEIF and not IF in general.
That's what I got from the message.  Correct me if I'm wrong.


Of course, you're absolutely right -- I said specifically IF/ELSEIF. 
My objection is not with the IF statement, of course I use that. In 
fact, I use if/else for two choices and switch for three or more.


I find it interesting that some programmers, who have to be exact 
with their syntax, can't read a simple statement containing proper 
syntax without misreading it.


---
John C. Nichel IV said:

I remember IF constructs from BASIC and PASCAL, but no switch 
statements (somebody correct me if I'm wrong).  But what I'm 
wondering is how in the world did you do conditional checking if 
there were no switches, and you don't use IF's?  Did you not code 
error handling, different cases based on user input, status of a 
data stream, etc in all the years prior to something like switch 
being introduced???


I'm no programming historian, but from memory, Fortran, BASIC, and 
PASCAL all started without a "switch" construct. However, later-on 
BASIC most definitely provided a SELECT/CASE and PASCAL had a case 
operation of some type -- as for FORTRAN, it's been a long time since 
I did anything in it, I don't know.


As for how did I did conditional checking, I did it like every other 
programmer of that day -- and without ELSE/IF's. You certainly can't 
use the construct if it's not there -- using IF's sufficed and as I 
said above, I NEVER said that I don't use if/else -- what I said was 
I don't use if/elseif.


Actually, by you misreading my post, you provided support for my 
claim that the use of if/elseif is confusing and thus less readable. 
Clearly if I had said that I don't use the switch, there would have 
been less confusion on your part, right?


---
Rob said:


I think I may have read too much into your previous post. Are you saying
specifically that you never use the elseif construct or any of the if,
elseif, else constructs? If the latter then I think your methodology is
somewhat asinine since I'm sure 99% of the programmers out there would
view code consisting entirely of switches in place of ifs with a huge
grain of WTF :)


You read too much? No, the case is that you didn't read enough -- or 
you didn't comprehend what I wrote. I said that I NEVER use the 
IF/ELSEIF construct. I did not say that I don't use IF/ELSE (forgive 
my double negative). Don't be what you called my methodology.


As for what the 99% of programmers out there -- Locus ab auctoritate 
est infirmissimus.


Also would you care to provide proof for your statistics?

---
Kevin provided:

benchmarks can be hazardous, but lets look at them at their most 
basic level. By this

I mean how folks use them every day...

http://www.phpro.org/benchmarks/if-switch-benchmark.html


Thanks for the link. That fits with my tests -- however, the speed 
difference, which in not significant IMO, is not at issue with me -- 
it's the readability. To me, the switch wins hands down in 
readability over the multiple if/elseif's. However, I realize that's 
a personal decision and do not claim good/bad practice in using 
either.


---
 M said:


If it can be used, I'd go for the clarity of switch.


I have yet to find a single problem where a switch can't be used to 
replace multiple if/elseif's. I even posted an open query to this 
list in that regard, and while at least one was compelled to call my 
methodology asinine, no one could provide an example otherwise.


So my claim stands that you simply don't need the if/elseif construct 
-- for it can be totally replaced with the switch. Now, someone prove 
me wrong -- please -- I would like to know why the construct is still 
around after being the evolutionary step between if/else and switch. 
Is it just habit, or what?


Personally, as I said before, I use if/else for two conditions and 
switch for three or more. Your mileage may vary, but it's truly a 
matter of choice and is not one of asinine methodology.


Thanks to all who replied.

tedd

--

http://sperling.com

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



RE: [PHP] Handling Large Select Boxes

2006-04-07 Thread Jay Blanchard
[snip]
I have a form for user interaction and part of it is a select box with a

large number of options from a database ~12K options.
Currently I have a function which queries the DB to get fresh data and 
loads the HTML (Y) into a string, so the DB is 
only hit once,
but the page still takes a while to load. 

Anyone else have any experience with something like this, or any other 
helpful suggestions for making the page load time a little less
cumbersome?
[/snip]

If you are loading 12000 entries into a select box then that is way too
much. The gods of usability frown on you. Is there no way to make the
data selection slimmer?

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



[PHP] Handling Large Select Boxes

2006-04-07 Thread Brad Bonkoski

Hello,

I have a form for user interaction and part of it is a select box with a 
large number of options from a database ~12K options.
Currently I have a function which queries the DB to get fresh data and 
loads the HTML (Y) into a string, so the DB is 
only hit once,
but the page still takes a while to load. 

Anyone else have any experience with something like this, or any other 
helpful suggestions for making the page load time a little less cumbersome?


Thanks!
-B

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



Re: [PHP] echo, print and is_callable()/function_exists()

2006-04-07 Thread Hans Juergen von Lengerke
Just wrap it, like Example 1 of the manual shows

function my_echo($array, $key) {
echo $array[$key];
}

array_walk_recursive($array, 'my_echo');


> Date: Fri, 7 Apr 2006 15:42:40 +0100
> From: Chris Boget <[EMAIL PROTECTED]>
> To: php-general@lists.php.net
> Subject: [PHP] echo, print and is_callable()/function_exists()
> 
> Because both echo and print are language constructs and not actual
> functions, you can't seem to use either is_callable() or
> function_exists() on either to determine if they are valid 'function'
> calls.  Is there any other way to determine to check to see if I can
> execute either or?  I'm writing a version of array_walk_recursive() (it
> doesn't exist in the version of PHP we are using) and if I try to pass
> in either echo or print as the function, nothing ever happens because
> neither resolves as an executable function...
>  
> Any ideas as to how I can get around this?
>  
> thnx,
> Chris
> 

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



Re: [PHP] make global variables accessible to functions?

2006-04-07 Thread John Nichel

Bing Du wrote:

Hello,

We use PHP 4.3.9. 'register_globals = Off' is set in php.ini.  I've heard
using 'global' could cause security problems.  Is using $GLOBALS still not
more secure than using the 'global' keyword? How should function foo()
obtain the value of $a?



===

Thanks in advance,

Bing



You could pass it.

--
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] echo, print and is_callable()/function_exists()

2006-04-07 Thread Chris Boget
Because both echo and print are language constructs and not actual
functions, you can't seem to use either is_callable() or
function_exists() on either to determine if they are valid 'function'
calls.  Is there any other way to determine to check to see if I can
execute either or?  I'm writing a version of array_walk_recursive() (it
doesn't exist in the version of PHP we are using) and if I try to pass
in either echo or print as the function, nothing ever happens because
neither resolves as an executable function...
 
Any ideas as to how I can get around this?
 
thnx,
Chris


[PHP] Re: make global variables accessible to functions?

2006-04-07 Thread El Bekko

Bing Du wrote:

Hello,

We use PHP 4.3.9. 'register_globals = Off' is set in php.ini.  I've heard
using 'global' could cause security problems.  Is using $GLOBALS still not
more secure than using the 'global' keyword? How should function foo()
obtain the value of $a?



===

Thanks in advance,

Bing

That way is secure and has nothing to do with register_globals ;)

What you can do too is this:



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



[PHP] make global variables accessible to functions?

2006-04-07 Thread Bing Du
Hello,

We use PHP 4.3.9. 'register_globals = Off' is set in php.ini.  I've heard
using 'global' could cause security problems.  Is using $GLOBALS still not
more secure than using the 'global' keyword? How should function foo()
obtain the value of $a?



===

Thanks in advance,

Bing

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



Re: [PHP] getimagesize()

2006-04-07 Thread John Nichel

Ed Curtis wrote:

 Can you call getimagesize() multiple times in one script? I'm trying to
use it multiple times but it only seems to work in the first loop I call
it in. I read something in the docs about it cacheing the results and
didn't know if this has something to do with it.


That 'something' you read was a user comment, not the manual.  AFAIK, 
getimagesize() *does no* cache.



 I also tried creating an array out of the results I get from it but it
will only output the size values when it's building the array, never when
I try to loop back through it and output the values.



Without seeing any code, I can only guess that you're doing something 
wrong, and need to fix it.


--
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] getimagesize()

2006-04-07 Thread Ed Curtis

 Can you call getimagesize() multiple times in one script? I'm trying to
use it multiple times but it only seems to work in the first loop I call
it in. I read something in the docs about it cacheing the results and
didn't know if this has something to do with it.

 I also tried creating an array out of the results I get from it but it
will only output the size values when it's building the array, never when
I try to loop back through it and output the values.

Thanks,

Ed

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



Re: [PHP] IF or SWITCH

2006-04-07 Thread Kevin Waterson
This one time, at band camp, Jad madi <[EMAIL PROTECTED]> wrote:

> Kevin, 
> I'm just curious to know how to did you do that benchmark.

Sure, use ab (Apache Benchmark) which comes with your build of apache.
Simply create your file foo.php and give ab the command
ab http://www.example.com/foo.php -n 1 -c 4

you may also use localhost as such
ab http://localhost/foo.php -n 1 -c 4

If the concurrency is omitted a concurrency of 1 is assumed

This will tell ab the url, and to request it 10,000 times with a concurrency of 
4.
Depending on your hardware ab will tick over and generate a report.

man ab will give you more info

Kind regards
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] Creating a Photo Album

2006-04-07 Thread Jay Blanchard
[snip]
I am postilng pictures up on a website.  So far I have a picture per
page. This will get not be very efficient as time goes on.  Is there
anyway that I can have one page with only the image updating?  Can
this be done in PHP.  If it can would someone explain it to me.  The
only thing I k.now how to do well in PHP is mysql queries and data
validatlion.
[/snip]

Check out http://gallery.menalto.com/ There is a way to watch a
slideshow in a single page, but it uses a Java component. 
http://www.akehrer.com/ffgallery/ is an Ajax and PHP photo gallery (it
resembles Lightbox), but it doesn't have the action that you require.
http://www.frwrd.net/minishowcase/ is another Ajax attempt.

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



Re: [PHP] Creating a Photo Album

2006-04-07 Thread Gerry Danen
Sure you can, Paul. See
http://www.lily-gallery.com/h/showlily.php?id=53&div=1 for an example.
There are 5 thumbnails and they all link to photo.php to display the
larger version.

On 4/7/06, Paul Goepfert <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am postilng pictures up on a website.  So far I have a picture per
> page. This will get not be very efficient as time goes on.  Is there
> anyway that I can have one page with only the image updating?  Can
> this be done in PHP.  If it can would someone explain it to me.  The
> only thing I k.now how to do well in PHP is mysql queries and data
> validatlion.



--
Gerry
http://dev.danen.org/

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



[PHP] Problems with Arrays and print and echo

2006-04-07 Thread Michael Felt

Slowly I am getting the output I want.

Trying to use "dynamic" arrays, does creat the array I want, but getting 
the info is sometimes surprising.


I notice a difference between arrays used locally in a function, and 
arrays used as a 'var' in a class function (all in PHP 4 atm).


Code snippet:
echo "ROWS returned are: $max\n";
$this->count = $max;

while ($max--) {
$row = mysql_fetch_row($result);
$this->name[$max] = sprintf("%s", $row[0]);
$Name[$max] = sprintf("%s", $row[0]);
echo "init \$this->Xame[$max] = $row[0]";
echo " $Name[$max] $this->name[$max]\n";
$regionID[$max] = $row[1];
$constellationID[$max] = $row[2];
$this->ID[$max] = $row[3]; 
printf("%d:%d/%d/%s\n",$max,$regionID[$max],$constellationID[$max],

   $this->name[$max]);
}

Line wrap is messing things up a bit.
Was trying sprintf to see if the was a buffer problem coming from mysql.
Problem seems to be the same, regardless.
Also, the names changes ($this->name[] versus $Name[]) are deliberate, 
for just in case



Output (debuging):
ROWS returned are: 7
init $this->Xame[6] = 8-TFDX 8-TFDX Array[6]
6:1003/2044/8-TFDX
init $this->Xame[5] = B-E3KQ B-E3KQ Array[5]
5:1003/2044/B-E3KQ
init $this->Xame[4] = BR-6XP BR-6XP Array[4]
4:1003/2044/BR-6XP
init $this->Xame[3] = G5ED-Y G5ED-Y Array[3]
3:1003/2044/G5ED-Y
init $this->Xame[2] = O-LR1H O-LR1H Array[2]
2:1003/2044/O-LR1H
init $this->Xame[1] = UL-4ZW UL-4ZW Array[1]
1:1003/2044/UL-4ZW
init $this->Xame[0] = Y5J-EU Y5J-EU Array[0]
0:1003/2044/Y5J-EU
++
Thanks for your ideas, help, etc..

Maybe it is somethign as simple as "can't do that with echo", but when 
the arrays are all single element ( foo_array[0] is only element ) all 
statements work as expected.


regards,
Michael

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



Re: [PHP] IF or SWITCH

2006-04-07 Thread Jad madi
Kevin, 
I'm just curious to know how to did you do that benchmark.


On Fri, 2006-04-07 at 12:40 +1000, Kevin Waterson wrote:
> This one time, at band camp, Robert Cummings <[EMAIL PROTECTED]> wrote:
> 
> > I'm gonna go out on a limb here and say WRONG!
> > 
> > Run yourself a benchmark.
> 
> benchmarks can be hazardous, but lets look at them at their most basic level. 
> By this
> I mean how folks use them every day...
> 
> http://www.phpro.org/benchmarks/if-switch-benchmark.html
> 
> Kind regards
> 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



  1   2   >