Re: [PHP] PHP Help Needed

2008-12-27 Thread John Corry
lol, Ashley!

Ayemowa,
http://www.google.com/search?q=becoming+a+programmer&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

You need to take your 2 steps below and break them down into smaller
steps...and smaller steps...and still smaller steps.

What PHP files will your application require?
Will there be forms?
What will the user interface look like?

Don't start with a 'PHP script'.

Start by defining in excruciating detail what your application is
going to do, how it will do it and then describe every little part
(variables, functions, models, views, controllers...whatever) that
will make it work.

Once you have that description, you can start to think about the code
by writing it's documentation.

Then, once you have the documentation, you can write code based on the
documentation...revising the docs as necessary.

It's a lengthy, complicated process that is going to demand a little
more of you than just reducing your app to 2 steps and asking a
mailing list how to do it.

Good luck, let us know how it goes and how we can help you take (much
smaller) steps.

John Corry

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



Re: [PHP] Webhotel structure

2008-12-27 Thread John Corry
+1

Is it me or has the php mailing list kind of dumbed itself down in the
last 5 years?



>
>What?
>
> --
> 
> daniel.br...@parasane.net || danbr...@php.net
> http://www.parasane.net/ || http://www.pilotpig.net/
> Unadvertised dedicated server deals, too low to print - email me to find out!
>
> --
> 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] Search functionality in website.

2008-12-29 Thread John Corry
Or even a google search widget...

Miles Thompson wrote:
> On Mon, Dec 29, 2008 at 10:47 AM, Tiji varghese  wrote:

> ht-dig (or digg)
> 

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



Re: [PHP] Php mysql update

2008-12-29 Thread John Corry
Wouldn't it be:
mysql_query("UPDATE database set Field = Field+1 WHERE
Criteria='Criteria'");

Note: no '' around +1, = operator

John Corry

ad...@buskirkgraphics.com wrote:
> Okay maybe i have just forgot.
> I am trying to update the database and do a +1 to a int field without pulling 
> the data and adding 1 to it and sticking it back in.
> 
> Someone refresh me on this please.
> I think it is something like.
> $dwsl = mysql_query("UPDATE database set Field='+1' WHERE 
> Criteria='Criteria'");
> 

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



Re: [PHP] Need Help

2008-12-29 Thread John Corry
1. It's generally considered poor etiquette to send that much code to a
mailing list. How about snipping the relevant section next time?

2. the error says: mysqli_fetch_assoc() expects parameter 1 to be
mysqli_result. There's your clue. Is the query good? Is the connection good?

I'm getting a little dismayed here lately at how many people are posting
to this list who don't have a clue and aren't willing to even TRY to get
a clue before asking for help from someone else.

Tracking down errors like this, function by function, is how you LEARN
this stuff.

Please do yourself (and everyone else on the list) a favor and do at
least just even a MODEST amount of research before sending your hundreds
of lines of crappy code out to the ether asking someone to fix it for you!

John

PS - sorry if that's not soft and sensitive enough. Where I come from
(vintage late 90s self-educated programmer), you didn't DARE ask for
help until you could demonstrate to everyone you were asking that you
had done your homework on the problem, researched the relevant
functions/error messages, tried some tests doing something similar, run
the query to make sure it's good...basically everything you COULD do to
debug your own mess.


dlinden wrote:
> I am getting this error and can't resolve;
> 
> Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result,
> boolean given in /home5/camfulco/public_html/CompanyHome.php on line 132
> 
> code listing follows;

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



Re: [PHP] Need Help - apology

2008-12-29 Thread John Corry

That was too heavy handed.

I'm sorry. Please forgive my harshness.

John

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



Re: [PHP] First steps towards unix and php

2009-01-08 Thread John Corry
Ubuntu linux has been really easy to set up, administrate and
install/run programs.

It has a huge user base, really good support forums and supports a
large variety of hardware configurations. I'm running it on my
Thinkpad T40, which I use for PHP development when travelling. It's
rock solid and easy to work with.

Definitely ought to be one of the packages you consider.

On Thu, Jan 8, 2009 at 11:44 AM, Frank Stanovcak
 wrote:
> I've been a microshaft punk for some time now, and am just getting ready to
> try to step over to unix on one of my own boxes.
>
> Does anyone have any suggestions on which flavor would be a good idea to
> start with?  I'm looking mostly for compatibility with php, mysql, and other
> web based programming languages.
>
> Thanks in advance!
>
> Frank
>
>
>
> --
> 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] [SOLVED] Re: can a session be used in a query?

2009-01-08 Thread John Corry
I read (well, skimmed anyway) this thread and saw that the original
poster's issue was resolved.

For the archives though, I'd like to mention that the PEAR Auth and
MDB2 packages would make all of the things that are being done by this
code much easier for the programmer.

Auth allows you to authenticate users from a table and retrieve any
other field in the table at the same time. It's always seemed a lot
cleaner to me than dealing directly with building session based user
info scripts. Based on what I've seen of the code here, it would have
saved you a lot of time.

Likewise, MDB2 makes working with MySQL easier and also provides
better error reporting.

Hope it's not off-topic or unreasonably presumptuous to mention these
packages here. They've saved me a lot of time and helped me code
better, thought I'd share that experience with the list.

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



Re: [PHP] Re: First steps towards unix and php

2009-01-08 Thread John Corry
I don't know about Geany, but you should definitely check out:
PDT/Eclipse
Zend Studio for Eclipse <- my favorite
Komodo Edit 5

Kate for PHP development? That sounds really slow and inefficient.
Eclipse and Zend studio offer such efficiencies as code
completion/hints (PHP core or any other included classes/files), code
explorer views/trees, SVN/CVS support, debugging...very capable IDEs.

Zend costs $$, Eclipse/PDT is free.

John Corry

On Thu, Jan 8, 2009 at 6:33 PM, Skip Evans  wrote:
> Ross McKay wrote:
>>
>> You should also check out editors and IDEs - STFW for previous posts
>> made to this and other groups. Then pick Geany ;)
>>
>
> Hey Ross & all,
>
> I used Kate on Ubuntu for a code editor. I just read through a bit about
> Geany (was not familiar with it), but don't see too much more it would do
> for me than Kate.
>
> What are some of your favorite features of Geany I should be aware of?
>
>
> --
> ===
> Skip Evans
> Big Sky Penguin, LLC
> 503 S Baldwin Street
> Madison, Wisconsin 53703
> 608.250.2720
> http://bigskypenguin.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] Convert CMYK values to RGB values?

