Re: [PHP] New to PHP question

2009-01-28 Thread Don Collier



Paul M Foster wrote:

On Wed, Jan 28, 2009 at 01:45:07PM -0700, Don Collier wrote:

  

On that note, what would be a better book to learn from?  I have always
been a fan of the O'Reilly books, but I am open to differing flavors of
kool-aid.  One can never have too many resources.



The book that sits on my desk and is incredibly dog-eared is
_Programming PHP_, also from O'Reilly. The whole back section is a
reference on all the PHP functions and some extensions. The front part
of the book explains nearly everything about the language.

There are some errata in the book, which I've pointed out to O'Reilly,
and when in doubt I check the function documentation on the php.net
site.

Paul


  
I have this "Learning PHP 5" and at the same time bought "PHP and MySQL" 
also from O'Reilly.  Ever since my first "Sed and Awk" book from them 
about 10 or so years ago I have been hooked.  I do have others in my 
library but I usually give them a shot first to see if I get what I need.


I will have to pick up a copy of the "Programming PHP" and give it a 
look.  Thanks.


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



Re: [PHP] New to PHP question

2009-01-28 Thread Paul M Foster
On Wed, Jan 28, 2009 at 11:41:31PM +, Nathan Rixham wrote:

> Paul M Foster wrote:
>> On Wed, Jan 28, 2009 at 09:26:10PM +, Ashley Sheridan wrote:
>>
>> 
>>
>>> I use CSS as much as possible, and it's second nature to me now to
>>> design with CSS rather than tables, but the only area I find it quicker
>>> to use tables is when I design forms. I know I'm going to browser hell,
>>> but meh, I can deal with it! :p
>>
>> That's my problem. Almost all the stuff I do is actual tabular data, or
>> forms. Of course, the header and side bars are built with CSS. But the
>> interior data are usually in tables.
>>
>> I've got forms with 50-odd fields in them, and I completely dispair of
>> trying to make it look as good in CSS as it does in tables. Even with
>> tables, I had more experimenting and colspans than you can imagine.
>>
>> Paul
>>
>
> see this is why i chant "flex flex flex flex flex flex flex flex flex
> flex flex flex flex  flx"

Oh, a proprietary protocol and set of tools meant to run on a
proprietary platform, built by a company as rapacious as Microsoft, and
whose applications can't be mined by search engines?

Oh yeah, I'm there.

Paul


-- 
Paul M. Foster

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



Re: [PHP] help with require/includes pathing frustration [SOLVED]

2009-01-28 Thread Daniel Brown
On Wed, Jan 28, 2009 at 22:23, Daevid Vincent  wrote:
>
> What a newb mistake!!! UGH. Sorry for wasting everyone's bandwidth.
> Is there a way to have this email deleted from the archives -- I am
> embarrassed by it! HAHAH!

You wish.  Just be glad the PostTrack isn't running right now.
I'd count you so hard that literally ALL your base are belong to us.

-- 

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



Re: [PHP] help with require/includes pathing frustration

2009-01-28 Thread Daniel Brown
On Wed, Jan 28, 2009 at 22:15, Daevid Vincent  wrote:
> At the very top of my login.php page I have this:
>
>  require_once('./includes/gui/gui_setup.inc.php');
> ...
> ?>
>
> (I've tried with and without the "./" prefix as if that might make a
> difference)

Not that it will make a difference in this case, but instead of
"./", use something like 

> When I try to load the URL:
> https://example.com/vincentd/mydart/login.php
>
> I get this error:
>
> Warning: require_once(./includes/gui/gui_setup.inc.php)
> [function.require-once]: failed to open stream:
> No such file or directory in /home/www/vincentd/mydart/login.php on line
> 2

1.) Note the name of the file required here.

> If I try to access it from the web:
> https://example.com/vincentd/mydart/includes/gui/gui_setup.inc.php

2.) Note the name of the file requested here.

> vince...@pse02 /home/www/vincentd/mydart/includes/gui $ ll
> -rw-rw-rw- 1 vincentd vincentd 11046 2009-01-29 01:17 gui_menu.inc.php
> -rw-r--r-- 1 vincentd vincentd  1589 2009-01-29 02:44 gui_setup.php

3.) Note the names of the files located here.  ;-P

> Doesn't the ".:" in include_path='.:/usr/share/php:/usr/share/pear' mean
> that PHP should look in the current directory (which I assume would be
> "/home/www/vincentd/mydart") as that is where login.php is located?
> And then relative to there it should look in "includes/gui/..." as per
> my require_once command.

You are correct, sir.  It's just a typo --- you merged the two
file names into one nonexistent file.

-- 

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



Re: [PHP] help with require/includes pathing frustration [SOLVED]

2009-01-28 Thread Daevid Vincent
OMFG! I'm an idiot. This is what happens when you work long hours and
refactor code without eating/sleeping properly..

so... it's "gui_setup.inc.php" I'm trying to include, yet the file is
named "gui_setup.php". 

What a newb mistake!!! UGH. Sorry for wasting everyone's bandwidth.
Is there a way to have this email deleted from the archives -- I am
embarrassed by it! HAHAH!

On Wed, 2009-01-28 at 19:15 -0800, Daevid Vincent wrote:

> At the very top of my login.php page I have this:
> 
>  require_once('./includes/gui/gui_setup.inc.php');
> ...
> ?>
> 
> (I've tried with and without the "./" prefix as if that might make a
> difference)
> 
> When I try to load the URL:
> https://example.com/vincentd/mydart/login.php
> 
> I get this error:
> 
> Warning: require_once(./includes/gui/gui_setup.inc.php) 
> [function.require-once]: failed to open stream: 
> No such file or directory in /home/www/vincentd/mydart/login.php on line
> 2
> 
> Fatal error: require_once() 
> [function.require]: Failed opening required
> './includes/gui/gui_setup.inc.php' 
> (include_path='.:/usr/share/php:/usr/share/pear') 
>   in /home/www/vincentd/mydart/login.php on line 2
> 
> If I try to access it from the web:
> https://example.com/vincentd/mydart/includes/gui/gui_setup.inc.php
> 
> I get a 404:
> 
> Not Found
> The requested URL /vincentd/mydart/includes/gui/gui_setup.inc.php was
> not found on this server.
> 
> Yet, the file exists.
> 
> vince...@pse02 /home/www/vincentd/mydart/includes/gui $ ll
> -rw-rw-rw- 1 vincentd vincentd 11046 2009-01-29 01:17 gui_menu.inc.php
> -rw-r--r-- 1 vincentd vincentd  1589 2009-01-29 02:44 gui_setup.php
> 
> vince...@pse02 /home/www/vincentd/mydart/includes/gui $ ll ../../
> drwxrwxrwx 2 vincentd vincentd4096 2009-01-28 23:50 css
> -rw-rw-rw- 1 vincentd vincentd3542 2008-12-29 22:45 favicon.ico
> drwxrwxrwx 5 vincentd vincentd4096 2009-01-27 00:19 images
> drwxrwxrwx 8 vincentd vincentd4096 2009-01-08 01:55 includes
> -rw-rw-rw- 1 vincentd vincentd7556 2009-01-29 02:49 login.php
> -rw-rw-rw- 1 vincentd vincentd   15748 2009-01-14 01:00 my_account.php
> -rw-rw-rw- 1 vincentd vincentd 121 2008-12-31 00:07 phpinfo.php
> -rw-rw-rw- 1 vincentd vincentd   20678 2009-01-29 01:14 template.html
> 
> or put another way (using the same path from the root www dir):
> 
> vince...@pse02 /home/www/vincentd/mydart $ ll
> includes/gui/gui_setup.php 
> -rw-r--r-- 1 vincentd vincentd 1589 2009-01-29 02:44
> includes/gui/gui_setup.php
> 
> Doesn't the ".:" in include_path='.:/usr/share/php:/usr/share/pear' mean
> that PHP should look in the current directory (which I assume would be
> "/home/www/vincentd/mydart") as that is where login.php is located?
> And then relative to there it should look in "includes/gui/..." as per
> my require_once command.
> 
> What am I not understanding about this?




Re: [PHP] help with require/includes pathing frustration

2009-01-28 Thread Edmund Hertle
2009/1/29 Daevid Vincent 

> At the very top of my login.php page I have this:
>
>  require_once('./includes/gui/gui_setup.inc.php');
> ...
> ?>
>
> (I've tried with and without the "./" prefix as if that might make a
> difference)
>
> When I try to load the URL:
> https://example.com/vincentd/mydart/login.php
>
> I get this error:
>
> Warning: require_once(./includes/gui/gui_setup.inc.php)
> [function.require-once]: failed to open stream:
> No such file or directory in /home/www/vincentd/mydart/login.php on line
> 2
>
> Fatal error: require_once()
> [function.require]: Failed opening required
> './includes/gui/gui_setup.inc.php'
> (include_path='.:/usr/share/php:/usr/share/pear')
>in /home/www/vincentd/mydart/login.php on line 2
>
> If I try to access it from the web:
> https://example.com/vincentd/mydart/includes/gui/gui_setup.inc.php
>
> I get a 404:
>
> Not Found
> The requested URL /vincentd/mydart/includes/gui/gui_setup.inc.php was
> not found on this server.
>
> Yet, the file exists.
> [...]
>  -rw-r--r-- 1 vincentd vincentd 1589 2009-01-29 02:44
> includes/gui/gui_setup.php
>
> Doesn't the ".:" in include_path='.:/usr/share/php:/usr/share/pear' mean
> that PHP should look in the current directory (which I assume would be
> "/home/www/vincentd/mydart") as that is where login.php is located?
> And then relative to there it should look in "includes/gui/..." as per
> my require_once command.
>
> What am I not understanding about this?


Well, the name of the file is just: gui_setup.php
but you tried to include: gui_setup.inc.php
Should work without "./"

 -eddy


[PHP] help with require/includes pathing frustration

2009-01-28 Thread Daevid Vincent
At the very top of my login.php page I have this:



(I've tried with and without the "./" prefix as if that might make a
difference)

When I try to load the URL:
https://example.com/vincentd/mydart/login.php

I get this error:

Warning: require_once(./includes/gui/gui_setup.inc.php) 
[function.require-once]: failed to open stream: 
No such file or directory in /home/www/vincentd/mydart/login.php on line
2

Fatal error: require_once() 
[function.require]: Failed opening required
'./includes/gui/gui_setup.inc.php' 
(include_path='.:/usr/share/php:/usr/share/pear') 
in /home/www/vincentd/mydart/login.php on line 2

If I try to access it from the web:
https://example.com/vincentd/mydart/includes/gui/gui_setup.inc.php

I get a 404:

Not Found
The requested URL /vincentd/mydart/includes/gui/gui_setup.inc.php was
not found on this server.

Yet, the file exists.

vince...@pse02 /home/www/vincentd/mydart/includes/gui $ ll
-rw-rw-rw- 1 vincentd vincentd 11046 2009-01-29 01:17 gui_menu.inc.php
-rw-r--r-- 1 vincentd vincentd  1589 2009-01-29 02:44 gui_setup.php

vince...@pse02 /home/www/vincentd/mydart/includes/gui $ ll ../../
drwxrwxrwx 2 vincentd vincentd4096 2009-01-28 23:50 css
-rw-rw-rw- 1 vincentd vincentd3542 2008-12-29 22:45 favicon.ico
drwxrwxrwx 5 vincentd vincentd4096 2009-01-27 00:19 images
drwxrwxrwx 8 vincentd vincentd4096 2009-01-08 01:55 includes
-rw-rw-rw- 1 vincentd vincentd7556 2009-01-29 02:49 login.php
-rw-rw-rw- 1 vincentd vincentd   15748 2009-01-14 01:00 my_account.php
-rw-rw-rw- 1 vincentd vincentd 121 2008-12-31 00:07 phpinfo.php
-rw-rw-rw- 1 vincentd vincentd   20678 2009-01-29 01:14 template.html

or put another way (using the same path from the root www dir):

vince...@pse02 /home/www/vincentd/mydart $ ll
includes/gui/gui_setup.php 
-rw-r--r-- 1 vincentd vincentd 1589 2009-01-29 02:44
includes/gui/gui_setup.php

Doesn't the ".:" in include_path='.:/usr/share/php:/usr/share/pear' mean
that PHP should look in the current directory (which I assume would be
"/home/www/vincentd/mydart") as that is where login.php is located?
And then relative to there it should look in "includes/gui/..." as per
my require_once command.

What am I not understanding about this?


Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Shawn McKenzie
Chris wrote:
> 
>> The main problem is that you've never explained what you want to get
>> from the query.  The replies have used your code as an example and I'm
>> pretty sure that's not what you want.  Unless I totally mis-understand
>> what you want, you have 2 options:
>>
>> 1. Use the 2 queries that I gave you in a previous post.
>> 2. Use a subquery:
>>
>> $sql = "SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM
>> admin WHERE UserName = '" .
>> mysql_real_escape_string($_SESSION['user']) . "')";
> 
> 3 - fix the join ;)
> 

Yes, however, I'm going out on a limb here because we don't really know
what he wants - he is only getting admin.AdminID, workorders.AdminID
returned in all of the queries I've seen.  I'm assuming that he wants
some of the workorder details.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Chris



The main problem is that you've never explained what you want to get
from the query.  The replies have used your code as an example and I'm
pretty sure that's not what you want.  Unless I totally mis-understand
what you want, you have 2 options:

1. Use the 2 queries that I gave you in a previous post.
2. Use a subquery:

$sql = "SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM admin WHERE UserName = '" 
. mysql_real_escape_string($_SESSION['user']) . "')";


3 - fix the join ;)

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


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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Shawn McKenzie


Terion Miller wrote:
>
>
>
> Your  post made perfect sense to me about the INNER JOIN , I
> looked it up but it is not returning the AdminID, maybe my
> syntax is wrong?
>
> $query =  "SELECT admin.AdminID , workorders.AdminID
> FROM admin
> INNER JOIN
> workorders
> ON  AdminID(admin, workorders)
> WHERE admin.UserName =   '".$_SESSION['user']."' ";
>
>
> The syntax is wrong.
>
> inner join workorders using (adminid)
> ^^
> only works if both tables are using the same field name, the db
> will expand it into the syntax below. Here you just need to
> specify the fieldname to join on (ie the common one).
>
> or
>
> inner join workorders on (admin.adminID=workorders.adminID)
> ^^
> if the field names are not named the same, eg:
>
> select * from
> comments
> inner join users on (comments.user_id=users.id )
>
> Well I tried both ways and still cannot get it to pick up the AdminID,
>
The main problem is that you've never explained what you want to get
from the query.  The replies have used your code as an example and I'm
pretty sure that's not what you want.  Unless I totally mis-understand
what you want, you have 2 options:

1. Use the 2 queries that I gave you in a previous post.
2. Use a subquery:

$sql = "SELECT * FROM workorders WHERE AdminID = (SELECT AdminID FROM admin 
WHERE UserName = '" 
. mysql_real_escape_string($_SESSION['user']) . "')";

-Shawn





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



Re: [PHP] Mailing list rules?

2009-01-28 Thread Daniel Brown
On Wed, Jan 28, 2009 at 17:52, Daniel Kolbo  wrote:
> Hello,
>
> Is it okay for me to post a message looking for programmers willing to help
> out with a php project?

Absolutely, Dan, go right ahead.  As long as you don't "bump" the
thread or post strictly to advertise any kind of product or service,
you'll have no problems posting it to PHP General.

-- 

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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Chris



Well I tried both ways and still cannot get it to pick up the AdminID,

$query	"SELECT admin.AdminID , workorders.AdminID FROM admin INNER JOIN 
workorders on AdminID WHERE admin.UserName = 'tmiller' "

