[PHP] Multiple posts?

2004-09-23 Thread Graham Cossey
Is it me or are posts being sent multiple times?

I have just received the topic "[PHP] Newbie array problem" for the second
time. The first was @ 11:17 the second @ 13:35.

I have had a few others come through twice as well.

Thanks

Graham

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



RE: [PHP] Multiple posts?

2004-09-23 Thread Graham Cossey
-Original Message-
[snip]
Is it me or are posts being sent multiple times?

I have just received the topic "[PHP] Newbie array problem" for the
second
time. The first was @ 11:17 the second @ 13:35.

I have had a few others come through twice as well.
[/snip]

Sometimes there is a delay on the processing of the e-mail and people
hit the send button twice (or more when they don't see their message
show up right away. Sometimes you'll get two messages if your address
(one for you, one for the list) is not removed when the person replying
clicks 'Reply All'. Other time people don't get an answer right away, so
they send again thinking that it will get some action.

-Reply-

Now that you mention "Reply All" I know why my first ever post didn't
appear: I simply used "Reply" that sent an email only to the post
originator, oops, sorry another mailing list I'm on only has the mailing
list address when I hit "Reply".

Graham.

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



RE: [PHP] Using '

2004-09-23 Thread Graham Cossey
> Hi!
> i have:
> $html = '
>  
>MY HTML
>  
>  ';
> Inside of my html i used ', this produced a parse error, how can i solved
> it?.

Try:

$html = "  ...   ... ";

However my personal preference is the other way around:

$html = '  ...   ... ';

HTH

Graham

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



[PHP] PDF from PHP generated HTML, possible?

2004-09-23 Thread Graham Cossey

Following the topic about generating PDF documents from within PHP has
prompted a thought...

Is it possible to have PHP dynamically build an HTML page (from database
data etc) and provide an option to output the page as PDF without going
through all the database query routine again?

In other words, to produce a PDF file from dynamic HTML.

This is because I have seen at least one 'product' that reports to produce
PDF from HTML 'files'.

Any help/guidance/suggestions/URLs welcomed.

Graham

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



RE: [PHP] PDF from PHP generated HTML, possible?

2004-09-23 Thread Graham Cossey
> > Following the topic about generating PDF documents from within PHP has
> > prompted a thought...
> >
> > Is it possible to have PHP dynamically build an HTML page (from database
> > data etc) and provide an option to output the page as PDF without going
> > through all the database query routine again?
> >
> > In other words, to produce a PDF file from dynamic HTML.
> >
> > This is because I have seen at least one 'product' that reports to
produce
> > PDF from HTML 'files'.
>
> Well, providing you save the generated HTML somewhere (if you just send it
> to the client, then you don't have a copy of it) and this "product" can be
> called through exec(), system(), etc, then sure it's possible. It's going
to
> take another request to the server where you'll load the cached HTML
version
> of the page, run it through the "product", send PDF headers and/or send
the
> PDF file.
>
> Can't give specific examples, but hopefully that gives you an idea.
>
> ---John Holmes...

Thanks for that John, I think the big issue will be how to 'cache' my HTML
pages should I want to proceed down this route. BTW from memory I think the
'product' was htmldoc, or similar.

Graham.

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



RE: [PHP] Re: PDF from PHP generated HTML, possible?

2004-09-23 Thread Graham Cossey
That's fine for static pages, my question was regarding dynamic pages that I
did not wish to pass through the database querying again.

I understand that if my dynamic page is
http://server/app/page1.php?cust=12345&t=3 I can supply that URL which will
result in HTML that can be processed by (for example) pdf-o-matic. However,
as I've already run all the queries necessary I would like to not have to
run them all again when requesting the PDF.

Thanks

Graham.

-Original Message-
From: Mikey [mailto:[EMAIL PROTECTED]
Sent: 23 September 2004 15:50
To: [EMAIL PROTECTED]
Subject: [PHP] Re: PDF from PHP generated HTML, possible?


Hmmm, I cannot believe that there are people on this list who do not know
how to use Google.  I tried "convert HTML to pdf" and came up with loads of
results - including http://www.easysw.com/htmldoc/pdf-o-matic.php that seems
to allow you to see their source code.

HTH,

Mikey

- Original Message -----
From: "Graham Cossey" <[EMAIL PROTECTED]>
Newsgroups: php.general
To: "Php-General" <[EMAIL PROTECTED]>
Sent: Thursday, September 23, 2004 3:44 PM
Subject: PDF from PHP generated HTML, possible?


>
> Following the topic about generating PDF documents from within PHP has
> prompted a thought...
>
> Is it possible to have PHP dynamically build an HTML page (from database
> data etc) and provide an option to output the page as PDF without going
> through all the database query routine again?
>
> In other words, to produce a PDF file from dynamic HTML.
>
> This is because I have seen at least one 'product' that reports to produce
> PDF from HTML 'files'.
>
> Any help/guidance/suggestions/URLs welcomed.
>
> Graham

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

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



RE: [PHP] Re: PDF from PHP generated HTML, possible?

2004-09-23 Thread Graham Cossey
Thanks to all, this is indeed most enlightening for me as I've only been
using PHP for about 6 months. The output buffering and saving of generated
HTML pages (using a hashed name) could be very beneficial, saving hundreds
of quite lengthy MySQL queries each day.

Brad: When you say "a hash of the query string" do you mean passing the
variable part of the URL thru mhash to obtain a hash/key/digest or whatever
you wish to call it? If so, do you recommend any particular hash, ie MD5,
GOST or TIGER? Not knowing much about these things, I imagine passing the
same text thru a given hash algorithm multiple times will always return the
same result.

So:

Requested URL
http://server/app/page1.php?cust=12345&t=3

Variable part hashed
page1.php?cust=12345&t=3 > hash > mdg4789gnvh095n

If the following URL exists use it, otherwise do processing, get buffer and
write to this file.
http://server/app/static/mdg4789gnvh095n.html

If PDF of page requested:
Send the current URL (http://server/app/static/mdg4789gnvh095n.html) through
pdf-o-matic or similar.

Is that about right?

Many thanks
Great list !!

Graham

-Original Message-
From: Brad Pauly [mailto:[EMAIL PROTECTED]
Sent: 23 September 2004 17:17
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: PDF from PHP generated HTML, possible?


On Thu, 23 Sep 2004 16:25:27 +0100, Graham Cossey
<[EMAIL PROTECTED]> wrote:
> That's fine for static pages, my question was regarding dynamic pages that
I
> did not wish to pass through the database querying again.
>
> I understand that if my dynamic page is
> http://server/app/page1.php?cust=12345&t=3 I can supply that URL which
will
> result in HTML that can be processed by (for example) pdf-o-matic.
However,
> as I've already run all the queries necessary I would like to not have to
> run them all again when requesting the PDF.

At the beginning of your page1.php script (and any others that you
want to cache as html and pdf) you could check to see if you have
created cached version of the page, if so, redirect to that page. If
not, use output buffering and save the generated content to a file.
Run that file through the pdf-o-matic to create the pdf version. You
could name the file by creating a hash of the query string and any
other variable that affects the dynamic content of that page (for
example, session variables). So the original request might look like
your example.

http://server/app/page1.php?cust=12345&t=3

Which, if it has a cached html version would redirect to a different
URL before any of your queries are executed.

http://server/html/.html

Or, for the pdf version.

http://server/pdf/.pdf

- Brad

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

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



RE: [PHP] Re: PDF from PHP generated HTML, possible?

2004-09-24 Thread Graham Cossey
Many thanks to all (especially Brad) for your input on this.

Although I have not got as far as producing PDFs I have managed to implement
output buffering and saving of generated pages under a hashed name, and of
course retrieving it instead of doing all the queries again. I've trimmed
slightly the code below as I do some trimming of the session contents before
hashing. I also have to work out how to handle some functionality that uses
session data, so will probably generate a 'hashed' csv file along with the
html file.

For those that are interested (if only to comment on my coding skills !!)
what I have done is:
( It may not be pretty but it seems to work )

page1.php
-
status == 'new') // Did not exist
  {
ob_start();  // Start output buffering
  }else{
echo $static->html;
exit();
  }

... query processing etc ...

  $str = ob_get_contents();
  $static->save_html($str);
  ob_flush();
?>

staticHtml.inc.php
--
$static_path = "../static/";
$ssn = implode('_',$_SESSION);
$this->hash = md5($fullUrl.$ssn);
$this->path = $this->$static_path.$this->hash.'.htm';
$this->find_html();
}

function find_html() {
if (file_exists($this->path))
{
$this->html = file_get_contents($this->path);
$this->status = 'old';
}else{
$this->status = 'new';
}
}

function save_html($str) {
if ($this->find_html() == 'old')
{
// replace static page??
}else{
$fp = fopen($this->path,'w');
$sts = fwrite($fp,$str);
fclose($fp);
}
}
}
?>

-Original Message-
From: Brad Pauly [mailto:[EMAIL PROTECTED]
Sent: 23 September 2004 23:36
To: Php-General
Subject: Re: [PHP] Re: PDF from PHP generated HTML, possible?


On Thu, 23 Sep 2004 22:39:06 +0100, Graham Cossey
<[EMAIL PROTECTED]> wrote:
>
> Brad: When you say "a hash of the query string" do you mean passing the
> variable part of the URL thru mhash to obtain a hash/key/digest or
whatever
> you wish to call it? If so, do you recommend any particular hash, ie MD5,
> GOST or TIGER? Not knowing much about these things, I imagine passing the
> same text thru a given hash algorithm multiple times will always return
the
> same result.

I tend to use md5, but the other hash functions ought to work too. I
don't know about GOST and TIGER, but I know php has support for SHA1
and another that I don't remember at the moment.

> So:
>
> Requested URL
> http://server/app/page1.php?cust=12345&t=3
>
> Variable part hashed
> page1.php?cust=12345&t=3 > hash > mdg4789gnvh095n
>
> If the following URL exists use it, otherwise do processing, get buffer
and
> write to this file.
> http://server/app/static/mdg4789gnvh095n.html

Yep. I would check for the file (or whatever mechanism you use to
store the cache) instead of the URL. You could write a class or a few
functions that could do this check for you based on the hash.

> If PDF of page requested:
> Send the current URL (http://server/app/static/mdg4789gnvh095n.html)
through
> pdf-o-matic or similar.

You might consider creating the pdf version at the same time you
create the html. I depends on how your app works. Can you request a
pdf before you reque

> Is that about right?

Yep. I think you've got it.

> Many thanks

No problem =)

- Brad

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

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



RE: [PHP] PHP gurus...how are they doing this?

2004-10-11 Thread Graham Cossey
[snip]
>
> This is how far I have come trying to imitate the
> above: (Its not working of course :-)   )
>
>  $url=fsockopen('http://www.jumac.com/');
> $html = implode('', file("$url")); //put the page
> source in a string
>
> //find the links and put them in an array
> $links = array();
> if (preg_match_all('/ >]*)[\"\']?[^>]*>.*?<\/a>/i', $html, $matches))
> {
> foreach($mathes as $match){$links[] = $match;}

If this is a copy&paste of your code you may want to change the above line
to:

  foreach($matches as $match){$links[] = $match;}
  ^

[snip]

Graham

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



RE: [PHP] Exporting HTML to Excel

2004-10-12 Thread Graham Cossey
Philip, have you checked the php freaks website? I do recall seeing a script
in their tutorials library that claimed to create Excel files.

http://www.phpfreaks.com

Just had a search and came up with:



Cell 1
Cell 2

";
?>

HTH
Graham

> -Original Message-
> From: Philip Thompson [mailto:[EMAIL PROTECTED]
> Sent: 12 October 2004 22:21
> To: [EMAIL PROTECTED]
> Subject: [PHP] Exporting HTML to Excel
>
>
> Hi all.
>
> This may not be completely a PHP question, but hopefully you will be
> able to provide some insight. I have a table in HTML that I want to
> export to an excel spreadsheet. Using PHP, I can create an excel
> document - however, it's empty/blank. I think I am just doing it
> incorrectly. Anybody done this before and/or have any ideas? I would
> prefer to NOT use a third-party program.
>
> I've searched the web and php.net, but have been somewhat unsuccessful
> in finding anything. Here's what I have so far:
>
> -
>  header('Content-Type: application/ms-excel');
> header('Content-Disposition: attachment; filename="project.xls"');
> ?>
>
> 
>   
>   Something
>   Something else
>   
> 
> -
>
> I just want it to have that content in the spreadsheet. It's actually
> more involved than that, but that's the gist of it.
>
> Thanks in advance.
> ~Philip
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Query Returning Error

2004-10-13 Thread Graham Cossey
Besides adding $ to Query01, I have had little luck in the past when  using
$_POST or $_GET directly in an evaluated string. If you are still having
problems, try something like:



HTH

Graham

> -Original Message-
> From: Harlequin [mailto:[EMAIL PROTECTED]
> Sent: 13 October 2004 08:32
> To: [EMAIL PROTECTED]
> Subject: [PHP] Query Returning Error
>
>
> Morning all.
>
> this is such a basic question I'm embarrassed to ask but the query worked
> fine a few minutes ago and now returns an error:
>
> I get an error:
>
> Parse error: parse error, unexpected '=' in sample.php on line 2
>
> [CODE]
> // Authenticate User:
>Query01 = "SELECT * FROM Users
>WHERE UserID='$_POST[TXT_UserID]'
>AND UserPassword='$_POST[TXT_UserPassword]'";
>$Result01 = mysql_query($Query01) or die("Error 01: " . mysql_error());
> [/CODE]
>
> WTF...?
>
> --
> -
>  Michael Mason
>  Arras People
>  www.arraspeople.co.uk
> -
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Query Returning Error

2004-10-13 Thread Graham Cossey
Thanks Chris, that'll help keep my code a bit more 'compact'.
(Sorry Harlequin, kinda hijacked your post here)

Graham

> -Original Message-
> From: Chris Dowell [mailto:[EMAIL PROTECTED]
> Sent: 13 October 2004 11:57
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Query Returning Error
>
>
> You can get around this problem more easily by putting your variables
> inside curly brackets when they appear inside strings.
>
> See here:
> http://uk.php.net/manual/en/language.types.string.php#language.typ
> es.string.parsing.complex
>
> Or as an example:
>
> 
> $Query01 = "SELECT * FROM Users
> WHERE UserID = '{$_POST['TXT_UserID']}'
> AND UserPassword = '{$_POST['TXT_UserPassword']}'";
>
> $Result01 = mysql_query($Query01) or die ("Error 01: " . mysql_error());
>
> ?>
>
> Note also that you didn't quote the index you were using inside the
> $_POST array. This is wrong - it will work in "raw" PHP because it will
> be interpreted as an undefined constant, and thus replaced with the
> string, however the behaviour inside a quoted string is even less
> correct, and will almost certainly not do what you expect.
>
> Hope this helps
>
> Cheers
>
> Chris
>
>
> Graham Cossey wrote:
> > Besides adding $ to Query01, I have had little luck in the past
> when  using
> > $_POST or $_GET directly in an evaluated string. If you are still having
> > problems, try something like:
> >
> >  > $user = $_POST['TXT_UserID'];
> > $pwd = $_POST['TXT_UserPassword'];
> >
> > // Authenticate User:
> >$Query01 = "SELECT * FROM Users
> >WHERE UserID='$user' AND
> >  UserPassword='$pwd'";
> >$Result01 = mysql_query($Query01) or die("Error 01: " .
> mysql_error());
> > ?>
> >
> > HTH
> >
> > Graham
> >
> >
> >>-Original Message-
> >>From: Harlequin [mailto:[EMAIL PROTECTED]
> >>Sent: 13 October 2004 08:32
> >>To: [EMAIL PROTECTED]
> >>Subject: [PHP] Query Returning Error
> >>
> >>
> >>Morning all.
> >>
> >>this is such a basic question I'm embarrassed to ask but the
> query worked
> >>fine a few minutes ago and now returns an error:
> >>
> >>I get an error:
> >>
> >>Parse error: parse error, unexpected '=' in sample.php on line 2
> >>
> >>[CODE]
> >>// Authenticate User:
> >>   Query01 = "SELECT * FROM Users
> >>   WHERE UserID='$_POST[TXT_UserID]'
> >>   AND UserPassword='$_POST[TXT_UserPassword]'";
> >>   $Result01 = mysql_query($Query01) or die("Error 01: " .
> mysql_error());
> >>[/CODE]
> >>
> >>WTF...?
> >>
> >>--
> >>-
> >> Michael Mason
> >> Arras People
> >> www.arraspeople.co.uk
> >>-
> >>
> >>--
> >>PHP General Mailing List (http://www.php.net/)
> >>To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



[PHP] Help with sessions problem please

2004-10-14 Thread Graham Cossey

I'm having a bad day with sessions which hopefully someone can help me with.

A user logs in to my 'site' (script1.php) and I store relevant details in a
session, all fine. I redirect to another page (script2.php) which checks and
retrieves certain session values, all fine. My problem is with script3.php
which happens to be within an iframe in script2.php. When the user is
automatically passed to that page, from log in, the session details are not
available but if the user makes a (menu) selection the session values are
available to script3.php within the iframe. help !

Simplified code:

script1.php


script2.php

Your browser does not support the use of frames.
  
  [some code]
?>

script3.php


If you need any specific info on my config just ask and I'll try and supply
it.

TIA
Graham

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



RE: [PHP] Help with sessions problem please [SOLVED]

2004-10-14 Thread Graham Cossey
Thanks guys for the help, adding SID to my iframe src solved my immediate
problem.

Am I correct in thinking then that the SID is automatically passed on
relative URLs only within the same browser/[i]frame/window when
use_trans_sid is enabled?

Graham

> -Original Message-
> From: Chris Shiflett [mailto:[EMAIL PROTECTED]
> Sent: 14 October 2004 11:03
> To: Jason Wong; [EMAIL PROTECTED]
> Subject: Re: [PHP] Help with sessions problem please
>
>
> --- Jason Wong <[EMAIL PROTECTED]> wrote:
> > Use an absolute URL for header redirects.
>
> Glad to see someone else preaching the good HTTP gospel. :-)
>
> > You're passing the session id (SID) onto script2 but not to
> > script3, if that's the only method by which you're propagating
> > the session id then script3 is not going to have a session.
>
> I think Jason hit the nail on the head with this one, but you might not
> understand the answer. While script3.php might seem to be within
> script2.php, due to the visual layout you're providing with the iframe,
> this is completely independent of the technical implementation, which is
> that each is a separate resource.
>
> If that's confusing, think of an iframe as a little embedded browser. If
> it fails to properly identify itself (via cookie or URL), then there is no
> existing session to resume. Your call to session_start() will actually
> create a new session every time script3.php is requested.
>
> Hope that helps.
>
> Chris
>
> =
> Chris Shiflett - http://shiflett.org/
>
> PHP Security - O'Reilly HTTP Developer's Handbook - Sams
> Coming December 2004http://httphandbook.org/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] User Defined Forms

2004-10-14 Thread Graham Cossey
I think the problem here will be in the database design.

You certainly could store PDFs or the like, but then someone is going to
want to run queries, produce reports, make updates etc etc.

The problem (I think) is to come up with a db design that is not fixed to a
given form structure. Using the relational model this is going to be tricky.
I'm sure someone somewhere has done something along these lines but to what
level of success I've no idea. I have (in the past) been involved with
non-relational data models that could possibly overcome the db design issue,
but you are then looking at having to use technologies that are maybe new to
you and possibly costly. For example using Java/XSLT with a non-open source
database server. However, having said all that the PHP-General mailing list
is probably not the place to be discussing this.

Graham

> -Original Message-
> From: Shaun [mailto:[EMAIL PROTECTED]
> Sent: 14 October 2004 18:23
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] User Defined Forms
>
>
>
> "Jay Blanchard" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> [snip]
> I am creating a site where users record details of their clients and
> record
> their progress. The whole point of the system is to reduce the amount of
> paper work and store everything online.
> [/snip]
>
>
> How much time have you spent with the users? How well do you understand
> their needs? Have you done a flowchart or any other modeling?
>
> Hi Jay,
>
> I have interviewed a few users and it has become instantly apparent that
> they all work differently and record slightly different information about
> their clients making it impossible to produce a general set of forms that
> would encompass all users. I haven't done any other forms of modelling as
> yet.
>
> Thanks for your help
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] problem with array

2004-10-15 Thread Graham Cossey
> Hi guys,
> Recently, I had to reformat one of the web servers and now I have
> encountered an unusual problem. I am not sure whether this is an
> issue which
> can be fixed in the .ini file or whether its specific to the
> version of php
> I am using.
>
> Here is the problem:
>$query="SELECT * FROM customizeViewClients WHERE employeeNum =
> $employeeNum";
>$results=mssql_query($query, $connection) or die("Couldn't execute
> query");
>$numRows=mssql_num_rows($results);
>
> if($numRows>0)
>{
>  $row=mssql_fetch_array($results);
> }
>
>  $selectedCol=$row["selectedCol"];
>   echo $selectedCol;
>  $selectedColName=$row[$selectCol];   //<--- PLEASE NOTE THIS SPECIFIC
ROW
[snip]

Note because you used $selectCol instead of $selectedCol?

I would also move the } to after this line so that you do not attempt to
access non-existent array elements when no rows are returned.

HTH

Graham

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



[PHP] PHP websites (www/uk/us2)

2004-10-15 Thread Graham Cossey

I was wondering what the difference is between the various PHP sites linked
to in this list, are they mirrors and what determines which site you get
directed to when doing a search from www.php.net?

http://www.php.net
http://uk.php.net
http://us2.php.net

and presumably others...


Thanks

Graham

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



RE: [PHP] Images in PHP and MySQL

2004-09-27 Thread Graham Cossey
I'm no certified expert, but preference would be storing a URL to an image
in the database rather than the image itself.

If however you do want to store them in the db try using a blob column type.

This article is PHP3 but shows the basics:
http://www.phpbuilder.com/columns/florian19991014.php3

HTH

Graham

-Original Message-
From: GH [mailto:[EMAIL PROTECTED]
Sent: 27 September 2004 23:19
To: php-general
Subject: [PHP] Images in PHP and MySQL


I was wondering how to get images into and out of a Mysql database
with in php... I do not have anything in my book... but was told it
was possible.

I have PHP 4.3.4 and mysql 4.0.18

Thanks

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

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



RE: [PHP] Re: grabbing information from websites

2004-09-28 Thread Graham Cossey
>From http://gnosis.cx/publish/programming/regular_expressions.html:

"Sometimes you have a programming problem and it seems like the best
solution is to use regular expressions; now you have two problems."

To me regular expressions are some kind of black art, I've been programming
for 20 years and until recently have pretty much managed to avoid them. The
above URL is a pretty good tutorial.

HTH

Graham

-Original Message-
From: champinoman [mailto:[EMAIL PROTECTED]
Sent: 28 September 2004 09:35
To: [EMAIL PROTECTED]
Subject: [PHP] Re: grabbing information from websites



> instead of the POSIX regexp, tr using PERL style RegExps
> (www.php.net/pcre) Once you've done that, you can add the pattern modifier
> 'm' to allow multilines .

i think im lost now. i had a look at the site but im not sure what im
looking at. any chance u could make a mock script up so i can see what your
explaining?

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

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



RE: [PHP] Re: grabbing information from websites

2004-09-28 Thread Graham Cossey

fgets() will read in from file until end of line or end of file up to the No
bytes given.

Is there an end of line between the "username=chapinoman" and the "70,277" ?

If there is a line break then $line will never contain both strings.

You may need to use fread() instead.

HTH

Graham

-Original Message-
From: champinoman [mailto:[EMAIL PROTECTED]
Sent: 28 September 2004 14:47
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: grabbing information from websites


i said i was learning this and didnt really understand it.
so going by what has been said i have come up with the following but
still doesnt want to work.
heres what i have:

http://hiscore.runescape.com/aff/runescape/hiscorepersonal.cgi?username=ch
ampinoman","r");
$line = fgets ($file, 1024);
if
(preg_match('#username=champinoman&category=13.*align="right">(.*)#mi',
$line,$out))
{
$rune = $out;
}
fclose($file);
print $rune;
?>

and the source it is looking at is:

http://www.runescape.com/img/hiscores/crafting.gif";
valign="bottom" width=16 height=16 /> 
Crafting
70,277
43

53,630


I want it to get the 70,277 and store as $rune
if someone can tell me where im wrong i would be extremely grateful

thank you for your ongoing support.




--
"M. Sokolewicz" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> ugh, obviously I'm a bad typer :) The code should be:
>
>
preg_match('#username=champinoman&category=13.*align="right">(.*)#mi',
> $text, $out);
>
> Or using any other patterndelimiter... ;)
>
> M. Sokolewicz wrote:
>
>> I thought I clearly stated that for the m modifier you need to use PCRE
>> functions!
>>
>> eg:
>>
>>
preg_match('/username=champinoman&category=13.*align="right">(.*)/mi',
>> $text, $out);
>>
>> Champinoman wrote:
>>
>>> so does this look right:
>>>
>>> eregi
>>>
("username=champinoman&category=13.*align=\"right\">(.*)"m,$line,$out))
>>>
>>> is that where i am ment to put the 'm' modifier? or am i still off on
>>> the wrong track?
>>>
>>>
>>>
>>>
>>> "Graham Cossey" <[EMAIL PROTECTED]> wrote in message
>>> news:[EMAIL PROTECTED]
>>>
>>>> From http://gnosis.cx/publish/programming/regular_expressions.html:
>>>>
>>>> "Sometimes you have a programming problem and it seems like the best
>>>> solution is to use regular expressions; now you have two problems."
>>>>
>>>> To me regular expressions are some kind of black art, I've been
>>>> programming
>>>> for 20 years and until recently have pretty much managed to avoid them.
>>>> The
>>>> above URL is a pretty good tutorial.
>>>>
>>>> HTH
>>>>
>>>> Graham
>>>>
>>>> -Original Message-
>>>> From: champinoman [mailto:[EMAIL PROTECTED]
>>>> Sent: 28 September 2004 09:35
>>>> To: [EMAIL PROTECTED]
>>>> Subject: [PHP] Re: grabbing information from websites
>>>>
>>>>
>>>>
>>>>
>>>>> instead of the POSIX regexp, tr using PERL style RegExps
>>>>> (www.php.net/pcre) Once you've done that, you can add the pattern
>>>>> modifier
>>>>> 'm' to allow multilines .
>>>>
>>>>
>>>> i think im lost now. i had a look at the site but im not sure what im
>>>> looking at. any chance u could make a mock script up so i can see what
>>>> your
>>>> explaining?
>>>>
>>>> --
>>>> PHP General Mailing List (http://www.php.net/)
>>>> To unsubscribe, visit: http://www.php.net/unsub.php



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

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



[PHP] Changing mta in /etc/alternatives : how?

2004-09-28 Thread Graham Cossey

Sorry for the probably basic question, but I would like to change the
default mta on my FC2 box from sendmail to exim. I believe to do this I need
to change the 'entry' in /etc/alternatives/ to point to
/usr/sbin/sendmail.exim instead of /usr/sbin/sendmail.sendmail.

Doing a 'ls -al' on /etc/alternatives shows that the entries here are
lrwxrwxrwx, what exactly is the 'l' and how do I change it? I have tried
creating a test symbolic link such as :

ln -isv /usr/sbin/sendmail.exim test

but the colour coding of the resulting 'test' link is different to the
existing ones.

Can someone shed some light on this for me?

Many thanks

Graham

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



[PHP] RE: [IGNORE] [PHP] Changing mta in /etc/alternatives : how?

2004-09-28 Thread Graham Cossey

Sorry, mailed to the wrong list :(

-Original Message-
From: Graham Cossey [mailto:[EMAIL PROTECTED]
Sent: 28 September 2004 23:27
To: Php-General
Subject: [PHP] Changing mta in /etc/alternatives : how?



Sorry for the probably basic question, but I would like to change the
default mta on my FC2 box from sendmail to exim. I believe to do this I need
to change the 'entry' in /etc/alternatives/ to point to
/usr/sbin/sendmail.exim instead of /usr/sbin/sendmail.sendmail.

Doing a 'ls -al' on /etc/alternatives shows that the entries here are
lrwxrwxrwx, what exactly is the 'l' and how do I change it? I have tried
creating a test symbolic link such as :

ln -isv /usr/sbin/sendmail.exim test

but the colour coding of the resulting 'test' link is different to the
existing ones.

Can someone shed some light on this for me?

Many thanks

Graham

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

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



RE: [PHP] Re: grabbing information from websites

2004-09-29 Thread Graham Cossey

OK, I've tried it out. What is interesting is that the URL you have posted
results in the site's 'home' page, for me anyway, which obviously results in
no matches for the preg_match. It appears to redirect to
http://www.runescape.com/ somehow.

I am using the code:

http://hiscore.runescape.com/aff/runescape/hiscorepersona
l.cgi?username=champinoman");
if
(preg_match('#username=champinoman&category=13.*align="right">(.*)#mi',
$content,$out))
{
echo $out;
}else{
echo $content;  // <- results in home page
}
?>

Graham

-Original Message-
From: champinoman [mailto:[EMAIL PROTECTED]
Sent: 29 September 2004 02:04
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Re: grabbing information from websites


i tried putting in fread() but still getting a blank screen. any other
errors in here?

http://hiscore.runescape.com/aff/runescape/hiscorepersonal.cgi?username=ch
ampinoman","r");
$line = fread ($file, 1024);
if
(preg_match('#username=champinoman&category=13.*align="right">(.*)#mi',
$line,$out))
{
$rune = $out;
}
fclose($file);
print $rune;
?>



"Graham Cossey" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> fgets() will read in from file until end of line or end of file up to the
> No
> bytes given.
>
> Is there an end of line between the "username=chapinoman" and the " align="right">70,277" ?
>
> If there is a line break then $line will never contain both strings.
>
> You may need to use fread() instead.
>
> HTH
>
> Graham
>
> -Original Message-
> From: champinoman [mailto:[EMAIL PROTECTED]
> Sent: 28 September 2004 14:47
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: grabbing information from websites
>
>
> i said i was learning this and didnt really understand it.
> so going by what has been said i have come up with the following but
> still doesnt want to work.
> heres what i have:
>
>  $file = fopen
>
("http://hiscore.runescape.com/aff/runescape/hiscorepersonal.cgi?username=ch
> ampinoman","r");
> $line = fgets ($file, 1024);
> if
>
(preg_match('#username=champinoman&category=13.*align="right">(.*)#mi',
> $line,$out))
> {
> $rune = $out;
> }
> fclose($file);
> print $rune;
> ?>
>
> and the source it is looking at is:
>
> http://www.runescape.com/img/hiscores/crafting.gif";
> valign="bottom" width=16 height=16 /> 
>  class=c>Crafting
> 70,277
> 43
> 
> 53,630
> 
>
> I want it to get the 70,277 and store as $rune
> if someone can tell me where im wrong i would be extremely grateful
>
> thank you for your ongoing support.
>
>
>
> --
--
> --
> "M. Sokolewicz" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> ugh, obviously I'm a bad typer :) The code should be:
>>
>>
>
preg_match('#username=champinoman&category=13.*align="right">(.*)#mi',
>> $text, $out);
>>
>> Or using any other patterndelimiter... ;)
>>
>> M. Sokolewicz wrote:
>>
>>> I thought I clearly stated that for the m modifier you need to use PCRE
>>> functions!
>>>
>>> eg:
>>>
>>>
>
preg_match('/username=champinoman&category=13.*align="right">(.*)/mi',
>>> $text, $out);
>>>
>>> Champinoman wrote:
>>>
>>>> so does this look right:
>>>>
>>>> eregi
>>>>
>
("username=champinoman&category=13.*align=\"right\">(.*)"m,$line,$out))
>>>>
>>>> is that where i am ment to put the 'm' modifier? or am i still off on
>>>> the wrong track?
>>>>
>>>>
>>>>
>>>>
>>>> "Graham Cossey" <[EMAIL PROTECTED]> wrote in message
>>>> news:[EMAIL PROTECTED]
>>>>
>>>>> From http://gnosis.cx/publish/programming/regular_expressions.html:
>>>>>
>>>>> "Sometimes you have a programming problem and it seems like the best
>>>>> solution is to use regular expressions; now you have two problems."
>>>>>
>>>>> To me regular expressions are some kind of black art, I've been
>>>>> programming
>>>>> for 20 years and until recently have pretty much managed to avoid
>>>>> them.
>>>>> The
>>>>> above URL is a pretty good

RE: [PHP] Multiple pages of data.

2004-09-29 Thread Graham Cossey
<> tutorial at phpfreaks.com:

http://www.phpfreaks.com/tutorials/73/0.php

HTH

Graham.

-Original Message-
From: Silvio Porcellana [mailto:[EMAIL PROTECTED]
Sent: 29 September 2004 10:53
To: [EMAIL PROTECTED]
Subject: Re: [PHP] Multiple pages of data.


You can solve it totally with SQL, using the FOUND_ROWS() function 
[http://dev.mysql.com/doc/mysql/en/Information_functions.html]

I think this is the most efficient way of doing it...

HTH, cheers

Silvio Porcellana

Nick Patsaros wrote:
> I'm trying to build a bulletin style system right now.  I have topics
> and replies to each topic.  If a topic gets more than 15 replies I
> want them to start carrying over onto page 2 and then 3 and so on with
> 15 replies per page.
> 
> The key that I'm missing I guess is, how do I keep track of the last
> accessed row in the database?  So if I run a LIMIT 15 I can go back
> and pick up where I left on previously?  Using the primary key isn't
> going to help because if posts get deleted I would have less than 15
> per page.
> 
> Maybe I'm totally lost on this though, if someone could give me a bit
> of help on the most efficient way to accomplish this.
> 
> --Nick
> 

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

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



RE: [PHP] PHP Data cache ideas/solutions

2004-09-29 Thread Graham Cossey
A bit rough and ready but I think this is kind of what you asked for:

** THIS IS UNTESTED CODE **
 $name2)
{
  echo "$id2 $name2 ";
}

...some code...

// Determine a valid value for $x and then:
$name3 = $user_array[$x];

?>



HTH

Graham

-Original Message-
From: Niklas Ojala [mailto:[EMAIL PROTECTED]
Sent: 29 September 2004 10:04
To: [EMAIL PROTECTED]
Subject: [PHP] PHP Data cache ideas/solutions


Hello

I am kind of new to this news thing, but here goes.

I am looking for a class or some samples that would read a table from mysql
and store it in an array variable, so that it will be avilable to other
parts of the page without having to get it from the database again. So I
would like to only get the table once per page load but I must be able to
filter the table to get the data that I want.

I am looking for some similar code to get me started or other ideas on how
to make less queries to the database.

/Niklas Ojala

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

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



RE: [PHP] Replace or regex?

2004-09-30 Thread Graham Cossey
If you can change the ##text## to say /#text#/ it would be easier as you
could then do something like:

$id = substr($orig_text,strpos($orig_text, '/#')+2,strpos($orig_text,
'#/')-1);
$new_text = str_replace( '/#', 'href="somewhere.php?id='.$id.'">',
$orig_text);
$new_text = str_replace( '#/', '', $new_text);

see:
http://www.php.net/manual/en/ref.strings.php

HTH

Graham

-Original Message-
From: Gareth Williams [mailto:[EMAIL PROTECTED]
Sent: 30 September 2004 09:38
To: mario
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] Replace or regex?



Well, if you can do it without a regex, then it's always best, because
the regex engine slows things down.

On 30 Sep 2004, at 10:39, mario wrote:

> Hi all
>
> I have a string: ##CODE## and I want to replace that with  href="somewhere.php?id=CODE">CODE
>
> can u help?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

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

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



RE: [PHP] UNSUBSCRIBE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

2004-09-30 Thread Graham Cossey

Great, I needed some humour today, thanks all :)

Graham
-Original Message-
From: Jay Blanchard [mailto:[EMAIL PROTECTED]
Sent: 30 September 2004 16:26
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: [PHP]
UNSUBSCRIBE


[snip]
Can we start mass flaming this guy? Ok one nice one...

Denise Holland
ITM - Network Support
703-358-1823
[/snip]

I vote we all call her

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

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



RE: [PHP] Zend PHP Certification test

2004-09-30 Thread Graham Cossey

> 
> 
> I passed.
> 
> 
> 
> Greg Donald
> Zend Certified Engineer
> http://gdconsultants.com/
> http://destiney.com/
 

Congratulations Greg.

Like the new sig ! ;)

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



RE: [PHP] Two people working on the same app / script?

2004-09-30 Thread Graham Cossey
Please correct me if I'm wrong, but I didn't think SourceSafe allowed for
versioning/branching, simply 'locking' a file until it was checked in, but I
haven't used it for a while.

This is actually the basic functionality I'm looking for, and possibly what
the OP requires too, I don't (currently) need versioning/branching just a
way to ensure that I can't change some code being worked on by a colleague.

Can CVS or Subversion operate in this 'basic' mode?

If not, does anyone know of a free/open source app that provides this?

Dreamweaver offers a simple locking functionality but would require all
developers on a project to use Dreamweaver, which can get expensive and I
would like each developer to be able to use the IDE they feel most
comfortable with.

Thanks

Graham

-Original Message-
From: Gryffyn, Trevor [mailto:[EMAIL PROTECTED]
Sent: 30 September 2004 14:44
To: [EMAIL PROTECTED]
Cc: Dave Carrera
Subject: RE: [PHP] Two people working on the same app / script?


CVS is definitely something to check into.  In addition to the Mac
product mentioned before, Zend Studio and many other IDEs and editors
have CVS compatibility built into them.

CVS is similar to (but of course has differences to) Microsoft's Source
Safe, if you're familiar with that product. (yeah, someone's going to
hang me for making the comparison, but they serve the same function so
I'm drawing a parallel).

-TG

> -Original Message-
> From: Chris Shiflett [mailto:[EMAIL PROTECTED]
> Sent: Thursday, September 30, 2004 4:38 AM
> To: Dave Carrera; [EMAIL PROTECTED]
> Subject: Re: [PHP] Two people working on the same app / script?
>
>
> --- Dave Carrera <[EMAIL PROTECTED]> wrote:
> > Is there a simple solution for two or more people to work on the
> > same php app /script without it turning into a mess of many tar /
> > zip files with contributed additions.
>
> Any version control system that supports concurrent
> development will work
> for this. For example, Concurrent Versions System, CVS. :-)
>
> Chris
>
> =
> Chris Shiflett - http://shiflett.org/
>
> PHP Security - O'Reilly HTTP Developer's Handbook - Sams
> Coming December 2004http://httphandbook.org/
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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

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



RE: [PHP] Zend PHP Certification test

2004-09-30 Thread Graham Cossey
This is very interesting reading.

I've been using PHP (almost) daily for the past 7 months so Chris' comments
do encourage me to consider the possibility of going for the certification
in time. I do think I would need the study guide though as there are many
topics being discussed on this list that are new to me and my experience has
been with only one application at present. My problem (as I'm sure is true
with many others) is that I need to get the job done ASAP and rarely have
time to research the 'best' way of doing things. This list is very good at
getting me to see alternatives to how I am doing things.

Thanks

Graham


-Original Message-
From: Chris Shiflett [mailto:[EMAIL PROTECTED]
Sent: 30 September 2004 18:18
To: Rory Browne; PHP General
Subject: Re: [PHP] Zend PHP Certification test


--- Rory Browne <[EMAIL PROTECTED]> wrote:
> I haven't done the exam, yet, but based on some of the practice
> questions, I'm getting worried. I'm finding sample questions whose
> answers are not covered in the book.

If you're talking about the questions in the back of the Zend
Certification Guide, don't worry - those questions are much more difficult
and obscure than what you'll find on the actual exam. If it makes you feel
better, several of us from the advisory board looked through those at
OSCON, and we all missed most of the first few questions. :-)

> One such question was a list(, $var) = whatever, and nowhere in
> the book could I find an explanation for same.

Yeah, I got that one, but the other guys thought it would be a parse error
or something. Having the comma first just skips the first argument - it's
like you don't want to assign the first value to a variable. Not knowing
this is fine.

> I've also used count, and strlen many times, but I've never used
> count on a non-array, which is what strlen returns.

I think this is something you should be able to answer, but that's just
me. It's true that most people who use count() use it on an array, but
it's not really an array function. It just happens to not make much
practical sense to count something that's only going to have one value (or
null, which will return 0). However, while practicality is great, I think
some theoretical foundation is also important.

I didn't write this question, so that's not why I'm defending it. :-)

Some of the questions in the guide require you to deduce the correct
answer from what you've learned. This can rarely be achieved if the guide
is your only exposure to a topic, and this is somewhat intentional. We
tried to target developers who have at least 6 months of professional PHP
experience (e.g., you've been writing non-trivial PHP applications every
day for at least 6 months). The guide was written to help people expose
themselves to a broader range of topics than their practical experience
might have exposed them to, because the exam is pretty thorough.

I think a very experienced developer can pass the exam without using the
guide with little trouble, but I don't think an inexperienced developer
can read the guide and hope to pass. You need more than that.

Hope that helps.

Chris

=
Chris Shiflett - http://shiflett.org/

PHP Security - O'Reilly HTTP Developer's Handbook - Sams
Coming December 2004http://httphandbook.org/

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

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



RE: [PHP] list of Months

2004-09-30 Thread Graham Cossey
What you have is basically what I do, but the current month check could be
tidied up and display the month name seeing as you have the array:

 $selected_QuoteMonth = (date('m')==$i)?'SELECTED':'';
 echo " $month_names[$i] ";

** CODE IS UNTESTED **

I'm sure if there is a better way then someone here will let u know.

HTH

Graham

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 30 September 2004 21:17
To: [EMAIL PROTECTED]
Subject: [PHP] list of Months


Hi,
to create a list of all months in drop-down menu I use this code:

'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
?>



 $i ";
}
?>


Is there any better way?

Thanks for any help.

Afan

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

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



RE: [PHP] Zend Optimizer not installed

2004-10-01 Thread Graham Cossey
Hi Ox

I'm UK based but currently use GlobalServers in the US
(www.globalservers.com).

They run Virtual Private Servers of 3 levels, 2 of which allow root access.
They do claim to run Zend Optimizer but as yet I have not determined if this
is active on my account.

HTH

Graham.

-Original Message-
From: Ox [mailto:[EMAIL PROTECTED]
Sent: 01 October 2004 08:35
To: [EMAIL PROTECTED]
Subject: [PHP] Zend Optimizer not installed


Hey All,

Does anyone know of a hosting company that will provide Zend Optimizer
v2.1.0 or later on a VIRTUAL hosting package. (preferably in the UK)

I have been helping a guy out who has had a development done and the
developers kindly didnt tell me that they use Zend Optimizer to encode
their pages, and the hosting package even after they said it was
"perrfect" is now not working cause it doesnt have Zend Optimizer on
it :\

Thanks
Ox

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

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



RE: [PHP] How do I produce a random database query for each day or week?

2004-10-01 Thread Graham Cossey
A couple of thoughts:

As you want to cycle through the list rather than randomly (with repetition)
picking from the list, have you considered storing the last CD shown details
in the DB?

If each CD has a sequential ID then each week (or day) you increment the
number which will determine what CD is shown. If the incremented CD id
exceeds the highest id in the DB, restart back at the first id.

You could also include a column (or two) in the CD info table to record when
it was last displayed and check that this is > 29 days ago.

What about cookies? Each visitor could then have their own 'cycle' through
the list.

HTH

Graham

-Original Message-
From: I.A. Gray [mailto:[EMAIL PROTECTED]
Sent: 01 October 2004 07:34
To: [EMAIL PROTECTED]
Subject: [PHP] How do I produce a random database query for each day or
week?


Hi,

My brain is working very slowly this morning (maybe that is because of
having 5hrs sleep...)
Could someone help me with this problem.

I would like to show a different CD with information on it, on the home page
each week- a kind of 'recording of the week' and I would also like to have
on the same page something that changes every day.

The recordings are in a MYSQL database and I would like all of them (there
are 29 at present) to be shown over how ever long it would take to get
through them (in this case 29 weeks) and then once they have all been shown
this would then repeat.  I would like them to be shown in a random order and
make sure that the recording hasn't been shown within the 29.  The same goes
for the other project which uses a mysql database which I would like to
rotate daily (in this case there are 103 items)

Obviously if I use PHP random functions this will always return a random
number, but how do I produce a random number which relates to the day or
week of the year?

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

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



RE: [PHP] Including function libraries

2004-10-02 Thread Graham Cossey
Do you have  in functions.lib ?

-Original Message-
From: Andrew W [mailto:[EMAIL PROTECTED]
Sent: 02 October 2004 16:52
To: php-gen
Subject: [PHP] Including function libraries


Ok, I've got a file called functions.lib which contains the following:

function checkLoggedIn()
{
return (true);
}


function Test ($x)
{
return ($x * $x);
}

and a file called test.php which contains the following:



They're both stored in a directory called 'test' which Ive uploaded to 
my webserver.  When I call test.php from my browser I get the following 
output:

  function checkLoggedIn() {  return (true); }  function Test ($x) {  
return ($x * $x); }
Fatal error: Call to undefined function: checkloggedin() in 
/home/sites/site116/web/test/test.php on line 5

Why can't I call the function defined in the lib file?

Thanks
AW

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



RE: [PHP] How to load another php page?

2004-10-02 Thread Graham Cossey
For my own clarification, would it not be possible to use output buffering
and then either redirect to another script using header() or output the
buffer contents?



thanks

Graham

-Original Message-
From: Marek Kilimajer [mailto:[EMAIL PROTECTED]
Sent: 02 October 2004 21:07
To: Arnold
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] How to load another php page?


Arnold wrote:
> Ok, i can live with it, include works but this doesnt replace the whole
> running script, only the rest of the script (what is still coming), so if
a
> few things have been written in "a.php", when "include('b.php') is
executed,
> this "b.php" does not replace all the (allready written) output of
"a.php".

That's how the life goes. Once you say something, you can't take it
back. So think first, then open your mouth :) (put your logic before the
output).

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

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



RE: [PHP] Re: set multiple variables

2004-10-03 Thread Graham Cossey

||= OR
&& = AND

-Original Message-
From: argesson [mailto:[EMAIL PROTECTED]
Sent: 03 October 2004 11:30
To: [EMAIL PROTECTED]
Subject: [PHP] Re: set multiple variables


Daniel Schierbeck wrote:
> Argesson wrote:
> 
>> try this:
>> if ($REMOTE_ADDR == "212.3.54.65" && $REMOTE_ADDR == "212.3.54.66")
>>
>> Joe Szilagyi wrote:
>>
>>> Hi, I have this working:
>>>
>>>
>>> if ($REMOTE_ADDR == "212.3.54.65")  {
>>> header("Location: http://www.google.com/search?&q=huzzah";);
>>> Redirect browser
>>> exit;
>>> }
>>>
>>>
>>> But I want to specify multiple IPs. What's the best recommended way for
>>> doing that?
>>>
>>>
>>> thanks
>>> Joe
> 
> 
> Make that:
> if ($REMOTE_ADDR == "212.3.54.65" || $REMOTE_ADDR == "212.3.54.66")

isn't the || same as && ? Or I missed something?

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

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



RE: [PHP] code not working...help?

2004-10-07 Thread Graham Cossey
[snip]
>
>  $lastmonth = date("YmdHis", mktime(date("H"), date("i"), date("s"),
> date("m")-1, date("d"), date("Y")));
>  $countResult = db_query("SELECT count(*) AS msgCount FROM messages WHERE
> uid = '". $userID ."' AND fid = '". $fid ."' AND post_date <= '".
> $lastmonth
> ."'");
>  $countRow = db_fetch_array($countResult);
>
> im then using $countRow as my variable but it keeps returning a value of
> zero.

Firstly, I've never come across the function db_query or db_fetch_array,
what are they? Are they 'home grown' or a readily available database
abstraction function set? (php.net function search returns no match)

Secondly I find it easier (to read) to code my SQL statements thus:

$countResult = db_query("SELECT count(*) AS msgCount FROM messages WHERE
 uid='$userID' AND fid='$fid' AND post_date<='$lastmonth'");

Finally, yes, echo the SQL statement so you know that all the variables are
being set correctly.

$sql = "SELECT count(*) AS msgCount FROM messages WHERE uid='$userID' AND
fid='$fid' AND post_date<='$lastmonth'";
echo "SQL statement = $sql ";
$countResult = db_query($sql);
$countRow = db_fetch_array($countResult);
echo "Result array = ";
print_r($countRow);

HTH
Graham

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



RE: [PHP] code not working...help?

2004-10-08 Thread Graham Cossey
[snip][snip]
>
> Secondly I find it easier (to read) to code my SQL statements thus:
>
> $countResult = db_query("SELECT count(*) AS msgCount FROM messages WHERE
>  uid='$userID' AND fid='$fid' AND post_date<='$lastmonth'");
>
> [snip]
> 
>
>  I find queries even easier to read when they are written like this:
>
> $countResult = db_query("SELECT count(*) AS msgCount
>  FROM messages
>  WHERE
> uid='$userID' AND
> fid='$fid' AND
> post_date<='$lastmonth'
>  ");
>

So do I, and I do actually format my queries like that in my code, I was
concentrating more on string evaluation by using " instead of lots of
concatenations with .

Graham

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



RE: [PHP] Sessions not destroyed

2004-10-08 Thread Graham Cossey
[snip]
> >
> > If you are right, then this is a severe design bug.
>
> Depends on your point of view. It is a sideeffect of loading current
> session (and thus accessing it) before the session gc is called.
>
> So the question is, should the session module give up on current session
> just because it should have been garbaged, even if the session file
> still exists?

Apologies if I'm way off here, but I'm relatively new to PHP.

Surely it should be down to settings in php.ini, not a point of view or the
probability of the garbage collection possibly having run when a new session
is started. Why can there not be a session_timeout value that is adhered to?
Would it not also save everyone from writing their own code to determine
whether or not they should be using the session that PHP is making
available?

If my site is accessed by few users and I have a session 'timeout' of
30minutes specified, if Bob leaves his PC at 10:00 I would expect that if he
returned at 10:40, and no-one else had accessed the system, his session
would have expired and he would need to re-authenticate to create a new
session.

Short of writing custom session handlers, the current arrangement seems
somewhat haphazard to me.

Those are my current thoughts anyway.

Graham

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



RE: [PHP] Nested foreach ?

2004-10-18 Thread Graham Cossey
How about this:

// Doing this makes the code below easier to read
$skills = $_SESSION['skills'];
$skys = $_SESSION['skys'];
$slus = $_SESSION['slus'];

// Set up the fixed part of teh query
$query = "INSERT INTO table (skill, sky, sku) VALUES (";

// Loop through each set of form elements
foreach($skills as $key => $skill)
{
   $query .= "'$skill','{$skys[$key]}','{$slus[$key]}',";
}
$query = rtrim($query, ','); // Remove any comma from end of $query
$query .= ')';  // Close VALUES (

echo $query;  // What do you get?

// RUN QUERY HERE

Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 18 October 2004 08:24
> To: John Holmes; [EMAIL PROTECTED]
> Subject: Re: [PHP] Nested foreach ?
> 
> 
> Not working.
> 
> > foreach($_SESSION['skills'] as $key => $skill)
> > {
> >$query = "INSERT INTO table (skill, sky, sku)
> > VALUES ('$skill', 
> >
> {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> >//run query
> > }
> The foreach is generating an invalid argument. 
> I'm just going to show again what I have set up:
> 
> There are five for each of these:
> 
> 
> 
> 
> Then I post the session variables as:
> $_SESSION['skills'] = $_POST['skill'];
> $_SESSION['skys'] = $_POST['sky']; 
> $_SESSION['slus'] = $_POST['slu'];
> 
> It looks like the loop above is using the $skills
> array to advance through the other arrays ? 
> 
> Stuart
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



RE: [PHP] Nested foreach ?

2004-10-18 Thread Graham Cossey
These lines store the FORM's posted values (arrays)
into your SESSION:
$_SESSION['skills'] = $_POST['skill']; 
$_SESSION['skys'] = $_POST['sky']; 
$_SESSION['slus'] = $_POST['slu'];

These lines get your SESSION variables (arrays) and
put them into 'local' script array variables.
If you are doing these then you MUST have done the above
in the previous script.
$skills = $_SESSION['skills'];
$skys = $_SESSION['skys'];
$slus = $_SESSION['slus'];

If you are doing it all in one script just use:
$skills = $_POST['skills'];
$skys = $_POST['skys'];
$slus = $_POST['slus'];

Make sense?
If not, may I suggest you do a bit of reading on
PHP and form processing before proceeding. 
I have found the PHP manual extremely useful. 
With it (and some googling) I have gone from zero 
PHP knowledge 10 months ago to being able to 
develop and maintain an entire PHP/MySQL based
web application subscribed to by several clients. 


HTH
Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 18 October 2004 09:37
> To: Graham Cossey; [EMAIL PROTECTED]
> Subject: RE: [PHP] Nested foreach ?
> 
> 
> Wish I had better news.
> 
> Warning: Invalid argument supplied for foreach() in
> /home/lurkkcom/public_html/TestMultiTrans2.php on line
> 90
> INSERT INTO LurkProfiles_Skicerts (ProfileID,
> SkilCerts, NumYear, Lused) VALUES ()
> 
> 
> line 90: foreach($skills as $key => $skill)
> 
> To confirm : 
> 
> I changed to this:
> > // Doing this makes the code below easier to read
> > $skills = $_SESSION['skills'];
> > $skys = $_SESSION['skys'];
> > $slus = $_SESSION['slus'];
> 
> From this : 
> I changed the $_SESSION['skills'] = $_POST['skill']; 
> $_SESSION['skys'] = $_POST['sky']; 
> $_SESSION['slus'] = $_POST['slu'];
> 

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



RE: [PHP] Floating values

2004-10-18 Thread Graham Cossey
How about this?

http://uk2.php.net/manual/en/function.number-format.php

HTH
Graham

> -Original Message-
> From: Nunners [mailto:[EMAIL PROTECTED]
> Sent: 18 October 2004 12:03
> To: [EMAIL PROTECTED]
> Subject: [PHP] Floating values
> 
> 
> Simple question. 
> 
>  
> 
> I'm writing an accounting package, and have setup the MySQL database with
> decimal(6,2) types for the amount of transactions etc.
> 
>  
> 
> Is there a way I can reproduce this in the php output?
> 
>  
> 
> i.e. the number sorted is 8.70 and when you output the value it 
> comes out as
> 8.7
> 
>  
> 
> The question is how do I add the .00?
> 
>  
> 
> Cheers
> 
> Nunners
> 
> 

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



RE: [PHP] dirty words

2004-10-18 Thread Graham Cossey
Skippy does have a point.

If you still receive spam emails you'll know what he means. I must have seen
20 different ways of spelling viagra, using various accented characters etc:
viagra, viagra, viiagra etc etc

As for the legit words, there is the tale of Scunthorpe town council having
ALL its email blocked by filtering. (Scunthorpe is a UK town BTW).

But then again I could be talking total b0llocks, [EMAIL PROTECTED] and shit. (Sorry 
for
any offense caused, but you see the problem)

Graham

> -Original Message-
> From: Skippy [mailto:[EMAIL PROTECTED]
> Sent: 18 October 2004 18:13
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] dirty words
>
>
> On Sat, 16 Oct 2004 07:41:11 -0700 (PDT) Mag <[EMAIL PROTECTED]> wrote:
> > I am useing file_get_contents on a remote page then
> > using stristr() to make sure there are no "bad words"
> > and its a family site.
>
> May I point out this is a lost battle from the start? If someone really
> wants to enter "bad words" they will, by masking them in various ways;
> humans will interpret the bad words correctly in far more cases than you
> can filter with software. Additionally, you will end up filtering parts of
> legit words that look like bad words.
>
> --
> Skippy - Romanian Web Developers - http://ROWD.ORG
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



[PHP] RE: [PHP-DB] Question: Putting separate form elements into an array

2004-10-17 Thread Graham Cossey
Stuart, now I'm confused.

You seem to be posting slightly different versions of problems relating to
the same script(s) on 2 lists.

What is the current situation? Iterating through the 3 arrays or inserting
into MySQL?

Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 17 October 2004 16:14
> To: Stuart Felenstein; Graham Cossey; [EMAIL PROTECTED]
> Subject: RE: [PHP-DB] Question: Putting separate form elements into an
> array
>
>
> Changed my direction somewhat but keep getting a parse
> error and although I know where it is , I can't seem
> to figure out what I need to do to make it syntax
> correct:
>
[snip]

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



RE: [PHP] Help: Suggestions for multi page form validation

2004-10-19 Thread Graham Cossey
Personally I would do as you suggest in 1. I would think your users would
get rather annoyed if they had gone through several form pages to be told at
the end of an error in form page1.

So, page2 validates page1 etc. I would assume that page2 already does some
processing of page1 anyway, as I believe you are adding the form values to
the session. You may want to think along the lines of adding to a string
variable for each validation exception and then passing that back to page1
which will display the string variable if it contains anything. If you want
the originally entered data to also appear in the form fields you will also
have to pass that data back to page1 and display it.

//This is pseudo code ;)
$str='';
Check form_field1
If (error)
  $str .= 'Field1 in error';
Check form_field2
If (error)
  $str .= 'Field2 in error';
$str .= "";
If (any errors found) {
  $location = "page1.php?err=$str&fld1=$field1.";
  Header($location);}
else{
  // Store form values in session & continue
}

HTH
Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 19 October 2004 08:51
> To: [EMAIL PROTECTED]
> Subject: [PHP] Help: Suggestions for multi page form validation
>
>
> I have a multi-page form that ends in the last page as
> a transaction to mysql.  In the transaction there are
> a number of steps, i.e.
>
> query1 = Insert into "..
> run query1
> query2 = Insert into ".
> run query 2
> query3 = Insert into "..
> run query 3
>
> Then an if / else statement that checks if all queries
> were sucessful (commit) or else (rollback)
>
> I need to add server side validation
> So my thoughts are :
>
> 1- Do it on a page by page (form by form) basis,
> meaning user can't go past page1 if there are form
> error.  I'm just not sure in this case where the
> validation would go.  Since 1st page is set on submit
> to go to 2nd page. Would I put the validations on
> page/form2 and then it would print out errors
> directing back to form1 ?
>
> 2- Last page validation - waiting till the transaction
> page to do validation. Should I set this up as one
> block on top that checks all the submitted form
> values, or pepper throughout all the transactions ?
>
> Hope my question is clear and am open to  any
> suggestions or ideas.
>
> Thank you ,
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Help: Suggestions for multi page form validation

2004-10-19 Thread Graham Cossey
I do not do any javascript validation, and try to avoid it if at all
possible as you cannot guarantee that the client has JavaScript enabled,
much like relying on cookies.

If you are concerned about 'crafty hackers' you'll probably need to check
every form element. You probably also want to check somehow that page2.php
is actually being called from page1.php and not by any other means.

Others on the list are much better equipped to deal with these matters than
I, as I don't currently lock down my application to this degree.

If you have not already, get along to Chris Shiflett's site, it's got some
great info.

http://shiflett.org especially: http://shiflett.org/articles

HTH
Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 19 October 2004 10:26
> To: Graham Cossey; [EMAIL PROTECTED]
> Subject: RE: [PHP] Help: Suggestions for multi page form validation
>
>
> If it's okay I'll throw out two more questions then.
>
> 1-Probably a silly question, but is a "faux pas" if I
> don't do client side [javascript] validations ?
>
> 2a-  Textboxes - provided I'm not allowing special
> characters (only alphanumeric) does this alone protect
> me from things like "sql injections" ?
>
> 2b- Do selects (menus, dropdowns) need to be validated
> for string content.  aka, can crafty hackers turn
> these into a way to enter some funky data ?
>
> Thank you ,
> Stuart
>
>
> --- Graham Cossey <[EMAIL PROTECTED]> wrote:
>
> > Personally I would do as you suggest in 1. I would
> > think your users would
> > get rather annoyed if they had gone through several
> > form pages to be told at
> > the end of an error in form page1.
> >
> > So, page2 validates page1 etc. I would assume that
> > page2 already does some
> > processing of page1 anyway, as I believe you are
> > adding the for.
>

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



RE: [PHP] Validation problem with array.

2004-10-20 Thread Graham Cossey
Not sure I really know where you have the problem, but I am assuming you are
trying to construct the INSERT statement within your foreach loop.

If so, why use $_POST["skill[]"] when you have $skill which is that current
element being iterated?
Did you read the foreach doc?
http://uk2.php.net/manual/en/control-structures.foreach.php

HTH
Graham


> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 20 October 2004 13:35
> To: [EMAIL PROTECTED]
> Subject: [PHP] Validation problem with array.
>
>
> After some back and forth posts here I had finally
> thought my array issue was over, but!
>
> To review I have 30 form elements on a page
> 10 are skill[]
> 10 are sky[]
> 10 are slu[]
>
> I pass them as session variables
>
> $_SESSION['skills'] = $_POST['skill'];
> $_SESSION['skys'] = $_POST['sky'];
> $_SESSION['slus'] = $_POST['slu'];
>
> Then when everyting is passed into a database
> transaction:
>
> $skills = $_SESSION['skills'];
> $skys = $_SESSION['skys'];
> $slus = $_SESSION['slus'];
>
> foreach($_SESSION['skills'] as $key => $skill)
> {
> $query = "INSERT INTO Profiles_skills (ProfileID,
> SkilCerts, NumYear, Lused)
> VALUES ($LID, '$skill',
> {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> //$result = mysql_query($query);
>
> Here is the problem:
>
> Using
> (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"") .
> "",true,true,true,true,"",false,1);
>
> I can't seem to differentiate between the the elements
> because they are all labeled skill[]
> So basically validation isn't doing anything .
>
> I'm thinking of finding a better way to validate , or
> if i change the elements to skill[1], skill[2] , what
> would that do to my iteration loop ?
>
> Thank you,
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Validation problem with array.

2004-10-20 Thread Graham Cossey
Maybe you would like to post your validation code then.

I (we) do not know where the line:

(((isset($_POST["skill[]"]))?$_POST["skill[]"]:"")."",true,true,true,true,""
,false,1);

is being called.

Have you thought about using an iteration as you have when constructing the
INSERT statement?
Have you considered placing validation within the iteration you have when
constructing the INSERT statement?

If you do a print_r($skills) you will see that although in the form they are
named skill[] when passed to your script they will be skill[0], skill[1],
skill[2]...

Also, this line :

foreach($_SESSION['skills'] as $key => $skill)

could read

foreach($skills as $key => $skill)

as you have the line:

$skills = $_SESSION['skills'];

Same for skys and slus.

Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 20 October 2004 14:06
> To: Graham Cossey; [EMAIL PROTECTED]
> Subject: RE: [PHP] Validation problem with array.
>
>
> My problem is not related to the insert or iteration.
> It's related to the validaton of those elements:
> skill[]
> skill[]
> etc.
>
> Clearer ?
>
> Stuart
> --- Graham Cossey <[EMAIL PROTECTED]> wrote:
>
> > Not sure I really know where you have the problem,
> > but I am assuming you are
> > trying to construct the INSERT statement within your
> > foreach loop.
> >
> > If so, why use $_POST["skill[]"] when you have
> > $skill which is that current
> > element being iterated?
> > Did you read the foreach doc?
> >
> http://uk2.php.net/manual/en/control-structures.foreach.php
> >
> > HTH
> > Graham
> >
> >
> > > -Original Message-
> > > From: Stuart Felenstein
> > [mailto:[EMAIL PROTECTED]
> > > Sent: 20 October 2004 13:35
> > > To: [EMAIL PROTECTED]
> > > Subject: [PHP] Validation problem with array.
> > >
> > >
> > > After some back and forth posts here I had finally
> > > thought my array issue was over, but!
> > >
> > > To review I have 30 form elements on a page
> > > 10 are skill[]
> > > 10 are sky[]
> > > 10 are slu[]
> > >
> > > I pass them as session variables
> > >
> > > $_SESSION['skills'] = $_POST['skill'];
> > > $_SESSION['skys'] = $_POST['sky'];
> > > $_SESSION['slus'] = $_POST['slu'];
> > >
> > > Then when everyting is passed into a database
> > > transaction:
> > >
> > > $skills = $_SESSION['skills'];
> > > $skys = $_SESSION['skys'];
> > > $slus = $_SESSION['slus'];
> > >
> > > foreach($_SESSION['skills'] as $key => $skill)
> > > {
> > > $query = "INSERT INTO Profiles_skills (ProfileID,
> > > SkilCerts, NumYear, Lused)
> > > VALUES ($LID, '$skill',
> > >
> >
> {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
> > > //$result = mysql_query($query);
> > >
> > > Here is the problem:
> > >
> > > Using
> > > (((isset($_POST["skill[]"]))?$_POST["skill[]"]:"")
> > .
> > > "",true,true,true,true,"",false,1);
> > >
> > > I can't seem to differentiate between the the
> > elements
> > > because they are all labeled skill[]
> > > So basically validation isn't doing anything .
> > >
> > > I'm thinking of finding a better way to validate ,
> > or
> > > if i change the elements to skill[1], skill[2] ,
> > what
> > > would that do to my iteration loop ?
> > >
> > > Thank you,
> > > Stuart
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit:
> > http://www.php.net/unsub.php
> > >
> > >
> >
> >
> >
>
>

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



RE: [PHP] Validation problem with array.

2004-10-21 Thread Graham Cossey
See inline:

[snip]
> 
> Now the transcation script:
> 
> $skills = $_SESSION['skills'];
> $skys = $_SESSION['skys'];
> $slus = $_SESSION['slus'];
> 
> foreach($_SESSION['skills'] as $key => $skill)
  ^^^
 ($skills as $key => $skill)
> {
if ($skill != '') // Has this skill been entered?
{
  // You may also want to check for sky & slu entries

> $query = "INSERT INTO LurkProfiles_Skicerts
> (SkicertID, ProfileID, SkilCerts, NumYear, Lused) 
> VALUES (null, $LID, '$skill',
> {$_SESSION['skys'][$key]},{$_SESSION['slus'][$key]})";
   ^^^   ^^^
   $skys[$key]   $slus[$key]

> //$result = mysql_query($query);
> $res6 = run_query($query);
> echo $query;
  ^^^
  What does this output?

}// end if ($skill != '')

> }
> 
> I understand that in the insert statement I need not
> repeat $_SESSION.
> The rest though is fuzzy. 
> It was working, now I'm getting some really odd
> behaviour, in that, unless i fill in every field in
> the form, I get a mysql syntax error.


HTH 
Graham

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



RE: [PHP] Validation problem with array.

2004-10-21 Thread Graham Cossey
See inline:

[snip]
> 
> > > {
> > if ($skill != '') // Has this skill been
> > entered?
>
> I don't know if I care if it's been entered.  My main
> concern would be to make sure that if a $skill was
> entered, then a matching $skys and $slus
> should be:
> skills[0]-baker skys[0]-7 slus[0]-2002
>
> but wouldn't want
> skill[0]-baker skys[1]-7 slus[2]-2002
>

So, you want to avoid all of the following:
  skill[0] 'baker'  skys[0] '7'  slus[0] ''
  skill[1] 'baker'  skys[1] ''   slus[1] '2002'
  skill[2] ''   skys[2] '7'  slus[2] '2002'
  skill[3] ''   skys[3] ''   slus[3] ''

You'll need to amend the if within the foreach loop to check for these.

if ($skill != '' && $skys[$key] != '' && $slus[$key] != '')

> In other words I need to figure out how to check that
> each "line" is complete.  But~ right now, it is
> matching all the values/inputs correctly.  If someone
> just chose a slus, seems the database won't take it.

But is this due to the sql statement being rejected as opposed to being
caught by your validation?

>
> > {
> >   // You may also want to check for sky & slu
> > entries
>
> Not sure why I would want too:

You would want to because of the paragraph above about "My main concern..."

>
> > > //$result = mysql_query($query);
> > > $res6 = run_query($query);
> > > echo $query;
> >   ^^^
> >   What does this output?
>
> It outputs the insert and values string.
> And it seems to print the iteration:
>
> INSERT INTO LurkProfiles_Skicerts (SkicertID,
> ProfileID, SkilCerts, NumYear, Lused) VALUES (null,
> 39, 'a', 2,1)INSERT INTO LurkProfiles_Skicerts
> (SkicertID, ProfileID, SkilCerts, NumYear, Lused)
> VALUES (null, 39, 'b', 3,2)INSERT INTO
> LurkProfiles_Skicerts (SkicertID, ProfileID,
> SkilCerts, NumYear, Lused) VALUES (null, 39, 'c',
> 4,3)INSERT INTO LurkProfiles_Skicerts (SkicertID,
> ProfileID, SkilCerts, NumYear, Lused) VALUES (null,
> 39, 'd', 5,4)INSERT INTO LurkProfiles_Skicerts
> (SkicertID, ProfileID, SkilCerts, NumYear, Lused)
> VALUES (null, 39, 'e', 6,5)your insertions were
> successful

This is OK, it's just a formatting thing, try changing your echo to:

echo "Query $key = $query ";

This should give you:

Query 0 = INSERT INTO LurkProfiles_Skicerts (SkicertID,ProfileID, SkilCerts,
NumYear, Lused) VALUES (null,39, 'a', 2,1)
Query 1 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null,9, 'b', 3,2)
Query 2 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null, 9, 'c', 4,3)
Query 3 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null,39, 'd', 5,4)
Query 4 = INSERT INTO LurkProfiles_Skicerts (SkicertID, ProfileID,
SkilCerts, NumYear, Lused) VALUES (null, 9, 'e', 6,5)

>
> > }// end if ($skill != '')
>
> This probably makes sense to add , perhaps that is why
> if I don't use all the elements for input I get a
> syntax error.

Possibly...

Graham

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



RE: [PHP] Validation problem with array.

2004-10-21 Thread Graham Cossey

[snip]
> Right now I have this [right below]: If I want to
> check for skys and slus, I add another set of braces
> with if($sky != '' ...
> and below "end if ($sky != '')
> 
> 
> > foreach($skills as $key => $skill)
> {
> if ($skill != '' && $skys[$key] != '' &&
> $slus[$key] != '')
> {
>   
> $query = "INSERT INTO LurkProfiles_Skicerts
> (SkicertID, ProfileID, SkilCerts, NumYear, Lused) 
> VALUES (null, $LID, '$skill',
> $skys[$key],$slus[$key])";
> $res6 = run_query($query);
> echo "Query $key = $query ";
>   } end if ($skill != '')
> 
> }

That looks pretty much like what you want except for:

} //end if ($skill != '')
^^
Comment, this is just to help identify what the brace is closing.

Graham

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



RE: [PHP] Strange Array Error

2004-10-21 Thread Graham Cossey
[snip]
> 
> Hi,
> 
> I have been trying for the past two hours to understand why I get 
> an error 
> with the following code:
> 
>   $test_array[] = array();
>  $i = 0;
>  while($i < 7){
>   $test_array[$i] += $i;
>   echo '$day_total[$i] = '.$day_total[$i].'';
>  }
> ?>
> 
> Fatal error: Unsupported operand types in 
> /usr/home/expensesystem/public_html/test.php on line 5
> 
> I am trying to create a loop where $i is added to array element $i, and 
> can't find any information relating to this on google or php.net...
> 
> Thanks for your advice. 

Try this:
';
  $i++;
 }
?>

PHP objected to the use of +=
You did NOT want to increment $i before doing the echo anyway, did you?

Graham

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



RE: [PHP] Strange Array Error

2004-10-21 Thread Graham Cossey
Oh @#*!
Thanks Greg, I always get that one wrong !

$test_array = array();

:)

> -Original Message-
> From: Graham Cossey [mailto:[EMAIL PROTECTED]
> Sent: 21 October 2004 14:48
> To: Shaun; [EMAIL PROTECTED]
> Subject: RE: [PHP] Strange Array Error
>
>
> [snip]
> >
> > Hi,
> >
> > I have been trying for the past two hours to understand why I get
> > an error
> > with the following code:
> >
> >  >  $test_array[] = array();
> >  $i = 0;
> >  while($i < 7){
> >   $test_array[$i] += $i;
> >   echo '$day_total[$i] = '.$day_total[$i].'';
> >  }
> > ?>
> >
> > Fatal error: Unsupported operand types in
> > /usr/home/expensesystem/public_html/test.php on line 5
> >
> > I am trying to create a loop where $i is added to array element $i, and
> > can't find any information relating to this on google or php.net...
> >
> > Thanks for your advice.
>
> Try this:
>   $test_array[] = array();
>  $i = 0;
>  while($i < 7){
>   $test_array[$i] = $i;
>   echo '$test_array[$i] = '.$test_array[$i].'';
>   $i++;
>  }
> ?>
>
> PHP objected to the use of +=
> You did NOT want to increment $i before doing the echo anyway, did you?
>
> Graham
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Question: Validation on select boxes and lists.

2004-10-21 Thread Graham Cossey
[snip]
> Hope this is not off topic, and it might be a dumb
> question, but I'm new.
> For drop down menus, list boxes, selects etc, would
> validation be needed to check the string , say for
> special characters ? (as a security precaution)

I have read several posts/articles on this matter and although the actual
HTML form will only pass the values available, it is possible for a hacker
to compose an HTTP 'message' with data other than that provided by the HTML
form.

So, validation is advisable.

A site that I would highly recommend as it has enlightened me on several
topics is: www.shiflett.org

Graham

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



RE: [PHP] Question: Validation on select boxes and lists.

2004-10-21 Thread Graham Cossey
[snip]
>
> How would a hacker pass an HTTP message ?
> That is interesting.

read the off-list posted message from [EMAIL PROTECTED]

(reproduced below for the benefit of other list members)

Graham
--

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: 21 October 2004 23:07
To: Graham Cossey; Stuart Felenstein
Subject: RE: [PHP] Question: Validation on select boxes and lists.


 you have to remember that the user isn't really "filling in a form on
your site", rather they are "retrieving a page from your site,
storing it on their machine (most times temporarily in their browser)
and then sending it back to your site". if you think of it in the
latter manner you'll realized that while they have it on their
machine, the user can save and edit the form to meet their desires
before sending it back.

as such, *all* data input, (whether from a text area, pulldown,
checkbox, or radio button) should be validated on your side.

an amusing thing to do is to find a site/page that puts prices as the
values on say a pulldown or checkbox. edit these values to something
more to your liking and then submit the form. you could end up being
charged your "price of choice", rather than what the site thought
they were going to charge you.

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



RE: [PHP] Question: Simpler loop

2004-10-22 Thread Graham Cossey
Slightly simpler:

foreach(...)
{
  $count = 0;
  if ($skill != '')
$count++;
  if ($skys[$key] != '')
$count++;
  if ($slus[$key] != '')
$count++;
  if $count < 3
echo 'Invalid';
  else
echo 'Valid';
}

Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 22 October 2004 15:34
> To: [EMAIL PROTECTED]
> Subject: [PHP] Question: Simpler loop 
> 
> 
> I have rows of input fields
> Each row contains 3 fields.  The user must fill out
> the entire row (all 3 fields) for things to work
> right. 
> 
> I want to generate an error in case they have only
> filled in 1 or 2 of the boxes.
> 
> Thinking I might use something like this:
> 
> foreach($skills as $key => $skill)
> 
> {
> if ($skill != '' && $skys[$key] = '' &&
> $slus[$key] = '')
> {
> 
>   }else if{
> if ($skill = '' && $skys[$key] != '' &&
> $slus[$key] = '')
> 
>   }else{
> if ($skill = '' && $skys[$key] = '' && $slus[$key]
> != '')
> 
> . above only takes into account that 1 of that 3
> has been filled in.  I would need another set to take
> into account if 2 of the 3 have been filled in.
> 
> Is there a simpler way / shorter way to check
> conditions to do this ?
> 
> Stuart
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



RE: [PHP] Question: Simpler loop

2004-10-22 Thread Graham Cossey
Yep, Mike's solution is simpler.

It's getting late on Friday and the brain is starting to slow down.
(That's my excuse anyway...)

[snip]
> > 
> > Is there a simpler way / shorter way to check
> > conditions to do this ?
> 
> So, the entry is valid only if all three are non-blank?
> 
> In which case:
> 
>if ($skill!='' && $skys[$key]!='' && $slus[$key] !='')
>{
>   // row is valid -- do stuff
>}
>else
>{
>   // entry has at least one value blank -- issue error
>}
> 
> If you prefer to have the error path come first, simply apply deMorgan's
> laws to the Boolean expression, to get:
> 
>if ($skills=='' || $skys[$key]=='' || $slus[$key]=='')
>{
>   // entry has at least one value blank -- issue error
>}
>else
>{
>   // row is valid -- do stuff
>}
> 
> Cheers!
> 
> Mike
> 
[snip]

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



RE: [PHP] Redirect then error message to user

2004-10-22 Thread Graham Cossey
I think what Brent is suggesting is a single script that will handle the
display and processing of all 5 form 'pages'. The code below is just to give
an idea of how I think the 'flow' could go, don't go copying the code and
expect anything (positive) to happen !!


if(!$_POST['step'] || $_POST['step']=='0')
{
  // Display form 1 or call appropriate function/method
  if ($_SESSION['errmsg'])
echo $errmsg;

  

}
if($_POST['step']=='1')
{
  // Validate form 1 or call appropriate function/method
  if (error found) {
$errmsg = "";
$errmsg .= "  Field One is required ";
// etc etc
$_SESSION['errmsg'] = $errmsg;
  }
  // Not sure about the following line ??
  Header("Location: http://mysite.com/path/to/myself?step=2";);
}

if ($_POST['step']=='2')
{
  ... etc...


Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 22 October 2004 21:55
> To: Brent Baisley
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Redirect then error message to user
>
>
> Brent - Thank you I will try that method.
>
> Can you elaborate more on below. I take it to mean you
> have one page/script that your pages are going to do
> all the checks.
>
> This form is 5 pages long.  So I chose session
> variables just to keep it neat and "maybe", more
> secure.
>
> Stuart
> --- Brent Baisley <[EMAIL PROTECTED]> wrote:
>
> > I design all my pages so that "one" file handles
> > display, edit,
> > validation and save. Then I don't have to worry
> > about going back and
> > forth between pages, doing redirects or retaining
> > data through session
> > variables. Most important, the user doesn't lose
> > what they already
> > entered just because they missed a field.
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



Re: [PHP] Re: PHP programming strategy; lots of little include files, or a few big ones?

2010-01-08 Thread Graham Cossey
On Fri, Jan 8, 2010 at 3:48 AM, Robert Cummings  wrote:

>
> They almost always make your shit run faster.

I love your final statement Robert!
A reply of good grammar and vocabulary summarised most succinctly.


-- 
Graham

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



Re: [PHP] PHP file as homepage?

2005-03-15 Thread Graham Cossey
On Tue, 15 Mar 2005 11:10:30 -0500, Phil Neeb <[EMAIL PROTECTED]> wrote:
> I've noticed that PHP.net uses index.php as its homepage and well, I'm
> curious as to how that's possible.  Is it the server setup that allows
> them to load a php file as their homepage or something else?

Yes, it's normally the configuration of the web server. Apache, for
example, can be given a list of possible index pages such as :

DirectoryIndex index.htm index.html index.php

No doubt there are various other more complex methods as well.

-- 
Graham

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



Re: [PHP] Adding Fonts to JpGraph

2005-04-11 Thread Graham Cossey
On Apr 6, 2005 2:53 AM, Richard Lynch <[EMAIL PROTECTED]> wrote:
> On Mon, April 4, 2005 12:39 pm, Stephen Johnson said:
> > I am using JPGraph for a project that I am working on right now and I have
> > hit a small snag -
> >
> > My client wants to have the user be able to select from a list of about 20
> > ­30 standard fonts.  JPGraph only has about six built into it and the
> > support in the docs is not very helpful since it wants you to register it
> > to
> > get font support.  I am willing to do that, BUT, their website says they
> > are
> > no longer accepting support clients.
> >
> > So ‹ anyone out there have any advice our a tutorial that I can look at
> > for
> > some assistance ?

If it's true type fonts you're after there is a TTF_DIR setting in
jpgraph.php that point s to a directory containing any fonts you may
wish to use.

If you're on Linux have you googled for msttcorefonts, I think they're
on sourceforge?

HTH

-- 
Graham

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



Re: [PHP] Pragmatically changing a "Record Number"

2007-09-02 Thread Graham Cossey
If I've understood correctly your record/Id number relates to a message/post.

Let's say the PHP list has message numbers and this post is number
456. If I have a list of posts and sort them by user and provide the
user with a numbered list of posts from 1 to N in user sequence
there's VERY little chance that if I was to quote message number 47
(or whatever number it had been assigned in the sorted list) that
someone else would be able to reliably find the post using number 47,
but give then number 456 that is always linked to this post and this
post only then they'll always be able to find it, until it's deleted
;-)

Help?

Graham

On 9/2/07, Bill Guion <[EMAIL PROTECTED]> wrote:
> I don't think you really want to do that, either. You don't need a
> field in the database to accomplish what you are trying to do.
> Execute your query to select the records you want, sorting them into
> what ever order you want. When you display the records on your web
> page, add a PHP variable, say $row_number, which starts at 1, and
> increments by one for each row you display.
>
>   -= Bill =-
>
> At 3:09 PM -0400 8/29/07, Jason Pruim wrote:
>
> >And what I'm looking for is away to take rows 4 and 5 and move them
> >to rows 2 and 3 so the next record inserted would be row 4 :)
> >
> >>
> >>it does not go back and fill in the holes/gaps
> >>
> >>--
> >>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
> >>
> >
> >--
> >
> >Jason Pruim
> >Raoset Inc.
> >Technology Manager
> >MQC Specialist
> >3251 132nd ave
> >Holland, MI, 49424
> >www.raoset.com
> >[EMAIL PROTECTED]
>
>
> --
>
> Reality is the leading cause of stress, for those in touch with it.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Graham

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



Re: [PHP] Pragmatically changing a "Record Number"

2007-09-04 Thread Graham Cossey
Surely we're into basic database design. If you have an auto_increment
record key that needs changing from time to time then you've designed
the database incorrectly. Use a 'normal' key field such as
"Product_Id" and have your application generate the number.

Simple.

No?

On 9/4/07, tedd <[EMAIL PROTECTED]> wrote:
> At 6:18 PM -0400 9/3/07, brian wrote:
> >>Renumbering anything is pretty quick these days. To me, things that
> >>are "horribly inefficient" are also slow. So, I don't agree. If I
> >>remember correctly, I can even renumber a 100K item dB
> >>auto_increment index in less than one second -- but I wouldn't
> >>recommend it. I think that's pretty quick.
> >>
> >
> >It may be just fine in your case, but from a DB design standpoint it
> >most certainly is not efficient. Why re-order the entire table for
> >something like this? Altering an entire table because one row has
> >been deleted suggests to me that the schema needs to revisited.
>
>  From a technical standpoint, I agree with you. It's far better to let
> the records fall as they may according to the sort, whatever that may
> be.
>
> However, we (or at least I) often work with clients who don't see
> that. Instead they see records that they place into their database
> that hold information about their widgets and they like to see a
> record number associated with their widget. And, when they add a new
> widget record, they want to see that count increased and when they
> delete a widget record they want to see it gone and a gap, where they
> can renumber at their will.
>
> This makes no difference to me, I can do anything they want. But the
> point is that customers usually not don't know the finer points to
> what "should" or "should-not" be done, but rather they way they think
> things should be done. Understand? After all, it's their business --
> not ours.
>
> Our charge is to provide them with as much correct information as
> they can absorb and then do just what they want beyond that.
>
> Believe me, arguing with clients about how things should be done has
> it's limits. At some point, you just have to listen and do what they
> want in spite of what is optimal.
>
>
> >>Presentation is made during presentation, obviously, by using css
> >>and proper html and pulling data from your dB to assemble
> >>presentation. If the client wants Roman notation, it's a simple
> >>process to provide that.
> >
> >So now you want to rewrite your triggers to use Roman notation? I
> >wasn't aware that MySQL had such terrific Roman numeral math support.
>
> I rewrite stuff all the time to make the presentation exactly what
> the client expects. Roman numeral math support is really a no brainer
> to create -- that's comp 101 sruff.
>
> >>There is no "separating data and presentation" in this issue.
> >
> >I don't buy that. Doing it that way is attaching unnecessary
> >presentation-specific baggage to your data. The column is only as
> >relational as it was the last time it changed. That is, it was
> >pointing to a completely different record then. This isn't a
> >"separating data and presentation" issue?
>
> We are disagreeing if having a record number is necessary or not?
>  From my perspective, if it is left up to me -- it's unnecessary and
> my dB's don't have any. However, if the client wants it, then the
> client get's it and it then becomes necessary.
>
> As for relational, I'm not talking about a relational dB field, but
> rather a simple record that the client can imagine. Relational fields
> are used to present the record, they certainly would not be involved
> in any renumbering schemes -- don't you see what I am talking about?
>
> Cheers,
>
> tedd
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Graham

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



Re: [PHP] Creating a File in Memory

2007-09-07 Thread Graham Cossey
Can't help with your main problem, however I find it easier to write
the likes of :

$kml_string = $kml_string . "";

as:

 $kml_string .= "";

;-)

On 9/7/07, John Schattel <[EMAIL PROTECTED]> wrote:
> Hello All,
>
> I am trying to zip data in a PHP program using the following code.  The
> resulting file (ndfdViaPipe.kmz) is zip'ed but the data in the archive
> lacks a file name.  So when a program like Google Earth tries to process
> the file, it fails.  When I bring ndfdViaPipe.kmz into WinZip, the file
> has no name but can otherwise be extracted just fine.  Once extracted,
> Google Earth can process the file.  Does anyone know how I might add the
> "file name" information to the ndfdViaPipe.kmz?  The reason I'm trying
> to use pipes is to avoid creating a file with the dynamically created
> data in $kml_string.  The plan is to send $kmz_content out in a SOAP
> service message with the payload as base64 encoded file.  If there is a
> better way to accomplish this I am certainly open to suggestions.
>
> In advance, thanks for any help you care to offer.
>
> John
>
> 
> $kml_string = "";
> $kml_string = $kml_string . " xmlns=\"http://earth.google.com/kml/2.1\";>";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "   National Digital Forecast Database
> Data";
> $kml_string = $kml_string . "   1";
> $kml_string = $kml_string . "   name=\"NdfdData\">";
> $kml_string = $kml_string . " name=\"UOM\">";
> $kml_string = $kml_string . " name=\"ValidTime\">";
> $kml_string = $kml_string . " name=\"MaxTemp\">";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "Maximum Temperature";
> $kml_string = $kml_string . "90F valid at
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "  -77.37,37.82";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "F";
> $kml_string = $kml_string . "
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "95";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "Maximum Temperature";
> $kml_string = $kml_string . "89F valid at
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "  -77.5,38.00";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "F";
> $kml_string = $kml_string . "
> 2007-06-26T00:00:00-04:00";
> $kml_string = $kml_string . "89";
> $kml_string = $kml_string . "  ";
> $kml_string = $kml_string . "";
> $kml_string = $kml_string . "";
>
> $descriptorAssignments = array(
>0 => array("pipe", "r"),  // stdin is a pipe that the child will read
> from
>1 => array("pipe", "w"),  // stdout is a pipe that the child will
> write to
>2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file
> to write to
> );
>
> $kmz_process = proc_open('zip',$descriptorAssignments,$pipes);
>
> if (is_resource($kmz_process))
> {
>fwrite($pipes[0],$kml_string);
>fclose($pipes[0]);
>
>$kmz_content = stream_get_contents($pipes[1]);
>
>fclose($pipes[1]);
>
>$return_value = proc_close($kmz_process);
>
>//  Only outputting data to ensure it is a properly formatted zip file
>//  Normally, a SOAP service will sent the data as a base64 encoded
> payload
>$output_file = fopen('ndfdViaPipe.kmz','w');
>fwrite($output_file,$kmz_content);
>fclose($output_file);
> }
>
> ?>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Graham

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



[PHP] Converting tab delimited file to CSV

2008-02-18 Thread Graham Cossey
I was wondering if someone could offer some advice please.

I'm being sent data in tab delimited files which I'm trying to split
into smaller files and convert to comma delimited using PHP.

Now, I can replace the tabs with commas and opening the resulting
files in a basic text editor all looks fine. However when I open the
files in M$ Excel they're still being treated as tab delimited and all
values are being shoved into a single column.

What can I do in the PHP code to specifically make the file CSV and be
treated as such by M$ Excel?

I'm currently just using fopen for old and new files and fwrite.

-- 
Graham

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



Re: [PHP] Converting tab delimited file to CSV

2008-02-18 Thread Graham Cossey
On Feb 18, 2008 1:58 PM, Edward Kay <[EMAIL PROTECTED]> wrote:
>
> > Now, I can replace the tabs with commas and opening the resulting
> > files in a basic text editor all looks fine.
>
> When you do this, ensure you escape any commas that may exist in the data.
>
> IIRC, Excel handles this be enclosing the whole field in "double quotes".
> Can remember how it handles escaping these though...
>
> Edward
>
>

I know I can Open in Excel and then go through an "import" process
specifying the delimiter and string enclosure etc, however the files I
used to get were "true" CSV files and opened fine, I'm wondering if
there's some kind a file header or the like that specifies the kind of
data contained in the file.

I don't have an issue with commas within the data, but thanks for highlighting.

Probably just excel trying to be "helpful" again and totally scr3wing
things up :-/


-- 
Graham

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



Re: [PHP] Converting tab delimited file to CSV

2008-02-18 Thread Graham Cossey
On Feb 18, 2008 5:23 PM, Andrew Ballard <[EMAIL PROTECTED]> wrote:
>
> On Feb 18, 2008 12:02 PM, Edward Kay <[EMAIL PROTECTED]> wrote:
>
> >
> > > On Mon, February 18, 2008 10:36 am, Jay Blanchard wrote:
> > > > [snip]
> > > > That's funny... MS defaults to tabs for a file whose extension is .csv
> > > > which is an acronym for (C)omma (S)eparated (V)alues.
> > > > [/snip]
> > > >
> > > > Welcome to Microsoftwhere do we want you to go today?
> > >
> > > I think it defaults to whatever you last used, not to a specific choice.
> > >
> >
> > That would seem to be a possibility. I can quite happliy double-click a
> > .csv
> > file and have it open correctly in Excel.
> >
> >
> Yes. And Excel seems to prefer .txt for tab delimited. However, .txt is
> usually opened by Notepad by default, so you have to right-click and tell it
> to Open With... Excel. When I do this, it reads it as columnar data rather
> than a single column.
>
> Andrew
>

I need to spend some time looking at *exactly* what is happening in
various scenarios from the sound of things.

My data source used to supply comma separated files which open just
fine in Excel (and still do) but they have recently changed to tab
delimited. These open fine in Excel but if you go to save the file it
auto-selects .txt !! I'm currently opening the tab delimited files in
Excel and doing a Save As to save as CSV. Excel then handles the file
OK and my app likes it when imported (using fgetcsv with , delimiter).
As I type I'm thinking I should make my import script a bit more
"intelligent" and check for ',' or '\t' in the incoming file and
proceed accordingly... My biggest gripe with tab delimited files is
that they are quite a bit bigger than comma delimited files so I may
have to split the large files I receive into smaller 'chunks' to allow
them to be uploaded.

One thing I have noticed is that the files I create in my PHP script
(The script breaks a large file into smaller files of 25,000
records/rows each.) when opened in Excel (by double-clicking the file
in Windows Explorer) came up with an unrecognised file format message
for all files except the first. If you ignore this message the tab
delimited files open OK but the comma separated ones do not. The
"except the first" made me think that there may be something "hidden"
at the beginning of the file to say what type of data follows.

I can probably code around the problem but I'd rather not have to but
from the sound of things I'd need to get M$ to change

-- 
Graham

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



Re: [PHP] Converting tab delimited file to CSV

2008-02-18 Thread Graham Cossey
On Feb 18, 2008 6:45 PM, Andrew Ballard <[EMAIL PROTECTED]> wrote:
> On Feb 18, 2008 1:39 PM, Robert Cummings <[EMAIL PROTECTED]> wrote:
>
> >
> > On Mon, 2008-02-18 at 13:24 -0500, Andrew Ballard wrote:
> > > On Feb 18, 2008 1:08 PM, Graham Cossey <[EMAIL PROTECTED]> wrote:
> > >
> > > > My biggest gripe with tab delimited files is
> > > > that they are quite a bit bigger than comma delimited files so I may
> > > > have to split the large files I receive into smaller 'chunks' to allow
> > > > them to be uploaded.
> > > >
> > > >
> > > Why would tab-delimited files be larger than CSV? A tab character takes
> > up
> > > just as much space as a comma as far as document size is concerned. Am I
> > > missing something?
> >
> > He's probably confusing tab delimited with fixed width columns.
> >
> > Cheers,
> > Rob.
> >
>
> Ah, yes. That would also explain why Excel would open it as a single column
> by default if he didn't use the text import wizard.
>
> FWIW - If you do open a text file like this, there is a menu item to convert
> text to columnar data once the sheet is already open so you don't have to
> close the document and reopen it.
>
> Andrew
>

Nope not fixed width, definitely tab delimited (longer fields
'overlap' ones above and below when viewed in a text editor), as for
the size difference I don't know why but when I open into Excel and
save as CSV the files are smaller.

I just opened a 50.2KB tab delimited file into Excel saved it as CSV
and this new file is 25KB!!

Maybe I really am finally going mad.


-- 
Graham

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



Re: [PHP] Converting tab delimited file to CSV

2008-02-20 Thread Graham Cossey
On Feb 20, 2008 3:05 AM, Richard Lynch <[EMAIL PROTECTED]> wrote:
> On Mon, February 18, 2008 12:08 pm, Graham Cossey wrote:
> > proceed accordingly... My biggest gripe with tab delimited files is
> > that they are quite a bit bigger than comma delimited files so I may
> > have to split the large files I receive into smaller 'chunks' to allow
> > them to be uploaded.
>
> This is not making sense...
>
> A tab-delimited file wil have a TAB character "\t" instead of comma ","
>
> A tab WITHIN the data then needs escaping as "\t" or somesuch.
>
> But commas to not need escaping with quotes.
>
> And quotes don't need escaping with double-quotes.
>
> So tab-delimited should be a TINY bit smaller or the same size.
>
> Perhaps your users are just uploading more data.
>
> > One thing I have noticed is that the files I create in my PHP script
> > (The script breaks a large file into smaller files of 25,000
> > records/rows each.) when opened in Excel (by double-clicking the file
> > in Windows Explorer) came up with an unrecognised file format message
> > for all files except the first. If you ignore this message the tab
> > delimited files open OK but the comma separated ones do not. The
> > "except the first" made me think that there may be something "hidden"
> > at the beginning of the file to say what type of data follows.
>
> Some CSV files include a "header" line with the names of the fields in
> the first line.
>
> This is less common in tab-delimited, but not unheard of.
>

If it's any help the data I'm getting comes out of a third party
Cognos environment.

The data opened into Textpad looks like this :

Column One  Column Two  Column ThreeColumn Four Column Five 
Column
Six Column Seven
ABCDE   XX99DCS HORSE   1   200602
ABFED   XX99DCS HORSE   1   200602
JHGNF   XX99DCS HORSE   1   200602
HNDGE   XX99DCS HORSE   1   200602

Tab delimited no?

This file is 385KB. If I open it into Excel just by double-clicking on
it it opens fine. I then do File > Save As, change Unicode Text
(*.txt) to CSV (Comma Delimited)(*.csv) and give it a name then Save.
This new file is now 193KB and looks like this in Textpad :

Column One,Column Two,Column Three,Column Four,Column Five,Column
Six,Column Seven
ABCDE,XX99,DCS,HORSE,1,2006,2
ABFED,XX99,DCS,HORSE,1,2006,2
JHGNF,XX99,DCS,HORSE,1,2006,2
HNDGE,XX99,DCS,HORSE,1,2006,2

Double-clicking on this newly created file opens fine into Excel.

Back to my 'original' problem/question, if I '$f = fopen("$file",
"r")' and 'while ($data = fgets($f))' on the above first format and do
a $data = str_replace("\t",",",$data); the resulting file looks like
the second example above when opened into Textpad but will not open
into separate columns when opened with Excel.

I thought these were supposed to be simple, basic flat text formats
that were universally accepted, guess I'm just naive ;-)

I'm on the verge of simply giving in, and continuing to Open & Save As
the 100+ files I have to process in the next week or so :-(

-- 
Graham

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



Re: [PHP] Converting tab delimited file to CSV

2008-02-20 Thread Graham Cossey
I have a suspision the files I receive are in unicode which is causing
the problems.

How can I categorically determine if a file uses unicode?

Am I correct in believing PHP4 doesn't work with unicode files?


-- 
Graham

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



Re: [PHP] Converting tab delimited file to CSV

2008-02-20 Thread Graham Cossey
On Wed, Feb 20, 2008 at 9:50 PM, Chris <[EMAIL PROTECTED]> wrote:
>
>  > Back to my 'original' problem/question, if I '$f = fopen("$file",
>  > "r")' and 'while ($data = fgets($f))' on the above first format and do
>  > a $data = str_replace("\t",",",$data); the resulting file looks like
>  > the second example above when opened into Textpad but will not open
>  > into separate columns when opened with Excel.
>
>  Look up http://www.php.net/fgetcsv
>
>  and pass "\t" as the field separator.
>

I give up :-(

My script was using fgetcsv() with ',' as delimiter quite happily for
3 years before the 3rd party changed to Cognos. I have a problem with
file encoding and I really don't understand enough about that.

The files are (I'm told) sent to me in UTF-8 multibyte. My PHP scripts
can't read them correctly so I tried using utf8_encode which made
slight progress (individual fields recognised in delimited file) but
then comparing a utf8_encoded string with one obtained from MySQL then
causes problems, such that utf8_encoded "PRIVATE" does not equal MySQL
sourced "PRIVATE".

The amount of time I'm 'wasting' with this problem will soon exceed
that required to manually convert my 100+ files so it's going on teh
"to do" list and maybe I'll revisit it at a later date.

-- 
Graham

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



[PHP] Storing £ (pound sterling) sign and displaying in HTML email

2008-06-02 Thread Graham Cossey
Could someone please point me in the right direction here please?

I have a form textarea field (submitted using POST) that accepts free
text that will include the likes of '£' (pound sterling symbol) that
is written to a MySql database and later retrieved to output into an
HTML email.

I have been experimenting with htmlentities, htmlspecialchars and
addslashes but still have the problem whereby I get "&ACirc;"
preceeding the "£"

Could someone kindly suggest what I'm doing wrong and what function(s)
I should be looking into?

Thanks

-- 
Graham

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



Re: [PHP] Storing £ (pound sterling) sign and displaying in HTML email

2008-06-03 Thread Graham Cossey
On Tue, Jun 3, 2008 at 12:06 AM, James Dempster <[EMAIL PROTECTED]> wrote:
> This is most likely a character encoding issue. Check that the html encoding
> is set to the same type as what your storing it as in mysql.
>

Thanks James, it certainly was a character encoding issue. My dev box
didn't have the "default_charset" set in php.ini.

Cheers

Graham

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



RE: [PHP] Most efficient way of fetching 1,000 records from MySQL ?

2004-10-25 Thread Graham Cossey
I would certainly agree with Marek.

I recently changed a query from using 20 or so 'OR' conditions to use the
'IN' statement and it drastically improved the performance of the query.

Graham

> -Original Message-
> From: Marek Kilimajer [mailto:[EMAIL PROTECTED]
> Sent: 25 October 2004 11:37
> To: Ian Firla
> Cc: Steve McGill; [EMAIL PROTECTED]
> Subject: Re: [PHP] Most efficient way of fetching 1,000 records from
> MySQL ?
>
>
> Ian Firla wrote:
> > I think you'll find that your first approach is not only more correct,
> > it's the only manageable one.
>
> No, it will be very slow. The biggest overhead is in transfering data to
> and from sql server. It's always better to get the results in one
> sql query.
>
> Use this aproach:
>
> $users =
> sql('select * from users where userID IN ('. implode(', ',$users) .')');
>
> >
[snip]

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



RE: [PHP] Substr

2004-10-25 Thread Graham Cossey
What about using explode()?

$array = explode('_', 'pid_1_date_2004_10_25');
$pid = $array[1];
$yr = $array[3];
$mn = $array[4];
$dy = $array[5];

Graham

> -Original Message-
> From: Shaun [mailto:[EMAIL PROTECTED]
> Sent: 25 October 2004 14:00
> To: [EMAIL PROTECTED]
> Subject: [PHP] Substr
> 
> 
> Hi,
> 
> I have a string as follows: pid_1_date_2004_10_25
> 
> pid tells me the Project_ID and date tells me the date(!). I need 
> to extract 
> this information from the string so to get the date I need 
> everything after 
> 'date_' as follows:
> 
> substr(strstr($key, 'date_'), 4)
> 
> However, to get the Project ID I need to extract everything after 
> 'pid_' and 
> everything before 'date_'. Can someone help me with this please as PHP 
> doesn't seem to provide a function for extracting information 
> from a string 
> that occurs before the 'needle'? 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



RE: [PHP] Php files with .html extension?

2004-10-25 Thread Graham Cossey
Do not forget that if you do this ALL files with the .html extension will be
parsed by PHP whether they are PHP scripts or not which could be something
you need to consider from a performance perspective.

> -Original Message-
> From: Jay Blanchard [mailto:[EMAIL PROTECTED]
> Sent: 25 October 2004 14:59
> To: [EMAIL PROTECTED]
> Subject: RE: [PHP] Php files with .html extension?
>
>
> [snip]
> How can i do a php script with a html extensionsuch as
> http://www.blinds-wise.com/shop/p/blind/bid/1/venetian_blinds.html
> [/snip]
>
> You set it up in your httpd.conf You should have
>
> AddType application/x-httpd-php .php
>
> change it to
>
> AddType application/x-httpd-php .php .html
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Validation and session variables

2004-10-27 Thread Graham Cossey

> --- Chris Shiflett <[EMAIL PROTECTED]> wrote:
>
> > On each page, it might be good to add some debugging
> > information near the
> > top (where session_start() is):
> >
> >  > session_start();
> > echo '' . htmlentities(print_r($_COOKIE, true))
> > . '';
> > echo '' . htmlentities(print_r($_GET, true)) .
> > '';
> > echo session_id();
> > ...
> >
> I added this in , on top, right under session_start()
> as shown and get this error:
>
> Warning: Cannot modify header information - headers
> already sent by (output started at
> /home/lurkkcom/public_html/page1.php:6) in
> /home/lurkkcom/public_html/page1.php on line 54
>
> So it's clashing with the redirect:
>
> Header ('Location:
> http://www.mysite.com/page2.php?'.SID);
>

If your script outputs anything and then tries to redirect it WILL throw
that error. I believe if you want to do echos AND redirects you'll have to
use output buffering (see the manual: http://uk.php.net/outcontrol) and only
output the buffer if you do not redirect.

HTH
Graham

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



RE: [PHP] Validation and session variables

2004-10-28 Thread Graham Cossey

See in-line comments...

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 28 October 2004 08:54
> To: [EMAIL PROTECTED]
> Subject: [PHP] Validation and session variables
>
>
> I guess my resolution was a fluke.
> Recap: Adding validation kills my session variables
> Now I tested a few things, SID is consistent across
> pages, so a new sid and cookie are not being
> generated.
>
> Perhaps it's a bug, Im on PHP 4.3.8
>
> Here is the code again, perhaps something will jump
> out.
>
> 
> //Start the Session - begin Block
> @session_start();
> header("Cache-control: private");
[snip]
>
>   if ($WAFV_Errors != "")  {
> PostResult($WAFV_Redirect,$WAFV_Errors,"page1");
>   }

I think we need to know what happens when this function returns the user to
the script upon finding an error. Are all the form field values passed back?
Does it do anything at all with the session? Does it pass the SID?

> }
> ?>
> 
>
> if ($_SERVER["REQUEST_METHOD"] == "POST") {
> Header ('Location:
> http://www.xx.com/page2.php?'.SID);
>
> }
> ?>
>
> I just set an echo on page2 and page3 of the first
> session variable 'listingname'.  If I have the
> validation code in page1 , it doesn't even make it to
> page2

Are you saying that page1 always fails validation even if you enter all the
form fields correctly? If so then something is most likely wrong with the
validation code. Double check all the validation steps.


Graham

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



RE: [PHP] Help needed

2004-10-29 Thread Graham Cossey
>
> Hi
>   I developed a html form in which I have text box and combo
> box. Now my
> problem is I have to pass the values of this page to another
> page. How can i
> pass the values/variables to next page using href
> Kindly help me
> Thanks
> Suma

As you've posted to a PHP list I will assume your second page is a PHP page.

Set your FORM action to the second page ie:


  

Then within page2.php all the form fields will be available in the $_POST
array.

$field1 = $_POST['field1'];

You can also use GET in place of POST.

As for using href, well this isn't a form option as far as I am aware. If
you wish to subsequently pass variables using href:

Link Text

--OR--

Link Text";
?>

HTH
Graham

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



RE: [PHP] Code help on a multi select list

2004-10-29 Thread Graham Cossey
[snip]
> What is not to understand here...you are the one who said, "I want to do
> a server side trap". JavaScript would be the only way to do that.
[snip]

Jay, you may want to re-read what you typed as JavaScript, to the best of my
knowledge, is actually client side...

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



RE: [PHP] Session and validation

2004-10-30 Thread Graham Cossey
[snip]
>
> Here is the example:
>
> testarray (page1)
> //Start the session
> 
> //Check for the array on submit
> if ( empty( $_SESSION['l_industry'] ) ) {
> $_SESSION['l_industry']=array();
> }

$industry = $_POST['industry']; // ??

> //Check to make sure user didnt exceed 5 selections
> if (count($industry) > 5) {
> echo "you have selected too many industries";
>   exit;
> }

So, if this is the result of a form submission how are you getting the POST
variables?
How/where is $industry being set? I appears that you are assuming that
variables are 'maintained' within a script, they are not. You have to
remember that although you are running the same script it is not the same
'instance' of the script as a request/response has occurred. You MUST pass
and retrieve SESSION/POST/GET variables if you intend to use them in your
script.

$_SESSION['x'] = $_POST['x'];
$_SESSION['y'] = $_POST['y'];
etc etc...

> ?>
>  //Redirect to results page if user stayed in 5 option
> //range
> if ($_SERVER["REQUEST_METHOD"] == "POST") {
>  Header("Location:
> http://www...com/TAresults.php";);
> }

You do not appear to have set the SESSION variables before redirecting to
the next page.

> ?> Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> 
> 
> 
> Untitled Document
> 
> 
>
> 
>  cellpadding="2" cellspacing="2">
>   
>  action="">

Not sure about this... have you used action="$PHP_SELF" ?

>multiple="multiple" id="industry[]">
>  "Please Select"))) {echo "SELECTED";}
> ?>>Accounting
>  "Please Select"))) {echo "SELECTED";}
> ?>>Entertainment
>  "Please Select"))) {echo "SELECTED";}
> ?>>label
>  "Please Select"))) {echo "SELECTED";} ?>>Advertising
> 
>  "Please Select"))) {echo "SELECTED";} ?>>Customer
> Service
>  "Please Select"))) {echo "SELECTED";} ?>>Informatin
> Technology
>   
>value="Submit">
> 
>   
> 
> 
> 
>
> TAresults (page2):
>
> 
> if ( empty( $_SESSION['l_industry'] ) ) {
> $_SESSION['l_industry']=array();
> }
>
> if ( is_array( $_REQUEST['LurkerIndustry'] ) ) {
> $_SESSION['l_industry'] = array_unique(
> array_merge( $_SESSION['l_industry'],
>  $_REQUEST['LurkerIndustry'] )
> );
> }
> ?>
>  Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
> 
> Untitled Document
> 
>
> 
>  echo "The time is"."";
> echo $industry['0']."";
> echo $industry['1']."";
> echo $industry['2']."";
> echo $industry['3']."";
> echo $industry['4']."";
> echo $industry['5']."";
> echo $industry['6']."";
> echo $industry['7']."";
> echo $industry['8']."";
> echo $industry['9']."";
> echo $industry['10']."";
> echo $industry['11']."";

Sorry, I cannot see where $industry is being set. This may just need

$industry = $_SESSION['industry'];

>
> ?>
>  unset($l_industry);
> ?>
> 
> 
>
> The results here, are whether the check passes or not
> the variables never echo.
> If I set action on page 1 to TAresults.php , then they
> echo out fine.
>
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Security: Forms and displaying invalid data

2004-10-30 Thread Graham Cossey
> -Original Message-
> From: rjc [mailto:[EMAIL PROTECTED]
> Sent: 30 October 2004 23:35
> To: [EMAIL PROTECTED]
> Subject: [PHP] Security: Forms and displaying invalid data
>
>
> I have a form, that takes user input, and was wondering what are your
> thoughts of redisplaying user input back on the page after validation
> has failed.
>
[snip]
>
> Some options that I have come up with are:
> 1. Displaying previous data (or empty field) for example if user is
> editing something.
> 2. Just displaying exactly what they entered again on the screen.
> 3. Stripping out certain undesirable characters before displaying.

Personally I get really pd off when a form errors and does not return
any of my original entries, especially the larger ones. However, I
understand not re-displaying any 'sensitive' entries such as passwords,
security phrases etc. as they can aid the 'hackers'.

I would not strip out anything you won't accept as you could be giving clues
to the unscrupulous users as to what you will and won't accept.

Graham

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



RE: [PHP] validate international phone numbers

2004-11-02 Thread Graham Cossey
> -Original Message-
> From: Merlin [mailto:[EMAIL PROTECTED]
> Sent: 02 November 2004 10:49
> To: [EMAIL PROTECTED]
> Subject: [PHP] validate international phone numbers
>
>
> Hi,
>
> I am trying to validate international phone numbers before adding
> into a db.
> After a bit of research I came up with this regex:
>
> return (ereg('^[0-9]{1,3}\.[0-9]{1,6}\.[0-9]{1,8}$', $phone));
> However, this tightens the numbers to something like this:  409.711.933838
>
> Thats a problem, since some countries have complete other formats
> and some
> peopole place a + in front and a : instead of . or even just the number.
>
> Can anybody recommend a good regex to validate this? I am not to good at
> creating regex :-(
>
> Thanx for any help,
>
> Merlin

I know this is not exactly what you were asking, but, some time ago I did
some phone number validation/formatting but not in PHP.

IIRC I had a list of countries each of which had the relevant international
dialling code recorded.

The user of a form would select their country and enter a telephone number.
The international dialling code would be added if not present or validated
if '+' was present. Any leading 0 (after an int. code) would be removed.
Beyond that I think all you can do is validate that a certain number of
digits must have been entered as different people/countries use different
formatting chars: space , . - : etc etc

Another approach would be to request each component separately: int.code,
area code, local number.

This of course was all done within a function/class not a single statement.

HTH
Graham

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



[PHP] How to display a 'please wait' message whilst processing?

2004-11-04 Thread Graham Cossey

On a number of sites a message and/or graphic is displayed asking you to
wait or be patient whilst some processing is being performed to compose the
next page.

How are these done within PHP scripts?
Could output buffering be used for this purpose?
For example is it possible to do something like:



Should I be aware of anything that could trip me up on this?

Any help or pointers much appreciated.

Graham

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



RE: [PHP] using require or include?

2004-11-04 Thread Graham Cossey
Have you looked at the GLOBAL keyword?

http://uk.php.net/manual/en/language.variables.scope.php

> -Original Message-
> From: Reinhart Viane [mailto:[EMAIL PROTECTED]
> Sent: 04 November 2004 23:02
> To: [EMAIL PROTECTED]
> Subject: [PHP] using require or include?
> 
> 
> i have made a page (overall.php) in which several elements are defined:
> the connection with the database
> a function called session_checker to check if users are logged in
> and a last function(function getuserinfo()) that substracts values from
> the database based on the session variables of the logged in user
>  
> Now this last function sets 2 variables eg.
> $username=$row['user_name'];
> $userstatus=$row['user_status'];
> like this i do not have to recall this script on every page but i just
> can do the function at the top of every page
>  
> Now on every page of my site I require this file
> require(overall.php);
>  
> But it seems that i cannot get the variables outta this file.
> So i can not use $username or $userstatus on the pages.
>  
> I think it has something to do with require not passing the variables?
> Off course i can repeat the function script on the top of every page,
> but that's stupid i think.
> Can i use a include without any problems? Or is there a significant
> difference in use and security?
>  
> Thx in advance
> Reinhart
>  
>  
>   _  
> 
> Reinhart Viane 
>   [EMAIL PROTECTED] 
> Domos || D-Studio 
> Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 --
> fax +32 15 43 25 26 
> 
> 
> STRICTLY PERSONAL AND CONFIDENTIAL 
> This message may contain confidential and proprietary material for the
> sole use of the intended 
> recipient.  Any review or distribution by others is strictly prohibited.
> If you are not the intended 
> recipient please contact the sender and delete all copies.
> 
>  
> 

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



RE: [PHP] How to display a 'please wait' message whilst processing?

2004-11-05 Thread Graham Cossey

[snip]
> On a number of sites a message and/or graphic is displayed asking you to
> wait or be patient whilst some processing is being performed to
> compose the
> next page.
>
> How are these done within PHP scripts?
> Could output buffering be used for this purpose?
> For example is it possible to do something like:
>
[snip]

Does anyone have any ideas on this?

I do not really want to use META refresh as my understanding is that this
either reloads the same page (loop?) or a new page, which I don't see
working as I want the "Please wait.." to remain until the processing has
finished, not for a fixed period of time as the report may take 10 seconds
or one minute to complete running.

I want to avoid Javascript if at all possible, as I cannot guarantee it
being available on the client.

I have managed to use flush() to display some text, but after processing (or
sleep) I cannot 'overwrite' this only add to it.

Any help much appreciated...

Graham

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



RE: [PHP] using mysql in php problem

2004-11-09 Thread Graham Cossey


> -Original Message-
> From: Garth Hapgood - Strickland [mailto:[EMAIL PROTECTED]
> Sent: 09 November 2004 11:27
> To: [EMAIL PROTECTED]
> Subject: [PHP] using mysql in php problem
>
>
> I have created a registration page
> http://www26a.your-server.co.za/matchm/registration4.php
>
> On this page I have many fields, some of them pulling data out from my
> database. I have a javascript validation scipt thats checks on
> submission of
> the form to see if all required fields are filled in correctly.
> IF thats the case it should submit the form. Which it isnt doing!

No need to go any further at this stage then. If your Javascript is not
doing/allowing the form submission then you need to check that code, no
point looking at the PHP code if it's never being called.

[snip]

>
> I am not sure where exactly I am going so wrong, and it really is starting
> to drive me crazy!

Have you tried commenting out the Javascript validation and submitting the
form? If the form then gets processed (by the PHP code) post your problem to
a Javascript list/forum for advice.

Graham

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



RE: [PHP] help with fopen path

2004-11-09 Thread Graham Cossey


> -Original Message-
> From: Giles Roadnight [mailto:[EMAIL PROTECTED]
> Sent: 09 November 2004 13:07
> To: [EMAIL PROTECTED]
> Subject: [PHP] help with fopen path
>
>
> Hi All
>
> I'm developing a fusebox PHP app and have a class in a /classes
> directory that opens an xml file in a directory below the site root
> using this path: "../siteconfig.xml"
>
> All of the places I have used this class from so far have been in the
> site root. I am now starting some pages in a sub directory. When I use
> this class it says it can't open the file. I have tried
> "../../siteconfig.xml" instead but it doesn't work either.
>
> What's the best way to go about fixing this? I'm quite new to php and
> I'm not sure where the relative path is taken from - i.e. is it the
> index.php page or the class (obviously not) or my switch file or what?
>

Just a thought:
If your referencing a file within a PHP script that is included/required
within another script the path should be relative to the 'parent' script.

I am guessing that if you make reference above the site root (using ../../)
the site root will be assumed.

If you have access to the web server config try setting up an alias
such as /config which points to the directory containing your config xml
so that your scripts can reference "/config/siteconfig.xml" from any
directory.

HTH

Graham

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



RE: [PHP] silly question - setting .php as default extension (Apache)

2004-11-09 Thread Graham Cossey

> 
> Uuuuh... Where do I set the default server extension type to .php in the
> apache config? Right now the page will execute on my server, but 
> if there is
> an index.php the server won't automatically open it, but instead 
> browses the
> directory.
> 
> Thanks in advance,
> 
> -Brian

Look for DirectoryIndex in httpd.conf and add index.php

OR

On my Apache2/Linux installation I had to uncomment a line in :
/etc/httpd/conf.d/php.conf

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



RE: [PHP] Help: Database Search

2004-11-10 Thread Graham Cossey
What about doing something like:

$sql = "SELECT * FROM my_table WHERE col1=$var1";

if (isset($var2))
$sql .= " AND col2='$var2'"; 

HTH

Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 10 November 2004 14:37
> To: [EMAIL PROTECTED]
> Subject: [PHP] Help: Database Search 
> 
> 
> I am creating a database search form and results.
> Running into a problem though.
> I have two form elements, both that are fed by tables
> that have int values (1, 2 , etc)
> 
> my sql statement is such:
> 
> SELECT vendorjobs.PostStart, vendorjobs.JobTitle,
> vendorjobs.Industry, vendorjobs.VendorID,
> vendorjobs.LocationCity, vendorjobs.TaxTerm FROM
> vendorjobs WHERE vendorjobs.Industry = '$Ind' AND
> Date_Sub(Curdate(), interval '$Days' day) <= PostStart
> "
> 
> But if the user decides to only use one of the
> elements, then I don't want the query to return
> nothing because of the "And" in the where clause so I
> have these 2 statements that set a default value
> (shown here as 0 in the event one of the two elements
> aren't selected:  (Having no luck as the form still
> only works correctly if I've set both elements)
> 
> $Ind = "0";
> if (isset($_POST['Ind'])) {
>   $Ind = (get_magic_quotes_gpc()) ? $_POST['Ind'] :
> addslashes($_POST['Ind']);
> }
> $Days = "0";
> if (isset($_POST['Days'])) {
>   $Days = (get_magic_quotes_gpc()) ? $_POST['Days'] :
> addslashes($_POST['Days']);
> 
> Thank you ,
> Stuart
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



RE: [PHP] Looking for pointers to mysql functions

2004-11-11 Thread Graham Cossey


> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 11 November 2004 11:32
> To: [EMAIL PROTECTED]
> Subject: [PHP] Looking for pointers to mysql functions
> 
> 
> I'm building a search function and I think most of the
> search part is solid. 
> 
> Now I'm trying to figure out the results part.
> Since my results would return about 7 fields per
> record, I'm thinking mysql_fetch_row over mysql
> results works better ?
> But I don't want every field from the row returned,
> only specific ones.
> Also, I want to allow for all records that meet
> criteria to be returned, and will set up a user
> variable, so they can choose how many records per page
> come back.
> 
> Can anyone share some ideas or pointers to
> documentation that will allow me to set this up ?
> 
> Very much appreciated!
> Stuart
> 

Is this something like what you are after:



  
  



For details on how to do the x rows per page with previous and next see

http://www.phpfreaks.com/tutorials/43/0.php
or
http://www.phpfreaks.com/tutorials/73/0.php

HTH
Graham

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



RE: [PHP] Re: Help: Database Search

2004-11-12 Thread Graham Cossey

I think you're implode example is pretty close.

 1)
  {
$IndStr = implode("','", $Ind);
$where[] = "vendorjobs.Industry IN($IndStr)";
  }else{
$where[] = "vendorjobs.Industry = {$Ind[0]}";
}else{
  // Is there an error if not an array?
}

$sql = 'SELECT ...
 FROM vendorjobs
 WHERE ' . implode( ' AND ', $where );
?>

Not sure if you need the {} above, I think you do as it's an array reference
in a string.

This should result in:

WHERE vendorjobs.Industry IN (2,3,5)

OR

WHERE vendorjobs.Industry = 2

HTH
Graham



> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 12 November 2004 12:42
> To: Sebastian Mendel; [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: Help: Database Search
>
>
>
> --- Sebastian Mendel <[EMAIL PROTECTED]> wrote:
> >
> > $where = array();
> >
> > if ( isset($_POST['Ind']) ) {
> >  $where[] = 'vendorjobs.Industry = ' . (int)
> > $_POST['Ind'];
> > }
> > if ( isset($_POST['Days']) ) {
> >  $where[] = 'Date_Sub(Curdate(), interval ' .
> > (int) $_POST['Days'] .
> > ' day) <= PostStart';
> > }
> >
> > $sql = '
> >   SELECT ...
> > FROM vendorjobs
> >WHERE ' . implode( ' AND ', $where );
> >
>
> Sebastian, I meant to thank you for this code the
> other day.
> What I'm trying to figure out is some of my elements
> are arrays themselves.  So for example I have this :
>
> $Ind = "";
> $Ind = $HTTP_POST_VARS['Ind'];
> if (count($Ind) > 0 AND is_array($Ind)) {
>  $Ind = "'".implode("','", $Ind)."'";
> }
>
> So how would this code , or array get into what you
> stated as:
>
> > $where = array();
> >
> > if ( isset($_POST['Ind']) ) {
> >  $where[] = 'vendorjobs.Industry = ' . (int)
> > $_POST['Ind'];
> > }
>
> I guess that is putting an array into an array ?
> Not quite sure how the loop would go.
>
> Thank you,
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Re: Help: Database Search

2004-11-12 Thread Graham Cossey
What I meant was that the $sql variable should contain
a where clause of "WHERE vendorjobs.Industry IN (2,3,5)"
if you had a multi-element array or "WHERE vendorjobs.Industry 
= 2" if you had a single-element array.

The IN statement is easier to construct than multiple ORs and
tends to run faster as well.

Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 12 November 2004 14:13
> To: Graham Cossey; Sebastian Mendel; [EMAIL PROTECTED]
> Subject: RE: [PHP] Re: Help: Database Search 
> 
> 
> 
> --- Graham Cossey <[EMAIL PROTECTED]> wrote:
> 
> > This should result in:
> > 
> > WHERE vendorjobs.Industry IN (2,3,5)
> > 
> > OR
> > 
> > WHERE vendorjobs.Industry = 2
> > 
> > HTH
> > Graham
> 
> Not sure what you mean by the above ?
> 
> Stuart
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



RE: [PHP] Re: probably stupid, but...

2004-11-13 Thread Graham Cossey
I know I'm a bit late to this topic and I may have missed a comment along
the way, but what about making a change to the form, is that possible?

Instead of calling your form entries book_title_1, book_title_2,
book_title_3 etc why not use book_title[] for all instances of book_title?

This way the PHP code would be something like:

for($i=0; $i -Original Message-
> From: Robert Sossomon [mailto:[EMAIL PROTECTED]
> Sent: 12 November 2004 21:20
> To: Ben Ramsey
> Cc: [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: probably stupid, but...
>
>
> Ben Ramsey is quoted as saying on 11/12/2004 3:41 PM:
> > You've got some parsing errors going on. Nothing particularly
> wrong with
> > the logic...
> 
> OK, I took out the extra ' that I had at the beginning, and then
> I changed
> everything around to:
>
> if (!empty($_POST['book_title_'.$i]))
> {
>$addtocart = "INSERT INTO `curriculum` VALUES
> ('',$_POST['book_title_'.$i],$_POST['book_level_'.$i],$_POST['leve
> l_grades_'.$i],$_POST['book_section_'.$i],$_POST['chapter_'.$i],$_
> POST['chapter_title_'.$i],$_POST['lesson_title_'.$i],$_POST['skill
> _'.$i],$_POST['life_skill_'.$i],$_POST['success_indicator_'.$i],$_
> POST['ncscos_'.$i],$_POST['subject_'.$i],$_POST['pages_'.$i],$_POS
> T['c_kit_'.$i])";
>echo "$addtocart";
>mysql_query($addtocart);
>
> And it still is producing an empty page (not even echoing out the
> $addtocart
> variable) when I run it.
>
> Unfortunately my server admins went AWOL, so I can get the exact
> error message,
> but I know it has to be some stupid that I just haven't put my
> finger on yet.
>
> I could have had this done already doing it one line @ a time,
> however I want to
> be able to change either form at any time and have only 2 pieces
> of code to change.
>
> Thanks for the help so far guys.
>
> Robert
>
> --
> Robert Sossomon, Business and Technology Application Technician
> 4-H Youth Development Department
> 200 Ricks Hall, Campus Box 7606
> N.C. State University
> Raleigh NC 27695-7606
> Phone: 919/515-8474
> Fax:   919/515-7812
> [EMAIL PROTECTED]
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Re: Help: Database Search

2004-11-13 Thread Graham Cossey
Hi Stuart

Not sure what's happening with the $Ind variable, maybe check the $_POST
array as you enter the script to ensure that the form is passing the data
correctly. It is almost as if you are appending it to itself at some point.
You don't have a line like this anywhere do you : $Ind[] = $Ind;  OR maybe 2
of: $Ind[] = $_POST['Ind']; ??

Part of the problem is with the implode statement. It is this that is not
adding the initial and final ' to your IN statement, see below:

  if (count($Ind) > 0)
  {

$IndStr = implode("','", $Ind);
$where[] = "VendorJobs.Industry IN('$IndStr')";
   ^---^
  }else{
$where[] = "VendorJobs.Industry = {$Ind[0]}";
}

I would also remove this line:
$Ind[] = "";

HTH
Graham

> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 13 November 2004 13:31
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] Re: Help: Database Search
>
>
>
> --- Jason Wong <[EMAIL PROTECTED]> wrote:
> > Yes, that was apparent from your previous post. So
> > did you print out your
> > query and examine it for any obvious mistakes? And
> > if you couldn't spot any
> > obvious mistakes then the least you could have done
> > was to copy and paste the
> > full query in your post so that we could see it in
> > all its glory instead of
> > the truncated query that was posted as part of the
> > mysql error message.
> > Please help us to help you.
> >
> > --
> > Jason Wong -> Gremlins Associates ->
>
> It was not apparent whatsoever.  Let me show the code
> again , but I'll include the print_r returns inline
> code.
>
>  $where = array();
> $Ind[] = "";
> print_r($Ind);
> //Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5
> [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] =>
> 11 [11] => 12 [12] => 13 [13] => 14 [14] => 15 [15] =>
> 16 [16] => 17 [17] => 18 [18] => 19 [19] => 20 [20] =>
> 21 [21] => 22 [22] => 23 [23] => 24 [24] => 25 [25] =>
> 26 [26] => 27 [27] => 28 [28] => 35 [29] => [30] =>
> Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5
> [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] =>
> 11 [11] => 12 [12] => 13 [13] => 14 [14] => 15 [15] =>
> 16 [16] => 17 [17] => 18 [18] => 19 [19] => 20 [20] =>
> 21 [21] => 22 [22] => 23 [23] => 24 [24] => 25 [25] =>
> 26 [26] => 27 [27] => 28 [28] => 35 ) )
> So maybe this is weird, since it seems to print out
> twice ?
>
>
>   if (count($Ind) > 0)
>   {
> $IndStr = implode("','", $Ind);
> $where[] = "VendorJobs.Industry IN($IndStr)";
>   }else{
> $where[] = "VendorJobs.Industry = {$Ind[0]}";
> }
> ?>
>
>  $sql = 'SELECT PostStart, JobTitle, Industry,
> LocationState, VendorID
> FROM VendorJobs
> WHERE ' . implode( ' AND ', $where );
> print_r($where);
> //Array ( [0] => VendorJobs.Industry
> IN(1','2','3','4','5','6','7','8','9','10','11','12','13','14','15
','16','17','18','19','20','21','22','23','24','25','26','27','28','35','','
Array)
> )
>
> $result = mysql_query($sql) or die ("Query failed: "
> .mysql_error());
> while($row = mysql_fetch_assoc($result))
> ?>
>
> Stuart
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

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



RE: [PHP] Database search logic question

2004-11-15 Thread Graham Cossey
A couple of possibilities are:

Store search criteria (form entries) in MySQL
Store query string in MySQL

If the user has to log-in then the MySQL table would
be keyed on the user_id or similar.

If the user does not have to log-in then you will most
likely need to store something in a client-side cookie 
that references the saved query details.

On one of my sites I allow users to either build a query
via a step-by-step procedure or manually enter a query
statement. It is the statement that I store in the 
database together with a name they supply and their user 
id. This allows the user to save multiple queries and 
recall them at a later date by a name that they supplied.

HTH
Graham


> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 15 November 2004 09:10
> To: [EMAIL PROTECTED]
> Subject: [PHP] Database search logic question
> 
> 
> For those who recognize this topic from me and perhaps
> are sick of it , my apologies :)
> 
> This is actually a different question more about logic
> then syntax or functionality.
> 
> One of the uses of my search form is that users may
> save their search parameters. Typical benefits, they
> don't have to re-enter all the criteria.  Hitting one
> link or receiving an email can get them the results
> they need.  
> 
> The way I was approaching this was to grab the url,
> the part after the ? , so not the referer.  Whatever
> the second part is called. 
> Only now that I've created a search and results page
> via Post method, of course there is nothing going to
> the URL. I'm wondering at this point if I should
> create a way to let users save their search
> parameters, by grabbing the variables and storing them
> as an array in the database or go back to the URL
> method.
> 
> Curious if anyone sees benefits or negatives with
> either.
> 
> Stuart
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



RE: [PHP] Database search logic question

2004-11-15 Thread Graham Cossey
> -Original Message-
> From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
> Sent: 15 November 2004 10:12
> To: Graham Cossey; [EMAIL PROTECTED]
> Subject: RE: [PHP] Database search logic question
>
>
> Please see inline:
> --- Graham Cossey <[EMAIL PROTECTED]> wrote:
>
> > A couple of possibilities are:
> >
> > Store search criteria (form entries) in MySQL
> > Store query string in MySQL
>
> So with my current form, the where statement is built
> from conditions that are set (or not set) in the form.
> Perhaps I grab that one array ?

[snip]

I was thinking more along the lines of storing the SQL string.

"SELECT ... FROM vendorjobs WHERE..."

Then when recalled there is no further array processing etc to be done.
However, you may want some kind of validation to prevent malicious use of
the feature.

I've never attempted to store an array in a MySQL table. But storing the
'where' is an alternative.

Other guys (and girls) on the list probably have much more experience of
this than myself.

Graham

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



RE: [PHP] include files, ".php" or ".inc" ?

2004-11-21 Thread Graham Cossey
> Perry Jönsson wrote:
>
> > Jon-Eirik Pettersen wrote:
> >
> >> Perry Jönsson wrote:
> >>
> >>> Hello,
> >>>
> >>> Does it make any difference if you include
> >>> (include/require/include_once/require_once) files with extension
> >>> ".inc" or ".php"?
> >>
> >>
> >>
> >> No, it does not.
> >
> >
> >
> > What it the purpose of the ".inc" file then?
>
> For organization. The file name shows what the file is, without having
> to look at the contents of any scripts.
>

If you only have limited control/knowledge of Apache you could adopt
names something like: script.inc.php

In such a way PHP will always process the script as it's extension
is .php and you can easily identify that it is a script to be
included/required.

Graham

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



RE: [PHP] How to $_POST from a grid

2004-11-25 Thread Graham Cossey
[snip]
>
> I'm doing my development in Dreamweaver though the
> code is basic.  To get to the grid I'm passing over
> the userID  .  Then basic a select statement in the
> results grid with a while loop the returns all the
> records related to the userID.
>
> It's just odd - because in Dreamweaver I build the
> grid with one table row, place my echo fieldx in each
> cell, then create a "repeat region" around the row.
> The repeat region is the while loop.
>
> The behaviour though is different for whatever reason.
>   Using a link with GET (paramter in the URL) it
> distinguishes each primaryID correctly.  Yet with POST
> no. As Jason just posted, yes it has individual submit
> buttons, yet they solely return the last record.
[snip]

Hi Stuart

Have you looked at the HTML generated by your PHP code?
Using view source you'll see what values each of your 3 forms contains and
therefore what will be submitted in the POST. My guess from one of your
previous posts is that all 3 forms contain the same value in the (hidden) ID
field. You were getting the value from a class but did not appear to be
passing any kind of index to the class to determine which value to return.

HTH
Graham

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



RE: [PHP] Have I learned nothing .> Foreach()

2004-11-30 Thread Graham Cossey
[snip]
> > > Then finally on the transaction page, some pages
> > down
> > > the road:
> > > 
> > 
> > and also print_r($_SESSION['schools']); here
> > 
> > > foreach($_SESSION['schools'] as $school)
> > > {
>  
> > What have you find out?
> > 
> They don't exist.  
[snip]

You have got session_start(); at the top of each script haven't you?

Is the SID being passed down the chain of scripts? 
Is this done by cookie or url?

Graham.


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



  1   2   >