2009-01-09 Thread John Corry
Have you looked here?

http://www.google.com/custom?domains=www.phpclasses.org&q=cmyk+to+rgb&sa=Search&sitesearch=www.phpclasses.org&client=pub-2951707118576741&forid=1&channel=5742870948&ie=ISO-8859-1&oe=ISO-8859-1&cof=GALT%3A%23663399%3BGL%3A1%3BDIV%3A%2322%3BVLC%3A663399%3BAH%3Acenter%3BBGC%3AA3C5CC%3BLBGC%3AA3C5CC%3BALC%3AFF%3BLC%3AFF%3BT%3A00%3BGFNT%3AFF%3BGIMP%3AFF%3BLH%3A50%3BLW%3A256%3BL%3Ahttp%3A%2F%2Ffiles.phpclasses.org%2Fgraphics%2Fgooglesearch.jpg%3BS%3Ahttp%3A%2F%2Fwww.phpclasses.org%2Fsearch.html%3BFORID%3A1%3B&hl=en

Without looking at any of their code, I do notice that some class
descriptions look promising.

John Corry

On Fri, Jan 9, 2009 at 8:03 PM, Shawn McKenzie  wrote:
> c...@l-i-e.com wrote:
>> Short Answer:
>>
>> You can't.
>> :-)
>>
>> http://en.wikipedia.org/wiki/CMYK
>>
>> Long Answer:
>> You probably can, but not in some way that makes sense to discuss here on 
>> PHP-general.
>>
>> The external links in the above article should get you started.
>>
>
> May not always come out with the best colors, but the rough formula is:
>
> Black   = minimum(1-Red,1-Green,1-Blue)
> Cyan= (1-Red-Black)/(1-Black)
> Magenta = (1-Green-Black)/(1-Black)
> Yellow  = (1-Blue-Black)/(1-Black)
>
> Write your own little functions to convert.
>
> --
> Thanks!
> -Shawn
> http://www.spidean.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] Couple of beginner questions

2009-01-11 Thread John Corry
One of the best things that ever happened to me (with regards to
writing PHP) was deciding not to embed it in HTML anymore.

I either:
a) generate the HTML from classes I've built (HTML, Forms, Tables,
Images, etc) or use an equivalent PEAR class

- or -

b) Use Smarty templates...in which I still generate the HTML that will
go to the template (where required) with the HTML generation classes.

The advantages are abundant.