$result ""
$row""
$SortBy "WorkOrderID DESC"
$Page   "1"
$PerPage"30"
$StartPage  "0"
$sql	"SELECT admin.AdminID , workorders.AdminID FROM admin INNER JOIN 
workorders ON AdminID(admin, workorders) WHERE admin.UserName = 'tmiller' "

$Total  "0"


That is not the right syntax still.

It needs to be:

select
 admin.AdminID, workorers.AdminID
from
 admin inner join workorders using (AdminID)
WHERE
 admin.userName='tmiller';


or


select
 admin.AdminID, workorers.AdminID
from
 admin inner join workorders ON (admin.AdminID=workorders.AdminID)
WHERE
 admin.userName='tmiller';

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


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



Re: [PHP] New to PHP question

2009-01-28 Thread Nathan Rixham

Paul M Foster wrote:

On Wed, Jan 28, 2009 at 09:26:10PM +, Ashley Sheridan wrote:




I use CSS as much as possible, and it's second nature to me now to
design with CSS rather than tables, but the only area I find it quicker
to use tables is when I design forms. I know I'm going to browser hell,
but meh, I can deal with it! :p


That's my problem. Almost all the stuff I do is actual tabular data, or
forms. Of course, the header and side bars are built with CSS. But the
interior data are usually in tables.

I've got forms with 50-odd fields in them, and I completely dispair of
trying to make it look as good in CSS as it does in tables. Even with
tables, I had more experimenting and colspans than you can imagine.

Paul



see this is why i chant "flex flex flex flex flex flex flex flex flex 
flex flex flex flex  flx"


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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Terion Miller
>
>
>  Your  post made perfect sense to me about the INNER JOIN , I looked it up
>> but it is not returning the AdminID, maybe my syntax is wrong?
>>
>> $query =  "SELECT admin.AdminID , workorders.AdminID
>> FROM admin
>> INNER JOIN
>> workorders
>> ON  AdminID(admin, workorders)
>> WHERE admin.UserName =   '".$_SESSION['user']."' ";
>>
>
> The syntax is wrong.
>
> inner join workorders using (adminid)
> ^^
> only works if both tables are using the same field name, the db will expand
> it into the syntax below. Here you just need to specify the fieldname to
> join on (ie the common one).
>
> or
>
> inner join workorders on (admin.adminID=workorders.adminID)
> ^^
> if the field names are not named the same, eg:
>
> select * from
> comments
> inner join users on (comments.user_id=users.id)
>
> Well I tried both ways and still cannot get it to pick up the AdminID,

$query"SELECT admin.AdminID , workorders.AdminID FROM admin INNER JOIN
workorders on AdminID WHERE admin.UserName = 'tmiller' "$result""$row""
$SortBy"WorkOrderID DESC"$Page"1"$PerPage"30"$StartPage"0"$sql"SELECT
admin.AdminID , workorders.AdminID FROM admin INNER JOIN workorders ON
AdminID(admin, workorders) WHERE admin.UserName = 'tmiller' "$Total"0"


RE: [PHP] New to PHP question

2009-01-28 Thread Ashley Sheridan
On Wed, 2009-01-28 at 16:05 -0600, Boyd, Todd M. wrote:
> > -Original Message-
> > From: Stephen [mailto:stephe...@rogers.com]
> > Sent: Wednesday, January 28, 2009 1:41 PM
> > To: Paul M Foster
> > Cc: php-general@lists.php.net
> > Subject: Re: [PHP] New to PHP question
> > 
> > Paul M Foster wrote:
> > > If you want exact layout (columns
> > > lined up, etc.), the simplest solution is to use HTML tables.
> > >
> > >
> > >
> > The horror.
> > 
> > Do not use tables for layout.
> > 
> > Use CSS.
> > 
> > Especially now that Microsoft, just this week, is sending out IE 8
> > which
> > seems to be fully CCS standards compliant.
> 
> Your high horse--get off of it.
> 
> Are you not familiar with "div-itis"? If I need to represent data in a
> grid-style layout, I am going to use a  every time instead of
> making tons of  elements and tying them into the appropriate CSS.
> 
> http://www.giveupandusetables.com
> 
> Also... as far as I know, XHTML 1.0 Strict and XHTML 1.1 still include
> the  tags. I can understand wanting to separate style from
> structure, but I think that tables are more structural than stylish. You
> have to draw the line somewhere.
> 
> If you're displaying tabular data, use a table. If you just want stuff
> to be in a grid and the structure has no bearing on the content, then
> it's time to weigh in. 
> 
> Finally, just because IE8 is (supposed to be) fully CSS standards
> compliant doesn't mean anything for IE7, IE6, IE5, etc.
> 
> 
> // Todd
> 
I hate div'itis as well. Some people seem to think it's a big faux pas
to use table tags now, when that couldn't be more wrong. Use tables for
tabular data, CSS for the rest (with as few exceptions - and there are
always some eh - as you can manage.) I've seen people try to rebuild a
table of data, that you might represent in a spreadsheet, as a
collection of div's. Bad form, as the data has now lost all meaning.
This is the same as replacing all your  tags with  or  with . Silly idea, slap
on the wrist, don't do it again.

Personally, CSS is my preferred way of working now. I can define a whole
bunch of elements, semantically as possible, and then can redefine the
look as often as I wish afterwards with CSS. Look at the CSS Zen Garden
if you don't believe how useful this is. Rather than going through a
bunch of page to replaces tables, or PHP code to change the output
layout, you can redefine your CSS to alter the look. It's not a black
art, it just needs a little practise. Remember how bad we all were when
we first started using HTML? It's exactly the same thing here!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] New to PHP question

2009-01-28 Thread Paul M Foster
On Wed, Jan 28, 2009 at 09:26:10PM +, Ashley Sheridan wrote:



> >
> I use CSS as much as possible, and it's second nature to me now to
> design with CSS rather than tables, but the only area I find it quicker
> to use tables is when I design forms. I know I'm going to browser hell,
> but meh, I can deal with it! :p

That's my problem. Almost all the stuff I do is actual tabular data, or
forms. Of course, the header and side bars are built with CSS. But the
interior data are usually in tables.

I've got forms with 50-odd fields in them, and I completely dispair of
trying to make it look as good in CSS as it does in tables. Even with
tables, I had more experimenting and colspans than you can imagine.

Paul

-- 
Paul M. Foster

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



Re: [PHP] New to PHP question

2009-01-28 Thread Paul M Foster
On Wed, Jan 28, 2009 at 03:33:19PM -0500, Ernie Kemp wrote:

> Is there any advantage to using CSS over table and would it be idea to go 
> to
> past website and change them.

If it works, don't fix it. If you want to take the time to figure out
how to get those same layouts in CSS, have a blast. But as you can see
here from other replies, tables are the simplest choice for a lot of
people who work with web pages all the time.

Paul

-- 
Paul M. Foster

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



Re: [PHP] New to PHP question

2009-01-28 Thread Paul M Foster
On Wed, Jan 28, 2009 at 01:45:07PM -0700, Don Collier wrote:

>>
> On that note, what would be a better book to learn from?  I have always
> been a fan of the O'Reilly books, but I am open to differing flavors of
> kool-aid.  One can never have too many resources.

The book that sits on my desk and is incredibly dog-eared is
_Programming PHP_, also from O'Reilly. The whole back section is a
reference on all the PHP functions and some extensions. The front part
of the book explains nearly everything about the language.

There are some errata in the book, which I've pointed out to O'Reilly,
and when in doubt I check the function documentation on the php.net
site.

Paul


-- 
Paul M. Foster

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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Chris

Terion Miller wrote:
I'm not sure what you mean by trim the posts, please explain so I can 
spare folks from redundant text. 


Before you post, remove any text that you're not referencing (in this 
case I removed my suggestion).


Your  post made perfect sense to me about the INNER JOIN , I looked it 
up but it is not returning the AdminID, maybe my syntax is wrong?


$query =  "SELECT admin.AdminID , workorders.AdminID
 FROM admin
 INNER JOIN
 workorders
 ON  AdminID(admin, workorders)
 WHERE admin.UserName =   '".$_SESSION['user']."' ";


The syntax is wrong.

inner join workorders using (adminid)
^^
only works if both tables are using the same field name, the db will 
expand it into the syntax below. Here you just need to specify the 
fieldname to join on (ie the common one).


or

inner join workorders on (admin.adminID=workorders.adminID)
^^
if the field names are not named the same, eg:

select * from
comments
inner join users on (comments.user_id=users.id)

You have to use the full tablename (or alias) and the field name.

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


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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Terion Miller
I'm not sure what you mean by trim the posts, please explain so I can spare
folks from redundant text.

Your  post made perfect sense to me about the INNER JOIN , I looked it up
but it is not returning the AdminID, maybe my syntax is wrong?

$query =  "SELECT admin.AdminID , workorders.AdminID
 FROM admin
 INNER JOIN
 workorders
 ON  AdminID(admin, workorders)
 WHERE admin.UserName =   '".$_SESSION['user']."' ";

$result = mysql_query ($query);
$row = mysql_fetch_assoc ($result);

echo $row['AdminID'];

thanks again!!
terion


On Wed, Jan 28, 2009 at 4:28 PM, Chris  wrote:

>
>  Here are my variables when I reveal them, I am picking up the right
>> adminID
>> I can't figure out why it's returning random orders though:
>> $query"SELECT admin.AdminID, workorders.AdminID FROM admin, workorders
>> WHERE
>> admin.UserName = 'tmiller' "
>>
>
> Please please please trim your posts to relevant stuff. I had to go through
> 4 pages of previous attempts to try and find what you posted. Trim it down
> to what you need to post.
>
> It's picking "random" stuff because you're not joining the tables properly.
>
> You have:
>
> select
>  admin.AdminID, workorers.AdminID
> from
>  admin, workorders
> WHERE
>  admin.userName='tmiller';
>
> You haven't told the db how to join the two tables together, so it's doing
> a cross or cartesian join (useful in some cases, but not here). What that
> means is for each row in 'admin', it will show every row in 'workorders' and
> vice versa.
>
> What you want is to only show rows that match up:
>
> select
>  admin.AdminID, workorers.AdminID
> from
>  admin inner join workorders using (AdminID)
> WHERE
>  admin.userName='tmiller';
>
>
> which means
>
> for every row in admin, make sure there is a matching row (based on the
> adminid) in workorders.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>


RE: [PHP] New to PHP question

2009-01-28 Thread Boyd, Todd M.
> -Original Message-
> From: Stephen [mailto:stephe...@rogers.com]
> Sent: Wednesday, January 28, 2009 4:40 PM
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] New to PHP question
> 
> Boyd, Todd M. wrote:
> >
> > Finally, just because IE8 is (supposed to be) fully CSS standards
> > compliant doesn't mean anything for IE7, IE6, IE5, etc.
> >
> Microsoft is pushing IE 8 with their bug fix process.
> 
> Not a bad idea to include a little JS to warm users with  upgrade.

If you're going to go that far, just ask them to install a worthwhile
browser. :P It's sad, but the burden falls on us web developers to
remain backwards-compatible (at least until EOL of the particular
browser(s) in question).

Personally, I look at that in the same light as I do pages that have a
disclaimer at the bottom that says, "Best viewed in 
with ." I understand that the programmer didn't want to go
through the nightmare of getting it to work across-the-board, but your
typical site visitor is going to look at that and frown.

Also, with that in mind, remember that Microsoft does not design their
web browser line with efficiency or speed of execution in mind. With
each iterative release, there is more feature bloat, more memory
required, and more processor cycles used up. Older PCs may very well be
stuck with IE6. This may not be your target market, but it's something
to consider.

This is just my opinion... but I know I'm not alone.


// Todd

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



[PHP] Mailing list rules?

2009-01-28 Thread Daniel Kolbo

Hello,

Is it okay for me to post a message looking for programmers willing to 
help out with a php project?


Thanks,
dK


Re: [PHP] New to PHP question

2009-01-28 Thread Stephen

Boyd, Todd M. wrote:

The horror.
Do not use tables for layout.

Use CSS.

Especially now that Microsoft, just this week, is sending out IE 8
which
seems to be fully CCS standards compliant.



Your high horse--get off of it.
  

Dude! Did you read what I wrote? I wrote do not use tables for layout!

Are you not familiar with "div-itis"? If I need to represent data in a
grid-style layout, I am going to use a  every time instead of
making tons of  elements and tying them into the appropriate CSS.
  
It you have tabular data to present, use HTML tables! That is what they 
are for.


But use CSS to format the table.

Finally, just because IE8 is (supposed to be) fully CSS standards
compliant doesn't mean anything for IE7, IE6, IE5, etc.
  

Microsoft is pushing IE 8 with their bug fix process.

Not a bad idea to include a little JS to warm users with http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Programming general question

2009-01-28 Thread Usamah M. Ali
On Wed, Jan 28, 2009 at 11:07 PM, Terion Miller  wrote:
> On Wed, Jan 28, 2009 at 3:54 AM, Ondrej Kulaty  wrote:
>> Thanks for all the information, I was asking because I inherited thousands
> of lines of code that had used mysql_fetch_object(), yet I kept getting so
> many errors so I starting playing with changing them to mysql_fetch_assoc()
> and things seem to work better, so I was wonder why sometimes data from a db
> field can be used as an object or array, the arrays, objects, classes still
> confuses me..oh add functions to that, is there a hiearchy?
>

If an object is not an ACTUAL class instance, then it's no more than a
syntactic sugar array. For example:

$user = new stdClass(); // General class name, used internally by PHP
$user->username = 'John Doe',
$user->email = 'john_...@example.com';
$user->password = md5('some_hard_or_easy_password_string');
...

is almost typical to:

$user = array();
$user['username'] = 'John Doe';
$user['email'] = 'john_...@example.com';
$user['password'] = md5('some_hard_or_easy_password_string');
...

Many programmers particularly use objects for retrieving database
results because they require less verbose than arrays:

$result->username is just easier and less error-prone than $result['username'].

Using objects as class instances is totally different than using
arrays as many repliers have said. They're usually used, objects that
is, within OOP (Object-Oriented Programming), which relies on the idea
of thinking of programming in resemblance to real-world things
(objects). Thinking in this paradigm is, again, totally different than
traditional procedural programming, and requires a hard shift in the
way you think about programming in general. I suggest consulting the
manual sections on OOP (specially for PHP5), or other basic tutorials
or books on this huge subject.

Regards,
Usamah

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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Chris



Here are my variables when I reveal them, I am picking up the right adminID
I can't figure out why it's returning random orders though:
$query"SELECT admin.AdminID, workorders.AdminID FROM admin, workorders WHERE
admin.UserName = 'tmiller' "


Please please please trim your posts to relevant stuff. I had to go 
through 4 pages of previous attempts to try and find what you posted. 
Trim it down to what you need to post.


It's picking "random" stuff because you're not joining the tables properly.

You have:

select
  admin.AdminID, workorers.AdminID
from
  admin, workorders
WHERE
  admin.userName='tmiller';

You haven't told the db how to join the two tables together, so it's 
doing a cross or cartesian join (useful in some cases, but not here). 
What that means is for each row in 'admin', it will show every row in 
'workorders' and vice versa.


What you want is to only show rows that match up:

select
  admin.AdminID, workorers.AdminID
from
  admin inner join workorders using (AdminID)
WHERE
  admin.userName='tmiller';


which means

for every row in admin, make sure there is a matching row (based on the 
adminid) in workorders.


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


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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Shawn McKenzie


> Here are my variables when I reveal them, I am picking up the right
> adminID I can't figure out why it's returning random orders though:
> $query"SELECT admin.AdminID, workorders.AdminID FROM admin,
> workorders WHERE admin.UserName = 'tmiller' "
> $result   "Resource id #5"
> $row  
> key   value
> [WorkOrderID] "44"
> [AdminID] "7"
>
> $SortBy   "WorkOrderID DESC"
> $Page "2"
> $PerPage  "30"
> $StartPage"30"
> $sql  "SELECT workorders.WorkOrderID, workorders.AdminID,
> admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
> admin.AdminID "
> $Total"3"
>
>
Because your queries are hosed.  You want to populate $row with what? 
If you want all the fields in workorders, then this works great:

SELECT * FROM workorders WHERE AdminID = 7

-Shawn

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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Terion Miller
On Wed, Jan 28, 2009 at 4:12 PM, Terion Miller wrote:

>
>
> On Wed, Jan 28, 2009 at 4:00 PM, Shawn McKenzie wrote:
>
>> Terion Miller wrote:
>> > On Wed, Jan 28, 2009 at 3:43 PM, Shawn McKenzie > >wrote:
>> >
>> >> Shawn McKenzie wrote:
>> >>> Terion Miller wrote:
>>  Well I'm stuck I have the AdminID but now I can't seem to use it to
>> pull
>>  workorders with that AdminID . I couldn't get your block to work
>> Andrew
>> >> :(
>>  I think I'm just not using it right now that I have it...lol
>> 
>> 
>>  On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard 
>> >> wrote:
>> > On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller <
>> >> webdev.ter...@gmail.com>
>> > wrote:
>> >> Not sure if I'm wording this right, what I am trying to do is look
>> in
>> >> two
>> >> tables, match the ID to use to pull information
>> >>
>> >> Here's my code but it's not right, although it is picking up the
>> user
>> > from
>> >> the session, I will also post what my variable debugging lists:
>> >>
>> >>$query = "SELECT  admin.AdminID, workorders.AdminID FROM admin,
>> >> workorders WHERE admin.UserName =   '".$_SESSION['user']."' ";
>> >>$result = mysql_query ($query);
>> >>$row = mysql_fetch_assoc ($result);
>> >>
>> >>echo $row['AdminID'];
>> >>
>> >>if ($row['ViewMyOrders'] == "NO") {
>> >>header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry,
>> you
>> >> do
>> >> not have access to that page.");
>> >>}
>> >>
>> >> *Also tried this to pull just this persons orders:*
>> >>
>> >>$sql = "SELECT workorders.WorkOrderID , workorders.AdminID,
>> >> admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
>> >> admin.AdminID ";
>> >>$result = mysql_query ($sql);
>> >>
>> >> Thanks for looking, t.
>> >>
>> > Your first version gives you a Cartesian product containing more
>> rows
>> > than you are expecting. (All rows from the workorders table joined
>> > with the row in the admin table where the username matches.) The
>> > second version returns all rows where the AdminIDs match, but for
>> all
>> > users. You need to combine them:
>> >
>> > $sql =
>> > "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
>> > FROM workorders, admin
>> > WHERE workorders.AdminID = admin.AdminID
>> >   AND admin.UserName = '" . mysql_real_escape_string($username) .
>> "'";
>> >
>> >
>> > Although I believe the preferred syntax (at least, I think it's the
>> > preferred) is
>> >
>> > $sql =
>> > "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
>> > FROM workorders
>> >  INNER JOIN
>> >   admin
>> > ON  workorders.AdminID = admin.AdminID
>> > WHERE admin.UserName = '" . mysql_real_escape_string($username) .
>> "'";
>> >
>> >
>> > Andrew
>> >
>> >>> I think I see what you're trying to do:
>> >>>
>> >>> $query = "SELECT AdminID FROM admin WHERE UserName = '"
>> >>> . mysql_real_escape_string($_SESSION['user']) . "'";
>> >>> $result = mysql_query($query);
>> >>> $admins = mysql_fetch_assoc($result);
>> >>>
>> >>> $query = "SELECT * FROM workorders WHERE AdminID = '"
>> >>> . $admins['AdminID'] . "'";
>> >>> $result = mysql_query($query);
>> >>> $workorders = mysql_fetch_assoc($result);
>> >>>
>> >> Well maybe not.  Has anyone noticed that all the proposed selects
>> >> including the OPs are only returning AdminID and WorkOrderID?  But in
>> >> the OPs code he's trying to use $row['ViewMyOrders']!
>> >>
>> >> --
>> >> Thanks!
>> >> -Shawn
>> >> http://www.spidean.com
>> >>
>> >
>> > I have to get only the work orders associated with the adminID, I get
>> the
>> > pages but no orders.  and if I print my variables I am grabbing the
>> right
>> > adminID but it's not then going and grabbing the work orders with it.
>>  I'm
>> > not up on the correct phrasing, been doing this about 2 months.
>> >
>> Well, try what I posted (needs some error checking).  Where does
>> ViewMyOrders come from?  admin table?  It would be even easier if you
>> put the AdminID in the SESSION also :-)
>>
>> There also seems to be some design flaws.  Why query the database for
>> orders if the user is not allowed to view their orders?
>>
>> --
>> Thanks!
>> -Shawn
>> http://www.spidean.com
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>> No the user is allowed to view them, or that is what I'm trying to do
> exactly , now I have it returning some orders but they don't belong to the
> correct AdminID , I'm getting closer, I appreciate everyone's help in the
> right direction!!
> Terion
>

Here are my variables when I reveal them, I am picking up the right adminID
I can't figure out why it's returning random orders though:
$query"SELECT admin.AdminID, workorde

Re: [PHP] New to PHP question

2009-01-28 Thread Shawn McKenzie
Boyd, Todd M. wrote:
>> -Original Message-
>> From: Stephen [mailto:stephe...@rogers.com]
>> Sent: Wednesday, January 28, 2009 1:41 PM
>> To: Paul M Foster
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] New to PHP question
>>
>> Paul M Foster wrote:
>>> If you want exact layout (columns
>>> lined up, etc.), the simplest solution is to use HTML tables.
>>>
>>>
>>>
>> The horror.
>>
>> Do not use tables for layout.
>>
>> Use CSS.
>>
>> Especially now that Microsoft, just this week, is sending out IE 8
>> which
>> seems to be fully CCS standards compliant.
> 
> Your high horse--get off of it.
> 
> Are you not familiar with "div-itis"? If I need to represent data in a
> grid-style layout, I am going to use a  every time instead of
> making tons of  elements and tying them into the appropriate CSS.
> 
> http://www.giveupandusetables.com
> 
> Also... as far as I know, XHTML 1.0 Strict and XHTML 1.1 still include
> the  tags. I can understand wanting to separate style from
> structure, but I think that tables are more structural than stylish. You
> have to draw the line somewhere.
> 
> If you're displaying tabular data, use a table. If you just want stuff
> to be in a grid and the structure has no bearing on the content, then
> it's time to weigh in. 
> 
> Finally, just because IE8 is (supposed to be) fully CSS standards
> compliant doesn't mean anything for IE7, IE6, IE5, etc.
> 
> 
> // Todd

Or firefox for that matter.  I tried to do a completely css site and
when I got it looking great in ff/linux, it looked horrible in IE.  Then
when it looked better in IE and better in ff/linux, it had some issues
iin ff/windows.  I love tables and will use them for most layouts until
they are removed from (x)html :-)

-Shawn

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Terion Miller
On Wed, Jan 28, 2009 at 4:00 PM, Shawn McKenzie wrote:

> Terion Miller wrote:
> > On Wed, Jan 28, 2009 at 3:43 PM, Shawn McKenzie  >wrote:
> >
> >> Shawn McKenzie wrote:
> >>> Terion Miller wrote:
>  Well I'm stuck I have the AdminID but now I can't seem to use it to
> pull
>  workorders with that AdminID . I couldn't get your block to work
> Andrew
> >> :(
>  I think I'm just not using it right now that I have it...lol
> 
> 
>  On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard 
> >> wrote:
> > On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller <
> >> webdev.ter...@gmail.com>
> > wrote:
> >> Not sure if I'm wording this right, what I am trying to do is look
> in
> >> two
> >> tables, match the ID to use to pull information
> >>
> >> Here's my code but it's not right, although it is picking up the
> user
> > from
> >> the session, I will also post what my variable debugging lists:
> >>
> >>$query = "SELECT  admin.AdminID, workorders.AdminID FROM admin,
> >> workorders WHERE admin.UserName =   '".$_SESSION['user']."' ";
> >>$result = mysql_query ($query);
> >>$row = mysql_fetch_assoc ($result);
> >>
> >>echo $row['AdminID'];
> >>
> >>if ($row['ViewMyOrders'] == "NO") {
> >>header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry,
> you
> >> do
> >> not have access to that page.");
> >>}
> >>
> >> *Also tried this to pull just this persons orders:*
> >>
> >>$sql = "SELECT workorders.WorkOrderID , workorders.AdminID,
> >> admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
> >> admin.AdminID ";
> >>$result = mysql_query ($sql);
> >>
> >> Thanks for looking, t.
> >>
> > Your first version gives you a Cartesian product containing more rows
> > than you are expecting. (All rows from the workorders table joined
> > with the row in the admin table where the username matches.) The
> > second version returns all rows where the AdminIDs match, but for all
> > users. You need to combine them:
> >
> > $sql =
> > "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
> > FROM workorders, admin
> > WHERE workorders.AdminID = admin.AdminID
> >   AND admin.UserName = '" . mysql_real_escape_string($username) .
> "'";
> >
> >
> > Although I believe the preferred syntax (at least, I think it's the
> > preferred) is
> >
> > $sql =
> > "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
> > FROM workorders
> >  INNER JOIN
> >   admin
> > ON  workorders.AdminID = admin.AdminID
> > WHERE admin.UserName = '" . mysql_real_escape_string($username) .
> "'";
> >
> >
> > Andrew
> >
> >>> I think I see what you're trying to do:
> >>>
> >>> $query = "SELECT AdminID FROM admin WHERE UserName = '"
> >>> . mysql_real_escape_string($_SESSION['user']) . "'";
> >>> $result = mysql_query($query);
> >>> $admins = mysql_fetch_assoc($result);
> >>>
> >>> $query = "SELECT * FROM workorders WHERE AdminID = '"
> >>> . $admins['AdminID'] . "'";
> >>> $result = mysql_query($query);
> >>> $workorders = mysql_fetch_assoc($result);
> >>>
> >> Well maybe not.  Has anyone noticed that all the proposed selects
> >> including the OPs are only returning AdminID and WorkOrderID?  But in
> >> the OPs code he's trying to use $row['ViewMyOrders']!
> >>
> >> --
> >> Thanks!
> >> -Shawn
> >> http://www.spidean.com
> >>
> >
> > I have to get only the work orders associated with the adminID, I get the
> > pages but no orders.  and if I print my variables I am grabbing the right
> > adminID but it's not then going and grabbing the work orders with it.
>  I'm
> > not up on the correct phrasing, been doing this about 2 months.
> >
> Well, try what I posted (needs some error checking).  Where does
> ViewMyOrders come from?  admin table?  It would be even easier if you
> put the AdminID in the SESSION also :-)
>
> There also seems to be some design flaws.  Why query the database for
> orders if the user is not allowed to view their orders?
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> No the user is allowed to view them, or that is what I'm trying to do
exactly , now I have it returning some orders but they don't belong to the
correct AdminID , I'm getting closer, I appreciate everyone's help in the
right direction!!
Terion


RE: [PHP] New to PHP question

2009-01-28 Thread Boyd, Todd M.
> -Original Message-
> From: Stephen [mailto:stephe...@rogers.com]
> Sent: Wednesday, January 28, 2009 1:41 PM
> To: Paul M Foster
> Cc: php-general@lists.php.net
> Subject: Re: [PHP] New to PHP question
> 
> Paul M Foster wrote:
> > If you want exact layout (columns
> > lined up, etc.), the simplest solution is to use HTML tables.
> >
> >
> >
> The horror.
> 
> Do not use tables for layout.
> 
> Use CSS.
> 
> Especially now that Microsoft, just this week, is sending out IE 8
> which
> seems to be fully CCS standards compliant.

Your high horse--get off of it.

Are you not familiar with "div-itis"? If I need to represent data in a
grid-style layout, I am going to use a  every time instead of
making tons of  elements and tying them into the appropriate CSS.

http://www.giveupandusetables.com

Also... as far as I know, XHTML 1.0 Strict and XHTML 1.1 still include
the  tags. I can understand wanting to separate style from
structure, but I think that tables are more structural than stylish. You
have to draw the line somewhere.

If you're displaying tabular data, use a table. If you just want stuff
to be in a grid and the structure has no bearing on the content, then
it's time to weigh in. 

Finally, just because IE8 is (supposed to be) fully CSS standards
compliant doesn't mean anything for IE7, IE6, IE5, etc.


// Todd

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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Shawn McKenzie
Terion Miller wrote:
> On Wed, Jan 28, 2009 at 3:43 PM, Shawn McKenzie wrote:
> 
>> Shawn McKenzie wrote:
>>> Terion Miller wrote:
 Well I'm stuck I have the AdminID but now I can't seem to use it to pull
 workorders with that AdminID . I couldn't get your block to work Andrew
>> :(
 I think I'm just not using it right now that I have it...lol


 On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard 
>> wrote:
> On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller <
>> webdev.ter...@gmail.com>
> wrote:
>> Not sure if I'm wording this right, what I am trying to do is look in
>> two
>> tables, match the ID to use to pull information
>>
>> Here's my code but it's not right, although it is picking up the user
> from
>> the session, I will also post what my variable debugging lists:
>>
>>$query = "SELECT  admin.AdminID, workorders.AdminID FROM admin,
>> workorders WHERE admin.UserName =   '".$_SESSION['user']."' ";
>>$result = mysql_query ($query);
>>$row = mysql_fetch_assoc ($result);
>>
>>echo $row['AdminID'];
>>
>>if ($row['ViewMyOrders'] == "NO") {
>>header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you
>> do
>> not have access to that page.");
>>}
>>
>> *Also tried this to pull just this persons orders:*
>>
>>$sql = "SELECT workorders.WorkOrderID , workorders.AdminID,
>> admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
>> admin.AdminID ";
>>$result = mysql_query ($sql);
>>
>> Thanks for looking, t.
>>
> Your first version gives you a Cartesian product containing more rows
> than you are expecting. (All rows from the workorders table joined
> with the row in the admin table where the username matches.) The
> second version returns all rows where the AdminIDs match, but for all
> users. You need to combine them:
>
> $sql =
> "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
> FROM workorders, admin
> WHERE workorders.AdminID = admin.AdminID
>   AND admin.UserName = '" . mysql_real_escape_string($username) . "'";
>
>
> Although I believe the preferred syntax (at least, I think it's the
> preferred) is
>
> $sql =
> "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
> FROM workorders
>  INNER JOIN
>   admin
> ON  workorders.AdminID = admin.AdminID
> WHERE admin.UserName = '" . mysql_real_escape_string($username) . "'";
>
>
> Andrew
>
>>> I think I see what you're trying to do:
>>>
>>> $query = "SELECT AdminID FROM admin WHERE UserName = '"
>>> . mysql_real_escape_string($_SESSION['user']) . "'";
>>> $result = mysql_query($query);
>>> $admins = mysql_fetch_assoc($result);
>>>
>>> $query = "SELECT * FROM workorders WHERE AdminID = '"
>>> . $admins['AdminID'] . "'";
>>> $result = mysql_query($query);
>>> $workorders = mysql_fetch_assoc($result);
>>>
>> Well maybe not.  Has anyone noticed that all the proposed selects
>> including the OPs are only returning AdminID and WorkOrderID?  But in
>> the OPs code he's trying to use $row['ViewMyOrders']!
>>
>> --
>> Thanks!
>> -Shawn
>> http://www.spidean.com
>>
> 
> I have to get only the work orders associated with the adminID, I get the
> pages but no orders.  and if I print my variables I am grabbing the right
> adminID but it's not then going and grabbing the work orders with it.  I'm
> not up on the correct phrasing, been doing this about 2 months.
> 
Well, try what I posted (needs some error checking).  Where does
ViewMyOrders come from?  admin table?  It would be even easier if you
put the AdminID in the SESSION also :-)

