[PHP] [PHP-DEV] Re: [PHP] PDO prepared statements and LIKE escaping

2008-08-05 Thread Lester Caine

Sorry - switched address to the wrong list :(
*I* hate reply not going to the right place - but one of these days I switch 
to something that just ignores the on board miss direction ;)


Larry Garfield wrote:
I'm building a multi-database system, although my main targets are MySQL, 
Postgres, and SQLite.


How would those handle something like "a string that ends in 100%"?  


Personally this is one of the reasons that PDO has never attracted me.
Providing the tools to flatten some of the differences between *SQL*
variations is just as important as flattening the name differences in functions.

My own use of LIKE tends to process the string and then add the wrapping %%
when passing it to the param array, but do all databases HANDLE 'escaped %' in
the LIKE data? Firebird allows a escape character but you need to include it
in the SQL
LIKE '%100#%%' ESCAPE '#'
But I think MySQL actually uses \% to achieve the same thing -
and the ESCAPE '\' is then optional?

--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/lsces/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--
PHP Internals - PHP Runtime Development Mailing List
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] An appeal to your better nature

2008-08-05 Thread Richard Heyes
Hi,

Seems my 1and1 server has finally gone kaput taking my website with
it, and in the tradition of all good IT professionals, I have no
backups. :( So this is an appeal to you to ask if you have downloaded
anything from phpguru.org at all, could you please send it to me so I
can try to rebuild my site.

A big thanks.

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] PHP querying mysql db for data limited to the last month

2008-08-05 Thread Per Jessen
Vinny Gullotta wrote:

> So I have this code I'm working with (pasted below) that queries a
> mysql db table called timetracking. The goal of the page is to search
> the db for all data based on a certain engineer, sorted by product and
> it takes pre-defined values based on actions performed, sums them
> based on product and display's the percentage of time an engineer has
> spent on each product. Everything works great except I need to limit
> the results to the last months data only, but everything I try seems
> to just break it. Can anyone push me in the right direction a little?

I can't see a timestamp field in your code, but I'm assuming you've got
one? 

SELECT *,SUM(timespent) FROM timetracking 
WHERE engineer= AND
month(timestamp)=month(date_sub(now(),interval 1 month))
GROUP BY product;


/Per Jessen, Zürich


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



Re: [PHP] SoapClient and arrays

2008-08-05 Thread Marten Lehmann

Hello,

What about $response->key ??? What does that give? It seems to me, that 
$response->key will be a public property of the stdClass?


thanks, this works fine.

Regards
Marten

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



[PHP] SOAP / Server Communication

2008-08-05 Thread stuart tonner

Hi,

At the moment I've taken over a group of individual systems that all do their 
job well enough independently, but all need to talk to one another. For 
example, one system handles stock levels, one system handles sales leads, 
another handles special offers, etc. etc.

A complete rewrite is in order but as a step towards that, I'd like each part 
to be able to communicate and keep the other systems aware of their own status. 
eg. the special offers system needs to know whether there is stock of a 
particular product.

Each system is running on a separate server and I need that level of separation 
to continue, what would be the best way of setting this up? I had used SOAP a 
while back on other projects but would this be the best solution in this case? 
Is there something better suited?

To give a rough estimate of the data, the special offers system will only hold 
roughly about 100 offers and be changed every month or so, the sales leads are 
only catching incoming website form enquiries (maybe about 50 a day) and the 
stock levels can change maybe once or twice a day but only normally by either a 
mass import or removing a sold product.

Thanks for any help / advice!

_
Win New York holidays with Kellogg’s & Live Search
http://clk.atdmt.com/UKM/go/107571440/direct/01/

Re: [PHP] An appeal to your better nature

2008-08-05 Thread Aschwin Wesselius

Richard Heyes wrote:

Hi,