I can't imagine having to maintain some of the code I saw in the
examples above. My favorite WTF was with this snippet:

$imgHTML = '';

Holy crap...REALLY!?

All that string concatenation and there's not even width/height
attributes in there!

That would look like:

$i = new Image('path/to/image/file');
$i->__set(array('class'=>$imgClass, 'alt' => $altText));
$i->toHtml();

Being able to change every image tag in a site by editing the
class/method that created is just too big an advantage not to use. Not
to mention the auto-generated width/height attributes, the ability to
auto-produce thumbnails and fullsize images from a single file...

After struggling through the beginnings, I wrote classes to generate
basic HTML elements, then tables, then forms, then images.

It saved me a bunch of time and taught me to see the website as an
application...not as a web-page with pieces of data in it.

Somehow, coming to that bit of knowledge was very helpful to my life
as a programmer.

Good luck,

John Corry

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



Re: [PHP] Zend (or other) Framework...where to start?

2009-01-14 Thread John Corry
Well, bummer.

I *seriously* need to divine a way to increase my efficiency both
immediately and for the long term as I maintain tomorrow the
applications I build today.

For the new-to-frameworks, is there a better/easier framework to use
that will streamline the development process from the beginning?

I've looked at Codeigniter and LOVE the user guide/documentation...the
underlying philosophy of that product looks very attractive too.

Any others?

I'd love to have the time to 'play around' with one or more of these
to get an idea of strengths/weaknesses...but due to schedule and
commitments, this 'playing around' is going to have to take place in
the production, for-hire context.

Surely we're all familiar with 'on the job training', right? ; )

John Corry

> ZF isn't going to save you any time on a single project.  The time
> savings is over time with multiple projects where everything is
> organized the same way, code sharing, new developers not having to
> learn something new each time, etc.  It is also one of the hardest to
> actually use too since it can be customized on any part of it.  I'd
> recommend it though because it does have a good community, lots of
> eyes on it, frequent releases, & docs
> 
> There's a lot more to this discussion though.  So keep researching and
> trying different ones out...

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



Re: [PHP] To check for existing user in database

2009-01-15 Thread John Corry
You might want to (seriously) look at the PEAR Auth class.

It can save you a TON of time...all the stuff you're trying to do with
this code (that you were just told you're going to have to rewrite) is
already done for you.

It's very handy for registering/tracking users of your sites.

John Corry

On Thu, Jan 15, 2009 at 1:43 PM, Daniel Brown  wrote:
>Welcome to the list, Chris.
>
>Your code is going to require some rewriting to save you a lot of
> headaches and serious security issues down the road.  So here we go:

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



Re: [PHP] PHP Enclosing Tags? Do You Close Your PHP Declarations?

2009-01-30 Thread John Corry
Same here.

They're just extraneous elements and can hide whitespace.

I leave them open in all applcation files and close them only in templates.

>
>
> I only close tags inside templates.  All of my logic code is outside
> of markup though so those files never have a closing ?> for exactly
> the reasons you stated.
>
> --
> http://www.voom.me | EFnet: #voom
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] pear:Auth invalid username/password

2009-02-02 Thread John Corry
I'm using Pear Auth on several sites and am looking for suggestions on the
best way to implement error reporting on a failed log-in.

Currently I'm using a function that checks if the posted username is in the
users table...and if the password is a match. Auth logs the user on if
so...but if not it takes manually running the queries to generate the right
failure message.

Is there a cleaner way using error messages generated by the getAuth()
method or another method in the Auth class? I didn't see anything in the
docs...but it seems like an obvious bit of functionailty I would sort of
expect it to be included.

Anyone know of such a thing?

John Corry


[PHP] Lightweight Picasa API v3

2009-02-13 Thread John Corry

Anyone using Cameron Hinkle's Picasa API?

I'm having a bitch of a time trying to get the AuthSub methods working
and would love to trade ideas if anyone is familiar.

thanks,

John Corry
email: jco...@gmail.com






[PHP] Google Apps AuthSub = missing $_GET element

2009-02-14 Thread John Corry

I am completely baffled by this.

I have a PHP script  that is using Cameron Hinkle's  
LightweightPicasaAPIv3 to authenticate with the Google Picasa service  
using the AuthSub method.


Basically, if we're not authenticated, redirect to the google authsub  
URL:
(https://www.google.com/accounts/AuthSubRequest?next=http%3A%2F%2Ftwozerowest.com%2Fsnowdog%2520gallery%2Fadmin.php&scope=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi&session=1 
)