There also seems to be some design flaws.  Why query the database for
orders if the user is not allowed to view their orders?

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Terion Miller
On Wed, Jan 28, 2009 at 3:43 PM, Shawn McKenzie wrote:

> Shawn McKenzie wrote:
> > Terion Miller wrote:
> >> Well I'm stuck I have the AdminID but now I can't seem to use it to pull
> >> workorders with that AdminID . I couldn't get your block to work Andrew
> :(
> >>
> >> I think I'm just not using it right now that I have it...lol
> >>
> >>
> >> On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard 
> wrote:
> >>
> >>> On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller <
> webdev.ter...@gmail.com>
> >>> wrote:
>  Not sure if I'm wording this right, what I am trying to do is look in
> two
>  tables, match the ID to use to pull information
> 
>  Here's my code but it's not right, although it is picking up the user
> >>> from
>  the session, I will also post what my variable debugging lists:
> 
> $query = "SELECT  admin.AdminID, workorders.AdminID FROM admin,
>  workorders WHERE admin.UserName =   '".$_SESSION['user']."' ";
> $result = mysql_query ($query);
> $row = mysql_fetch_assoc ($result);
> 
> echo $row['AdminID'];
> 
> if ($row['ViewMyOrders'] == "NO") {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you
> do
>  not have access to that page.");
> }
> 
>  *Also tried this to pull just this persons orders:*
> 
> $sql = "SELECT workorders.WorkOrderID , workorders.AdminID,
>  admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
>  admin.AdminID ";
> $result = mysql_query ($sql);
> 
>  Thanks for looking, t.
> 
> >>> Your first version gives you a Cartesian product containing more rows
> >>> than you are expecting. (All rows from the workorders table joined
> >>> with the row in the admin table where the username matches.) The
> >>> second version returns all rows where the AdminIDs match, but for all
> >>> users. You need to combine them:
> >>>
> >>> $sql =
> >>> "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
> >>> FROM workorders, admin
> >>> WHERE workorders.AdminID = admin.AdminID
> >>>   AND admin.UserName = '" . mysql_real_escape_string($username) . "'";
> >>>
> >>>
> >>> Although I believe the preferred syntax (at least, I think it's the
> >>> preferred) is
> >>>
> >>> $sql =
> >>> "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
> >>> FROM workorders
> >>>  INNER JOIN
> >>>   admin
> >>> ON  workorders.AdminID = admin.AdminID
> >>> WHERE admin.UserName = '" . mysql_real_escape_string($username) . "'";
> >>>
> >>>
> >>> Andrew
> >>>
> >
> > I think I see what you're trying to do:
> >
> > $query = "SELECT AdminID FROM admin WHERE UserName = '"
> > . mysql_real_escape_string($_SESSION['user']) . "'";
> > $result = mysql_query($query);
> > $admins = mysql_fetch_assoc($result);
> >
> > $query = "SELECT * FROM workorders WHERE AdminID = '"
> > . $admins['AdminID'] . "'";
> > $result = mysql_query($query);
> > $workorders = mysql_fetch_assoc($result);
> >
>
> Well maybe not.  Has anyone noticed that all the proposed selects
> including the OPs are only returning AdminID and WorkOrderID?  But in
> the OPs code he's trying to use $row['ViewMyOrders']!
>
> --
> Thanks!
> -Shawn
> http://www.spidean.com
>

I have to get only the work orders associated with the adminID, I get the
pages but no orders.  and if I print my variables I am grabbing the right
adminID but it's not then going and grabbing the work orders with it.  I'm
not up on the correct phrasing, been doing this about 2 months.


Re: [PHP] Making a Variable from different tables with Matching Dbfields?

2009-01-28 Thread Shawn McKenzie
Shawn McKenzie wrote:
> Terion Miller wrote:
>> Well I'm stuck I have the AdminID but now I can't seem to use it to pull
>> workorders with that AdminID . I couldn't get your block to work Andrew :(
>>
>> I think I'm just not using it right now that I have it...lol
>>
>>
>> On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard  wrote:
>>
>>> On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller 
>>> wrote:
 Not sure if I'm wording this right, what I am trying to do is look in two
 tables, match the ID to use to pull information

 Here's my code but it's not right, although it is picking up the user
>>> from
 the session, I will also post what my variable debugging lists:

$query = "SELECT  admin.AdminID, workorders.AdminID FROM admin,
 workorders WHERE admin.UserName =   '".$_SESSION['user']."' ";
$result = mysql_query ($query);
$row = mysql_fetch_assoc ($result);

echo $row['AdminID'];

if ($row['ViewMyOrders'] == "NO") {
header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
 not have access to that page.");
}

 *Also tried this to pull just this persons orders:*

$sql = "SELECT workorders.WorkOrderID , workorders.AdminID,
 admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
 admin.AdminID ";
$result = mysql_query ($sql);

 Thanks for looking, t.

>>> Your first version gives you a Cartesian product containing more rows
>>> than you are expecting. (All rows from the workorders table joined
>>> with the row in the admin table where the username matches.) The
>>> second version returns all rows where the AdminIDs match, but for all
>>> users. You need to combine them:
>>>
>>> $sql =
>>> "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
>>> FROM workorders, admin
>>> WHERE workorders.AdminID = admin.AdminID
>>>   AND admin.UserName = '" . mysql_real_escape_string($username) . "'";
>>>
>>>
>>> Although I believe the preferred syntax (at least, I think it's the
>>> preferred) is
>>>
>>> $sql =
>>> "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
>>> FROM workorders
>>>  INNER JOIN
>>>   admin
>>> ON  workorders.AdminID = admin.AdminID
>>> WHERE admin.UserName = '" . mysql_real_escape_string($username) . "'";
>>>
>>>
>>> Andrew
>>>
> 
> I think I see what you're trying to do:
> 
> $query = "SELECT AdminID FROM admin WHERE UserName = '"
> . mysql_real_escape_string($_SESSION['user']) . "'";
> $result = mysql_query($query);
> $admins = mysql_fetch_assoc($result);
> 
> $query = "SELECT * FROM workorders WHERE AdminID = '"
> . $admins['AdminID'] . "'";
> $result = mysql_query($query);
> $workorders = mysql_fetch_assoc($result);
> 

Well maybe not.  Has anyone noticed that all the proposed selects
including the OPs are only returning AdminID and WorkOrderID?  But in
the OPs code he's trying to use $row['ViewMyOrders']!

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Making a Variable from different tables with Matching Db fields?

2009-01-28 Thread Christoph Boget
> >> Because there is ambiguity w/r/t the columns you are selecting, you'll
> >> need to use aliases.
> >> http://dev.mysql.com/doc/refman/5.1/en/identifiers.html
> >> In your code, when you are referencing the column, do so using the
> >> alias.  That should solve your problem.
> > I just read it 3 times and I don't understand it.
> Try this... (just make sure to assign a valid $username value.)
> $sql =
> "SELECT workorders.WorkOrderID , workorders.AdminID
> FROM workorders
> INNER JOIN
>   admin
> ON  workorders.AdminID = admin.AdminID
> WHERE admin.UserName = '" . mysql_real_escape_string($username) . "'";

Andrew is right.  If you use the above query, that will probably get you
going.  But in general, aliases allow you to reference a column as
something other than what it is named in the table's schema.  It would
allow you to do something along the lines of:

SELECT
  Employee.Name AS EmployeeName,
  Employer.Name AS EmployerName
FROM
  blah blah blah.

In the above example, the column "Name" is ambiguous.  By defining an
alias, it removes the ambiguity and allows mysql to return the value of
both columns.  In your code, you would just reference it using:

$rowData['EmployeeName']
$rowData['EmployerName']

I hope that helps explain aliases a bit.

thnx,
Christoph


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



Re: [PHP] Making a Variable from different tables with Matching Db fields?

2009-01-28 Thread Shawn McKenzie
Terion Miller wrote:
> Well I'm stuck I have the AdminID but now I can't seem to use it to pull
> workorders with that AdminID . I couldn't get your block to work Andrew :(
> 
> I think I'm just not using it right now that I have it...lol
> 
> 
> On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard  wrote:
> 
>> On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller 
>> wrote:
>>> Not sure if I'm wording this right, what I am trying to do is look in two
>>> tables, match the ID to use to pull information
>>>
>>> Here's my code but it's not right, although it is picking up the user
>> from
>>> the session, I will also post what my variable debugging lists:
>>>
>>>$query = "SELECT  admin.AdminID, workorders.AdminID FROM admin,
>>> workorders WHERE admin.UserName =   '".$_SESSION['user']."' ";
>>>$result = mysql_query ($query);
>>>$row = mysql_fetch_assoc ($result);
>>>
>>>echo $row['AdminID'];
>>>
>>>if ($row['ViewMyOrders'] == "NO") {
>>>header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
>>> not have access to that page.");
>>>}
>>>
>>> *Also tried this to pull just this persons orders:*
>>>
>>>$sql = "SELECT workorders.WorkOrderID , workorders.AdminID,
>>> admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
>>> admin.AdminID ";
>>>$result = mysql_query ($sql);
>>>
>>> Thanks for looking, t.
>>>
>> Your first version gives you a Cartesian product containing more rows
>> than you are expecting. (All rows from the workorders table joined
>> with the row in the admin table where the username matches.) The
>> second version returns all rows where the AdminIDs match, but for all
>> users. You need to combine them:
>>
>> $sql =
>> "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
>> FROM workorders, admin
>> WHERE workorders.AdminID = admin.AdminID
>>   AND admin.UserName = '" . mysql_real_escape_string($username) . "'";
>>
>>
>> Although I believe the preferred syntax (at least, I think it's the
>> preferred) is
>>
>> $sql =
>> "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
>> FROM workorders
>>  INNER JOIN
>>   admin
>> ON  workorders.AdminID = admin.AdminID
>> WHERE admin.UserName = '" . mysql_real_escape_string($username) . "'";
>>
>>
>> Andrew
>>
> 

I think I see what you're trying to do:

$query = "SELECT AdminID FROM admin WHERE UserName = '"
. mysql_real_escape_string($_SESSION['user']) . "'";
$result = mysql_query($query);
$admins = mysql_fetch_assoc($result);

$query = "SELECT * FROM workorders WHERE AdminID = '"
. $admins['AdminID'] . "'";
$result = mysql_query($query);
$workorders = mysql_fetch_assoc($result);

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Making a Variable from different tables with Matching Db fields?

2009-01-28 Thread Andrew Ballard
On Wed, Jan 28, 2009 at 4:31 PM, Terion Miller  wrote:
> On Wed, Jan 28, 2009 at 3:22 PM, Christoph Boget 
> wrote:
>>
>> > Well I'm stuck I have the AdminID but now I can't seem to use it to pull
>> > workorders with that AdminID . I couldn't get your block to work Andrew
>> > :(
>> > I think I'm just not using it right now that I have it...lol
>>
>> Because there is ambiguity w/r/t the columns you are selecting, you'll
>> need to use aliases.
>>
>> http://dev.mysql.com/doc/refman/5.1/en/identifiers.html
>>
>> In your code, when you are referencing the column, do so using the
>> alias.  That should solve your problem.
>>
>> thnx,
>> Christoph
>>
> I just read it 3 times and I don't understand it.
>

Try this... (just make sure to assign a valid $username value.)

$sql =
"SELECT workorders.WorkOrderID , workorders.AdminID
FROM workorders
INNER JOIN
  admin
ON  workorders.AdminID = admin.AdminID
WHERE admin.UserName = '" . mysql_real_escape_string($username) . "'";

Andrew

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



Re: [PHP] Making a Variable from different tables with Matching Db fields?

2009-01-28 Thread Andrew Ballard
On Wed, Jan 28, 2009 at 4:22 PM, Christoph Boget
 wrote:
>> Well I'm stuck I have the AdminID but now I can't seem to use it to pull
>> workorders with that AdminID . I couldn't get your block to work Andrew :(
>> I think I'm just not using it right now that I have it...lol
>
> Because there is ambiguity w/r/t the columns you are selecting, you'll
> need to use aliases.
>
> http://dev.mysql.com/doc/refman/5.1/en/identifiers.html
>
> In your code, when you are referencing the column, do so using the
> alias.  That should solve your problem.
>
> thnx,
> Christoph
>
>

You're right about the ambiguity. I didn't even pay attention to his
SELECT list. Actually, though, in this case aliases aren't even
necessary. Since workorders.AdminID and admin.AdminID are going to be
the same value since that's a join condition, so the OP really only
needs to choose one and use it.

Andrew

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



Re: [PHP] Making a Variable from different tables with Matching Db fields?

2009-01-28 Thread Terion Miller
I just read it 3 times and I don't understand it.

On Wed, Jan 28, 2009 at 3:22 PM, Christoph Boget
wrote:

> > Well I'm stuck I have the AdminID but now I can't seem to use it to pull
> > workorders with that AdminID . I couldn't get your block to work Andrew
> :(
> > I think I'm just not using it right now that I have it...lol
>
> Because there is ambiguity w/r/t the columns you are selecting, you'll
> need to use aliases.
>
> http://dev.mysql.com/doc/refman/5.1/en/identifiers.html
>
> In your code, when you are referencing the column, do so using the
> alias.  That should solve your problem.
>
> thnx,
> Christoph
>
>


Re: [PHP] Making a Variable from different tables with Matching Db fields?

2009-01-28 Thread Christoph Boget
> Well I'm stuck I have the AdminID but now I can't seem to use it to pull
> workorders with that AdminID . I couldn't get your block to work Andrew :(
> I think I'm just not using it right now that I have it...lol

Because there is ambiguity w/r/t the columns you are selecting, you'll
need to use aliases.

http://dev.mysql.com/doc/refman/5.1/en/identifiers.html

In your code, when you are referencing the column, do so using the
alias.  That should solve your problem.

thnx,
Christoph


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



Re: [PHP] New to PHP question

2009-01-28 Thread mike
On Wed, Jan 28, 2009 at 1:26 PM, Ashley Sheridan
 wrote:

> I use CSS as much as possible, and it's second nature to me now to
> design with CSS rather than tables, but the only area I find it quicker
> to use tables is when I design forms. I know I'm going to browser hell,
> but meh, I can deal with it! :p

I've had the same pain. If I want to get something up quick, I wind up
doing it in tables. I have some basic CSS templates I can get up, but
for forms and some other things I wind up tweaking things over and
over; with tables it's just done and I can move on.

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



Re: [PHP] New to PHP question

2009-01-28 Thread Ashley Sheridan
On Wed, 2009-01-28 at 15:33 -0500, Ernie Kemp wrote:
> Is there any advantage to using CSS over table and would it be idea to go to 
> past website and change them.
> /Ernie
> - Original Message - 
> From: "Stephen" 
> Newsgroups: php.general
> To: "Paul M Foster" 
> Cc: 
> Sent: Wednesday, January 28, 2009 2:40 PM
> Subject: Re: [PHP] New to PHP question
> 
> 
> > Paul M Foster wrote:
> >> If you want exact layout (columns
> >> lined up, etc.), the simplest solution is to use HTML tables.
> >>
> >>
> >>
> > The horror.
> >
> > Do not use tables for layout.
> >
> > Use CSS.
> >
> > Especially now that Microsoft, just this week, is sending out IE 8 which 
> > seems to be fully CCS standards compliant.
> >
> > Stephen
> > 
> 
> 
Some browsers (IE) need the entire table to load before it can begin to
display it. Note this is only the whole table, not it's contents, so it
may appear to jump around as images, etc load in. Also, pages with lots
and lots of nested tables do render slightly more slowly, but these at
worst is going to be a second or two. Tables are great for tabular
layout, but divs when used properly an be a lot more flexible and
forgiving.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] New to PHP question

2009-01-28 Thread Ashley Sheridan
On Wed, 2009-01-28 at 15:17 -0500, Paul M Foster wrote:
> On Wed, Jan 28, 2009 at 02:40:55PM -0500, Stephen wrote:
> 
> > Paul M Foster wrote:
> >> If you want exact layout (columns
> >> lined up, etc.), the simplest solution is to use HTML tables.
> >>
> >>
> >>
> > The horror.
> >
> > Do not use tables for layout.
> >
> > Use CSS.
> >
> > Especially now that Microsoft, just this week, is sending out IE 8 which
> > seems to be fully CCS standards compliant.
> 
> I'm happy to be a Luddite in this area. We've been doing websites for
> about ten years, and have yet to find it either simple or easy to get
> exact, gracefully-degrading layouts with CSS. (We use CSS for all kinds
> of nifty things, but not to line things up properly.)
> 
> Hey, I've got an idea. If someone knows of one of these uber-web-design
> "authorities" who writes books touting the superiority of CSS over
> tables, have them write a book showing us all how it's done ["easily"].
> I'll be first in line to buy it, because I agree that page layout is not
> the original proper use of tables.
> 
> Paul
> 
> PS: I have to snicker as well anytime Microsoft says they're "compliant"
> with *any* standard. Their history speaks for itself; why should we
> believe them now?
> 
> -- 
> Paul M. Foster
> 
I use CSS as much as possible, and it's second nature to me now to
design with CSS rather than tables, but the only area I find it quicker
to use tables is when I design forms. I know I'm going to browser hell,
but meh, I can deal with it! :p


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Making a Variable from different tables with Matching Db fields?

2009-01-28 Thread Terion Miller
Well I'm stuck I have the AdminID but now I can't seem to use it to pull
workorders with that AdminID . I couldn't get your block to work Andrew :(

I think I'm just not using it right now that I have it...lol


On Wed, Jan 28, 2009 at 2:26 PM, Andrew Ballard  wrote:

> On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller 
> wrote:
> > Not sure if I'm wording this right, what I am trying to do is look in two
> > tables, match the ID to use to pull information
> >
> > Here's my code but it's not right, although it is picking up the user
> from
> > the session, I will also post what my variable debugging lists:
> >
> >$query = "SELECT  admin.AdminID, workorders.AdminID FROM admin,
> > workorders WHERE admin.UserName =   '".$_SESSION['user']."' ";
> >$result = mysql_query ($query);
> >$row = mysql_fetch_assoc ($result);
> >
> >echo $row['AdminID'];
> >
> >if ($row['ViewMyOrders'] == "NO") {
> >header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> > not have access to that page.");
> >}
> >
> > *Also tried this to pull just this persons orders:*
> >
> >$sql = "SELECT workorders.WorkOrderID , workorders.AdminID,
> > admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
> > admin.AdminID ";
> >$result = mysql_query ($sql);
> >
> > Thanks for looking, t.
> >
>
> Your first version gives you a Cartesian product containing more rows
> than you are expecting. (All rows from the workorders table joined
> with the row in the admin table where the username matches.) The
> second version returns all rows where the AdminIDs match, but for all
> users. You need to combine them:
>
> $sql =
> "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
> FROM workorders, admin
> WHERE workorders.AdminID = admin.AdminID
>   AND admin.UserName = '" . mysql_real_escape_string($username) . "'";
>
>
> Although I believe the preferred syntax (at least, I think it's the
> preferred) is
>
> $sql =
> "SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
> FROM workorders
>  INNER JOIN
>   admin
> ON  workorders.AdminID = admin.AdminID
> WHERE admin.UserName = '" . mysql_real_escape_string($username) . "'";
>
>
> Andrew
>


Re: [PHP] New to PHP question

2009-01-28 Thread Ashley Sheridan
On Wed, 2009-01-28 at 13:45 -0700, Don Collier wrote:
> 
> Paul M Foster wrote:
> > See? This is what I'm talking about.
> >
> > *I* understand what you're saying, Don, and I agree. But this guy is
> > just learning PHP from what is arguably not one of the best books on PHP
> > (IMO). And you're throwing MVC at him. Let him master the subtleties of
> > the language first, then we'll give him the MVC speech.
> >
> > Yes, I know, they should learn proper programming practices from the
> > beginning, blah blah blah. But think back to the first programming
> > language you ever learned, when you were first learning it. If someone
> > had thrown stuff like this at you, would you have had a clue? I had
> > enough trouble just learning the proper syntax and library routines for
> > Dartmouth BASIC and Pascal, without having to deal with a lot of
> > "metaprogramming" stuff.
> >
> > This is the problem when you get newbies asking questions on a list
> > whose membership includes hardcore gurus. The gurus look at things in
> > such a lofty way that answering simple questions at the level of a
> > beginner sounds like a dissertation on the subtleties of Spanish art in
> > the 1500s.
> >
> > Just my opinion.
> >
> > Paul
> >   
> On that note, what would be a better book to learn from?  I have always 
> been a fan of the O'Reilly books, but I am open to differing flavors of 
> kool-aid.  One can never have too many resources.
> 
I agree with your choice; never seen a bad O'Reilly book yet.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] New to PHP question

2009-01-28 Thread Frank Stanovcak

"Don Collier"  wrote in message 
news:4980c3d3.8040...@collierclan.com...
>
>
> Paul M Foster wrote:
>> See? This is what I'm talking about.
>>
>> *I* understand what you're saying, Don, and I agree. But this guy is
>> just learning PHP from what is arguably not one of the best books on PHP
>> (IMO). And you're throwing MVC at him. Let him master the subtleties of
>> the language first, then we'll give him the MVC speech.
>>
>> Yes, I know, they should learn proper programming practices from the
>> beginning, blah blah blah. But think back to the first programming
>> language you ever learned, when you were first learning it. If someone
>> had thrown stuff like this at you, would you have had a clue? I had
>> enough trouble just learning the proper syntax and library routines for
>> Dartmouth BASIC and Pascal, without having to deal with a lot of
>> "metaprogramming" stuff.
>>
>> This is the problem when you get newbies asking questions on a list
>> whose membership includes hardcore gurus. The gurus look at things in
>> such a lofty way that answering simple questions at the level of a
>> beginner sounds like a dissertation on the subtleties of Spanish art in
>> the 1500s.
>>
>> Just my opinion.
>>
>> Paul
>>
> On that note, what would be a better book to learn from?  I have always 
> been a fan of the O'Reilly books, but I am open to differing flavors of 
> kool-aid.  One can never have too many resources.


First of all...for **insert deities name here** sake don't drink the 
kool-aid!  I started with the visual series of books just to get the hang of 
the rudimentry language, and then went right to the online php manual.  www. 
devguru. com isn't bad, but tends to be a bit sparse on explinations.  If 
you are familliar with any programming language google is your friend.  php 
is pretty close to c for ease of refference so googling for like 'switch 
php' brings up loads of examples and refs.  I still don't know anything 
about this pear, or other frameworks they speak of on here, but I'm sure I 
will learn it in time.  :)

Personally I think French art from the 1500's was better any way.

Frank 



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



Re: [PHP] New to PHP question

2009-01-28 Thread Don Collier



Paul M Foster wrote:

See? This is what I'm talking about.

*I* understand what you're saying, Don, and I agree. But this guy is
just learning PHP from what is arguably not one of the best books on PHP
(IMO). And you're throwing MVC at him. Let him master the subtleties of
the language first, then we'll give him the MVC speech.

Yes, I know, they should learn proper programming practices from the
beginning, blah blah blah. But think back to the first programming
language you ever learned, when you were first learning it. If someone
had thrown stuff like this at you, would you have had a clue? I had
enough trouble just learning the proper syntax and library routines for
Dartmouth BASIC and Pascal, without having to deal with a lot of
"metaprogramming" stuff.

This is the problem when you get newbies asking questions on a list
whose membership includes hardcore gurus. The gurus look at things in
such a lofty way that answering simple questions at the level of a
beginner sounds like a dissertation on the subtleties of Spanish art in
the 1500s.

Just my opinion.

Paul
  
On that note, what would be a better book to learn from?  I have always 
been a fan of the O'Reilly books, but I am open to differing flavors of 
kool-aid.  One can never have too many resources.


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



Re: [PHP] New to PHP question

2009-01-28 Thread Bastien Koert
On Wed, Jan 28, 2009 at 3:28 PM, Paul M Foster wrote:

> On Wed, Jan 28, 2009 at 03:06:36PM -0500, Bastien Koert wrote:
>
> > On Wed, Jan 28, 2009 at 2:58 PM, Don Collier  >wrote:
> >
> > >
> > >> On Wed, Jan 28, 2009 at 12:05:34PM -0700, Don Collier wrote:
> > >>
> > >>
> > >>
> > >>> I am just learning PHP from the O'Reilly "Learning PHP 5" book and I
> > >>> have a question regarding the formatting of text.  Actually it is a
> > >>> couple of questions.
> > >>>
> > >>> First, when I use the \n and run the script from the command line it
> > >>> works great.  When I run the same code in a browser it does not put
> the
> > >>> newline in and the text runs together.  I know that I can use 
> to
> > >>> do the same thing, but why is it this way?
> > >>>
>
> 
>
> > >>
> > >>
> > > Thanks to everyone that responded.
> > > From what I am seeing in the responses if I plan on using php for
> command
> > > line scripts things get written one way.  If, on the other hand, the
> php is
> > > written for a web page it gets written a slightly different way
> inserting
> > > html where necessary for formatting.
> > >
>
> 
>
> > >
> > Not quite true in a properly layered application. Separating the data
> from
> > the display (whatever that is) is prime idea behind the MVC (Model View
> > Controller) design pattern. This way your code that runs via the CLI
> > (command line) can produce the same data as the code that gets the data
> for
> > the HTML. The only difference is what you plan to do with that data. You
> > could feed it to a controller and let the controller feed it to a View to
> > render in a browser, or send it to a FileOutput class to create a file of
> > the data for comsumption by another resource.
>
> See? This is what I'm talking about.
>
> *I* understand what you're saying, Don, and I agree. But this guy is
> just learning PHP from what is arguably not one of the best books on PHP
> (IMO). And you're throwing MVC at him. Let him master the subtleties of
> the language first, then we'll give him the MVC speech.
>
> Yes, I know, they should learn proper programming practices from the
> beginning, blah blah blah. But think back to the first programming
> language you ever learned, when you were first learning it. If someone
> had thrown stuff like this at you, would you have had a clue? I had
> enough trouble just learning the proper syntax and library routines for
> Dartmouth BASIC and Pascal, without having to deal with a lot of
> "metaprogramming" stuff.
>
> This is the problem when you get newbies asking questions on a list
> whose membership includes hardcore gurus. The gurus look at things in
> such a lofty way that answering simple questions at the level of a
> beginner sounds like a dissertation on the subtleties of Spanish art in
> the 1500s.
>
> Just my opinion.
>
> Paul
> --
> Paul M. Foster
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Paul,

You make a valid point, but I suggest that once you get beyonds the basics
of programming (loops, if then else, do while etc) and granted that I do not
know where the OP sits in this area, it would have saved me many hours of
frustration, having to unlearn what I know and force feed myself a new
paradigm.

To me its kind of 6 of one and half a dozen of the other...but the
requirement is having that basic programming knowledge that gives a solid
foundation to any language.

My 2 cents...

-- 

Bastien

Cat, the other other white meat


Re: [PHP] New to PHP question

2009-01-28 Thread Ernie Kemp
Is there any advantage to using CSS over table and would it be idea to go to 
past website and change them.

/Ernie
- Original Message - 
From: "Stephen" 

Newsgroups: php.general
To: "Paul M Foster" 
Cc: 
Sent: Wednesday, January 28, 2009 2:40 PM
Subject: Re: [PHP] New to PHP question



Paul M Foster wrote:

If you want exact layout (columns
lined up, etc.), the simplest solution is to use HTML tables.




The horror.

Do not use tables for layout.

Use CSS.

Especially now that Microsoft, just this week, is sending out IE 8 which 
seems to be fully CCS standards compliant.


Stephen




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



Re: [PHP] New to PHP question

2009-01-28 Thread Paul M Foster
On Wed, Jan 28, 2009 at 03:06:36PM -0500, Bastien Koert wrote:

> On Wed, Jan 28, 2009 at 2:58 PM, Don Collier wrote:
> 
> >
> >> On Wed, Jan 28, 2009 at 12:05:34PM -0700, Don Collier wrote:
> >>
> >>
> >>
> >>> I am just learning PHP from the O'Reilly "Learning PHP 5" book and I
> >>> have a question regarding the formatting of text.  Actually it is a
> >>> couple of questions.
> >>>
> >>> First, when I use the \n and run the script from the command line it
> >>> works great.  When I run the same code in a browser it does not put the
> >>> newline in and the text runs together.  I know that I can use  to
> >>> do the same thing, but why is it this way?
> >>>



> >>
> >>
> > Thanks to everyone that responded.
> > From what I am seeing in the responses if I plan on using php for command
> > line scripts things get written one way.  If, on the other hand, the php is
> > written for a web page it gets written a slightly different way inserting
> > html where necessary for formatting.
> >



> >
> Not quite true in a properly layered application. Separating the data from
> the display (whatever that is) is prime idea behind the MVC (Model View
> Controller) design pattern. This way your code that runs via the CLI
> (command line) can produce the same data as the code that gets the data for
> the HTML. The only difference is what you plan to do with that data. You
> could feed it to a controller and let the controller feed it to a View to
> render in a browser, or send it to a FileOutput class to create a file of
> the data for comsumption by another resource.

See? This is what I'm talking about.

*I* understand what you're saying, Don, and I agree. But this guy is
just learning PHP from what is arguably not one of the best books on PHP
(IMO). And you're throwing MVC at him. Let him master the subtleties of
the language first, then we'll give him the MVC speech.

Yes, I know, they should learn proper programming practices from the
beginning, blah blah blah. But think back to the first programming
language you ever learned, when you were first learning it. If someone
had thrown stuff like this at you, would you have had a clue? I had
enough trouble just learning the proper syntax and library routines for
Dartmouth BASIC and Pascal, without having to deal with a lot of
"metaprogramming" stuff.

This is the problem when you get newbies asking questions on a list
whose membership includes hardcore gurus. The gurus look at things in
such a lofty way that answering simple questions at the level of a
beginner sounds like a dissertation on the subtleties of Spanish art in
the 1500s.

Just my opinion.

Paul
-- 
Paul M. Foster

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



Re: [PHP] Making a Variable from different tables with Matching Db fields?

2009-01-28 Thread Andrew Ballard
On Wed, Jan 28, 2009 at 3:18 PM, Terion Miller  wrote:
> Not sure if I'm wording this right, what I am trying to do is look in two
> tables, match the ID to use to pull information
>
> Here's my code but it's not right, although it is picking up the user from
> the session, I will also post what my variable debugging lists:
>
>$query = "SELECT  admin.AdminID, workorders.AdminID FROM admin,
> workorders WHERE admin.UserName =   '".$_SESSION['user']."' ";
>$result = mysql_query ($query);
>$row = mysql_fetch_assoc ($result);
>
>echo $row['AdminID'];
>
>if ($row['ViewMyOrders'] == "NO") {
>header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> not have access to that page.");
>}
>
> *Also tried this to pull just this persons orders:*
>
>$sql = "SELECT workorders.WorkOrderID , workorders.AdminID,
> admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
> admin.AdminID ";
>$result = mysql_query ($sql);
>
> Thanks for looking, t.
>

Your first version gives you a Cartesian product containing more rows
than you are expecting. (All rows from the workorders table joined
with the row in the admin table where the username matches.) The
second version returns all rows where the AdminIDs match, but for all
users. You need to combine them:

$sql =
"SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
FROM workorders, admin
WHERE workorders.AdminID = admin.AdminID
  AND admin.UserName = '" . mysql_real_escape_string($username) . "'";


Although I believe the preferred syntax (at least, I think it's the
preferred) is

$sql =
"SELECT workorders.WorkOrderID , workorders.AdminID, admin.AdminID
FROM workorders
 INNER JOIN
   admin
 ON  workorders.AdminID = admin.AdminID
WHERE admin.UserName = '" . mysql_real_escape_string($username) . "'";


Andrew

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



[PHP] Re: Making a Variable from different tables with Matching Db fields?

2009-01-28 Thread Terion Miller
Wow I got it !! Well I now have the AdminID variable to work with!! If I
wasn't so tired and brain dead from marathoning this project because I'm so
so So SICK of it, I would get up and do the happy dance

On Wed, Jan 28, 2009 at 2:18 PM, Terion Miller wrote:

> Not sure if I'm wording this right, what I am trying to do is look in two
> tables, match the ID to use to pull information
>
> Here's my code but it's not right, although it is picking up the user from
> the session, I will also post what my variable debugging lists:
>
> $query = "SELECT  admin.AdminID, workorders.AdminID FROM admin,
> workorders WHERE admin.UserName =   '".$_SESSION['user']."' ";
> $result = mysql_query ($query);
> $row = mysql_fetch_assoc ($result);
>
> echo $row['AdminID'];
>
> if ($row['ViewMyOrders'] == "NO") {
> header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
> not have access to that page.");
> }
>
> *Also tried this to pull just this persons orders:*
>
> $sql = "SELECT workorders.WorkOrderID , workorders.AdminID,
> admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
> admin.AdminID ";
> $result = mysql_query ($sql);
>
> Thanks for looking, t.
>


[PHP] Making a Variable from different tables with Matching Db fields?

2009-01-28 Thread Terion Miller
Not sure if I'm wording this right, what I am trying to do is look in two
tables, match the ID to use to pull information

Here's my code but it's not right, although it is picking up the user from
the session, I will also post what my variable debugging lists:

$query = "SELECT  admin.AdminID, workorders.AdminID FROM admin,
workorders WHERE admin.UserName =   '".$_SESSION['user']."' ";
$result = mysql_query ($query);
$row = mysql_fetch_assoc ($result);

echo $row['AdminID'];

if ($row['ViewMyOrders'] == "NO") {
header ("Location: Welcome.php?AdminID=$AdminID&msg=Sorry, you do
not have access to that page.");
}

*Also tried this to pull just this persons orders:*

$sql = "SELECT workorders.WorkOrderID , workorders.AdminID,
admin.AdminID FROM workorders, admin WHERE workorders.AdminID =
admin.AdminID ";
$result = mysql_query ($sql);

Thanks for looking, t.


Re: [PHP] New to PHP question

2009-01-28 Thread Paul M Foster
On Wed, Jan 28, 2009 at 02:40:55PM -0500, Stephen wrote:

> Paul M Foster wrote:
>> If you want exact layout (columns
>> lined up, etc.), the simplest solution is to use HTML tables.
>>
>>
>>
> The horror.
>
> Do not use tables for layout.
>
> Use CSS.
>
> Especially now that Microsoft, just this week, is sending out IE 8 which
> seems to be fully CCS standards compliant.

I'm happy to be a Luddite in this area. We've been doing websites for
about ten years, and have yet to find it either simple or easy to get
exact, gracefully-degrading layouts with CSS. (We use CSS for all kinds
of nifty things, but not to line things up properly.)

Hey, I've got an idea. If someone knows of one of these uber-web-design
"authorities" who writes books touting the superiority of CSS over
tables, have them write a book showing us all how it's done ["easily"].
I'll be first in line to buy it, because I agree that page layout is not
the original proper use of tables.

Paul

PS: I have to snicker as well anytime Microsoft says they're "compliant"
with *any* standard. Their history speaks for itself; why should we
believe them now?

-- 
Paul M. Foster

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



Re: [PHP] New to PHP question

2009-01-28 Thread Per Jessen
Don Collier wrote:

> From what I am seeing in the responses if I plan on using php for
> command line scripts things get written one way.  If, on the other
> hand, the php is written for a web page it gets written a slightly
> different way inserting html where necessary for formatting.

No, the scripts are written the same way, but you are using two
different output media, so your output must be different. 

Like Stuart said - if you want your browser to output in text-mode, just
set the right header-type.  (text/plain).



/Per Jessen, Zürich


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



Re: [PHP] Re: Programming general question

2009-01-28 Thread Terion Miller
On Wed, Jan 28, 2009 at 3:54 AM, Ondrej Kulaty  wrote:

> Depends on what for you want to use that. Array is simple data structure,
> it
> holds data, like variable, but objects has methods and properties, it acts
> as someting which can do some sort of task and you access it via it's
> interface (you call it's methods). You can use array for example to hold
> result from database and than iterate it with for or foreach cycle. On the
> other hand, object can be used for exaplme to send mail, you put into it
> text body, mail adresses and so on and then call it's method send() which
> causes mail to be send. The process of transforming data, generating
> headers
> etc is completely done by the object and it's internal methods, you access
> it only via it's well defined interface (it's methods you can call).
> Objects
> are mainly used in OOP programming, where they cooperate together. Good way
> to learn OOP is to learn something about design patterns...
> --
>
>
> "Terion Miller"  píse v diskusním príspevku
> news:37405f850901271518r21f5f73j44841e864de5c...@mail.gmail.com...
> >I googled this and didn't find an answer 
> > my question is how do you know when to use an object or array
> >
> > would an object just be 1 instance, and array is several things together
> > ( I
> > know infantile coder language I use..but I'm a baby still in this)
> >
> > Can someone explain objects and arrays in plain speak for me?
> > Thanks
> > Happy Coding
> >
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> Thanks for all the information, I was asking because I inherited thousands
of lines of code that had used mysql_fetch_object(), yet I kept getting so
many errors so I starting playing with changing them to mysql_fetch_assoc()
and things seem to work better, so I was wonder why sometimes data from a db
field can be used as an object or array, the arrays, objects, classes still
confuses me..oh add functions to that, is there a hiearchy?


Re: [PHP] New to PHP question

2009-01-28 Thread Stuart
2009/1/28 Stephen :
> Don Collier wrote:
>>
>> I am just learning PHP from the O'Reilly "Learning PHP 5" book and I have
>> a question regarding the formatting of text.  Actually it is a couple of
>> questions.
>>
>> First, when I use the \n and run the script from the command line it works
>> great.  When I run the same code in a browser it does not put the newline in
>> and the text runs together.  I know that I can use  to do the same
>> thing, but why is it this way?
>>
>> The second question is closely related to the first.  When formatting text
>> using printf the padding works great when running from the command line but
>> not at all when in a browser.
>> Here is the code that I am working with:
>>
> Browsers **only** support HTML.
>
> They do not understand things like "\n" to be anything special, so they just
> print as it is sent to the browser.



-Stuart

-- 
http://stut.net/

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



Re: [PHP] New to PHP question

2009-01-28 Thread Bastien Koert
On Wed, Jan 28, 2009 at 2:58 PM, Don Collier wrote:

>
>
> Paul M Foster wrote:
>
>> On Wed, Jan 28, 2009 at 12:05:34PM -0700, Don Collier wrote:
>>
>>
>>
>>> I am just learning PHP from the O'Reilly "Learning PHP 5" book and I
>>> have a question regarding the formatting of text.  Actually it is a
>>> couple of questions.
>>>
>>> First, when I use the \n and run the script from the command line it
>>> works great.  When I run the same code in a browser it does not put the
>>> newline in and the text runs together.  I know that I can use  to
>>> do the same thing, but why is it this way?
>>>
>>>
>>
>> Browser don't break lines on the \n character. They only break on 
>> or  tags. That's just the way it is. You can use the PHP function
>> nl2br() to insert  tags where the \n characters are.
>>
>>
>>
>>> The second question is closely related to the first.  When formatting
>>> text using printf the padding works great when running from the command
>>> line but not at all when in a browser.
>>>
>>>
>>
>> Browsers don't respect multiple spaces, etc., except in between certain
>> tags, like . Instead, they combine multiple spaces into a
>> single space and break lines where they like, based on layout. You can
>> use the HTML   character if you don't want lines or phrases to
>> break at the whim of the browser. If you want exact layout (columns
>> lined up, etc.), the simplest solution is to use HTML tables.
>>
>> Paul
>>
>>
>>
> Thanks to everyone that responded.
> From what I am seeing in the responses if I plan on using php for command
> line scripts things get written one way.  If, on the other hand, the php is
> written for a web page it gets written a slightly different way inserting
> html where necessary for formatting.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Not quite true in a properly layered application. Separating the data from
the display (whatever that is) is prime idea behind the MVC (Model View
Controller) design pattern. This way your code that runs via the CLI
(command line) can produce the same data as the code that gets the data for
the HTML. The only difference is what you plan to do with that data. You
could feed it to a controller and let the controller feed it to a View to
render in a browser, or send it to a FileOutput class to create a file of
the data for comsumption by another resource.


-- 

Bastien

Cat, the other other white meat


Re: [PHP] New to PHP question

2009-01-28 Thread Don Collier



Paul M Foster wrote:

On Wed, Jan 28, 2009 at 12:05:34PM -0700, Don Collier wrote:

  

I am just learning PHP from the O'Reilly "Learning PHP 5" book and I
have a question regarding the formatting of text.  Actually it is a
couple of questions.

First, when I use the \n and run the script from the command line it
works great.  When I run the same code in a browser it does not put the
newline in and the text runs together.  I know that I can use  to
do the same thing, but why is it this way?



Browser don't break lines on the \n character. They only break on 
or  tags. That's just the way it is. You can use the PHP function
nl2br() to insert  tags where the \n characters are.

  

The second question is closely related to the first.  When formatting
text using printf the padding works great when running from the command
line but not at all when in a browser.



Browsers don't respect multiple spaces, etc., except in between certain
tags, like . Instead, they combine multiple spaces into a
single space and break lines where they like, based on layout. You can
use the HTML   character if you don't want lines or phrases to
break at the whim of the browser. If you want exact layout (columns
lined up, etc.), the simplest solution is to use HTML tables.

Paul

  
Thanks to everyone that responded. 

From what I am seeing in the responses if I plan on using php for 
command line scripts things get written one way.  If, on the other hand, 
the php is written for a web page it gets written a slightly different 
way inserting html where necessary for formatting.


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



Re: [PHP] Re: New to PHP question

2009-01-28 Thread Jim Lucas
Frank Stanovcak wrote:
> "Don Collier"  wrote in message 
> news:4980ac7e.2080...@collierclan.com...
>> I am just learning PHP from the O'Reilly "Learning PHP 5" book and I have a 
>> question regarding the formatting of text.  Actually it is a couple of 
>> questions.
>>
>> First, when I use the \n and run the script from the command line it works 
>> great.  When I run the same code in a browser it does not put the newline 
>> in and the text runs together.  I know that I can use  to do the same 
>> thing, but why is it this way?
>>
>> The second question is closely related to the first.  When formatting text 
>> using printf the padding works great when running from the command line 
>> but not at all when in a browser.
>> Here is the code that I am working with:
>>
>> > $hamburger = 4.95;
>> $chocmilk = 1.95;
>> $cola = .85;
>> $subtotal = (2 * $hamburger) + $chocmilk + $cola;
>> $tax = $subtotal * .075;
>> $tip = $subtotal * .16;
>> $total = $subtotal + $tip + $tax;
>> print "Welcome to Chez Don.\n";
>> print "Here is your receipt:\n";
>> print "\n";
>> printf("%1d %9s \$%.2f\n", 2, 'Hamburger', ($hamburger * 2));
>> printf("%1d %9s \$%.2f\n", 1, 'Milkshake', 1.95);
>> printf("%1d %9s \$%.2f\n", 1, 'Soda', .85);
>> printf("%25s: \$%.2f\n",'Subtotal', $subtotal);
>> printf("%25s: \$%.2f\n", 'Tax', $tax);
>> printf("%25s: \$%.2f\n", 'Tip', $tip);
>> printf("%25s: \$%.2f\n", 'Total', $total);
>> ?>
>>
>> Thanks for the help everyone.
> 
> It has specifically to do with how the browser renders the page.  part of 
> the spec for rendering is that newlines are ignored, and the only way to get 
> a line to break in a browser window is with the use of .  As for the 
> padding this is the same issue.  In Browswer rendering all white space 
> except the first one is ignored, and you have to use   for aditionall 
> spaces.
> 

You could always wrap things in a ...

or tell CSS to handle white-space: pre;  where needed.

http://www.w3schools.com/CSS/pr_text_white-space.asp

> ie: 3 space would be '   ' or '   '
> 
> Hope that helps!
> 
> Frank. 
> 
> 
> 


-- 
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



Re: [PHP] New to PHP question

2009-01-28 Thread Ashley Sheridan
On Wed, 2009-01-28 at 14:40 -0500, Stephen wrote:
> Especially now that Microsoft, just this week, is sending out IE 8
> which 
> seems to be fully CCS standards compliant. 

*snigger*

I'll believe that when I see it, rather I give it to you oh web
developers everywhere, that this is just a new M$ standard of CSS!


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] New to PHP question

2009-01-28 Thread Stephen

Paul M Foster wrote:

If you want exact layout (columns
lined up, etc.), the simplest solution is to use HTML tables.


  

The horror.

Do not use tables for layout.

Use CSS.

Especially now that Microsoft, just this week, is sending out IE 8 which 
seems to be fully CCS standards compliant.


Stephen


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



Re: [PHP] Re: unlink file rights problem

2009-01-28 Thread Ashley Sheridan
On Thu, 2009-01-29 at 03:49 +1030, Michael Kubler wrote:
> http://au2.php.net/cli
> 
> PHP via command line.
> 
> Michael Kubler
> *G*rey *P*hoenix *P*roductions 
> 
> 
> 
> Shawn McKenzie wrote:
> > Merlin Morgenstern wrote:
> >   
> >> Hi there,
> >>
> >> I am trying to unlink a file which is inside a folder that is not
> >> writable to phps user "www". Of course this failes, but I need to find a
> >> solution for it.
> >>
> >> Backgroud is following:
> >> I have pure-ftpd installed where user directories get created by
> >> pure-ftpd. Unfortunatelly there seems to be a bug and pure-ftpd does
> >> only create the homedirectory folder in 750 mod.
> >> My PHP-Script scans this directories every x minutes and processes those
> >> files. Upon completinon those files should get deleted, but as the dir
> >> is not writable by the user www this failes.
> >>
> >> The dir looks like this:
> >> drwxr-x--- 2 ftpuser ftpgroup 4096 Jan 28 10:18 merlin/
> >>
> >> files inside look like this:
> >> -rwxrwx--- 1 ftpuser ftpgroup 16868 Jan 28 10:20 test.xml*
> >>
> >> User www which executes php via cron is inside the group "ftpgroup".
> >>
> >> Any ideas? I am kind of lost with this one. Thank you for any help!
> >>
> >> Best regards, Merlin
> >> 
> >
> > Why not run the cron as root, or ftpuser?
> >
> >   
I was doing a similar thing with VSFTP, but I had that set the user mask
to allow rw rights to both the owner and the group. If that's not
possible because of your bug, then can you exec out to a shell script to
deal with this? Sudo has an -S parameter which allows the root password
to be given to it over the same command line without prompting, so you
could essentially keep the root password very separate from the PHP.
Obviously, there are various security flaws you would have to try and
tackle with this, but if you really tighten down your scripts this
should not be a problem.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] New to PHP question

2009-01-28 Thread Paul M Foster
On Wed, Jan 28, 2009 at 12:05:34PM -0700, Don Collier wrote:

> I am just learning PHP from the O'Reilly "Learning PHP 5" book and I
> have a question regarding the formatting of text.  Actually it is a
> couple of questions.
>
> First, when I use the \n and run the script from the command line it
> works great.  When I run the same code in a browser it does not put the
> newline in and the text runs together.  I know that I can use  to
> do the same thing, but why is it this way?

Browser don't break lines on the \n character. They only break on 
or  tags. That's just the way it is. You can use the PHP function
nl2br() to insert  tags where the \n characters are.

>
> The second question is closely related to the first.  When formatting
> text using printf the padding works great when running from the command
> line but not at all when in a browser.

Browsers don't respect multiple spaces, etc., except in between certain
tags, like . Instead, they combine multiple spaces into a
single space and break lines where they like, based on layout. You can
use the HTML   character if you don't want lines or phrases to
break at the whim of the browser. If you want exact layout (columns
lined up, etc.), the simplest solution is to use HTML tables.

Paul

-- 
Paul M. Foster

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



Re: [PHP] New to PHP question

2009-01-28 Thread Stephen

Don Collier wrote:
I am just learning PHP from the O'Reilly "Learning PHP 5" book and I 
have a question regarding the formatting of text.  Actually it is a 
couple of questions.


First, when I use the \n and run the script from the command line it 
works great.  When I run the same code in a browser it does not put 
the newline in and the text runs together.  I know that I can use 
 to do the same thing, but why is it this way?


The second question is closely related to the first.  When formatting 
text using printf the padding works great when running from the 
command line but not at all when in a browser.

Here is the code that I am working with:


Browsers **only** support HTML.

They do not understand things like "\n" to be anything special, so they 
just print as it is sent to the browser.


Stephen


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



Re: [PHP] New to PHP question

2009-01-28 Thread Per Jessen
Don Collier wrote:

> First, when I use the \n and run the script from the command line it
> works great.  When I run the same code in a browser it does not put
> the newline in and the text runs together.  I know that I can use
>  to do the same thing, but why is it this way? 

That's how HTML works. 

> The second question is closely related to the first.  When formatting
> text using printf the padding works great when running from the
> command line but not at all when in a browser.

Same answer. 


/Per Jessen, Zürich


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



[PHP] Re: New to PHP question

2009-01-28 Thread Frank Stanovcak

"Don Collier"  wrote in message 
news:4980ac7e.2080...@collierclan.com...
>I am just learning PHP from the O'Reilly "Learning PHP 5" book and I have a 
>question regarding the formatting of text.  Actually it is a couple of 
>questions.
>
> First, when I use the \n and run the script from the command line it works 
> great.  When I run the same code in a browser it does not put the newline 
> in and the text runs together.  I know that I can use  to do the same 
> thing, but why is it this way?
>
> The second question is closely related to the first.  When formatting text 
> using printf the padding works great when running from the command line 
> but not at all when in a browser.
> Here is the code that I am working with:
>
>  $hamburger = 4.95;
> $chocmilk = 1.95;
> $cola = .85;
> $subtotal = (2 * $hamburger) + $chocmilk + $cola;
> $tax = $subtotal * .075;
> $tip = $subtotal * .16;
> $total = $subtotal + $tip + $tax;
> print "Welcome to Chez Don.\n";
> print "Here is your receipt:\n";
> print "\n";
> printf("%1d %9s \$%.2f\n", 2, 'Hamburger', ($hamburger * 2));
> printf("%1d %9s \$%.2f\n", 1, 'Milkshake', 1.95);
> printf("%1d %9s \$%.2f\n", 1, 'Soda', .85);
> printf("%25s: \$%.2f\n",'Subtotal', $subtotal);
> printf("%25s: \$%.2f\n", 'Tax', $tax);
> printf("%25s: \$%.2f\n", 'Tip', $tip);
> printf("%25s: \$%.2f\n", 'Total', $total);
> ?>
>
> Thanks for the help everyone.

It has specifically to do with how the browser renders the page.  part of 
the spec for rendering is that newlines are ignored, and the only way to get 
a line to break in a browser window is with the use of .  As for the 
padding this is the same issue.  In Browswer rendering all white space 
except the first one is ignored, and you have to use   for aditionall 
spaces.

ie: 3 space would be '   ' or '   '

Hope that helps!

Frank. 



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



Re: [PHP] Re: validating directory and file name with preg_match

2009-01-28 Thread Frank Stanovcak

""Boyd, Todd M.""  wrote in message 
news:33bde0b2c17eef46acbe00537cf2a19003bb9...@exchcluster.ccis.edu...
> -Original Message-
> From: Frank Stanovcak [mailto:blindspot...@comcast.net]
> Sent: Wednesday, January 28, 2009 1:04 PM
> To: php-general@lists.php.net
> Subject: [PHP] Re: validating directory and file name with preg_match
>
>
> ""Frank Stanovcak""  wrote in message
> news:a8.d6.08436.5cf80...@pb1.pair.com...
> > I'm limiting access to certain proceedures based on the file trying
> to use
> > them, and the directory they are located in on my server.  Right now
> I am
> > using two preg_match statments as you will see.  What I want to know
> is
> > this.  Is there a way to write a single regex for this that will
> supply
> > the file name as a match, and only return if the directory is valid?
> >
> > 
> > //make sure we are calling from the propper directory, and get the
> file
> > name that included to determine
> > //database access needs
> >
>
preg_match('#^C:Inetpubwwwrootfolder(entry|edit)(\w
> *\\.(php|pdf))#i',
> > $included_files[0], $check1);
> >
>
preg_match('#^C:Inetpubwwwrootfolder(\w*\\.(php|pdf))#i
> ',
> > $included_files[0], $check2);
> > if(isset($check1)){
> > if(is_array($check1)){
> >  $matches[4] = $check1[2];
> > };
> > unset($check1);
> > };
> > if(isset($check2)){
> > if(is_array($check2)){
> >  $matches[4] = $check2[1];
> > };
> > unset($check2);
> > };
> > if(isset($matches[4]){
> > more code here
> > };
> >
>
> --Then Robyn Sed--
> Looks like the difference between the 2 patterns is the
> '(entry|edit)' part -- couldn't you make that optional and combine
> it into one expression? Ie,  '((entry|edit))*'
>
> As for returning the filename, basename() is your friend.
>
> R
> --end--
>
> I would use basename, but I want only the two file types specified to
> trigger a return.  They are the only two valid php types on this
> server.
>
> Your suggestion worked like a charm!  Thank you very much!

Upon reading this, I realize that I over-thought my suggestion.

/^c:\\inetpub\\wwwroot\\folder\\(?:entry|edit)\\(\w+\.(?:php|pdf))$/i

That's my final answer. :)


// Todd

Thank you too Todd.  I don't know why, but for some reason if I don't double 
escape the slashes it fails everytime.  I never knew you could stop the 
return with ?:  that will help a great deal in the future!

Frank 



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



[PHP] New to PHP question

2009-01-28 Thread Don Collier
I am just learning PHP from the O'Reilly "Learning PHP 5" book and I 
have a question regarding the formatting of text.  Actually it is a 
couple of questions.


First, when I use the \n and run the script from the command line it 
works great.  When I run the same code in a browser it does not put the 
newline in and the text runs together.  I know that I can use  to 
do the same thing, but why is it this way?


The second question is closely related to the first.  When formatting 
text using printf the padding works great when running from the command 
line but not at all when in a browser. 


Here is the code that I am working with:



Thanks for the help everyone.

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



Re: [PHP] Connection error on URI

2009-01-28 Thread Jim Lucas
Skip Evans wrote:
> Hey all,
> 
> I'm working on someone else's code that tries to read an XML transaction
> from a remote server with the following code.
> 
> $url="http://xx.xx.xx.xx:1972/csp/test/SASS.Web1.cls?soap_method=FindMemBySASSNum&SNum=".$user_sass;
> 
> // $url = urlencode($url);

The previous line would encode the entire url that you are working with.
This isn't the proper use of urlencode().
You should use this function on the values that you are adding as, in this 
case, the get values that you are submitting as soap_method and SNum

> $xml_response = file_get_contents($url, true);

are you using PHP 6?  if so, then that second argument will limit your search 
to only looking within your include_path

Take a look at this page, and take note of the warning for the second argument.

http://php.net/file_get_contents

The second argument has been changed, but that will only take effect with PHP6.

> 
> But this transaction times out and returns an empty transaction, even
> with the call to urlencode, which I tried as a quick fix.
> 
> If I paste the identical transaction into a browser it works fine.
> 
> Any suggestions would be greatly appreciated.
> 
> Peace, Love & Curly Fries,
> Skip
> 
> 


-- 
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



RE: [PHP] Re: validating directory and file name with preg_match

2009-01-28 Thread Boyd, Todd M.
> -Original Message-
> From: Frank Stanovcak [mailto:blindspot...@comcast.net]
> Sent: Wednesday, January 28, 2009 1:04 PM
> To: php-general@lists.php.net
> Subject: [PHP] Re: validating directory and file name with preg_match
> 
> 
> ""Frank Stanovcak""  wrote in message
> news:a8.d6.08436.5cf80...@pb1.pair.com...
> > I'm limiting access to certain proceedures based on the file trying
> to use
> > them, and the directory they are located in on my server.  Right now
> I am
> > using two preg_match statments as you will see.  What I want to know
> is
> > this.  Is there a way to write a single regex for this that will
> supply
> > the file name as a match, and only return if the directory is valid?
> >
> > 
> > //make sure we are calling from the propper directory, and get the
> file
> > name that included to determine
> > //database access needs
> >
>
preg_match('#^C:Inetpubwwwrootfolder(entry|edit)(\w
> *\\.(php|pdf))#i',
> > $included_files[0], $check1);
> >
>
preg_match('#^C:Inetpubwwwrootfolder(\w*\\.(php|pdf))#i
> ',
> > $included_files[0], $check2);
> > if(isset($check1)){
> > if(is_array($check1)){
> >  $matches[4] = $check1[2];
> > };
> > unset($check1);
> > };
> > if(isset($check2)){
> > if(is_array($check2)){
> >  $matches[4] = $check2[1];
> > };
> > unset($check2);
> > };
> > if(isset($matches[4]){
> > more code here
> > };
> >
> 
> --Then Robyn Sed--
> Looks like the difference between the 2 patterns is the
> '(entry|edit)' part -- couldn't you make that optional and combine
> it into one expression? Ie,  '((entry|edit))*'
> 
> As for returning the filename, basename() is your friend.
> 
> R
> --end--
> 
> I would use basename, but I want only the two file types specified to
> trigger a return.  They are the only two valid php types on this
> server.
> 
> Your suggestion worked like a charm!  Thank you very much!

Upon reading this, I realize that I over-thought my suggestion.

/^c:\\inetpub\\wwwroot\\folder\\(?:entry|edit)\\(\w+\.(?:php|pdf))$/i

That's my final answer. :)


// Todd

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



RE: [PHP] validating directory and file name with preg_match

2009-01-28 Thread Boyd, Todd M.
> -Original Message-
> From: Frank Stanovcak [mailto:blindspot...@comcast.net]
> Sent: Wednesday, January 28, 2009 11:08 AM
> To: php-general@lists.php.net
> Subject: [PHP] validating directory and file name with preg_match
> 
> I'm limiting access to certain proceedures based on the file trying to
> use
> them, and the directory they are located in on my server.  Right now I
> am
> using two preg_match statments as you will see.  What I want to know
is
> this.  Is there a way to write a single regex for this that will
supply
> the
> file name as a match, and only return if the directory is valid?
> 
> 
> //make sure we are calling from the propper directory, and get the
file
> name
> that included to determine
> //database access needs
>
preg_match('#^C:Inetpubwwwrootfolder(entry|edit)(\w
> *\\.(php|pdf))#i',
> $included_files[0], $check1);
>
preg_match('#^C:Inetpubwwwrootfolder(\w*\\.(php|pdf))#i
> ',
> $included_files[0], $check2);
> if(isset($check1)){
>  if(is_array($check1)){
>   $matches[4] = $check1[2];
>  };
>  unset($check1);
> };
> if(isset($check2)){
>  if(is_array($check2)){
>   $matches[4] = $check2[1];
>  };
>  unset($check2);
> };
> if(isset($matches[4]){
> more code here
> };

I don't see why you're double-escaping the backslashes like that. If you
want a period, \. will do it for you. \\. Will match a backslash and
then any character (or delimiter).

As for failing if the directory isn't valid, read up on regex
look-arounds [1]. You could do a look-ahead to ensure that the directory
matches before continuing with the file portion of the pattern.

But, seriously... why are you double-escaping? Why not just C:\\Inetpub
instead of C:Inetpub? I would think that C:Inetpub would turn
into C:\\Inetpub, which is not a valid FAT/NTFS/etc. locator.

Try this:

/^c:\\inetpub\\wwwroot\\folder\\(?=entry|edit)\\(\w+\.(?:php|pdf))$/i

The (?=entry|edit) group is the look-ahead. If folder\\ isn't followed
by entry or edit, the look-ahead fails. The (?:php|pdf) group uses the
?: syntax to tell the regex engine not to save this capture group. You
could just as easily remove the ?: and ignore the extra capture in your
code (as you have done).

1. http://www.regular-expressions.info/lookaround.html 

HTH,


// Todd

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



[PHP] Re: validating directory and file name with preg_match

2009-01-28 Thread Frank Stanovcak

""Frank Stanovcak""  wrote in message 
news:a8.d6.08436.5cf80...@pb1.pair.com...
> I'm limiting access to certain proceedures based on the file trying to use 
> them, and the directory they are located in on my server.  Right now I am 
> using two preg_match statments as you will see.  What I want to know is 
> this.  Is there a way to write a single regex for this that will supply 
> the file name as a match, and only return if the directory is valid?
>
> 
> //make sure we are calling from the propper directory, and get the file 
> name that included to determine
> //database access needs
> preg_match('#^C:Inetpubwwwrootfolder(entry|edit)(\w*\\.(php|pdf))#i',
>  
> $included_files[0], $check1);
> preg_match('#^C:Inetpubwwwrootfolder(\w*\\.(php|pdf))#i', 
> $included_files[0], $check2);
> if(isset($check1)){
> if(is_array($check1)){
>  $matches[4] = $check1[2];
> };
> unset($check1);
> };
> if(isset($check2)){
> if(is_array($check2)){
>  $matches[4] = $check2[1];
> };
> unset($check2);
> };
> if(isset($matches[4]){
> more code here
> };
>

--Then Robyn Sed--
Looks like the difference between the 2 patterns is the
'(entry|edit)' part -- couldn't you make that optional and combine
it into one expression? Ie,  '((entry|edit))*'

As for returning the filename, basename() is your friend.

R
--end--

I would use basename, but I want only the two file types specified to 
trigger a return.  They are the only two valid php types on this server.

Your suggestion worked like a charm!  Thank you very much!

Frank 



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



[PHP] Re: validating directory and file name with preg_match

2009-01-28 Thread Al



Frank Stanovcak wrote:
I'm limiting access to certain proceedures based on the file trying to use 
them, and the directory they are located in on my server.  Right now I am 
using two preg_match statments as you will see.  What I want to know is 
this.  Is there a way to write a single regex for this that will supply the 
file name as a match, and only return if the directory is valid?



//make sure we are calling from the propper directory, and get the file name 
that included to determine

//database access needs
preg_match('#^C:Inetpubwwwrootfolder(entry|edit)(\w*\\.(php|pdf))#i', 
$included_files[0], $check1);
preg_match('#^C:Inetpubwwwrootfolder(\w*\\.(php|pdf))#i', 
$included_files[0], $check2);

if(isset($check1)){
 if(is_array($check1)){
  $matches[4] = $check1[2];
 };
 unset($check1);
};
if(isset($check2)){
 if(is_array($check2)){
  $matches[4] = $check2[1];
 };
 unset($check2);
};
if(isset($matches[4]){
more code here
}; 




I don't have time to go thru your code in detail; but, here are a couple of 
hints:

Get rid of all those "\"s Use the hex equivalents for special characters. e.g. 
"." use \x2E It's tough enough testing regex expressions without worrying about 
all the back slashes.


You need preg_match_all()

Consider: if(!preg_match_all()){//no match code here}//Or maybe do the opposite

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



Re: [PHP] Connection error on URI

2009-01-28 Thread Skip Evans

Here's the output with the call to error_reporting(255); in place.

Calling Sassnet...
Warning: 
file_get_contents(http://xx.xx.xx.xx:1972/csp/test/SASS.Web1.cls?soap_method=FindMemBySASSNum&SNum=59) 
[function.file-get-contents]: failed to open stream: 
Connection timed out in 
/usr/sites/sassnet.com/members/www/url_test.php on line 6


I think the issue is not programming, but might be that the 
target server is not accepting requests from calling server.


Skip

Jan G.B. wrote:

2009/1/28 Skip Evans :

Hey all,
$url="http://xx.xx.xx.xx:1972/csp/test/SASS.Web1.cls?soap_method=FindMemBySASSNum&SNum=".$user_sass;
$xml_response = file_get_contents($url, true);

But this transaction times out and returns an empty transaction, even with
the call to urlencode, which I tried as a quick fix.

If I paste the identical transaction into a browser it works fine.


Please call error_reporting(255); before your http-request starts,
then post the error message you get.
bye



--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



Re: [PHP] Connection error on URI

2009-01-28 Thread Jan G.B.
2009/1/28 Skip Evans :
> Hey all,
> $url="http://xx.xx.xx.xx:1972/csp/test/SASS.Web1.cls?soap_method=FindMemBySASSNum&SNum=".$user_sass;
> $xml_response = file_get_contents($url, true);
>
> But this transaction times out and returns an empty transaction, even with
> the call to urlencode, which I tried as a quick fix.
>
> If I paste the identical transaction into a browser it works fine.

Please call error_reporting(255); before your http-request starts,
then post the error message you get.
bye

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



[PHP] Connection error on URI

2009-01-28 Thread Skip Evans

Hey all,

I'm working on someone else's code that tries to read an XML 
transaction from a remote server with the following code.
	 
$url="http://xx.xx.xx.xx:1972/csp/test/SASS.Web1.cls?soap_method=FindMemBySASSNum&SNum=".$user_sass;

// $url = urlencode($url);
$xml_response = file_get_contents($url, true);

But this transaction times out and returns an empty 
transaction, even with the call to urlencode, which I tried as 
a quick fix.


If I paste the identical transaction into a browser it works fine.

Any suggestions would be greatly appreciated.

Peace, Love & Curly Fries,
Skip


--

Skip Evans
Big Sky Penguin, LLC
503 S Baldwin St, #1
Madison WI 53703
608.250.2720
http://bigskypenguin.com

Those of you who believe in
telekinesis, raise my hand.
 -- Kurt Vonnegut

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



Re: [PHP] Re: unlink file rights problem

2009-01-28 Thread Michael Kubler

http://au2.php.net/cli

PHP via command line.

Michael Kubler
*G*rey *P*hoenix *P*roductions 



Shawn McKenzie wrote:

Merlin Morgenstern wrote:
  

Hi there,

I am trying to unlink a file which is inside a folder that is not
writable to phps user "www". Of course this failes, but I need to find a
solution for it.

Backgroud is following:
I have pure-ftpd installed where user directories get created by
pure-ftpd. Unfortunatelly there seems to be a bug and pure-ftpd does
only create the homedirectory folder in 750 mod.
My PHP-Script scans this directories every x minutes and processes those
files. Upon completinon those files should get deleted, but as the dir
is not writable by the user www this failes.

The dir looks like this:
drwxr-x--- 2 ftpuser ftpgroup 4096 Jan 28 10:18 merlin/

files inside look like this:
-rwxrwx--- 1 ftpuser ftpgroup 16868 Jan 28 10:20 test.xml*

User www which executes php via cron is inside the group "ftpgroup".

Any ideas? I am kind of lost with this one. Thank you for any help!

Best regards, Merlin



Why not run the cron as root, or ftpuser?

  


Re: [PHP] Kinda 0.T... php site and maintenance

2009-01-28 Thread Ryan S
@Bastien, Stuart:

Thanks for your input guys, was very useful and appreciate it.

cheers!
R


  

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



[PHP] validating directory and file name with preg_match

2009-01-28 Thread Frank Stanovcak
I'm limiting access to certain proceedures based on the file trying to use 
them, and the directory they are located in on my server.  Right now I am 
using two preg_match statments as you will see.  What I want to know is 
this.  Is there a way to write a single regex for this that will supply the 
file name as a match, and only return if the directory is valid?


//make sure we are calling from the propper directory, and get the file name 
that included to determine
//database access needs
preg_match('#^C:Inetpubwwwrootfolder(entry|edit)(\w*\\.(php|pdf))#i',
 
$included_files[0], $check1);
preg_match('#^C:Inetpubwwwrootfolder(\w*\\.(php|pdf))#i', 
$included_files[0], $check2);
if(isset($check1)){
 if(is_array($check1)){
  $matches[4] = $check1[2];
 };
 unset($check1);
};
if(isset($check2)){
 if(is_array($check2)){
  $matches[4] = $check2[1];
 };
 unset($check2);
};
if(isset($matches[4]){
more code here
}; 



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



Re: [PHP] Coding for email response forms

2009-01-28 Thread Shawn McKenzie
Tom wrote:
> "Clancy"  wrote in message 
> news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com...
>> On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net ("Tom") wrote:
>>
>> ..
 Also make sure there aren't line returns or any nonsense like that in
 the to & subjects.  Look up email header injection.  Your script might
 become quite popular at advertising p3n1s pills otherwise. :)
>>> Thanks I'll check it out. I tried including the above code but I still 
>>> can't
>>> seem to get it to work. Must be missing something.
>>>
>>> Thanks,
>> David Powers books "PHP for Dreamweaver xxx" (Friends of Ed) give very 
>> clear  instructions
>> on installing PHP and implementing the essential items such as this.
>>
> Thanks I'll check it out.
> 
>  I am no Coder and don't have a lot of time to devote to these things, to 
> busy running a business, but I do enjoy learning how things work which is 
> why I have taken this on. Website is just for informational display as they 
> don't produce much in the way of mortgage originations. I was hoping to get 
> something along the lines of the actually coding needed to pull this off. I 
> have spent every available moment over the last three  months on this 
> website (which is my first) with nothing more than an online beginners 
> course in CS3 & CSS. I have appreciated everyones feedbackl. If anyone has 
> coding I can cut and paste with just a few adjustments on my end that would 
> be great.
> 
> Thanks,
> Tom 
> 
> 
You have the code.  You just need to create a contact.php file and put
the email specific PHP in it and then modify your form to have
method="post" action="contact.php".

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Coding for email response forms

2009-01-28 Thread Tom
"Clancy"  wrote in message 
news:c77vn4pri9tsbaqg9avv3i7dnfb8nvk...@4ax.com...
> On Mon, 26 Jan 2009 17:57:29 -0600, obeli...@comcast.net ("Tom") wrote:
>
> ..
>>>
>>> Also make sure there aren't line returns or any nonsense like that in
>>> the to & subjects.  Look up email header injection.  Your script might
>>> become quite popular at advertising p3n1s pills otherwise. :)
>>
>>Thanks I'll check it out. I tried including the above code but I still 
>>can't
>>seem to get it to work. Must be missing something.
>>
>>Thanks,
>
> David Powers books "PHP for Dreamweaver xxx" (Friends of Ed) give very 
> clear  instructions
> on installing PHP and implementing the essential items such as this.
>
Thanks I'll check it out.

 I am no Coder and don't have a lot of time to devote to these things, to 
busy running a business, but I do enjoy learning how things work which is 
why I have taken this on. Website is just for informational display as they 
don't produce much in the way of mortgage originations. I was hoping to get 
something along the lines of the actually coding needed to pull this off. I 
have spent every available moment over the last three  months on this 
website (which is my first) with nothing more than an online beginners 
course in CS3 & CSS. I have appreciated everyones feedbackl. If anyone has 
coding I can cut and paste with just a few adjustments on my end that would 
be great.

Thanks,
Tom 



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



Re: [PHP] Re: [PROJECT HELP] - JotBug - A Project Management & Issue Tracker written 100% with Zend Framework

2009-01-28 Thread Thorsten Suckow-Homberg

Colin Guthrie schrieb:

'Twas brillig, and rcastley at 27/01/09 23:26 did gyre and gimble:
I am looking (begging!) for help/testing/feedback etc etc etc on my 
JotBug

project


A few years ago we had similiar in mind with phrac - it's over at 
phrac.tigris.org. I put a lot of effort into writing the WebDAV adapter 
that allows to query SVN information over HTTP/WebDAV - without the need 
of having a local SVN client running. It was never finished, but feel 
free to take whatever you need.



--
Thorsten Suckow-Homberg
http://www.siteartwork.de
http://www.conjoon.org


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



[PHP] Re: [PROJECT HELP] - JotBug - A Project Management & Issue Tracker written 100% with Zend Framework

2009-01-28 Thread Colin Guthrie

'Twas brillig, and rcastley at 27/01/09 23:26 did gyre and gimble:

I am looking (begging!) for help/testing/feedback etc etc etc on my JotBug
project


Looks interesting.

I do hack a bit on Trac, but much prefer PHP (and ZF) to Python (just 
what I know etc.)


That said I've got too much invested in Trac (and the plugins I wrote) 
to jump ship right now.


I wish you all the best of luck tho', and I'll monitor this to see what 
progress you make :)


Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


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



Re: [PHP] Global Changes With Loop To Allow Nulls In A Table...

2009-01-28 Thread Andrew Ballard
On Tue, Jan 27, 2009 at 5:24 PM, Boyd, Todd M.  wrote:
>> -Original Message-
>> From: Chris [mailto:dmag...@gmail.com]
>> Sent: Tuesday, January 27, 2009 4:04 PM
>> To: Boyd, Todd M.
>> Cc: php-general@lists.php.net
>> Subject: Re: [PHP] Global Changes With Loop To Allow Nulls In A
>> Table...
>>
>>
>> >> The other responses should get you started if this is something you
>> >> really want to do. However, I'll play devil's advocate here and just
>> >> raise the question why you would want to make this change in the
>> first
>> >> place. I'm not quite as anti-NULL as a lot of arguments I've read
>> >> against them, but I tend to agree that the number of columns that
>> >> accept NULL values should be kept as small as possible. Even if you
>> >> decide that you need to allow NULL values in some cases, IMHO I
>> >> wouldn't write a script that ran through my entire database and
>> opened
>> >> every column in every table to accept.
>> >
>> > I just thought I'd throw this out there...
>> >
>> > A lot of people who post questions on this list are programming their
>> algorithms and structuring their applications in a certain way because
>> that's what the client wants, or that's what their boss told them to
>> do. Yes, accepting NULL values in a database is frowned upon (unless
>> the table is a transaction table)... but I doubt his boss or his client
>> cares in the least.
>>
>> I don't understand what you mean about a "transaction table" - you
>> should only use nulls if you understand what they do and why you'd need
>> them in that particular case. I'd ask why and find specifically what
>> they want/why they suggested it and make sure they understand the
>> repercussions.
>
> A transaction table -- a table that is used to house the state of a 
> transaction. If the transaction is incomplete, some of its values will be 
> NULL. This is, of course, only one method for employing a transaction system. 
> There exist others that use many disparate tables for separate steps in the 
> transaction, but I've seen several that use one table with NULL columns for 
> steps that haven't yet been processed.
>
>
> // Todd
>

Even so - I would think it undesirable (and dangerous) for EVERY
column (including primary/foreign keys) in EVERY table to allow NULL
values. Granted, I don't know the nature of the project here, nor the
problem being addressed. I just wanted to raise a flag noting that
this MAY not be a great idea in the event a self-described "newbie"
hadn't considered the potential pitfalls he could be introducing.

Andrew

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



[PHP] Re: unlink file rights problem

2009-01-28 Thread Shawn McKenzie
Merlin Morgenstern wrote:
> Hi there,
> 
> I am trying to unlink a file which is inside a folder that is not
> writable to phps user "www". Of course this failes, but I need to find a
> solution for it.
> 
> Backgroud is following:
> I have pure-ftpd installed where user directories get created by
> pure-ftpd. Unfortunatelly there seems to be a bug and pure-ftpd does
> only create the homedirectory folder in 750 mod.
> My PHP-Script scans this directories every x minutes and processes those
> files. Upon completinon those files should get deleted, but as the dir
> is not writable by the user www this failes.
> 
> The dir looks like this:
> drwxr-x--- 2 ftpuser ftpgroup 4096 Jan 28 10:18 merlin/
> 
> files inside look like this:
> -rwxrwx--- 1 ftpuser ftpgroup 16868 Jan 28 10:20 test.xml*
> 
> User www which executes php via cron is inside the group "ftpgroup".
> 
> Any ideas? I am kind of lost with this one. Thank you for any help!
> 
> Best regards, Merlin

Why not run the cron as root, or ftpuser?

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Re: Programming general question

2009-01-28 Thread Ondrej Kulaty
Depends on what for you want to use that. Array is simple data structure, it 
holds data, like variable, but objects has methods and properties, it acts 
as someting which can do some sort of task and you access it via it's 
interface (you call it's methods). You can use array for example to hold 
result from database and than iterate it with for or foreach cycle. On the 
other hand, object can be used for exaplme to send mail, you put into it 
text body, mail adresses and so on and then call it's method send() which 
causes mail to be send. The process of transforming data, generating headers 
etc is completely done by the object and it's internal methods, you access 
it only via it's well defined interface (it's methods you can call). Objects 
are mainly used in OOP programming, where they cooperate together. Good way 
to learn OOP is to learn something about design patterns...
-- 


"Terion Miller"  píse v diskusním príspevku 
news:37405f850901271518r21f5f73j44841e864de5c...@mail.gmail.com...
>I googled this and didn't find an answer 
> my question is how do you know when to use an object or array
>
> would an object just be 1 instance, and array is several things together 
> ( I
> know infantile coder language I use..but I'm a baby still in this)
>
> Can someone explain objects and arrays in plain speak for me?
> Thanks
> Happy Coding
> 



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



[PHP] unlink file rights problem

2009-01-28 Thread Merlin Morgenstern

Hi there,

I am trying to unlink a file which is inside a folder that is not 
writable to phps user "www". Of course this failes, but I need to find a 
solution for it.


Backgroud is following:
I have pure-ftpd installed where user directories get created by 
pure-ftpd. Unfortunatelly there seems to be a bug and pure-ftpd does 
only create the homedirectory folder in 750 mod.
My PHP-Script scans this directories every x minutes and processes those 
files. Upon completinon those files should get deleted, but as the dir 
is not writable by the user www this failes.


The dir looks like this:
drwxr-x--- 2 ftpuser ftpgroup 4096 Jan 28 10:18 merlin/

files inside look like this:
-rwxrwx--- 1 ftpuser ftpgroup 16868 Jan 28 10:20 test.xml*

User www which executes php via cron is inside the group "ftpgroup".

Any ideas? I am kind of lost with this one. Thank you for any help!

Best regards, Merlin

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