Seems my 1and1 server has finally gone kaput taking my website with
it, and in the tradition of all good IT professionals, I have no
backups. :( So this is an appeal to you to ask if you have downloaded
anything from phpguru.org at all, could you please send it to me so I
can try to rebuild my site.

A big thanks.


Hi,

What does Google cache has? And the Wayback Machine 
(http://www.archive.org/)? Coral Cache?


Bummer dude, but you've got to learn it once the hard time. On the other 
hand, good backup solutions just cost a lot.


I'm going to have a look at my browser cache. Maybe I find something.
--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


[PHP] flock and file reading

2008-08-05 Thread ragnarok
Hi all,


I've simple question: LOCK_EX is only effective for file writing or it locks
reading, too?
 
Ciao,
Stefano 
 --
 Email.it, the professional e-mail, gratis per te: http://www.email.it/f
 
 Sponsor:
 E' arrivato EmailBlog, il blog ufficiale di Email.it. Partecipa anche tu!
 Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=8136&d=20080805



[PHP] Re: [PHP-DEV] PHP 5.3.0alpha1

2008-08-05 Thread Hannes Magnusson
On Fri, Aug 1, 2008 at 09:31, Lukas Kahwe Smith <[EMAIL PROTECTED]> wrote:
> Hello!
>
> Johannes has packed PHP 5.3.0alpha1 yesterday evening, which you can find
> here:
> http://downloads.php.net/johannes/

So.. Apparently we will not get Windows builds of alpha1 as some of
the new extensions didn't build on Windows.. Is someone working on
fixing that problem for alpha2?

-Hannes

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Richard Heyes
Hi,

> What does Google cache has? And the Wayback Machine
> (http://www.archive.org/)? Coral Cache?

Currently going through them. For some reason I've found a page with
all CSS and JS intact. Odd, but fortunate.

> I'm going to have a look at my browser cache. Maybe I find something.

Thanks.

-- 
Richard Heyes
http://www.phpguru.org

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



[PHP] Re: [PHP-DEV] PHP 5.3.0alpha1

2008-08-05 Thread Pierre Joye
On Tue, Aug 5, 2008 at 2:14 PM, Hannes Magnusson
<[EMAIL PROTECTED]> wrote:
> On Fri, Aug 1, 2008 at 09:31, Lukas Kahwe Smith <[EMAIL PROTECTED]> wrote:
>> Hello!
>>
>> Johannes has packed PHP 5.3.0alpha1 yesterday evening, which you can find
>> here:
>> http://downloads.php.net/johannes/
>
> So.. Apparently we will not get Windows builds of alpha1 as some of
> the new extensions didn't build on Windows.. Is someone working on
> fixing that problem for alpha2?

Indeed, as you can notice yourself snaps are working.

Cheer,
-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Aschwin Wesselius

Richard Heyes wrote:



I'm going to have a look at my browser cache. Maybe I find something.



Thanks.
I'm sorry Richard, seems that my browser doesn't hold the history long 
enough.


Forgive me to ask, but how come that you don't have much copies of your 
work? Do you work straight on your server?


I've got my editor (UltraEdit Studio) setup, that it makes a backup of 
the file I'm editing every 5 minutes with a timestamp and the full path. 
Besides that, we use SVN (wich is not that difficult to setup and manage).


So, if your server is your food (so to speak), you'd better take a look 
at the simple things that might rescue you some day. Nowadays there are 
little NAS devices with RAID-0 support (like My Books from Western 
Digital), that gives a good backup solution for a quick buck. Off 
course, you can always step up to better solutions and methods.


Doesn't your hosting provider has a backup facility? Maybe rent another 
webserver (could be virtual) and mirror it with rsync? I don't know. 
there must be something that suits your needs.


I wouldn't like to loose my stuff, but I can't afford much for the best 
solutions either. It's not that my job depends on it, but personal data 
is a big loss too.

--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] An appeal to your better nature

2008-08-05 Thread Richard Heyes
> Forgive me to ask, but how come that you don't have much copies of your
> work? Do you work straight on your server?

I do, via WinSCP (now). This normally would be fine, except I haven't
made any backups. Doh.

> I've got my editor (UltraEdit Studio) setup, that it makes a backup of the
> file I'm editing every 5 minutes with a timestamp and the full path. Besides
> that, we use SVN (wich is not that difficult to setup and manage).

Yes, fortunately my PEAR stuff is all fine since it is in
(unsurprisingly) PEAR cvs.

> So, if your server is your food (so to speak), you'd better take a look at
> the simple things that might rescue you some day. Nowadays there are little
> NAS devices with RAID-0 support (like My Books from Western Digital), that
> gives a good backup solution for a quick buck. Off course, you can always
> step up to better solutions and methods.


I think from now on I'll be doing a million backups a day. Or,
alternatively, one.

> Doesn't your hosting provider has a backup facility?

My hosting provider is 1and1. Cheap but, well, nuff said I think.

> Maybe rent another
> webserver (could be virtual) and mirror it with rsync? I don't know.
> there must be something that suits your needs.

That would work well I think.

> I wouldn't like to loose my stuff, but I can't afford much for the best
> solutions either. It's not that my job depends on it, but personal data is a
> big loss too.

Losing stuff sucks donkey d***.

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Daniel Brown
On Tue, Aug 5, 2008 at 8:53 AM, Aschwin Wesselius
<[EMAIL PROTECTED]> wrote:
>
> I wouldn't like to loose my stuff, but I can't afford much for the best
> solutions either. It's not that my job depends on it, but personal data is a
> big loss too.

Tell me about it.  One of the sickest feelings in the world comes
when you hear your hard drive start going "click click
choke click"

-- 

Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Intel 2.4GHz/320GB/1GB/3TB $74.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Richard Heyes
>Tell me about it.  One of the sickest feelings in the world comes
> when you hear your hard drive start going "click click
> choke click"

I think the only reason I'm not sitting in a corner comatose is
because I can't... :-)

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Per Jessen
Daniel Brown wrote:

> On Tue, Aug 5, 2008 at 8:53 AM, Aschwin Wesselius
> <[EMAIL PROTECTED]> wrote:
>>
>> I wouldn't like to loose my stuff, but I can't afford much for the
>> best solutions either. It's not that my job depends on it, but
>> personal data is a big loss too.
> 
> Tell me about it.  One of the sickest feelings in the world comes
> when you hear your hard drive start going "click click
> choke click"

I use two in every system.  They're so cheap that it's not worth saving
the expense.


/Per Jessen, Zürich


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



[PHP] Re: RPM

2008-08-05 Thread Colin Guthrie

VamVan wrote:

Hello All,

Does any body create installable RPM's for reinstalling their PHP based
websites? Is it possible

If yes could you please share your experience. Oh yes you could tar it but
that's a primitive method.

My quest is to make all my websites installable on any given server using 2
or 3 commands to the maximum.


I'd use a VCS like Subversion for websites, and just do a checkout on 
the server.


Easier to update and maintain than RPMs IMO, but YMMV.



For software development projects, I'd personally opt for git, but for 
websites, SVN is IMO a better choice. But everyone has their own tastes.


Col




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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Aschwin Wesselius

Daniel Brown wrote:

On Tue, Aug 5, 2008 at 8:53 AM, Aschwin Wesselius
<[EMAIL PROTECTED]> wrote:
  

I wouldn't like to loose my stuff, but I can't afford much for the best
solutions either. It's not that my job depends on it, but personal data is a
big loss too.



Tell me about it.  One of the sickest feelings in the world comes
when you hear your hard drive start going "click click
choke click"
Well.. I don't know about you and your empathy. But most of my 
sickest feelings are caused by human behavior, not hardware.. Some 
acts come from darker corners of a sick human mind, than the situations 
where Murphy's laws are famous for.

--

Aschwin Wesselius

/'What you would like to be done to you, do that to the other'/


Re: [PHP] An appeal to your better nature

2008-08-05 Thread Daniel Brown
On Tue, Aug 5, 2008 at 9:20 AM, Per Jessen <[EMAIL PROTECTED]> wrote:
>
> I use two in every system.  They're so cheap that it's not worth saving
> the expense.

Yeah, now, thank God but remember, it wasn't always that way ;-P

http://web.archive.org/web/19961110071252/http://www.maxtor.com/

When the DiamondMax drives first came out, they were a couple
hundred dollars each.  I wanted to be the first guy on the block with
a terabyte RAID, but I bought a car instead.

-- 

Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Daniel Brown
On Tue, Aug 5, 2008 at 9:30 AM, Aschwin Wesselius
<[EMAIL PROTECTED]> wrote:
>
> Well.. I don't know about you and your empathy. But most of my sickest
> feelings are caused by human behavior, not hardware.. Some acts come
> from darker corners of a sick human mind, than the situations where Murphy's
> laws are famous for.

What the hell is "empathy?"  Isn't that a brand of kids cereal?

-- 

Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Richard Heyes
> Well.. I don't know about you and your empathy. But most of my sickest
> feelings are caused by human behavior,

Hah, you probably wouldn't want to know about my feelings for 1and1 now then...

-- 
Richard Heyes
http://www.phpguru.org

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



[PHP] Fatal error: Cannot redeclare

2008-08-05 Thread Kai Kauer
Hi @all,

I was just installing the Moodle-Version 1.9.2 at our university. It was 
installed without any problems. But during testing and preparing for use I 
got this error message:

Fatal error: Cannot redeclare make_log_url() (previously declared 
in /global/WEB_DAT/documents/fme/institute/get/lehre/course/lib.php:25) 
in ./lib.php on line 54

This error is only shown in the course administration (e. g. adding or editing 
courses). Other function do not have any problems. I tried to find 
single "include" or "require", but didn't find any (there are 
always "inlcude_once" or "require_once" commands used). If I try to 
deactivate the function this error is shown again with the next function.

Does anyone know a solution? Or does anyone know where I can ask for a 
solution? I posted this also at the moodle-forum.

Thanks for help
greets 
Kai
P.S.: Sorry for my bad english.

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Richard Heyes
>When the DiamondMax drives first came out, they were a couple
> hundred dollars each.  I wanted to be the first guy on the block with
> a terabyte RAID, but I bought a car instead.

I think I probably would rather have the HDDs. :/ Does that make me a geek?

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] Fatal error: Cannot redeclare