This page requests that the user either grant access or deny access.

Grant access takes us to the URL specified (my authentication script)  
with a ?token=x added to the end of the URL.


This all works. We get back to my URL with ?token=x appended to  
the URL.


That's when it starts getting weirder than anything I've seen in PHP:
My debugging output confirms that:
1. $_SERVER['request_method'] = GET
2. strlen($_GET['token']) = 0
3. $_GET - array()...but it's empty!
4. $_REQUEST[] contains no 'token' element
5. echo($_GET['token']) prints the value of ?token= from the URL

So WTF?

My code:

Note the comments inside/around the try/catch statement inside the if  
block.


WTF? This evaluates to false...or seems to anyway. Code that is inside  
it's if{} statement does not execute.

if(strlen($_GET['token']) > 0)

But then, other code that IS in it's if{} statement DOES execute...and  
the $_GET['token'] that has a 0 strlen in the if() statement now echos  
as a 16 character string!


WTF!!???

if(strlen($_GET['token']) > 0) {
// evaluates ???...
$firephp->info('got a token: ' . $_GET['token']); #this  
doesn't happen
echo ('echo $_GET[\'token\'] output: ' . $_GET['token']);  
#this doesn't happen

// try to authenticate with it

# this try/catch block DOES NOT happen!
try{
$token = $pic->authorizeWithAuthSub($_GET['token']);
$firephp->info('running authorizeWithAuthSub() with  
token: ' . $_GET['token']);

if($pic->isAuthenticated()){
$firephp->info('there we go...authenticated!');
$firephp->info('token :' . $pic->getAuthToken());
echo 'inside try/catch :' . $_GET['token']; #this  
echo statement inside the try/catch DOES happen...WTF!?

}
    } catch (Picasa_Exception_FailedAuthorizationException $e){
$firephp->log($e, 'error');
}
} else {
$pic->redirectToLoginPage('http://twozerowest.com/snowdog%20gallery/admin.php' 
, 1);

}

Anyone have ANY idea what's going on?

John Corry
email: jco...@gmail.com



Re: [PHP] Sorting times

2009-02-14 Thread John Corry
1. convert the string representation of times to timestamps using  
strtotime()

2. sort the timestamps
3. display the timestamps as strings using date('format', timestamp)

Would that work?

John Corry
email: jco...@gmail.com




On Feb 14, 2009, at 4:07 PM, tedd wrote:


Hi gang:

Anyone have/know a routine that will sort an array of times?

For example, a function that would take an array like this:

time[0] ~ '1:30pm'
time[1] ~ '7:30am'
time[2] ~ '12:30pm'

and order it to:

time[0] ~ '7:30am'
time[1] ~ '12:30pm'
time[2] ~ '1:30pm'


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.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



[PHP] PHP 5.3 date.timezone

2009-07-17 Thread John Corry
Why is date.timezone blank...I'm setting it in the config file?
How come PHP is ignorning teh directives I have set in the .ini?

OS X with PHP 5.3 compiled from source on Apache 2.2.9

WTF?

Here's my php.ini file:[Date]
; Defines the default timezone used by the date functions
date.timezone = America/New_York

date.default_latitude = 34.3044
date.default_longitude = -83.8338

;date.sunrise_zenith = 90.58
;date.sunset_zenith = 90.58

But here's my phpinfo() output:
*Warning*: phpinfo()
[function.phpinfo<http://jcorry.localhost.com/function.phpinfo>]:
It is not safe to rely on the system's timezone settings. You are *required*
to use the date.timezone setting or the date_default_timezone_set()
function. In case you used any of those methods and you are still getting
this warning, you most likely misspelled the timezone identifier. We
selected 'America/New_York' for 'EDT/-4.0/DST' instead in *
/Users/jcorry/web_work/jcorry/httpdocs/info.php* on line *2*
 date/time support enabled "Olson" Timezone Database Version 2009.10 Timezone
Database internal Default timezone America/New_York
 DirectiveLocal ValueMaster Value date.default_latitude31.766731.7667
date.default_longitude35.25.2333 date.sunrise_zenith90.5890.58
date.sunset_zenith90.58333390.58 date.timezone*no value**no value*

-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com


Re: [PHP] get an object property

2009-09-11 Thread John Corry

Wouldn't it be $o[1]->a?

J Corry
Sent from my iPhone

On Sep 11, 2009, at 7:31 PM, Tom Worster  wrote:

if i have an expression that evaluates to an object, the return  
value from a
function, say, and i only want the value of one of the objects  
properties,

is there a tidy way to get it without setting another variable?

to illustrate, here's something that doesn't work, but it would be
convenient if it did:

$o = array( (object) array('a'=>1), (object) array('a'=>2) );

if ( end($o)->a > 1 ) {  // can't use -> like this!
...
}




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



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



[PHP] sending HTML email

2009-10-05 Thread John Corry
I've inherited a PHP application, first task of which was relocating to a
new server.
We've installed and configured all of the files on a dedicated linux server
at 1 and 1 (using qmail as an MTA).

Since the move, the client is complaining that *some* of the recipients of
the HTML email that the server sends out to all of the users are receiving
plain HTML code in their mail clients...not the nice, rendered, styled
content they intend.

It looks fine to me.

I found one small error in the HTML that was sent and fixed it (there may be
more)...

But the client is telling me that this is a new problem as of the server
move.

Any suggestions which direction to look to try to resolve this?

-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com


[PHP] mod_rewrite...https index page -> http index page

2009-12-01 Thread John Corry
My apologies, this is not strictly PHP...but it is relevant to a great
number of PHP application frameworks that many of us use or will use.

I have a Magento installation that relies heavily on mod_rewrite. For the
most part, I have all of my canonical URLs worked out, minus one issue.

How do I make sure that https:// requests for / are redirected to http:// /
?

I've got a rule already that strips the index.php off of requests, so I
don't want to check for that...just want to check for requests for the
https:// version of my root home page and redirect to the non-secure
version.

I suck with regex and all of my attempts to modify examples I've found have
failed.
-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com


Re: [PHP] Checking for internet connection.

2009-12-19 Thread John Corry
Curl_init() will return a resource or false if it fails, like it would  
if no Internet connection were present.


J Corry
Sent from my iPhone

On Dec 19, 2009, at 5:36 PM, "Angus Mann"  wrote:



Why can't you put the update on the same LAN server that the app  
resides?


If that is not possible, what about using CURL, and update if it can  
connect successfully, but don't if it cannot?


 Thanks,
 Ash
 http://www.ashleysheridan.co.uk

 Since the LAN is remote (many hundreds of miles away) from the  
source of the update, the only practical way to deliver an update  
every month or week to multiple users is to make it available for  
download from a central "update server".


 I'm just trying to maximize efficiency by checking if an  
internet connection exists, and abandoning further attempts to check  
for update availability if it does not.


 The idea to use CURL seems valid, but it pre-supposes that I  
know the answer to my own question. To use your suggestion, I'd have  
to have some mechanism to detect if it "can connect successfully".  
I'm asking what that mechanism should be, and if the one I've  
suggested is good, or flawed in some way.







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



[PHP] RewriteCond / rule for mod_rewrite

2010-01-12 Thread John Corry
I have this in my .htaccess file (for a Magento installation).


## never rewrite for existing files, directories and links

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l


## rewrite everything else to index.php
RewriteRule .* index.php [L]

The client just asked for a wordpress installation. I installed and set it
up in /blog.

But when I request /blog in my browser, I get an endless redirect error.

???

Anyone care to offer help with why?

-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com


Re: [PHP] POLL: To add the final ?> or not...

2010-01-12 Thread John Corry
I leave ?> out.

I'm pretty careful about my code formatting and whitespace.

It's my opinion that if I can eliminate a potential problem by not including
an optional closing tag...there's really no reason why I shouldn't.
-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com


[PHP] IDE -> SVN -> dev server -> live server

2010-01-14 Thread John Corry
I am working on designing an documenting a process for our team to use to
manage code updates/changes.

What we've been doing has been ghastly: a bunch of developers using
dreamweaver's 'check in/out' functions, all using the same FTP login, to FTP
files to the production server.

It turns out the site we're working on together is a bit too complex for
this, so it's on me to come up with a better way.

I'm a big fan of SVN and think we'll be light years ahead of where we are
presently by using SVN to manage code revisions.

So, I've set up an SVN repository on our dedicated server and imported all
of the live-site code. Then I set up a dev virtual host (dev.domain.com) and
exported all of the code in my repository to that vhost's DocRoot. So...that
gave me a copy. Next, I copied the MySQL db to a separate db that we'll use
for the dev server...so dev code doesn't query the live db. Then of course,
I had to edit the config files that have DSN information in them to make
sure my dev site actually uses my dev db.

Here's where the problems start to creep in...

If I export the whole repository from SVN to the dev DocRoot directory, I'm
going to overwrite the config files that have DSN info in them. Similarly,
there are some javascript files that declare variables like var base_url = '
http://mysite.com'...those variables need to be set once for the environment
(my local IDE? the dev server? the production server?) and then not messed
with afterward.

After an SVN commit, it's really easy to svn export svn://localhost/mysite
/path/to/my/dev_server

Simple, all of the code in the repository goes to the dev server.

The issue I'm having is that there are a number of files that I do NOT want
to be copied from the repository to the dev server, except on
rare occasions.

So, I can choose to add the files to my svn:ignore in my working copy so
they aren't committed/updated. But I can't ensure that all of the developers
take this step and it's not a reliable way to keep those select files in the
repository out of my dev server.

Or, I can write a shell script that does the SVN export, then overwrites the
selected config files with master versions that are stored somewhere else
and not edited by any of the team. One problem with that though, is that our
main javascript file tends to be edited/changed and it's one that can create
problems if that base_url var isn't appropriate to the server it's on.

Or, in all of my PHP files, I can write the config values into switch
statements:
switch($_SERVER['HTTP_HOST']) {
  case 'mysite.local':
 // local IDE config directives
  case 'dev.mysite.com':
 // dev server config directives
  // etc...
}

...but that leaves the production server DSN sitting around in development
code, which I'd like to avoid, and I don't have an analogous solution for my
javascript files.

JS question: is there a js way to do the same thing? Evaluate the js
equivalent of PHP's $_SERVER['HTTP_HOST']? If there is, I think this
solution will work.

This has got to be a fairly typical workflow and problem.

What are some of the strategies you folks use for designing your flow of
code from local IDE to SVN to dev server to production server?

-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com


[PHP] intermittent failure of php date

2010-01-18 Thread John Corry
I maintain a site that is generating some strange behavior...

It's a custom built event registration app.

Events have event_dates that are stored in the MySQL db.

This code retrieves the event title and event date for display on the
registration acknowledgment page:

$q2 = "SELECT title, event_date, DATE_FORMAT(event_date, '%M %d, %Y') AS
formatted_event_date FROM events WHERE id =" . $eid . ";";
 $result = mysql_query($q2);
 if ($result) {
   $row = mysql_fetch_array($result);
   $title = $row['title'];

   if(strtotime($row['event_date'])) {
  $event_date = date("F m, Y", strtotime($row['event_date']));
   } else {
  $event_date = $row['formatted_event_date'];
   }

Sometimes, it doesn't work.

Every 3rd or 4th registration notification email comes through with an empty
value for event_date.

There are no other references to the variable $event_date.

It works most of the time.

There's no pattern I can see. I even tried to force it to show a date by
selecting a formatted date and displaying that if the original programmer's
strtotime failed.

Where do you look for help with intermittent failures of a date field in the
DB?


-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com


[PHP] Re: intermittent failure of php date

2010-01-18 Thread John Corry
The field in the DB is defined as type date.

I've had several event registrations for an upcoming event come through. THe
event date is '2010-01-27'.

2 of the 5 event registrations contained empty values for the date.

wtf?

On Mon, Jan 18, 2010 at 10:23 AM, John Corry  wrote:

> I maintain a site that is generating some strange behavior...
>
> It's a custom built event registration app.
>
> Events have event_dates that are stored in the MySQL db.
>
> This code retrieves the event title and event date for display on the
> registration acknowledgment page:
>
> $q2 = "SELECT title, event_date, DATE_FORMAT(event_date, '%M %d, %Y') AS
> formatted_event_date FROM events WHERE id =" . $eid . ";";
>  $result = mysql_query($q2);
>  if ($result) {
>$row = mysql_fetch_array($result);
>$title = $row['title'];
>
>if(strtotime($row['event_date'])) {
>   $event_date = date("F m, Y", strtotime($row['event_date']));
>} else {
>   $event_date = $row['formatted_event_date'];
>}
>
> Sometimes, it doesn't work.
>
> Every 3rd or 4th registration notification email comes through with an
> empty value for event_date.
>
> There are no other references to the variable $event_date.
>
> It works most of the time.
>
> There's no pattern I can see. I even tried to force it to show a date by
> selecting a formatted date and displaying that if the original programmer's
> strtotime failed.
>
> Where do you look for help with intermittent failures of a date field in
> the DB?
>
>
> --
> John Corry
> PHP developer - 3by400, Inc
> http://www.3by400.com
>
>


-- 
John Corry
PHP developer - 3by400, Inc
http://www.3by400.com