2008-08-05 Thread Daniel Brown
On Tue, Aug 5, 2008 at 9:37 AM, Kai Kauer <[EMAIL PROTECTED]> wrote:
> Hi @all,
>
> I was just installing the Moodle-Version 1.9.2 at our university. It was
> installed without any problems. But during testing and preparing for use I
> got this error message:
>
> Fatal error: Cannot redeclare make_log_url() (previously declared
> in /global/WEB_DAT/documents/fme/institute/get/lehre/course/lib.php:25)
> in ./lib.php on line 54

This is usually a result of the same function include script being
included twice, and thus, the function being defined a second time.
Check ./lib.php on line 54 and see if it's including itself, or if -
for whatever reason - there's two entries in that file starting with
"function make_log_url(***)".



*** Optional parameters may be enclosed within the parentheses.


-- 

Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Daniel Brown
On Tue, Aug 5, 2008 at 9:36 AM, Richard Heyes <[EMAIL PROTECTED]> wrote:
>>When the DiamondMax drives first came out, they were a couple
>> hundred dollars each.  I wanted to be the first guy on the block with
>> a terabyte RAID, but I bought a car instead.
>
> I think I probably would rather have the HDDs. :/ Does that make me a geek?

In hindsight, I'd rather have done the same.  All the car got me
was the ability to get back and forth from a job I didn't like, to
take out the girlfriend and spend the money I didn't have, to incur
more headaches that I didn't really need, and to get me that speeding
ticket that I didn't really want.

-- 

Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Variable number of parameters

2008-08-05 Thread Daniel Brown
On Tue, Aug 5, 2008 at 1:40 AM, Philip Thompson <[EMAIL PROTECTED]> wrote:
> Is it possible to grab a variable number of parameters and send the
> appropriate amount to another function?

You can predefine function parameters:



 but more likely, you're looking for func_get_args().

http://php.net/func_get_args

-- 

More full-root dedicated server packages:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] PDO prepared statements and LIKE escaping

2008-08-05 Thread Andrew Ballard
On Mon, Aug 4, 2008 at 1:36 AM, Larry Garfield <[EMAIL PROTECTED]> wrote:
> Hi folks.  I am trying to figure out the best way to handle an interesting
> issue in PDO prepared statements.  Consider:
>
> $search = 'mystring';
>
> $stmt = $dbh->prepare("SELECT * FROM mytable WHERE myfield LIKE :myfield");
> $stmt->execute(array(':myfield' => $search . '%'));
>
> The above will search for any record whose myfield entry begins with the value
> in $search.  Great.  And because it's a prepared statement, the database
> handles SQL injection protection for us.
>
> According to the manual, that is the correct way of handling LIKE statements:
>
> http://us3.php.net/manual/en/pdo.prepared-statements.php
>
> (See Example #6)
>
> But!  Now consider this:
>
> $search = "100% pure PHP";
>
> When that is run, the % in the literal string will get interpreted by the SQL
> server as another wildcard character.  That is not desired.
>
> IIRC, the way in SQL to circumvent that is to convert "100%" into "100%%".
> However, that does rather defeat the purpose of a prepared statement if I
> have to do my own escaping anyway, does it not?  We also cannot use
> $dbh->quote(), as that is intended for cases where you're building a query
> string directly rather than using a prepared statement.
>
> How do other folks handle this issue?
>
> --
> Larry Garfield
> [EMAIL PROTECTED]
>

I don't see any way around it, nor do I see it as defeating the
purpose of prepared statements. I also don't see that this is any
special limitation of PDO when compared to any other database library.
How can any escaping mechanism know that in one case you are looking
for a literal percent sign and in another you are using a wildcard?
You have to provide it with hints, which is what the escape character
does.

Escaping a percent sign inside a string literal used as the pattern
for a LIKE comparison is not the same thing as escaping single quotes
within a string. Most of the time a percent sign in a pattern will be
a wildcard; matching a literal percent sign is usually the exception.
If you fail to escape a percent sign in your condition, the query will
still execute successfully. You may get more (but not less) results
than you desired or intended, but it will still work. However, if you
fail to escape literal delimiters like single quotes, your query will
not (usually) run at all. (And if it does run, it will likely produce
undesired results or side effects, which is the definition of SQL
injection.) As I see it, this is one of the purposes of prepared
statements.

Andrew

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



Re: [PHP] Variable number of parameters

2008-08-05 Thread Philip Thompson

On Aug 5, 2008, at 8:58 AM, Daniel Brown wrote:

On Tue, Aug 5, 2008 at 1:40 AM, Philip Thompson <[EMAIL PROTECTED] 
> wrote:

Is it possible to grab a variable number of parameters and send the
appropriate amount to another function?


   You can predefine function parameters:



    but more likely, you're looking for func_get_args().

   http://php.net/func_get_args


Fortunately, I am quite familiar with your example. However, I am more  
looking for something in which I could send any number of parameters  
to my own function, grab each one of those individually, and then send  
them each to another built-in function. Basically, I want to avoid  
hard-coding this. On top of looking ugly, it's bad practice.


  anotherFunction ($args[0], $args[1], $args[2], $args[3], $args[4],  
$args[5]);

  // And continue counting up to a random number where I don't
  // think I'll have more than, say, 10 arguments
}
?>

Of course, even if I did hard-code this nastiness, anotherFunction()  
would still complain about whatever parameters were not used. So, args  
0 and 1 are filled, but 2-5 are not. "Warning! Warning! You can't have  
args 2 through 5, stoopud!"


Alas, I feel I must take a different approach to solve this problem.

~Philip

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



Re: [PHP] Variable number of parameters

2008-08-05 Thread Igor Kolodziejczyk

Philip Thompson wrote:

On Aug 5, 2008, at 8:58 AM, Daniel Brown wrote:

On Tue, Aug 5, 2008 at 1:40 AM, Philip Thompson 
<[EMAIL PROTECTED]> wrote:

Is it possible to grab a variable number of parameters and send the
appropriate amount to another function?


   You can predefine function parameters:



    but more likely, you're looking for func_get_args().

   http://php.net/func_get_args


Fortunately, I am quite familiar with your example. However, I am more 
looking for something in which I could send any number of parameters to 
my own function, grab each one of those individually, and then send them 
each to another built-in function. Basically, I want to avoid 
hard-coding this. On top of looking ugly, it's bad practice.


  anotherFunction ($args[0], $args[1], $args[2], $args[3], $args[4], 
$args[5]);

  // And continue counting up to a random number where I don't
  // think I'll have more than, say, 10 arguments
}
?>

Of course, even if I did hard-code this nastiness, anotherFunction() 
would still complain about whatever parameters were not used. So, args 0 
and 1 are filled, but 2-5 are not. "Warning! Warning! You can't have 
args 2 through 5, stoopud!"


Alas, I feel I must take a different approach to solve this problem.

~Philip


Hi Phillip

Why not use a foreach()?



That way you can send as many arguments as you please, without any ugly 
hardcoding...


Igor

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



Re: [PHP] Variable number of parameters

2008-08-05 Thread Per Jessen
Philip Thompson wrote:

>> but more likely, you're looking for func_get_args().
>>
>>http://php.net/func_get_args
> 
> Fortunately, I am quite familiar with your example. However, I am more
> looking for something in which I could send any number of parameters
> to my own function, grab each one of those individually, and then send
> them each to another built-in function. 

But isn't that *exactly* what func_get_args() allows you to do:

1. send any number of arguments to your own function - check!
2. grab each one of those individually - check!
3. send them each to  - check!

> Basically, I want to avoid hard-coding this. On top of looking ugly,
> it's bad practice. 
> [smip]
> Alas, I feel I must take a different approach to solve this problem.

What exactly _is_ the problem you're trying to solve? 


/Per Jessen, Zürich


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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Robert Cummings
On Tue, 2008-08-05 at 14:07 +0200, Aschwin Wesselius wrote:
> Richard Heyes wrote:
> > Hi,
> >
> > Seems my 1and1 server has finally gone kaput taking my website with
> > it, and in the tradition of all good IT professionals, I have no
> > backups. :( So this is an appeal to you to ask if you have downloaded
> > anything from phpguru.org at all, could you please send it to me so I
> > can try to rebuild my site.
> >
> > A big thanks.
> 
> Hi,
> 
> What does Google cache has? And the Wayback Machine 
> (http://www.archive.org/)? Coral Cache?
> 
> Bummer dude, but you've got to learn it once the hard time. On the other 
> hand, good backup solutions just cost a lot.

Not to stick a finger in Richard's bleeding wound... but a 1TB
hard-drive is less than $200 CAD. And you can get 6GB of Google mail for
free if you're really feeling the pinch. 8GB USB thumb drives are around
$30 CAD, and DVD blanks are like 25 cents a piece. I don't see the cost
issue.

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


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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Robert Cummings
On Tue, 2008-08-05 at 14:53 +0200, Aschwin Wesselius wrote:
> Richard Heyes wrote:
> >
> >> I'm going to have a look at my browser cache. Maybe I find something.
> >> 
> >
> > Thanks.
> I'm sorry Richard, seems that my browser doesn't hold the history long 
> enough.
> 
> Forgive me to ask, but how come that you don't have much copies of your 
> work? Do you work straight on your server?
> 
> I've got my editor (UltraEdit Studio) setup, that it makes a backup of 
> the file I'm editing every 5 minutes with a timestamp and the full path. 
> Besides that, we use SVN (wich is not that difficult to setup and manage).
> 
> So, if your server is your food (so to speak), you'd better take a look 
> at the simple things that might rescue you some day. Nowadays there are 
> little NAS devices with RAID-0 support (like My Books from Western 
> Digital), that gives a good backup solution for a quick buck. Off 
> course, you can always step up to better solutions and methods.
> 
> Doesn't your hosting provider has a backup facility? Maybe rent another 
> webserver (could be virtual) and mirror it with rsync? I don't know. 
> there must be something that suits your needs.
> 
> I wouldn't like to loose my stuff, but I can't afford much for the best 
> solutions either. It's not that my job depends on it, but personal data 
> is a big loss too.

Regardless of any backup solution... my stuff is usually in 3 different
places:

- my locale dev machine
- CVS repository on my other machine
- live deployment

Now the database is a different matter. But Richard has mentioned he's
missing CSS files. Even without a distinct CVS machine, his stuff could
have been in 2 different places.

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


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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Robert Cummings
On Tue, 2008-08-05 at 09:32 -0400, Daniel Brown wrote:
> On Tue, Aug 5, 2008 at 9:20 AM, Per Jessen <[EMAIL PROTECTED]> wrote:
> >
> > I use two in every system.  They're so cheap that it's not worth saving
> > the expense.
> 
> Yeah, now, thank God but remember, it wasn't always that way ;-P
> 
> http://web.archive.org/web/19961110071252/http://www.maxtor.com/
> 
> When the DiamondMax drives first came out, they were a couple
> hundred dollars each.  I wanted to be the first guy on the block with
> a terabyte RAID, but I bought a car instead.

Choices, choices. One must live with the repercussions of said
choices :)

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


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



RE: [PHP] An appeal to your better nature

2008-08-05 Thread Chris Haensel


-Original Message-
From: Robert Cummings [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 05, 2008 5:40 PM
To: Aschwin Wesselius
Cc: Richard Heyes; php-general@lists.php.net
Subject: Re: [PHP] An appeal to your better nature

On Tue, 2008-08-05 at 14:07 +0200, Aschwin Wesselius wrote:
> Richard Heyes wrote:
> > Hi,
> >
> > Seems my 1and1 server has finally gone kaput taking my website with
> > it, and in the tradition of all good IT professionals, I have no
> > backups. :( So this is an appeal to you to ask if you have downloaded
> > anything from phpguru.org at all, could you please send it to me so I
> > can try to rebuild my site.
> >
> > A big thanks.
>
> Hi,
>
> What does Google cache has? And the Wayback Machine
> (http://www.archive.org/)? Coral Cache?
>
> Bummer dude, but you've got to learn it once the hard time. On the other
> hand, good backup solutions just cost a lot.

Not to stick a finger in Richard's bleeding wound... but a 1TB
hard-drive is less than $200 CAD. And you can get 6GB of Google mail for
free if you're really feeling the pinch. 8GB USB thumb drives are around
$30 CAD, and DVD blanks are like 25 cents a piece. I don't see the cost
issue.

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


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

OMG! Richard, so sorry to hear this. I have been like that, not having a
backup at all. Now I have done my masterpiece about a year ago, and have it
on backup on DVD at 4 different locations as well as 3 webservers, 1 USB
stick and, as Rob pointed out, in my Gmail account.

I know it's hard and can cost you quite a sum if you don't have backups at
all (thank God my customers always sign a contract where it says that data
backup is their responsibility, not mine). Once, it cost me 7.000 Euros :o(

Sorry to say that I have never downloaded from your site, just wanted to
give you a little pad on the shoulder. Sometimes it's not too bad to start
from sratch (by god, i have done it many times until I learned about data
backup *lol*)

Cheers mate! Don't worry, things could be worse!

Chris



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



[PHP] Date formatting issue

2008-08-05 Thread Don Don
Hi all,

I've got dates in the following formats e.g.

August 05, 2008, 10:14 am (e.g. today's date)
August 04, 2008, 7:08 am (e.g. yesterda's date)
August 03, 2008, 9:08 am (e.g. in the past)

I am trying to format these dates do I can display them like this

Today at 10:14 am (today)
Yesterday at 9:08 am (yesterday)
August 03, 9:08 am (if its not today or yesterday then display the month and 
day and time only)

Can anyone help with tips on how to achieve this ?

Cheers




  

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



Re: [PHP] Date formatting issue

2008-08-05 Thread Dan Joseph
On Tue, Aug 5, 2008 at 11:48 AM, Don Don <[EMAIL PROTECTED]> wrote:

> Hi all,
>
> I've got dates in the following formats e.g.
>
> August 05, 2008, 10:14 am (e.g. today's date)
> August 04, 2008, 7:08 am (e.g. yesterda's date)
> August 03, 2008, 9:08 am (e.g. in the past)
>
> I am trying to format these dates do I can display them like this
>
> Today at 10:14 am (today)
> Yesterday at 9:08 am (yesterday)
> August 03, 9:08 am (if its not today or yesterday then display the month
> and day and time only)
>
> Can anyone help with tips on how to achieve this ?
>
> Cheers
>
>
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Check out date() and mktime() -- http://www.php.net/date
http://www.php.net/mktime

Both of those should get you in the direction of formating dates.

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


Re: [PHP] An appeal to your better nature

2008-08-05 Thread Richard Heyes
> Cheers mate! Don't worry, things could be worse!

There's time yet... :-/

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Micah Gersten
Seems like 1and1 screwed up their Apache installs.  My site shows a
blank page when I go to the domain, but when I go to index.php, it works.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Heyes wrote:
> Hi,
>
> Seems my 1and1 server has finally gone kaput taking my website with
> it, and in the tradition of all good IT professionals, I have no
> backups. :( So this is an appeal to you to ask if you have downloaded
> anything from phpguru.org at all, could you please send it to me so I
> can try to rebuild my site.
>
> A big thanks.
>
>   

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Richard Heyes
> Seems like 1and1 screwed up their Apache installs.  My site shows a
> blank page when I go to the domain, but when I go to index.php, it works.

Doubt it's that. When I first got the server I reinstalled practically
everything.

-- 
Richard Heyes
http://www.phpguru.org

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



Re: [PHP] An appeal to your better nature

2008-08-05 Thread Micah Gersten
I'm on a shared host, I should have mentioned that.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Richard Heyes wrote:
>> Seems like 1and1 screwed up their Apache installs.  My site shows a
>> blank page when I go to the domain, but when I go to index.php, it works.
>> 
>
> Doubt it's that. When I first got the server I reinstalled practically
> everything.
>
>   

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



[PHP] Echo in __GET()

2008-08-05 Thread Tyler C.
Is the a way to have an array, or use __get() to provide different data 
if you are echoing a variable, rather than if you are using it in a 'if' 
statement?


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



Re: [PHP] Echo in __GET()

2008-08-05 Thread Micah Gersten
You can write 2 functions to handle this.

Value and OutputValue

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Tyler C. wrote:
> Is the a way to have an array, or use __get() to provide different
> data if you are echoing a variable, rather than if you are using it in
> a 'if' statement?
>

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



Re: [PHP] Date formatting issue

2008-08-05 Thread Daniel Brown
On Tue, Aug 5, 2008 at 11:48 AM, Don Don <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I've got dates in the following formats e.g.
>
> August 05, 2008, 10:14 am (e.g. today's date)
> August 04, 2008, 7:08 am (e.g. yesterda's date)
> August 03, 2008, 9:08 am (e.g. in the past)
>
> I am trying to format these dates do I can display them like this
>
> Today at 10:14 am (today)
> Yesterday at 9:08 am (yesterday)
> August 03, 9:08 am (if its not today or yesterday then display the month and 
> day and time only)

If $month equals date("m") and $year equals date("Y") and $day
equals date("d") - 1 then it's yesterday.

If $month equals date("m") and $year equals date("Y") and $day
equals date("d") then it's today.

If $month equals date("m") and $year equals date("Y") and $day
equals date("d") + 1 then it's tomorrow.

Otherwise, echo date("F d, g:i a");


As Dan Joseph mentioned, read up on date()[1] and mktime()[2], and
I'd also recommend strtotime()[3].  Moreover, take the logic above and
code your PHP to match it. A simple if/elseif/else or case/switch
block will do it for you.



1:  http://php.net/date
2:  http://php.net/mktime
3:  http://php.net/strtotime

-- 

More full-root dedicated server packages:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



[PHP] Re: PHP Brain Teasers

2008-08-05 Thread Daniel Brown
On Tue, Jun 26, 2007 at 1:44 PM, Daniel Brown <[EMAIL PROTECTED]> wrote:
>
>   Try to use some really common phrases that all of us around the
> world should recognize, but feel free to get really elaborate with the
> code.







-- 

More full-root dedicated server packages:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Intel 2.4GHz/320/GB/1GB/3TB $74.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] PHP querying mysql db for data limited to the last month

2008-08-05 Thread Vinny Gullotta
Sorry, I took that stuff out because it was making the page not load and so 
I figured it was wrong. I guess I should have posted the whole thing, but 
since it didn't work I left it out.


Micah, thank you very much for the idea, it is working great!!!


"Micah Gersten" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]

1.  To get last months date, you can use strtotime("1 month ago")
instead of mktime.
2.  I don't see anywhere in the code where you are limiting by date.
Try using > and <.  Between is tricky on dates.

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Vinny Gullotta wrote:

So I have this code I'm working with (pasted below) that queries a
mysql db table called timetracking. The goal of the page is to search
the db for all data based on a certain engineer, sorted by product and
it takes pre-defined values based on actions performed, sums them
based on product and display's the percentage of time an engineer has
spent on each product. Everything works great except I need to limit
the results to the last months data only, but everything I try seems
to just break it. Can anyone push me in the right direction a little?
I have tried using BETWEEN in the SELECT statement, some while
statements and if statements, and all I do is keep breaking it. If
anyone has any ideas, it would be exceptionally helpful.

Thanks in advance,
Vinny


One Month Ago = ", $monthago, "";

$query = "SELECT *, SUM(timespent) FROM timetracking WHERE engineer =
'$engineer' GROUP BY product";
$result = mysql_query($query) or die(mysql_error());
$result2 = mysql_query($query) or die(mysql_error());
echo "";

 while($row = mysql_fetch_array($result)){
  $total = $row['SUM(timespent)'] + $total;
 }
 while($row = mysql_fetch_array($result2)){
  $perc = $row['SUM(timespent)'] * 100 / $total;
  echo "[ ", $row[product]. " = ".
number_format($perc,2), "% ]";
 }

?>





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



Re: [PHP] Variable number of parameters

2008-08-05 Thread Philip Thompson

On Aug 5, 2008, at 10:34 AM, Igor Kolodziejczyk wrote:


Philip Thompson wrote:

On Aug 5, 2008, at 8:58 AM, Daniel Brown wrote:
On Tue, Aug 5, 2008 at 1:40 AM, Philip Thompson <[EMAIL PROTECTED] 
> wrote:

Is it possible to grab a variable number of parameters and send the
appropriate amount to another function?


  You can predefine function parameters:



   but more likely, you're looking for func_get_args().

  http://php.net/func_get_args
Fortunately, I am quite familiar with your example. However, I am  
more looking for something in which I could send any number of  
parameters to my own function, grab each one of those individually,  
and then send them each to another built-in function. Basically, I  
want to avoid hard-coding this. On top of looking ugly, it's bad  
practice.

 anotherFunction ($args[0], $args[1], $args[2], $args[3], $args[4],  
$args[5]);

 // And continue counting up to a random number where I don't
 // think I'll have more than, say, 10 arguments
}
?>
Of course, even if I did hard-code this nastiness,  
anotherFunction() would still complain about whatever parameters  
were not used. So, args 0 and 1 are filled, but 2-5 are not.  
"Warning! Warning! You can't have args 2 through 5, stoopud!"

Alas, I feel I must take a different approach to solve this problem.
~Philip


Hi Phillip

Why not use a foreach()?




This isn't exactly what I'm wanting to achieve. I don't want to send  
each parameter individually, I want to send them all at the same time.  
It's *almost* like I want to create a string of parameters that I can  
send..




But, of course, this won't work because now 'sendThis' is a single  
string - not what I want. Thanks for the thoughts anyhow. =/


~Philip


That way you can send as many arguments as you please, without any  
ugly hardcoding...


Igor


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



Re: [PHP] Variable number of parameters

2008-08-05 Thread Per Jessen
Philip Thompson wrote:

> This isn't exactly what I'm wanting to achieve. I don't want to send
> each parameter individually, I want to send them all at the same time.

Sounds like you want the standard varargs behaviour from C ? Where you
can "gather up" a list of arguments as a va_list and pass that as an
argument to vfprintf() et al. 


/Per Jessen, Zürich


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



Re: [PHP] Fatal error: Cannot redeclare

2008-08-05 Thread Kai Kauer
Am Dienstag, 5. August 2008 15:46:42 schrieb Daniel Brown:
> On Tue, Aug 5, 2008 at 9:37 AM, Kai Kauer <[EMAIL PROTECTED]> wrote:
> > Hi @all,
> >
> > I was just installing the Moodle-Version 1.9.2 at our university. It was
> > installed without any problems. But during testing and preparing for use
> > I got this error message:
> >
> > Fatal error: Cannot redeclare make_log_url() (previously declared
> > in /global/WEB_DAT/documents/fme/institute/get/lehre/course/lib.php:25)
> > in ./lib.php on line 54
>
> This is usually a result of the same function include script being
> included twice, and thus, the function being defined a second time.
> Check ./lib.php on line 54 and see if it's including itself, or if -
> for whatever reason - there's two entries in that file starting with
> "function make_log_url(***)".
>
>
>
> *** Optional parameters may be enclosed within the parentheses.
>

This function make the error message

> function make_log_url($module, $url) {
> switch ($module) {
> case 'course':
> case 'file':
> case 'login':
> case 'lib':
> case 'admin':
> case 'calendar':
> case 'mnet course':
> return "/course/$url";
> break;
> case 'user':
> case 'blog':
> return "/$module/$url";
> break;
> case 'upload':
> return $url;
> break;
> case 'library':
> case '':
> return '/';
> break;
> case 'message':
> return "/message/$url";
> break;
> default:
> return "/mod/$module/$url";
> break;
> }
> }

and is in the whole project just called one time in this function:

> function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0,
> $perpage=100, $url="", $modname="", $modid=0, $modaction="", $groupid=0) {
>
> global $CFG;
>
> if (!$logs = build_logs_array($course, $user, $date, $order,
> $page*$perpage, $perpage, $modname, $modid, $modaction, $groupid)) {
> notify("No logs found!");
> print_footer($course);
> exit;
> }
>
> $courses = array();
>
> if ($course->id == SITEID) {
> $courses[0] = '';
> if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
> foreach ($ccc as $cc) {
> $courses[$cc->id] = $cc->shortname;
> }
> }
> } else {
> $courses[$course->id] = $course->shortname;
> }
>
> $totalcount = $logs['totalcount'];
> $count=0;
> $ldcache = array();
> $tt = getdate(time());
> $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
>
> $strftimedatetime = get_string("strftimedatetime");
>
> echo "\n";
> print_string("displayingrecords", "", $totalcount);
> echo "\n";
>
> print_paging_bar($totalcount, $page, $perpage,
> "$url&perpage=$perpage&");
>
> echo ' summary="">'."\n"; // echo " cellspacing=\"0\" summary=\"\">\n"; echo "";
> if ($course->id == SITEID) {
> echo " scope=\"col\">".get_string('course')."\n"; }
> echo " scope=\"col\">".get_string('time')."\n"; echo " scope=\"col\">".get_string('ip_address')."\n"; echo " header\" scope=\"col\">".get_string('fullname')."\n"; echo " class=\"c4 header\" scope=\"col\">".get_string('action')."\n"; echo
> "".get_string('info')."\n"; echo
> "\n";
>
> // Make sure that the logs array is an array, even it is empty, to
> avoid warnings from the foreach. if (empty($logs['logs'])) {
> $logs['logs'] = array();
> }
>
> $row = 1;
> foreach ($logs['logs'] as $log) {
>
> $row = ($row + 1) % 2;
>
> if (isset($ldcache[$log->module][$log->action])) {
> $ld = $ldcache[$log->module][$log->action];
> } else {
> $ld = get_record('log_display', 'module', $log->module,
> 'action', $log->action); $ldcache[$log->module][$log->action] = $ld;
> }
> if ($ld && is_numeric($log->info)) {
> // ugly hack to make sure fullname is shown correctly
> if (($ld->mtable == 'user') and ($ld->field ==
> sql_concat('firstname', "' '" , 'lastname'))) { $log->info =
> fullname(get_record($ld->mtable, 'id', $log->info), true); } else {
> $log->info = get_field($ld->mtable, $ld->field, 'id',
> $log->info); }
> }
>
> //Filter log->info
> $log->info = format_string($log->info);
>
> // If $log->url has been trimmed short by the db size restriction
> // code in add_to_log, keep a note so we don't add a link to a
> broken url $tl=textlib_get_instance();
> $brokenurl=($tl->strlen($log->url)==100 &&
> $tl->substr($log->url,97)=='...');
>
> $log->url  = strip_tags(urldecode($log->url));   // Some XSS
> protection $log->info = strip_tags(urldecode($log->info));  // Some XSS
> protection $log->url  = s($log->url); /// XSS protection and XHTML
> compatibi

Re: [PHP] Fatal error: Cannot redeclare

2008-08-05 Thread Micah Gersten
What is around this line?

/global/WEB_DAT/documents/fme/institute/get/lehre/course/lib.php:25


Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Kai Kauer wrote:
> Am Dienstag, 5. August 2008 15:46:42 schrieb Daniel Brown:
>   
>> On Tue, Aug 5, 2008 at 9:37 AM, Kai Kauer <[EMAIL PROTECTED]> wrote:
>> 
>>> Hi @all,
>>>
>>> I was just installing the Moodle-Version 1.9.2 at our university. It was
>>> installed without any problems. But during testing and preparing for use
>>> I got this error message:
>>>
>>> Fatal error: Cannot redeclare make_log_url() (previously declared
>>> in /global/WEB_DAT/documents/fme/institute/get/lehre/course/lib.php:25)
>>> in ./lib.php on line 54
>>>   
>> This is usually a result of the same function include script being
>> included twice, and thus, the function being defined a second time.
>> Check ./lib.php on line 54 and see if it's including itself, or if -
>> for whatever reason - there's two entries in that file starting with
>> "function make_log_url(***)".
>>
>>
>>
>> *** Optional parameters may be enclosed within the parentheses.
>>
>> 
>
> This function make the error message
>
>   
>> function make_log_url($module, $url) {
>> switch ($module) {
>> case 'course':
>> case 'file':
>> case 'login':
>> case 'lib':
>> case 'admin':
>> case 'calendar':
>> case 'mnet course':
>> return "/course/$url";
>> break;
>> case 'user':
>> case 'blog':
>> return "/$module/$url";
>> break;
>> case 'upload':
>> return $url;
>> break;
>> case 'library':
>> case '':
>> return '/';
>> break;
>> case 'message':
>> return "/message/$url";
>> break;
>> default:
>> return "/mod/$module/$url";
>> break;
>> }
>> }
>> 
>
> and is in the whole project just called one time in this function:
>
>   
>> function print_log($course, $user=0, $date=0, $order="l.time ASC", $page=0,
>> $perpage=100, $url="", $modname="", $modid=0, $modaction="", $groupid=0) {
>>
>> global $CFG;
>>
>> if (!$logs = build_logs_array($course, $user, $date, $order,
>> $page*$perpage, $perpage, $modname, $modid, $modaction, $groupid)) {
>> notify("No logs found!");
>> print_footer($course);
>> exit;
>> }
>>
>> $courses = array();
>>
>> if ($course->id == SITEID) {
>> $courses[0] = '';
>> if ($ccc = get_courses('all', 'c.id ASC', 'c.id,c.shortname')) {
>> foreach ($ccc as $cc) {
>> $courses[$cc->id] = $cc->shortname;
>> }
>> }
>> } else {
>> $courses[$course->id] = $course->shortname;
>> }
>>
>> $totalcount = $logs['totalcount'];
>> $count=0;
>> $ldcache = array();
>> $tt = getdate(time());
>> $today = mktime (0, 0, 0, $tt["mon"], $tt["mday"], $tt["year"]);
>>
>> $strftimedatetime = get_string("strftimedatetime");
>>
>> echo "\n";
>> print_string("displayingrecords", "", $totalcount);
>> echo "\n";
>>
>> print_paging_bar($totalcount, $page, $perpage,
>> "$url&perpage=$perpage&");
>>
>> echo '> summary="">'."\n"; // echo "> cellspacing=\"0\" summary=\"\">\n"; echo "";
>> if ($course->id == SITEID) {
>> echo "> scope=\"col\">".get_string('course')."\n"; }
>> echo "> scope=\"col\">".get_string('time')."\n"; echo "> scope=\"col\">".get_string('ip_address')."\n"; echo "> header\" scope=\"col\">".get_string('fullname')."\n"; echo "> class=\"c4 header\" scope=\"col\">".get_string('action')."\n"; echo
>> "".get_string('info')."\n"; echo
>> "\n";
>>
>> // Make sure that the logs array is an array, even it is empty, to
>> avoid warnings from the foreach. if (empty($logs['logs'])) {
>> $logs['logs'] = array();
>> }
>>
>> $row = 1;
>> foreach ($logs['logs'] as $log) {
>>
>> $row = ($row + 1) % 2;
>>
>> if (isset($ldcache[$log->module][$log->action])) {
>> $ld = $ldcache[$log->module][$log->action];
>> } else {
>> $ld = get_record('log_display', 'module', $log->module,
>> 'action', $log->action); $ldcache[$log->module][$log->action] = $ld;
>> }
>> if ($ld && is_numeric($log->info)) {
>> // ugly hack to make sure fullname is shown correctly
>> if (($ld->mtable == 'user') and ($ld->field ==
>> sql_concat('firstname', "' '" , 'lastname'))) { $log->info =
>> fullname(get_record($ld->mtable, 'id', $log->info), true); } else {
>> $log->info = get_field($ld->mtable, $ld->field, 'id',
>> $log->info); }
>> }
>>
>> //Filter log->info
>> $log->info = format_string($log->info);
>>
>> // If $log->url has been trimmed short by the db size restriction
>> // code in add_to_log, keep a note so

[PHP] A specific(ish) request

2008-08-05 Thread Richard Heyes
Hi,

After spending most of day trying to retrieve code, I've got the
majority. But specifically, if you have downloaded any of these, I'd
be grateful if you could send whatever you have to
[EMAIL PROTECTED]

Thanks.

Datagrid
RPC for PHP5
htmlMimeMail5
Any of my HTML5 charts
PEAR::DB replacement
My updated templating class
Javascript dynContext (Context menus)
Javascript dynCalendar (A calendar...)
Anything else I may have missed

Thanks for any help!

-- 
Richard Heyes
http://www.phpguru.org

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



[PHP] Job Opportunity - User Experience Designer / Boulder, CO

2008-08-05 Thread Nick Gasparro
Hello Group,

We are looking for a User Experience Designer to join our dynamic and growing 
Internet-based company. The User Experience Designer will iteratively specify, 
prototype, design and implement UI Skins, Interaction Flows, and Information 
Architecture for new product features. Here are some additional skills we are 
looking for:

* Passion for User Experience Design and solving large community design problems
* Advanced to Expert level CSS2 - hand coding with strong knowledge of browser 
compatibility issues
* Ability to read and code XHTML to standards without WYSIWYG editing tool
* Advanced to Expert Photoshop / Illustrator CS3 skills
* Extremely comfortable in a mixed computing environments (Mac, Windows, Linux)

Please reply back with your resume and contact information if you are 
interested in the opportunity.

Best,

Nick Gasparro
Managing Partner, REMY Corp.
Denver, CO 80202
303-539-0448 Direct
303-547-7469 Cell
[EMAIL PROTECTED]
www.remycorp.com



[PHP] Newbie problem: Php script not running in browser.

2008-08-05 Thread V S Rawat

I have put the first php script to hello.php file:


  
   PHP Test
  
  
  Hello World'; ?>
  


I am on xpsp3, wampserver 2.0, having apache 2.2.8, php 5.2.6, MySQL 5.0.51b

http://localhost/ is E:\wamp\www

I put the hello.php file to E:\wamp\www. drag/dropping it to browser
shows the above source code in ff3/ie6

putting it to E:\wamp\bin\apache\apache2.2.8\htdocs and drag/dropping it
to browser shows the same source code.

However, putting it to E:\wamp\www\php_ex but giving
http://localhost/hello.php shows a blank screen

I have forgotten some situation where it had appeared as

Hello World

'; ?>

on the browser.

E:\wamp\bin\apache\apache2.2.8\conf\httpd.conf file has the lines:
LoadModule php5_module "e:/wamp/bin/php/php5.2.6/php5apache2_2.dll"
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php3

On double clicking the php file in windows explorer, it opens in notepad
for edit, instead of getting opened in firefox that is my default.

Please give me the starting push.
-- V

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



Re: [PHP] Newbie problem: Php script not running in browser.

2008-08-05 Thread Andrew Ballard
On Tue, Aug 5, 2008 at 3:05 PM, V S Rawat <[EMAIL PROTECTED]> wrote:
> I have put the first php script to hello.php file:
>
> 
>  
>   PHP Test
>  
>  
>  Hello World'; ?>
>  
> 
>
> I am on xpsp3, wampserver 2.0, having apache 2.2.8, php 5.2.6, MySQL 5.0.51b
>
> http://localhost/ is E:\wamp\www
>
> I put the hello.php file to E:\wamp\www. drag/dropping it to browser
> shows the above source code in ff3/ie6
>
> putting it to E:\wamp\bin\apache\apache2.2.8\htdocs and drag/dropping it
> to browser shows the same source code.
>
> However, putting it to E:\wamp\www\php_ex but giving
> http://localhost/hello.php shows a blank screen
>
> I have forgotten some situation where it had appeared as
>
> Hello World
>
> '; ?>
>
> on the browser.
>
> E:\wamp\bin\apache\apache2.2.8\conf\httpd.conf file has the lines:
> LoadModule php5_module "e:/wamp/bin/php/php5.2.6/php5apache2_2.dll"
> AddType application/x-httpd-php .php
> AddType application/x-httpd-php .php3
>
> On double clicking the php file in windows explorer, it opens in notepad
> for edit, instead of getting opened in firefox that is my default.
>
> Please give me the starting push.
> -- V
>


If you simply drag-and-drop the file from an explorer window into
Firefox, Firefox will display the page directly from the file system
instead of serving it through your web server. (You can tell this
because your address bar will say file:///E:/wamp/www/hello.php.) Your
browser won't parse the PHP as script; it will just think it is
malformed HTML and it would show the output you listed above.
Double-clicking the file, or dragging it into IE will try to open the
file with whatever program is associated with that extension in
Windows. (If there isn't a file association for *.php files, it will
either prompt you for a program to handle the file or it might do the
same as Firefox. I'm not sure, and I'm not really interested in
changing my file associations to test.)

IF the file is located at E:\wamp\www\hello.php AND PHP is configured
correctly AND your web server's document root is E:\wamp\www\, THEN
opening http://localhost/hello.php should work.

Andrew

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



Re: [PHP] Variable number of parameters

2008-08-05 Thread Jim Lucas

Philip Thompson wrote:
Is it possible to grab a variable number of parameters and send the 
appropriate amount to another function?


db->prepare("SELECT * FROM `table` WHERE (`id`=?)");
$this->db->bind('ii', $id1);

$this->db->prepare("SELECT * FROM `table` WHERE (`id`=? AND 
`other_id`=?)");

$this->db->bind('ii', $id1, $id2);

// DB class
function bind () {
  $args = func_get_args();
  $this->statement->bind_param($args[0], $args[1], ...);
}
?>

Ok, is it possible to send any number of variables to db->bind() in 
order to send those to statement->bind_param()?


Or, if someone else has a better db abstraction method, feel free to 
educate...


Thanks,
~Phil



 $v ) {
// Check to see if this value is a string, if so escape the data
// Else, let is pass through untouched!
if ( is_string($v) ) {
  $values[$k] = escapeshellarg($v);
} else {
  $values[$k] = $v;
}
  }

  // Put it all together in one long string
  $arguments = join(', ', $values);


  // Combined your argument string and function call
  // Process and return results.
  return eval("return anotherFunction({$arguments})");

}

myFunction (1, 5, 'Hi');

// This will result in calling anotherFunction as such
anotherFunction ('1, 5, Hi');
// and not
anotherFunction (1, 5, 'Hi');
?>

If this isn't what you are looking for, please explain a little more!

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare


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



[PHP] Re: An appeal to your better nature

2008-08-05 Thread Ross McKay
On Tue, 5 Aug 2008 12:34:53 +0100, "Richard Heyes" wrote:

>Seems my 1and1 server has finally gone kaput taking my website with
>it, and in the tradition of all good IT professionals, I have no
>backups. :( So this is an appeal to you to ask if you have downloaded
>anything from phpguru.org at all, could you please send it to me so I
>can try to rebuild my site.

Problems I see with the above:

* good IT professionals use version control AND take backups
* good IT professionals work on dev servers and migrate to test, prod
* good IT professionals don't tend to claim "guru" status themselves :)

Having said that, I'm about to commit yesterday's changes to Subversion
and run another backup whilst touching wood!

Checking Google's cache should give you an idea of what you had up
there, and the rebuild is always better than the original anyway...
-- 
Ross McKay, Toronto, NSW Australia
"Let the laddie play wi the knife - he'll learn"
- The Wee Book of Calvin

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



Re: [PHP] Variable number of parameters

2008-08-05 Thread Daniel Brown
On Tue, Aug 5, 2008 at 6:07 PM, Jim Lucas <[EMAIL PROTECTED]> wrote:
>
> # WARNING 
> # The following example uses eval() to do the execution.
> # The following answer is a YMMV answer.
> # Be careful with it.  I could be a sleeping snake waiting to bite...
> #

Errata for those of you reading this in the archives, newsgroups,
or wherever:

I'm sure Jim meant to say, "It could be a sleeping snake" above.
So don't worry about him trying to get 1337 with his h4x0r skillz by
pwn1ng ur b0x.  It's a typo, it's not malicious code.

-- 

Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Why PHP4?

2008-08-05 Thread Jason
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

n3or wrote:
> Compatibility to older Software of the hosters and sloth of the developers
> 
> Richard Heyes schrieb:
>> I'm interested - why are people still using PHP4? It's been over 4
>> years (I think) - plenty of time to upgrade to five.

Don't lump the developers into the bin for the sys-admins.  When I took
my current position over 2 years ago I started pushing for upgrading to
PHP5...and it's just barely getting done now.


-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFImOMKNE8/G8NKdKMRApW3AKC8iMu5GISY4w1XohqNCcJto1iUPACfVZcV
XcMLg2367XByo1wRevrVe2g=
=0w0w
-END PGP SIGNATURE-

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



Re: [PHP] Re: An appeal to your better nature

2008-08-05 Thread Daniel Brown
On Tue, Aug 5, 2008 at 7:28 PM, Ross McKay <[EMAIL PROTECTED]> wrote:
>
> Problems I see with the above:
>
> * good IT professionals use version control AND take backups
> * good IT professionals work on dev servers and migrate to test, prod
> * good IT professionals don't tend to claim "guru" status themselves :)

Addendum:

* Good IT professionals don't usually criticize one another in a
public forum in the above manner, if nothing else than out of
professional courtesy.

-- 

Better prices on dedicated servers:
Intel 2.4GHz/60GB/512MB/2TB $49.99/mo.
Intel 3.06GHz/80GB/1GB/2TB $59.99/mo.
Dedicated servers, VPS, and hosting from $2.50/mo.

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



Re: [PHP] Variable number of parameters

2008-08-05 Thread Larry Garfield
On Tuesday 05 August 2008 12:40:27 am Philip Thompson wrote:

> Ok, is it possible to send any number of variables to db->bind() in
> order to send those to statement->bind_param()?
>
> Or, if someone else has a better db abstraction method, feel free to
> educate...
>
> Thanks,
> ~Phil

Unless I'm misunderstanding you entirely:

http://us.php.net/manual/en/function.func-get-args.php
http://us.php.net/call_user_func_array

You can pretty much do anything you want with that.

-- 
Larry Garfield
[EMAIL PROTECTED]

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



Re: [PHP] A specific(ish) request

2008-08-05 Thread Per Jessen
Richard Heyes wrote:

> Anything else I may have missed

A backup script?  :-)


/Per Jessen, Zürich


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