RE: [PHP-DB] Corn job anomaly

2016-09-27 Thread Ford, Mike
> -Original Message-
> From: Karl DeSaulniers [mailto:k...@designdrumm.com]
> Sent: 25 September 2016 09:59
> To: PHP List Database 
> Subject: Re: [PHP-DB] Corn job anomaly
>
> Now I am getting an error with mysql syntax.
>
> "SELECT otn.*, cf.* FROM ".ORDER_TABLE." otn LEFT JOIN ".FIELDS_TABLE." cf
> ON cf.Order_ID = otn.Order_ID WHERE cf.Earliest_Pickup >= DATE(NOW()) AND
> cf.Earliest_Pickup <= DATE(NOW() + INTERVAL ".($Num_Days_Away+1)." DAY) AND
> otn.Order_Status != 'Shipping' AND otn.Order_Status != 'Completed'"
>
> is giving me this error:
>   You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use near
> '\"Shipping\" AND otn.Order_Status != \"Completed\"' at line 1

I don't think INTERVAL works like that - you probably need something like:

... cf.Earliest_Pickup <= DATE_ADD(CURDATE(), INTERVAL 
".($Num_Days_Away+1)." DAY) AND ...

Incidentally, as I understand it CURDATE() does exactly the same as 
DATE(NOW()), and is probably more readable.

Cheers!

Mike

--
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,
110 Queen Square House, 80 Woodhouse Lane,
Leeds Beckett University, Leeds LS2 8NU,  United Kingdom
E & S4B: m.f...@leedsbeckett.ac.uk T: +44 113 812 4730

To view the terms under which this email is distributed, please go to:-
http://disclaimer.leedsbeckett.ac.uk/disclaimer/disclaimer.html

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



RE: [PHP-DB] Re: Formatting

2012-11-26 Thread Ford, Mike
 -Original Message-
 From: Karl DeSaulniers [mailto:k...@designdrumm.com]
 Sent: 26 November 2012 08:48
 To: php-db@lists.php.net
 Subject: Re: [PHP-DB] Re: Formatting
 
 Ethan,
 is this valid PHP? What is the ampersand for? What is it doing? Just
 curious.
 
 $args[] = $_POST[$k]; // Note the addition of the ampersand here

That's a perfectly valid reference assignment. Please see the Fine
Manual at: http://php.net/manual/language.references.whatdo.php


Cheers!

Mike

-- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] SELECT

2011-10-21 Thread Ford, Mike
 -Original Message-
 From: tamouse mailing lists [mailto:tamouse.li...@gmail.com]
 Sent: 20 October 2011 21:37
 
 On Tue, Oct 18, 2011 at 5:36 AM, Ford, Mike m.f...@leedsmet.ac.uk
 wrote:
  -Original Message-
  From: Ron Piggott [mailto:ron.pigg...@actsministries.org]
  Sent: 17 October 2011 18:38
 
  What I am storing in the table is the start month # (1 to 12) and
  day # (1 to 31) and then the finishing month # (1 to 12) and the
  finishing day # (1 to 31)
 
 
  This is a little bit of a tricky one, as you have to consider both
  start_month and end_month as special cases - so you need a three-
 part
  conditional, for the start month, the end month, and the months in
  between. Something like this:
 
  SELECT * FROM `introduction_messages`
   WHERE (month`start_month` AND month`end_month`)
        OR (month=`start_month AND day=`start_day`)
        OR (month=`end_month` AND day=`end_day`);
 
 This still suffers from the problem in Jim's offer -- wrap of year
 and
 wrap of month

Look again. Month wrap *is* handled by the specific tests for start_month
and end_month.

As to year-wrap, Ron's original post said:

  ... The reason I didn’t use ‘DATE’ is because the same message
  will be displayed year after year, depending on the date range.

so I didn't bother about year-wrap, assuming he would include a range
with start_date of 1/1 and another with end_date of 31/12.

Cheers!

Mike

-- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730


 But in the
case of years actually mattering then, yes, the above would not work


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


RE: [PHP-DB] SELECT

2011-10-18 Thread Ford, Mike
 -Original Message-
 From: Ron Piggott [mailto:ron.pigg...@actsministries.org]
 Sent: 17 October 2011 18:38
 
 I need help creating a mySQL query that will select the correct
 introduction message for a website I am making.  The way I have
 designed the table I can’t wrap my mind around the SELECT query that
 will deal with the day # of the month.
 
 The part of the SELECT syntax I am struggling with is when the
 introduction message is to change mid month.  The reason I am
 struggling with this is because I haven’t used ‘DATE’ for the column
 type.  The reason I didn’t use ‘DATE’ is because the same message
 will be displayed year after year, depending on the date range.
 
 What I am storing in the table is the start month # (1 to 12) and
 day # (1 to 31) and then the finishing month # (1 to 12) and the
 finishing day # (1 to 31)
 

This is a little bit of a tricky one, as you have to consider both
start_month and end_month as special cases - so you need a three-part
conditional, for the start month, the end month, and the months in
between. Something like this:

SELECT * FROM `introduction_messages`
 WHERE (month`start_month` AND month`end_month`)
   OR (month=`start_month AND day=`start_day`)
   OR (month=`end_month` AND day=`end_day`);

Cheers!

Mike

-- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730




To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


RE: [PHP-DB] Re: Stuck in apostrophe hell

2010-08-04 Thread Ford, Mike
 -Original Message-
 From: Simcha Younger [mailto:sim...@syounger.com]
 Sent: 04 August 2010 08:19
 
  paul_s_john...@mnb.uscourts.gov wrote:
 
  
   THE INPUT:
  
   $sql_insert_registration = sprintf(INSERT INTO
 Registrations (
   Class_ID,
   prid,
   Registrant,
   Company,
   Phone,
   Email
 )
   VALUES (
   $_POST[Class_ID],
   $_POST[prid],
   '%s',.
 
 You need double-quotes here,
  \%s\,

No, he doesn't. Single quotes are fine. Doubles would more than likely be a SQL 
error.

   parseNull($_POST['Company']).,
   '$_POST[Phone]',
   '$_POST[Email]'
   ), mysql_real_escape_string($_POST['Registrant']));
  
 
 
 --
 Simcha Younger sim...@syounger.com


Cheers!

Mike

 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507 City Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730




To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] losing MySQL resource

2009-11-11 Thread Ford, Mike
 -Original Message-
 From: Nehemias Duarte [mailto:ndua...@aflac.com]
 Sent: 11 November 2009 14:25
 To: Stan; php-db@lists.php.net
 Subject: RE: [PHP-DB] losing MySQL resource
 
 I was under the impression that session_start() had to be the FIRST
 thing ran in the script. Is this incorrect?

Yes.

It has to be before any actual *output*, but it would be perfectly valid to 
have umpteen thousand lines of PHP before session_start() so long as all the 
output came after it.

Cheers!

Mike

 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730






To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] newbie: how to return one iteration *per unique date (DAY!)* in a timestamp column?

2009-08-05 Thread Ford, Mike
 -Original Message-
 From: Govinda [mailto:govinda.webdnat...@gmail.com]
 Sent: 05 August 2009 01:41
 
  Taking this:
  SELECT count(*) AS
  `CountUniqueDatesInMyTbl`, date(solarAWDateTime) AS `uniqueDate`,
  'aweber_7solar_aw' AS `tableAlias` FROM aweber_7solar_aw GROUP BY
  DATE(solarAWDateTime)

Just one other tiny point of style here: having given the expression 
date(solarAWDateTime) the alias uniqueDate, you should probably use that alias 
to refer to the same thing elsewhere in your query, such as in the GROUP BY 
column.  So:

SELECT count(*) AS `CountUniqueDatesInMyTbl`,
   date(solarAWDateTime) AS `uniqueDate`,
   'aweber_7solar_aw' AS `tableAlias`
   FROM aweber_7solar_aw
   GROUP BY `uniqueDate`;

That's how I'd write it, anyway.


Cheers!

Mike
 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.f...@leedsmet.ac.uk 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] Postgres query failing, not enough info for debugging...

2009-06-17 Thread Ford, Mike
On 16 June 2009 15:57, Carol Walter advised:

 Hello,
 
 I'm using PHP 5 and PostgreSQL 8.3.6.  I have a query that is failing
 and I don't know how to troubleshoot the problem.  The error message
 that it is giving is quite vague.  The error message is as follows:
 
 
 Warning: pg_query_params() [function.pg-query-params]: Query failed:
 ERROR: syntax error at end of input at character 156 in /home/walterc/
 ssl/PHP/km_input_test2c.php on line 631
 ERROR: syntax error at end of input at character 156
 
 The query that is failing looks like this...
 
 $pg_pres_ins6 = pg_query_params(INSERT INTO \brdgMediaCallsEvents
 \ (\mediumId\, \eventId\, rank) VALUES
 ((currval('\tblMedia_mediumId_seq\'),
 (currval('\tblCallsEvents_eventId_seq\'), $1), array($ev_rank));
   echo pg_last_error($pg_connection);

You have 2 more opening parentheses than close parentheses in that SQL
-- in both cases, the parenthesis immediately preceding currval should
be omitted.

Also, to ameliorate your quote hell, you might consider using a heredoc
(http://php.net/manual/language.types.string.php#language.types.string.s
yntax.heredoc) for this:

  $pg_pres_ins6 = pg_query_params(SQL
  INSERT INTO brdgMediaCallsEvents (mediumId, eventId, rank)
  VALUES (currval('tblMedia_mediumId_seq'),
  currval('tblCallsEvents_eventId_seq'), $1)
  SQL
 , array($ev_rank));

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: m.f...@leedsmet.ac.uk
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] Re: PHP and table/view names with '$'

2009-04-23 Thread Ford, Mike
On 23 April 2009 11:36, Mark Casson advised:

 Hi Guys,
 
 Thanks to you both - you are spot on!
 
 Shame this is not better documented somewhere.

I don't know how much better documented it can be than at
http://php.net/language.types.string ... ;)

Cheers!

Mike

 --
Mike Ford,  Electronic Information Developer,
C507, Leeds Metropolitan University, Civic Quarter Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom
Email: m.f...@leedsmet.ac.uk
Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] variable with NULL value

2007-05-04 Thread Ford, Mike
On 03 May 2007 16:22, OKi98 wrote:

 Hi,
 
 one more question.
 
 Why the variable, that contains NULL value appears to be not
 set.

U -- because that's how it's defined??  (http://php.net/isset)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


RE: [PHP-DB] weird comparsion

2007-05-03 Thread Ford, Mike
On 03 May 2007 12:30, OKi98 wrote:

 I know about identity operator (===) but with == operator 0 is false
 and foo is true

No, that's not correct.

  , try this:
 
 $foo=0;
 $bar=bar;
 if ($foo) echo($foo is true, );
 else echo($foo is false, );
 if ($bar) echo($bar is true, );
 else echo($bar is false, );
 if ($foo==$bar) echo($foo==$bar);
 
 returns 0 is false, bar is true, 0==$bar

That's because you've got loads of implicit type conversions going on there, so 
you're not comparing like with like.

For  if ($foo) ... and if ($bar) ...:

within the context of the if(), both $foo and $bar are implicitly converted to 
Boolean:
  - (bool)0 is FALSE
  - (bool)any non-empty() string is TRUE


On the other hand, for  if ($foo==$bar) ...:

in the context of the == comparison, $bar is converted to a number, and any 
string not beginning with a numeric character converts to numeric zero -- so 
you get a comparison of zero with zero, which is, of course, TRUE!

Or, in other words, (bool)$foo!==(bool)$bar, BUT (int)$foo===(int)$bar


It's exactly when you *don't* want this kind of automatic type-conversion 
shenanigans going on that you should use the === operator to make your intent 
entirely clear -- otherwise you have to be extremely aware of the context in 
which you are evaluating your variables in order to avoid hidden surprises like 
this.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
JG125, The Headingley Library,
James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 812 4730  Fax:  +44 113 812 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm


RE: [PHP-DB] detecting negative numbers

2006-07-17 Thread Ford, Mike
On 17 July 2006 01:07, Dave W wrote:

 No, I get it. I just thought that there might have been some built in
 function like if(neg_num($quant - $amount))
 or something like that. I know how to do it, but I thought
 that there might
 have been an alternate method. Just because I asked a simple question
 doesn't mean I'm stupid, I'm just curious if there is a
 simpler way to do an
 already simple task.

The absolute simplest way to do this is what you originally had.  I would not 
look further than

if ($quant$amount)
   // $quant-$amount is negative

If I were reading your code, I would find both if(($quant-$amount)0) and 
if(neg_num($quant-$amount)) more obfuscating than if($quant$amount).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] PHPSESSID how to append and access

2006-05-25 Thread Ford, Mike
On 25 May 2006 12:12, Girish Agarwal wrote:

 Hi All,
  I am using header(Location:
 http://dv-medical/phpscripts/test.php;) function to hop from
 one Page to
 Another in My Web Application
 My Problem is I have been unable to get the exact
 syntax to append
 the Session ID to the URL specified in the header so that it
 is available

  header(Location: http://dv-medical/phpscripts/test.php?.SID)

That's what the SID constant is for.  You can even use it with impunity when 
cookies are in use, since it is set to the empty string in that case.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] Displaying results from a query properly.

2006-03-27 Thread Ford, Mike
On 24 March 2006 16:40, Alex Major wrote:

 Thanks, works like a charm (had to make is -2 instead of -1
 as it added a
 space after each result). Hadn't thought of something so simple.
 
 On 24/3/06 16:22, Bastien Koert [EMAIL PROTECTED] wrote:
 
  Build it up as a string and remove the trailing comma at the end of
  the loop 
  
  do { $sHTML .= ''.$administrators['username'].', ';}
  while ($administrators = mysql_fetch_assoc($administrators_result))
  
  $sHTML = substr($sHTML, 0, strlen($sHTML)-1);

You don't need a strlen() call here, as substr understands count from the 
right notation:

   $sHTML = substr($sHTML, 0, -1);

... or, with Alex's correction:

   $sHTML = substr($sHTML, 0, -2);

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] Quick question

2005-12-09 Thread Ford, Mike
On 08 December 2005 20:53, Chris Payne wrote:

 Hi there everyone,
 
 
 
 How do I set the following items with ini_set()?  I looked at
 the manual but
 when I try nothing happens:
 
 
 
 * file_uploads
 * upload_max_filesize
 * max_input_time
 * memory_limit
 * max_execution_time
 * post_max_size

Apart from max_execution_time, the things affected by those settings all take 
place before your script even gains control -- so changing them in the script 
can never have any useful effect.  To do any good, they must be set in an 
appropriate config file (php.ini, httpd.conf, .htaccess, etc.) as permitted.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] problem of transmiting variabl into another page?

2005-12-07 Thread Ford, Mike
On 02 December 2005 13:06, Bastien Koert wrote:

 ?php for ($j=ord('A'); $j = ord('Z'); $j++) {
 echo | ba
 href='alpha.php?artist=.chr($j).'.chr($j)./a/b ;
 
   } ?
 
 You need to use the ORD function to get the numerical ascii
 equivalent of the letter and the CHR function to go back the other
 way.

Gak! That's almost worse than the original!!

 
 Bastien
 
 
  From: Mohamed Yusuf [EMAIL PROTECTED]
  To: php-db@lists.php.net
  Subject: [PHP-DB] problem of transmiting variabl into another page?
  Date: Fri, 2 Dec 2005 12:30:12 +0200
  
  I am transmitting variable from one of my pages and I would like to
  match that variable into mysql data. it won't return data.
  my code is this.
  
  ?php for ($j=A; $j = Z; $j++) {
 echo | ba href='alpha.php?artist=$j'$j/a/b |;
 if  ($j == Z) {
   break;
}
   } ?

1. You have unquoted strings -- should be 'A' and 'Z'.

2. The test condition in your for is wrong (and either that or the break is 
redundant).

Here's how I'd write it:

   for ($j='A'; $j!='AA'; $j++):
 echo | ba href='alpha.php?artist=$j'$j/a/b |;
   endfor;

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 



To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

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



RE: [PHP-DB] timestamp

2005-02-01 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



 -Original Message-
 From: Balwant Singh [mailto:[EMAIL PROTECTED] 
 Sent: 01 February 2005 08:08
 
 on echoing $timestamp i m getting Fri Jan 28 19:53:09 2005 
 but on echoing $date i m getting 1970-01-01.  
 also i m getting full info. by phpinfo()
 
 i m using php 4.2.2 , apache 2.0 and rad hat 9.

The Change Log includes this line for version 4.3.3:

Fixed bug #13142 (strtotime not handling M d H:i:s Y format). (Ilia)

So I guess you need at least PHP 4.3.3 for this to work correctly for you.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services, JG125, James
Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS,
LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] mysql - image storing

2005-01-18 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 18 January 2005 17:11, Joseph Crawford wrote:

 Jason, can you explain why stripslashes should not be used on data
 taken from the db? when you store data in the db i thought it was good
 practice to addslashes, when you retrieve from the db, you will need
 to use stripslashes to remove the extra \

It's simple.  Suppose you have a script that looks a bit like this (but
hopefully with more input validation and error checking!):


$value = addslashes($_POST['text']); // magic_quotes_gpc off

$sql = INSERT INTO tbl SET fld = '$value';

database_execute($sql);

Now suppose the user types this into the 'text' form field:

Here's an apostrophe

Here's what happens:

  PHP does this:

$value is set to: Here\'s an apostrophe

$sql becomes: INSERT INTO tbl SET fld = 'Here\'s an apostrophe'

Which is sent to the database via database_execute()

  The DATABASE now does this:

Receives the SQL statement: INSERT INTO tbl SET fld = 'Here\'s an
apostrophe'

(Note how the \ escape is required here to stop the field
value from terminating prematurely -- but this escape is
aimed at the *database*, and is not a PHP escape.  A lot of
confusion seems to arise here for databases which use the
same \ escape character as PHP.)

Extracts the value:   Here\'s an apostrophe
and de-escapes it to give:Here's an apostrophe

Which gets inserted into the database.

So the value inserted into the database is the unescaped original, and on
retrieval there are no \ characters in the retrieved value to be
stripslashes()ed.

Hope that's clearer than mud, and helps you understand what's going on
better.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] php latest release!

2005-01-10 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 10 January 2005 09:28, JeRRy wrote:

 With PHP latest release from http://php.net/ do we
 require to update Zend Optimizer?

Yes.
 
 People are claiming some scripts previously that
 worked in a previous version of PHP works and not with the new
 version. 

There are several bug reports on bugs.php.net about this. Also see the red
warning text on http://php.net/downloads.php

 Why is it required to update Zend?

Earlier versions are incompatible with PHP 4.3.10, and exhibit various
incorrect behaviours -- in particular, foreach produces the wrong results.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-07 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 06 January 2005 21:10, Norland, Martin wrote:

  -Original Message-
  From: Ford, Mike [mailto:[EMAIL PROTECTED]
  Sent: Thursday, January 06, 2005 1:13 PM
  Subject: RE: [PHP-DB] Trying to connext to MySQL with PEAR [snip]
  Oh dear, as a fully-paid-up pedant, I'm afriad I can't resist this
  one: 
  
  Doesn't affect the answer, but this occurrence of 'effect' should
  be 'affect'. ;) 
  
  Cheers!
  
  Mike
 
 * Joining in on the fun *
 
 I'm afraid you spelled afraid incorrectly.  I'll be sending you the
 bill for my services related to this matter.

Please send it to Mr Murphy, who obviously insinuated one of his pet
gremlins into my keyboard for those few moments...! ;)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] PHP query to mysql database returns emtpy data, but Query Browser shows records

2005-01-07 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 07 January 2005 03:25, Jason Walker wrote:

 Graeme - you were moving in the right direction. Since the
 data in the field
 is varchar(250), the only thing that changes is the fact that the last
 number is 3 digits. Other page queries were also affected
 with 4 x 2 digit
 numbers in the category field (eg. '37 48 49 52').
 
 By adding '%' between each number and using 'LIKE' as opposed
 to '=', the
 queries through PHP return the correct value.
 
 I think is very strange as 3x numbers work fine when using
 spaces (' ')
 between each criteria (as in '37 48 53').
 
 The change would look something like:
 
 SELECT description from cpProducts where category like '39%47%48%172'

That's not a good idea, as it would also match entries like:

 391 247 48 172
 39 147 148 172
 395 347 1486 1172

etc.

I think you really need to find out exactly what's in those failing records,
and why it's not matching your query.

 

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



RE: [PHP-DB] Trying to connext to MySQL with PEAR

2005-01-06 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 06 January 2005 16:39, Jochem Maas wrote:

 Hutchins, Richard wrote:
  echo $dsn; $isPersistant = TRUE;
 
 doesn't effect the code but 'Persistant' is spelled 'Persistent'

Oh dear, as a fully-paid-up pedant, I'm afriad I can't resist this one:

Doesn't affect the answer, but this occurrence of 'effect' should be
'affect'. ;)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] _POST, _GET, _REQUEST not working

2004-12-23 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 23 December 2004 01:12, Keane, Warren A FIN:EX wrote:

 I did try
 
 if (empty($_GET)) { parse_str($_SERVER['QUERY_STRING'],$_GET); }
 
 which worked so I guess I should be able to come up with an
 equivalent for _POST using argv, argc.
 
  I am guessing but I also think the problem is to do with the fact
  that the CGI sapi is being used.
 
 I am using the CLI SAPI, I checked using php_sapi_name(). Is this
 causing the problem?

Absolutely -- this is the Command-Line Interface.  As this is intended for
command-line scripting, it has no notion of being used in a Web context and
does not even attempt to fill the $_POST or $_GET (or most of the other $_)
arrays.  You need to use either the CGI SAPI, or the Apache module.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] still Parse errors ,,, can you. impart me about it.

2004-12-23 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 23 December 2004 18:04, amol patil wrote:

 hallo Mike,
 
 thanks for reply, but i want a bit more help, again

Please keep this on-list -- someone else may have time to reply before I can
(especially as I am about to go home for my tea and a well-earned sleep!).

 
 i know these parse errors are generally typing mistakes ,
 
 but i have checked for it , but still i am getting errors.
 
 i have attached files  with  their codes , can you go through
 it to find what is going wrong
 
 
 Parse error: parse error, unexpected '' in
 /home/dollar1/public_html/signup.php on line 263
 
 
 parse error, unexpected '' in
 /home/dollar1/public_html/login.php on line 94
 
 
 Parse error: parse error, unexpected T_STRING in
 /home/dollar1/public_html/addfunds.php on line 91 then on 102
 
 
 
 thank you.
 
 
 Ford, Mike [EMAIL PROTECTED] wrote:
 To view the terms under which this email is distributed,
 please go to http://disclaimer.leedsmet.ac.uk/email.htm
 
 
 
 On 21 December 2004 07:58, amol patil wrote:
 
  hallo friend,
  
  i have developed simple and small database website using php ,html
  and java script. 
  
  but i am getting these three parse errors on clicking ,
  
  i have checked 3-4 imes on these line numbers, but there wasn't any
  $ variable. php script is also correctly written.
  what is this T_STRING error.
  
  can you help me regarding this.
  
  thank you.
  
  errors:
  
  Parse error: parse error, unexpected $ in
  /home/dollar1/public_html/signup.php3 on line 379
 
 $ in PHP's error messages represents the end of the file, so PHP has
 reached the end of signup.php3 when it's still expecting more
 program. This means you have an error somewhere in the preceding 378
 lines -- most likely a missing }. (If PHP was complaining about a
 variable reference, the message would refer to unexpected
 T_VARIABLE.) 
 
 
 Cheers!
 
 Mike
 
 -
 Mike Ford, Electronic Information Services Adviser,
 Learning Support Services, Learning  Information Services,
 JG125, James Graham Building, Leeds Metropolitan University,
 Headingley Campus, LEEDS, LS6 3QS, United Kingdom
 Email: [EMAIL PROTECTED]
 Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
 
 
 
 Do you Yahoo!?
 Jazz up your holiday email with celebrity designs. Learn more.


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

RE: [PHP-DB] Parse errors ,,, can you. impart me about it.

2004-12-22 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 21 December 2004 07:58, amol patil wrote:

 hallo friend,
 
 i have developed simple and small database website using php ,html
 and java script. 
 
 but i am getting these three parse errors on clicking ,
 
 i have checked 3-4 imes on these line numbers, but there wasn't any $
 variable. php script is also correctly written.
 what is this T_STRING error.
 
 can you help me regarding this.
 
 thank you.
 
 errors:
 
 Parse error: parse error, unexpected $ in
 /home/dollar1/public_html/signup.php3 on line 379

$ in PHP's error messages represents the end of the file, so PHP has reached
the end of signup.php3 when it's still expecting more program.  This means
you have an error somewhere in the preceding 378 lines -- most likely a
missing }.  (If PHP was complaining about a variable reference, the message
would refer to unexpected T_VARIABLE.)


Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] _POST, _GET, _REQUEST not working

2004-12-22 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 20 December 2004 21:50, Warren wrote:

 Hello,
 
 I am running PHP 4.39 as a CGI under Tomcat 5.025,  Linux 2.4.20-31.9.
 Configure = './configure' '--with-java=/usr/java/j2sdk1.4.2_04'
 '--with-servlet=/home/www/jakarta-tomcat-5.0.25' '--with-mysql'
 
 I cannot get the _GET function or _REQUEST functions to pick
 up values from
 a form generating even though I can see the query string
 values in the URL
 as in:
 http://localhost:8080/ip7/httptest.php?var1=212122var2=343434
 
 My HTML is very simple:
 
 form action=http://localhost:8080/ip7/httptest.php; method=get
 input type=text name=var1
 input type=text name=var2
 input type=submit
 /form
 
 The PHP program httptest.php is also very simple:
 
 ?PHP
 global $_SERVER, $_GET, $_POST, $_REQUEST, $_SESSION, $_COOKIE;
 
 if(!empty($_REQUEST['var1'])) { $var1 = $_REQUEST['var1']; }
 else { $var1 ='undefined'; }
 
 if(!empty($_GET['var2'])) { $var2 = $_GET['var2']; }
 else  $var2 ='undefined';
 
 // Various HMTL tags removed for simplicity
 echo   $var1
 echo   $var1

Is this a direct paste from your original?  If so, there's an obvious error
here -- one of those should be $var2,'cos as it is you're never even echoing
the value of the $_GET parameter.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] date conversions

2004-12-16 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 16 December 2004 06:00, neil wrote:

 Hi
 
 I am needing to convert a d/m/y date such as 30/11/2004 into the
 format that mysql can use ie. 2004-11-20
 
 If I try the following:
 
 $testdate=30/11/2004;
 echo date(Y-m-d, strtotime($testdate));
 
 the result is - 2006-06-11

strtotime() is, unfortunately, a little American biased and only recognises
the mm/dd/ numeric format (using slashes).  So the above is returning
the equivalent of the 11th day of the 30th month of 2004!

You can use other PHP functions, as has been suggested, but you might also
investigate the mySQL date formatting functions, as I believe they work
perfectly well on input dates as well as output ones.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] PHP 4.3.10RC2 - Any change in the way rows are fetch ed ?

2004-12-16 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 16 December 2004 12:51, Vincent KONIECZEK wrote:

 Hi there,
 
 
 I was testing PHP 4.3.10RC2 with a well-tested web application when I
 saw it failed badly. 
 
 After a little debug, I have found that the problem comes
 from this SQL
 query:
 SELECT CONCAT(num) AS k FROM user WHERE uid LIKE '%%'
 where user is a table with num as the PK and uid as a VARCHAR(128).
 
 I expect a result like this one (var_export-like display) of
 the fetched
 row (with mysql_fetch_array()):
 ([0] = 67,[k] = 67)
 But mysql_fetch_array() gives me:
 ([0] = ([0] = 67,[k] = 67))
 
 For me, it is a really big problem.
 I do not have it with PHP 4.3.8.
 I did not take the time to test with PHP 4.3.9 nor 4.3.10 but
 I took a
 look at the documentation web sites, the latest Changelogs and made a
 search on the mailing lists but found nothing about it.

Similar problems have been reported to the bugs database, and have been
traced to an old version of the Zend Optimiser -- if you are using this, try
disabling it, and if your application then works ok upgrade to the latest
version.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] mysql_array_array

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 13:15, Yemi Obembe wrote:


 $sql = SELECT * FROM arcadia WHERE email=$v;

$sql_in = INSERT INTO arcadia ('email') VALUES ('$v');

Spot the difference: you have quoted the email value $v in the INSERT
(correct) but not in the SELECT (wrong).  This means that:

   $res = mysql_query( $sql ) ; 

is failing with a SQL error, so $res is not being set to a valid MySQL
result resource, so that when you execute:

   if (list($row) = mysql_fetch_array($res)) {

The mysql_fetch_array() complains with the error you have seen.

After any database operation, you should check for failure and echo out any
error message -- see mysql_errno()  (http://php.net/mysql_errno) and
mysql_error() (http://php.net/mysql_error).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 14:39, Stuart Felenstein wrote:

 I want to send back a message when no matches are
 found on my search page.  Basically No matches
 found.  I assumed that mysql_fetch_assoc would be the
 determining factor on whether any rows will come back.
  As you can see below I do a if ($row_rsCS == false).
 Apparently though (while the message is sharp and
 centered ;)), it is not to right place, since it sends
 the message and exits whether records / matches exist or not.   Any
 suggestions ? 
 
 Thank you
 Stuart
 
 $query_limit_rsCS = sprintf(%s LIMIT %d, %d,
 $query_rsCS, $startRow_rsCS, $maxRows_rsCS);
 //print_r($query_limit_rsCS);
 $rsCS = mysql_query($query_limit_rsCS, $Pmmodel) or
 die(mysql_error()); //print_r($rsCS);
 $row_rsCS = mysql_fetch_assoc($rsCS);
 
 if ($row_rsCS == false)
 ?

The closing ? of a PHP segment also implies an end-of-statement semicolon
-- so the above is equivalent to:

   if ($row_rsCS == false) ;
   ?

Which, of course, means that the scope of the if doesn't extend to anything
beyond this point.

You need to mark the block controlled by the if, using either {-} or
:-endif, according to your taste.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 15:06, Stuart Felenstein wrote:

  The closing ? of a PHP segment also implies an
  end-of-statement semicolon
  -- so the above is equivalent to:
  
 if ($row_rsCS == false) ;
  ? 
  
  Which, of course, means that the scope of the if
  doesn't extend to anything
  beyond this point.
  
  You need to mark the block controlled by the if,
  using either {-} or
  :-endif, according to your taste.
  
 The reason the close is there is because the next line
 of code is the print_r , and I put some html in there.

Nothing wrong with having the closing ? there -- please re-read my
response.  If it's still unclear to you, please ask specific questions.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 15:16, Stuart Felenstein wrote:

 --- Stuart Felenstein [EMAIL PROTECTED] wrote:
 
  The reason the close is there is because the next
  line
  of code is the print_r , and I put some html in
  there.
  
 So this works great:
 
 if ($row_rsCS == false) {
 print_r (No Matches Found);
 exit;
 }
 
 But because I want to have some html formatting around
 the print_r, I closed the tags.

Yes, but you didn't include the { } to indicate the scope of the if -- so it
terminated at the ?.

  I'm not sure how to use the endif.

Well, your taste seems to be to use { }, so :-endif is irrelevant.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 15:26, Stuart Felenstein wrote:

 --- Ford, Mike [EMAIL PROTECTED] wrote:
 
  Well, your taste seems to be to use { }, so :-endif is irrelevant.
  
 Alright it's Friday, I'm punchy but we're all in a
 good mood !
 
 Yes, I like the closing curlies
 
 So, then where do these lovely ladies go here ?
 
 if ($row_rsCS == false) {

?

 p align=centerstrong?php print_r (No Matches Found);?
 /strong/p

?php

 exit;
 }

Just put the PHP tags in as indicated and you'll be good to go.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Question: For no results

2004-12-03 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 03 December 2004 15:26, Stuart Felenstein wrote:

 --- Ford, Mike [EMAIL PROTECTED] wrote:
 
  Well, your taste seems to be to use { }, so :-endif is irrelevant.
  
 Alright it's Friday, I'm punchy but we're all in a
 good mood !
 
 Yes, I like the closing curlies
 
 So, then where do these lovely ladies go here ?
 
 if ($row_rsCS == false) {
 p align=centerstrong?php print_r (No Matches Found);?
 /strong/p exit;
 }

And, by the way, why on earth are you using a print_r an a straight literal
string?  Seems to me you could just put that text in as part of the HTML:

   if ($row_rsCS == false) {
   ?
 p align=centerstrongNo Matches Found/strong/p
   ?php
 exit;
   }

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Multi-User Update Problem

2004-12-01 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 30 November 2004 14:45, SCALES, Andrew wrote:

 Thanks very much for your help. The main difficulty I was
 having really was
 unlocking the record again if the user crashed out or just
 closed down their
 browser/computer (something they have a bad habit of doing)
 but storing the
 time the record was locked and ignoring the lock if it's over
 that time
 sounds interesting.
 I may try storing the data in a session variable and then
 comparing that to
 the database before the updated data is inserted into the
 record as Bastien
 suggested. We wanted to keep hits on the db to a minimum, but
 seen as some
 extra traffic will be necessary anyway I may just try that.

Another approach to this might be:

Keep a column in your database table for time of last update of each record.

When a user reads a record for update, don't lock it at this point, but save
the time at which it was read into the user's session (or somewhere in the
database).

On receiving a potential update, check the time the record was read (as
recorded above) and the last update time of the record (lock the record as
part of this query) -- if the update time is later then the read time,
someone else has updated in the interim and you should abandon ship;
otherwise, update the record including a new last-updated value; in either
case, unlock the record.

This methodology keeps both the lock and unlock in the same script (and
potentially within a single database transaction), so no need for any
external checks for locked records, and minimizes the amount of time for
which any one record is locked.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Transaction suddenly not working

2004-11-29 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 29 November 2004 13:19, Stuart Felenstein wrote:

 Now the printout of the query is this:
 
 0: INSERT INTO Table1 (LurkID, ProfileName, Edu,
 WorkAuth, WorkExp, CarLev, Secu, Confi, Relo,
 Telecomu, City1, State1, City2, State2, TravelPref,
 SalaryAnnual, SalaryHourly, Available) VALUES (47,
 '', 7, 2, 1015, 5, , '', '', '', 'fds', 5, '',

You have 2 successive commas in this last line, with no value in between --
this is your syntax error.

 , 4, 26, , 2004-02-02)01062 : Duplicate entry '0-f' for key 1

And again on this line -- twice, in fact, since the previous line ends with
a comma, too.

Track down whatever is outputting these null values, fix it, and you should
be good to go (well, at least less bad!).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] PHP / Javascript question

2004-11-16 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 16 November 2004 03:03, Chris Payne wrote:

This is OT, really, but because it's an easy answer:

 if ( document.removeitems.del.value ==  )

 BUT because the tickboxes information is stored in a PHP
 Array called del[]
 I am having major problems getting it to work.

You shouldn't be, since any good JavaScript text will tell you that, by
definition, x.y is identical to x['y']; so:

document.removeitems['del[]']

will get you started.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Re: Subject: Javascript Question (Was PHP / Javascri pt question)

2004-11-16 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 16 November 2004 15:12, Neil Smith wrote:

 That
 
 if (df[i].checked=true) {
 
 should of course read
 
 if (df[i].checked==true) {

No it shouldn't -- it should read 

  if (df[i].checked) {

More efficient, more readable, and, more important, The Right Way (TM)! ;)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Persistent Connections to Oracle databases

2004-11-15 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 11 November 2004 19:11, Patrick David wrote:

 My understanding of persistent connections was that using the
 ociplogon function a connection would be opened to the
 database and all other connections to the same database (with
 the same username and password) would use the first one
 previously opened, which mean I would have only 1 connection
 to the database.

I know this is a late response, but I haven't seen anybody point this out
yet: that's 1 connection *per Apache child process*, since each process
still has to have its own connection.

  But in fact it is not what is happening,
 every time I submit the page to the same database a new
 connection is opened. Which is a little bit annoying if I
 submit this one 100 times (100 connections at the end).

Potentially, if you have Apache configured to run 100 children or more.  If
you configure it to run only 50 children, that's the maximum number of
Oracle connections you will get.


Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Forms list from database

2004-11-02 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 01 November 2004 21:11, Jason T. Davidson wrote:

 Here is the code:
 
 form name=form1 method=post action=staff_code/add_code.php
 table width=600 border=0 align=center cellpadding=0
cellspacing=0 tr bgcolor=#CC
  td colspan=3 bgcolor=#FFdiv align=center
select name=controller id=controller
  option /option
   option
 ?
   while ($check=mysql_fetch_array($result)){
 print $check[LNAME],$check[FNAME]($check[CID]);
 }
  
   /option
/select
  /div/td
  /tr

I think you're missing some option/option tags -- these should be
present around each value extracted from the database, so:

while ($check=mysql_fetch_array($result)){
print
option{$check['LNAME']},{$check['FNAME']}({$check['CID']})/option\n;
}
 

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Problems with mysql_num-rows()

2004-11-01 Thread Ford, Mike
To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm



On 01 November 2004 05:01, Doug Thompson wrote:

 The variables are not being expanded. As a minimum, you need to
   escape the single quotes. $query = SELECT * from user where
  name=\'$userid\' and pass=password(\'$password\')

This is complete BS.  The whole string is in double quotes -- the
presence of single quotes within it has no effect whatsoever on the
expansion of variables, nor is it necessary to escape them.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Convert plain text to HTML tagged text

2004-09-28 Thread Ford, Mike
On 28 September 2004 18:15, [EMAIL PROTECTED] wrote:

 To the list:
 
 I've googled and searched the manual, but I'm still looking
 for a simple solution to a simple problem.
 
 I have a MySQL database of text stories in longtext MySQL
 fields. These stories have simple returns (\r) in them and no
 other formatting. I need to use these stories both for web
 and print production, so I need to be able to get the text
 out of MySQL via PHP and have those returns change to P
 tags. But I also need to keep those extra P tags out of the
 database file so the text can be exported and poured into a
 layout program.
 
 HTMLspecialchars and HTMLentities don't seem like the right
 solution, but maybe I'm missing something. Do I have to use
 regular expressions in PHP as the text is pulled from the database?

http://www.php.net/str_replace should be all you need -- no need for regexps for such 
a simple replace.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] MultSelect ListBox hell!

2004-09-24 Thread Ford, Mike
On 23 September 2004 20:53, Stuart Felenstein wrote:

 So here is what I have:
 
 //Here is defines the field variable and uses
 //CodeCharge function to grab the variable
 $s_Industry = CCGetParam(s_Industry, );
 $s_LocationState = CCGetParam(s_LocationState, );
 $s_TaxTerm = CCGetParam(s_TaxTerm, );
 
 //Here is the parsing of the array.  I'm not sure
 what the $proj variable is for.  I gather it's a
 holder for the array values
 
 if (count($s_Industry)  0 AND is_array($s_Industry)) {
 foreach ($s_Industry as $key = $value) {
 if ($Proj1 != ) $Proj1 = $Proj1.,;
 $Proj1 = $Proj1.'.$value.';
 }
 }

$Proj1 now contains a comma-separated list of the values passed to
$s_Industry, which was filled by the CCGetParam() above.  The above code
block is equivalent to (and would be better coded as):

  if (count($s_Industry)  0 AND is_array($s_Industry)) {
 $Proj1 = '.implode(',', $s_Industry).';
  }

which may look somewhat familiar to you!

 //Parsing next array
 if (count($s_LocationState)  0 AND
 is_array($s_LocationState))
 {
 foreach ($s_LocationState as $key = $value) {
 if ($Proj2 != ) $Proj2 = $Proj2.,;
 $Proj2 = $Proj2.'.$value.';
 }
 }
 //Parsing file array
 if (count($s_TaxTerm)  0 AND is_array($s_TaxTerm)) {
 foreach ($s_TaxTerm as $key = $value) {
 if ($Proj3 != ) $Proj3 = $Proj3.,;
 $Proj3 = $Proj3.'.$value.';
 }
 }

These two blocks are similar for the other two parameters, $s_LocationState
and $s_TaxTerm

 Here is what will be the death of me :)
 First the where condition below is being appended to
 anoher file in my main sql statement (don't ask:))
 CC keeps their code in various sections and files.
 Anyway , if you remember yesterday, it was determined
 that I needed the where condition to be dynamically
 created based on the user input.
 Obviously the code below does nothing of that sort.

Obviously it does, using the lists of values built above.

 So as a start, I'm trying to figure out what I can do
 with this section here (since this is really what
 needs to be changed, I think) to make it all right.
 
 if ($Proj1)
 $VendorJobs-ds-SQL.=  AND (`VendorJobs`.Industry IN (.$Proj1.));

Plug the value for $Proj1 built above into this, and again you have
something that may look very familiar to you.  It's the very same IN clause
I was urging you to use yesterday! ;)

 if ($Proj2)
 $VendorJobs-ds-SQL.=  AND
 (`VendorJobs`.LocationState IN (.$Proj2.));
 if ($Proj3)
 $VendorJobs-ds-SQL.=  AND (VendorJobs.TaxTerm IN (.$Proj3.));
 echo SQL:. $VendorJobs-ds-SQL.br;

So you now have a dynamically built portion of SQL, in $VendorJobs-ds-SQL,
that has a clause like AND x IN ('a','b','c') for each input field that
has any values set.  According to your specs, this could be anywhere up to
six separate clauses.  This seems to be exactly what you wanted, so your
code looks good to go.

To help you understand exactly what's going on here, or in any script or
program you're struggling to interpret, I would recommend two time-honoured
techniques:

(i) Dry running: get out your genuine old-fashioned pen and paper, pretend
you're the PHP interpreter processing this program, and write down the value
of each variable as you work through the code.  Yes, it can be quite
long-winded and tedious, but you really get a tremendous feel for exactly
what's going on.  The number of times I've done this and cursed myself as
I've watched a value going out of range, or not getting set at all, I
couldn't begin to count.

(ii) As a variation of the above, put *lots* of debugging echos in your
script: echo the value of every variable frequently and redundantly -- it
can help sometimes just to have the reassurance that a value really hasn't
changed, even though you know it absolutely shouldn't!!  Again, if you're
struggling with how a script operates this can help you see how values are
built up, and can often show you exactly where a wrong value gets calculated
(and how, and maybe even why).  It's especially important to echo your final
complete SQL statement just before it's executed, so that if it produces an
error message you've got the actual relevant SQL right in front of you.

Hope this helps.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] MultSelect ListBox hell!

2004-09-23 Thread Ford, Mike
On 22 September 2004 18:45, Stuart Felenstein wrote:

 Just to confirm,
 This is what I'm going to start with:

Yeah, I'd say you've pretty much got it, except...
 
 //base sql statement
 $sql = select * from jobs where record_deleted = 'NO' ;
 
 if (isset($_POST['states'])){

Your SQL is going to need some sort of conjunction here, as your WHERE phrase already 
has an initial condition in it.  I'm guessing you'll want an AND, so:

$sql .= 'AND ';

 //check to see if the states is an array
 // multiple items or just one
 if (is_array($_POST['state']))

You've switched from $_POST['states'] to $_POST['state'] -- fix whichever is wrong ;)

 $sql .= state='.implode(' OR state=',
 $_POST['state']).';

Given the conditions you want your WHERE phrase to test, you're going to need more 
parentheses to force the ORs to be evaluated before the ANDs; this is where the IN 
syntax, IMO, is more readable.  So you want either:

$sql .= (state='.implode(' OR state=',$_POST['state']).');

or:

$sql .= state IN ('.implode(',',$_POST['state']).');

 
  }else{
 //$_POST['state'] is not an array
  $sql .= state = '.$_POST['state'].' ;
 }//end if
 
  if (isset($_POST['job'])){
if (isset($_POST['state'])){  $sql .=  AND ; }

And throughout this second block you've used a cut'n'paste of the first block without 
altering ['state'] to ['job'] -- just the sort of oversight that can give you the 
raving heebie-jeebies somewhere down the line if you fail to fix it! ;)

 
 //add in the AND if the state is set
 //check to see if the states is an array
 //multiple items or just one
 
 if (is_array($_POST['state']))
$sql .= state='.implode(' OR state=',
 $_POST['state']).';
 $sql .= );
   }else{
 $_POST['job'] is not an array
  $sql .= job = '.$_POST['job'].' ;
  }
 //end if

Given the moderate complexity of this code, I'd strongly recommend echo-ing out $sql 
immediately before it's used whilst you're in testing mode.  When your query fails, 
you'll already be one step ahead in working out what the problem is.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Using PHP to generate SQL statement

2004-09-23 Thread Ford, Mike
On 23 September 2004 07:47, Ed Lazor wrote:

 I keep looking at the following code and thinking there's
 gotta be a better
 way.  I've been in front of the computer all day tho and I'm drawing
 a blank.  Any ideas?

Seems to me we've just answered a very similar question to this (and I'd be
surprised it there weren't several relevant threads in the list archives).
Nonetheless:

 $sql = select ID from products where ;
 
 if ($webpage-parameter_isset(CategoryID)) {

Two possible approaches that spring to mind are:


  $sql = select ID from products where 1=1;
 
  if ($webpage-parameter_isset(CategoryID)) {
 $sql .=  AND CategoryID = '{$webpage-CategoryID}';
  }

  if ($webpage-parameter_isset(CompanyID)) {
 $sql .=  AND CompanyID = '{$webpage-CompanyID}';
  }

  if ($webpage-parameter_isset(SettingID)) {
 $sql .=  AND SettingID = '{$webpage-SettingID}';
  }

  if ($webpage-parameter_isset(SystemID)) {
 $sql .= AND SystemID = '{$webpage-SystemID}';
  }

Or:

  $where = ''
  foreach (array('CategoryID', 'CompanyID', 'SettingID', 'SystemID')
   as $field):
 if ($webpage-parameter_isset($field)):
$where .= ($where?' AND':''). $field = '{$webpage-$field}';
 endif;
  endforeach;

  if ($where):
 $sql = select ID from products where$where;
 ...
  else:
 // no where information -- major error
  endif;

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] MultSelect ListBox hell!

2004-09-22 Thread Ford, Mike
 -Original Message-
 From: Bastien Koert [mailto:[EMAIL PROTECTED] 
 Sent: 22 September 2004 15:27

[]

 //base sql statement
 $sql = select * from jobs where record_deleted = 'NO' ;
 
 if (isset($_POST['states'])){
//check to see if the states is an array (multiple items 
 or just one

This check isn't really necessary in PHP, since $_POST['state'] will *always* be an 
array if the form field has NAME='state[]', even if only 1 is selected.

if (is_array($_POST['state'])){
  $sql .= (;
  $x = 0;
  foreach ($_POST['state'] as $state)
if ($x == 0){
$sql.= state = '$state' ;
$x=1;
  }else{
 $sql .=  OR state = '$state' ;
 }
 $sql .= );

PHP has the very nice implode function to make this much easier:

$sql = state='.implode(' OR state=', $_POST['state']).';

(If your database supports the IN operator, this is probably even better:
$sql = state IN ('.implode(',', $_POST['state']).'); )

   }else{
  //$_POST['state'] is not an array
  $sql .= state = '.$_POST['state'].' ;
 }//end if
 
 if (isset($_POST['job'])){
   if (isset($_POST['state'])){  $sql .=  AND ; }  //add in 
 the AND if the 
 state is set
   //check to see if the states is an array (multiple items or just one
if (is_array($_POST['job'])){
  $sql .= (;
  $x = 0;
  foreach ($_POST['job'] as $job )
if ($x == 0){
$sql.= job = '$job ;
$x=1;
  }else{
 $sql .=  OR job = '$job ;
 }
 $sql .= );
   }else{
  //$_POST['job'] is not an array
  $sql .= job = '.$_POST['job'].' ;
 }//end if

Ditto for the job field.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services, JG125, James Graham 
Building, Leeds Metropolitan University, Headingley Campus, LEEDS,  LS6 3QS,  United 
Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] MultSelect ListBox hell!

2004-09-22 Thread Ford, Mike
 -Original Message-
 From: John Holmes [mailto:[EMAIL PROTECTED] 
 Sent: 22 September 2004 16:39
 
 From: Ford, Mike [EMAIL PROTECTED]
 if (is_array($_POST['state'])){
 
  This check isn't really necessary in PHP, since 
 $_POST['state'] will 
  *always* be an array if the form field has NAME='state[]', even if 
  only 1 is selected.
 
 But remember that the form comes from the client. Just 
 because you create 
 the form with state[], that doesn't mean I'm going to send 
 it that way. ;)

Yeah, true -- I have a very bad tendency to forget about security considerations like 
that until someone reminds me (often a posting on this list does it ;).  Just because 
I have a well-defined set of well-behaved users...!!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services, JG125, James Graham 
Building, Leeds Metropolitan University, Headingley Campus, LEEDS,  LS6 3QS,  United 
Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] MultSelect ListBox hell!

2004-09-22 Thread Ford, Mike
 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 
 Sent: 22 September 2004 16:45
 
 --- Ford, Mike [EMAIL PROTECTED] wrote:
 
  if (is_array($_POST['state'])){
$sql .= (;
$x = 0;
foreach ($_POST['state'] as $state)
  if ($x == 0){
  $sql.= state = '$state' ;
  $x=1;
}else{
   $sql .=  OR state = '$state' ;
   }
   $sql .= );
  
  PHP has the very nice implode function to make this
  much easier:
  
  $sql = state='.implode(' OR state=', $_POST['state']).';
  
  (If your database supports the IN operator, this is
  probably even better:
  $sql = state IN ('.implode(',', $_POST['state']).'); )
 
 Sorry, cause I know this is probably a stupid
 question, but what block of code does the implode
 statement replace ?

Everything inside the if(is_array()).  Ummm, that should probably still be a
.= operator, then.  There's also some quotes missing in the original
version, so:

if (is_array($_POST['state']))
   $sql .= state='.implode(' OR state=', $_POST['state']).';

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services, JG125, James
Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS,
LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] Re: Checkboxes in a table

2004-08-20 Thread Ford, Mike [LSS]
 -Original Message-
 From: Ford, Mike   [LSS]
 Sent: 21/08/04 01:57

   foreach ($_POST['checkbox'] as $key=$irrelevant):
 // checkbox[$key] was checked
   endif;

OK, it's 2a.m. here and I'm about asleep, whioch is why that last line
didn't read

endforeach;

!!!

Cheers!

Mike

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

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



RE: [PHP-DB] Inserting a ' into mySQL

2004-08-20 Thread Ford, Mike [LSS]
 -Original Message-
 From: Ron Piggott
 Sent: 21/08/04 01:53

[]

 One of the problems I am now having is if the user types an ' into their
 entry --- these ones do not get saved into the mySQL database.

[]

 I can look at this and understand that if an ' is keyed why it wouldn't save 
 and that line would create an error --- How do you work around this? 

That's what mysql_real_escape_string() is for -- 
http://www.php.net/mysql_real_escape_string.

Cheers!

Mike

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



RE: [PHP-DB] I have a CR-LF problem when pulling stuff out of my DB

2004-08-19 Thread Ford, Mike [LSS]
On 19 August 2004 17:02, Michael Cortes wrote:

 ctrl-m is a carriage return.  Does anyone know what ctrl seqence is
 line feed? 

ctrl-j

(CR and LF are ASCII codes 13 and 10, so ctrl+ the 13th and 10th letters of
the alphabet respectively!)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Check Boxes

2004-08-18 Thread Ford, Mike [LSS]
On 18 August 2004 11:24, randy wrote:

 $chkboxes = $_POST['ch'];
 $sql = 'SELECT ';
 foreach($chkboxes as $k = $v)
 {
   $sql .= $v;
   if($k  (sizeof($chkboxes) - 1))
   {
   $sql .= ', ';
   }
 }
 $sql .= ' FROM form';

  $sql = 'SELECT ' . implode(', ', $chkboxes) . 'FROM form';

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Check Boxes

2004-08-18 Thread Ford, Mike [LSS]
On 18 August 2004 15:53, John Holmes wrote:

 Ford, Mike [LSS] wrote:
 
   $chkboxes = $_POST['ch'];
   $sql = 'SELECT ';
   foreach($chkboxes as $k = $v)
   {
 $sql .= $v;
 if($k  (sizeof($chkboxes) - 1))
 {
 $sql .= ', ';
 }
   }
   $sql .= ' FROM form';
  
  
$sql = 'SELECT ' . implode(', ', $chkboxes) . 'FROM form';
 
 Just note that with either solution, someone can post a value of *
 FROM table WHERE 1# and see everything in any table in your database.

I was waiting for someone to come in with a security warning, but knew that whoever it 
was would express it much better than I could ;) -- so, a gold medal to John!!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] OCI8

2004-08-13 Thread Ford, Mike [LSS]
On 13 August 2004 13:29, yannick wrote:

 I have some trouble with Oracle Database and php...
 
 see this code:
 ?
 while (1) {
 $conn=OCILogon($username,$password,$database);

Try OCIPLogon() rather than OCILogon().

 $stmt=OCIParse($conn,select 50 as toto from dual);
 OCIDefineByName($stmt,TOTO,$total);

Not related to your problem, but you don't need that  -- in fact, it's deprecated and 
may, one day, cause a parse error.

 OCIExecute($stmt);
 OCIFetch($stmt);
 echo :::$total:::\n;
 OCILogoff($conn);
 $err=OCIError($conn);
 OCILogoff($conn);
 sleep(10);
 }
  
 
 when i execute it, the number of fd on ocius.msg is growing. but
 there is only 1 connection at database.
 
 Can someone help me ?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Date problem: data is current as of yesterday

2004-07-03 Thread Ford, Mike [LSS]
-Original Message-
From: Karen Resplendo
To: [EMAIL PROTECTED]
Sent: 02/07/04 19:36
Subject: [PHP-DB] Date problem: data is current as of yesterday

The database queries all the sources at night after everyone has gone
home. That means the data was current as of yesterday. This little
snippet below returns yesterday's date, except that the first day of the
month returns 0 for the day. Now, I know why this is happening, but I
can't find out how to fix it (in VBA or SQL Server I would just say,
date()-1:
 
$today = getdate(); 
$month = $today['month'] ; 
$mday = $today['mday'] -1; 
$year = $today['year']; 
echo Data is current  as of  b$month $mday, $year/bbr;

--

The mktime() function is your friend for this kind of date arithmetic. For
example, this is one possible way to do what you want:

  $yesterday = mktime(12, 0, 0, $today['mon'], $today['mday']-1,
$today['year']);
  echo Data is current as of b.date(F j, Y, $yesterday);

(Note the use of time 12:00:00 to avoid daylight savings oddities!)

The examples on the date() and mktime() manual pages may suggest other
possibilities to you.

Cheers!

Mike
 


-
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!

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



RE: [PHP-DB] More problems with searching

2004-07-01 Thread Ford, Mike [LSS]
On 01 July 2004 18:36, Justin Patrin wrote:

 On Thu, 1 Jul 2004 12:28:46 -0500, Shiloh Madsen
 [EMAIL PROTECTED] wrote:
  
  After the very kind help i was given last night I have the query
  being built right, however the query does not work. Just to
  refresh, the gentlemen who had helped me suggested creation of a
  query that looks like: 
  
  SELECT * FROM table1 where 1 or cat or dog...and so forth. Now,
  this query is building fine, but the where 1 is causing it to
  return rows even if it has none of the search terms. When i run it
  in sql without the where 1 it works as it should, but with that, i
  get all rows returned. Is there a way i can reword this query or am
  I doing something wrong? 
  
  this was Mr Holmes's solution (in part):
  $query = SELECT * FROM keyword WHERE 1 
  $words = explode(' ',$_GET['search_text']);
  foreach($words as $word)
  { $query .=  AND keyword = '$word' ; }
 
 Shouldn't that be OR?

... and, if it should, that should be a 0 instead of a 1 (although I'm not a huge fan 
of this technique!).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] [PHP]: session problem

2004-06-25 Thread Ford, Mike [LSS]
On 24 June 2004 16:44, H. J. Wils wrote:

 this is the code, but this code works on my hosting provider but not
 on my own server. I think i have to change settings in php.ini but
 dont know which...
 first page:
 
 session_start();
 
 include connect.php;
 include functions.php;
 
   $user= $_GET[email];
   $ww = $_GET[ww];
 
   $check_user_query = select id,email, password from user where
 email='$user' and password='$ww';
   $check_user_res = mysql_query($check_user_query) or
 die(mysql_error().: $check_user_query);
 
   if (mysql_num_rows($check_user_res) == 1){
  //user is ingelogd
 
$userdata =
 mysql_fetch_array($check_user_res);
$sid=session_id();
$uid=$userdata[id];
$_SESSION['logged_in'] = true;
$_SESSION['sid'] = $sid;
$_SESSION['user'] = $uid;
 
$dt = date(Y-m-d H:i:s);
 
  header(location: user.php?action=0);
   }else{
  header(location: user.php?action=9);
   }

Redirecting like this will not pass the session id in the URL if that is
necessary, which it would be if cookies are not being used.  Since you say
it works for you from your provider's system but not your local one, this
suggests that your provider has session.use_cookies turned on, but you have
it turned off.

If this is so, you can solve your immediate problem by turning that option
on in your php.ini, but the redirects will still not work correctly for
anyone who has cookies turned off in their browser.  If you are bothered
about this, you need to make use of the handy-dandy SID constant that PHP
helpfully provides, thusly:

  header(Location: user.php?action=0.SID);

or, if you're a tidy-URL geek, something like:

  header(Location: user.php?action=0.(SID?.SID:));

(BTW, notice the correct spelling of the Location header, with a capital
L; and, yes, others are right when they say it should be a full absolute
URL.  These things have been known to matter to some browsers, so it's best
to make a habit of getting them right!)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Image / file uploader

2004-04-30 Thread Ford, Mike [LSS]
On 30 April 2004 01:10, Craig Hoffman wrote:

 When I put single quotes in the PHP_SELF and I get this error:
 Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE,
 expecting T_STRING or T_VARIABLE or T_NUM_STRING
 
 and I can't use double quotes because its in an echo statement.  What
 am I missing?

Curly braces:

   echo (form method='post' action='{$_SERVER['PHP_SELF']}'
encType='multipart/form-data'

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] quotations in value field

2004-04-14 Thread Ford, Mike [LSS]
On 14 April 2004 15:21, Mikael Grön wrote:

 On Apr 14, 2004, at 15:14, H-Mac Moderator wrote:
 
  Mikael-
  
  I suspect you want htmlspecialchars, Not stripslashes. See:
  http://us4.php.net/manual/en/function.htmlspecialchars.php

 Well, I guess a combination of htmlspecialchars and some
 other function
 to convert it back, before it gets sent of in the _plain text mails_.

You don't need to convert it back -- that happens automatically when the
form is resubmitted.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] How to redirect after a valid login

2004-03-15 Thread Ford, Mike [LSS]
On 14 March 2004 02:14, Benjamin wrote:

 What kind of error does it give you?  Because in the snippet you gave
 us you wrote
 
   include mainmenu.php; // Which gives me an error !
 
 And that should give you an error because it should be
 
 include( mainmenu.php );  //note parenthesies

Nope.  Perfectly valid without the parentheses -- do it all the time.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] win32 Timestamp problem

2004-03-10 Thread Ford, Mike [LSS]
On 09 March 2004 20:36, J. Kevin C. Burton wrote:

 Hey all, after reading documentation on the Win32 bug
 regarding Timestamps
 not being able to go prior than 1970..
 
 I am in need of a way to calculate someone's age.
 
 Has anyone found a fix or workaround for this bug? Or a way
 to calculate age
 without using the timestamp?
 
 They say that v5 of PHP will fix this issue, but I've been using every
 stable release of PHP5 and it's a no go.

No, it won't.  It's an operating system issue, and nothing PHP *can* fix.

 Any help would be appreciated.

Have you looked at the Calendar extension? http://www.php.net/calendar

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Two Column Sort

2004-03-05 Thread Ford, Mike [LSS]
On 04 March 2004 19:04, [EMAIL PROTECTED] wrote:

 On Thu, 4 Mar 2004 10:55:20 -, Ford, Mike   [LSS]
 [EMAIL PROTECTED] wrote:
 
  On 03 March 2004 17:07, [EMAIL PROTECTED] wrote:
  
   Here's the php code for the sort command:
   
   echo tddiv align='center'font size='3'bCBC a
   href='contributions22504.php?sort_field=cbc,
   net_receiptssort_order=desc'
   target='_self'font size='2'Sort/a/b/font/div/td\n;
   
   Here's the basic setup that begins the script:
   
   # get sort order (if any) passed to script
   $sort_field = $_REQUEST['sort_field'];
   if (! $sort_field) {$sort_field = State;}
   $sort_order = $_REQUEST['sort_order'];
   if (! $sort_order) {$sort_order = asc;}
  
  Well, you're going to need an order phrase that looks like this:
  
  ORDER BY CBC DESC, NET_RECEIPTS ASC
  
  so you may need a little rethink about how you're passing those
  arguments. 
  
  Cheers!
  
  Mike
  
 Thanks, but you're past my level.  Can you show me the exact coding I
 should use?

Well, not really, as there are several ways you could approach this and the one you 
choose will depend on your exact application, personal preference, and whether there's 
an r in the month ;)

  Apparently I can't just replace SORT_FIELD=CBC,
 NET_RECEIPTSSORT_ORDER=DESC with ORDER BY CBC DESC, NET_RECEIPTS ASC

Well, you can, but the question is more whether that's what you want to do.

My original point was that if your URL has a query string that looks like

?sort_field=cbc, net_receiptssort_order=asc

then you're going to get your variables set like this:

$sort_field = 'cbc, net_receipt';
$sort_order = 'asc';

but you need to interpolate an additional 'desc' into the sort order string to get the 
CBC column to sort the way you want, so that the query ends up like:

SELECT ... ORDER BY cbc DESC, net_receipts asc

Whilst this is possible using PHP string functions (or regexes), it doesn't seem like 
the easiest or most flexible method.  A couple of alternatives off the top of my head 
might be:

(i) just pass the full ORDER BY phrase (...?sort_order=cbc desc, net_receipts asc)

(ii) pass multiple parameters each with one column name and sort order (either 
...?sort1=cbc descsort2=net_receipts asc, or ?sort[]=cbc descsort[]=net_receipts asc)

(iii) pass a parameter with a set of column names, and another with a matching set of 
sort orders (...?sort_field=cbc,net_receiptssort_order=desc,asc).  This requires you 
to break each set apart (by explode()ing on the comma, say), then reassemble them into 
a suitable ORDER BY phrase.  This option probably also requires you to do the most 
validation, as you have to decide what happens when one set has more items in it than 
the other, or is misformed in some other way, and so on.

Of course, you might decide that column CBC always wants to be sorted descending 
regardless, in which case looking for it in the parameters and interpolating the 
required DESC keyword is probably the way to go after all...!!

At the end of the day, only you can decide which of these is appropriate (or if some 
other solution is), but I hope I've given you some pointers to help you make that 
decision.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] ocistatement

2004-03-05 Thread Ford, Mike [LSS]
On 05 March 2004 09:38, Torsten Lange wrote:

 Hello,
 I receive an array from an OCIFetchStatement() and want to
 address its
 elements by indices, which fails. The original select has two columns.
 How do I have to visualize that array? I want to load it into an
 option list.  I tried also some examples with
 while(list...), but it
 can not work until I don't know the structure.

If your column names are, say, ID and NAME, then the array looks like this:

Array ('ID' = Array ('id1', 'id2', 'id3', ...),
   'NAME' = Array ('name1', 'name2', 'name3', ...)
  )

So the rows of your query result are:

$arr['ID'][0], $arr['NAME'][0]
$arr['ID'][1], $arr['NAME'][1]
$arr['ID'][2], $arr['NAME'][2]
... etc. ...

HTH

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Two Column Sort

2004-03-05 Thread Ford, Mike [LSS]
On 05 March 2004 14:49, Ken Colburn wrote:

 Mike -
 
 I've tried your options and I get either an error message, no
 sorting, or sorting that does not do both columns with B's at the
 top.  It's my understanding that I must still use sort_field and
 sort_order (though I tried just ORDER BY).  It does seem simple, but
 nothing 
 works.  It would
 be a great help if you could plug something (anything) into
 the url that
 works at
 http://congress.techpolitics.org/contributions22504.php/
 Hope this isn't
 asking too much.

Right, this is what I plugged in that I think gives the result you're asking
for:

 
http://congress.techpolitics.org/contributions22504.php?sort_field=cbc%20des
c,%20net_receiptssort_order=asc

I've had to contrive the parameters a bit to work around the way you're
processing them, but hopefully you get the idea.

Just to over-egg the pudding a bit, I thought I'd extend the idea slightly
and give you one more example:

 
http://congress.techpolitics.org/contributions22504.php?sort_field=cbc%20des
c,state%20asc,%20net_receiptssort_order=desc

Cheers!

Mike

P.S. please keep the discussion on the list so others can chip in if they
want -- and any final resolution gets into the list archives for anyone
reading the thread in the future.

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Two Column Sort

2004-03-04 Thread Ford, Mike [LSS]
On 03 March 2004 17:07, [EMAIL PROTECTED] wrote:

 I'm re-raising an issue I never quite resolved which has become more
 critical.  I want to sort a table on two columns.  There are
 about 440
 rows of which about 400 are blank in the first sort column (CBC); the
 other rows show B in that column.  When I use the coding
 below, the two
 column sort takes place but the rows designated B are at the
 bottom of the
 (long) table and I want them at the top.  Neither asc nor desc
 accomplishes this (just reverses the second factor order,
 still at the
 bottom below the blanks).
 
 Here's the php code for the sort command:
 
 echo tddiv align='center'font size='3'bCBC a
 href='contributions22504.php?sort_field=cbc,
 net_receiptssort_order=desc'
 target='_self'font size='2'Sort/a/b/font/div/td\n;
 
 Here's the basic setup that begins the script:
 
 # get sort order (if any) passed to script
 $sort_field = $_REQUEST['sort_field'];
 if (! $sort_field) {$sort_field = State;}
 $sort_order = $_REQUEST['sort_order'];
 if (! $sort_order) {$sort_order = asc;}

Well, your going to need an order phrase that looks like this:

ORDER BY CBC DESC, NET_RECEIPTS ASC

so you may need a little rethink about how you're passing those arguments.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] oracle: fetch a query result into an array

2004-02-18 Thread Ford, Mike [LSS]
On 18 February 2004 18:22, Torsten Lange contributed these pearls of wisdom:

 
   while(OCIFetch($stmt))
  {
  $column_name = OCIResult($stmt,'COLUMN_NAME');

missing [] here -- should be:

  $column_name[] = OCIResult($stmt,'COLUMN_NAME');

  $counter++; }

You might also want to look up ocifetchstatement
(http://www.php.net/ocifetchstatement).

Cheers!

Mike

-- 
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] Inserting querydata as default value in form

2004-01-28 Thread Ford, Mike [LSS]
On 28 January 2004 18:05, Georg Herland wrote:

 Hi!
 
 I hav made a simle page to insert update and delete data in MYSQL.
 I try to put existing data into a standard form field to make editing
 easyer: input name=link TYPE=TEXT cols=40 value=$query_data[4]
 Problem is when the text data contains a space ie Look
 here. Then only the
 first word show.

Oh dear, it's HTML 101 time again.

Quote your attribute values!

input name=link TYPE=TEXT cols=40 value=?php echo $query_data[4]
?


Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Quick Question: Line Breaks

2004-01-09 Thread Ford, Mike [LSS]
On 09 January 2004 03:58, Jacob Hackamack wrote:

 Hello,
 
 I have a couple of quick questions.  When I execute this code on my
 php page (I know that the .PSD image isn¹t web ready, but Safari does
 what I need it to do :) ) it displays the entire source as one line. 
 Is there anyway to have it be broken.  I have read places (internet
 sites) that say that the following solutions might work:
 echo OE¹;\n\n
 echo OE¹\n\n ;
 echo OE\n\n¹;
 
 None of them seem to work, am I doing something wrong?
 
 
 echo 'meta http-equiv=content-type content=text/html;
 charset=utf-8'; echo 'html';
 echo 'head';
 echo 'title';
 echo 'FilmCanister Desktops';
 echo '/title';
 echo '/head';
 echo 'body';
 echo 'center';
 echo 'img src=images/Rotating.psd';
 echo 'h2';
 echo 'Coming SoonDesktop Pictures (2.83 GB Worth)/h2'; echo
 '/center'; echo '/body';
 echo '/html';

The reason you have it all on one line is because you haven't echoed any
newlines.  You have a number of options to do this.  As there is no variable
interpolation anywhere in there, you could just break out of PHP and do it
as straight HTML:

...
?
meta http-equiv=content-type content=text/html; charset=utf-8
html
head
title
FilmCanister Desktops
/title
/head
body
center
img src=images/Rotating.psd
h2
Coming SoonDesktop Pictures (2.83 GB Worth)/h2
/center
/body
/html
?php
...

Or you could echo the whole thing in one go (since you can have newlines in
a PHP string):

echo 'meta http-equiv=content-type content=text/html; charset=utf-8
html
head
...
/body
/html
';

If you plan to have variables in there at some point, you can either use
?php echo $var ? segments, or use a heredoc:

echo END
meta http-equiv=content-type content=text/html; charset=utf-8
html
head
body
center
img src=images/$name.psd
...
/body
/html
END;

or, again, you could use a multi-line string -- but this time double-quoted
to give interpolation (but note that you now have to escape all your
embedded double quotes):

echo 
meta http-equiv=\content-type\ content=\text/html; charset=utf-8\
html
head
body
center
img src=\images/$name.psd\
...
/body
/html
;

Which route you choose is pretty much personal taste -- personally, if I
have a page that's mostly straight HTML with not much PHP code, I write it
as HTML with embedded PHP snippets, but I know some people think that looks
weird or ugly...!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] inserting dynamic drop down menu data into mysql

2004-01-07 Thread Ford, Mike [LSS]
On 07 January 2004 15:12, Duane Barnes contributed these pearls of wisdom:

 I'm having a problem with a standard html form.  I'm using a
 php function to
 populate a drop down menu on a standard form.  I want the
 contents of the
 submitted form to insert into a mysql table. All of the
 variables are inserted correctly except for the data from the
 drop down 
 menu.  For some
 reason it will only insert the first word in the variable.
 It cuts off
 everything after the frist word.

This sounds like an unquoted multi-word attribute problem.

[snip]

 function build_dropdown() {
 $sql = select category from categories ORDER BY category;
 $result = mysql_query($sql) or DIE(mysql_error(). -
 .mysql_errno()); 
 
 while($row = mysql_fetch_array($result, MYSQL_ASSOC)) {   
 extract($row); $output .= option
 value=$category$category/option;

Yup, here it is -- quote the argument to the value= attribute, and everything should 
be hunky dorey.

Cheers!

Mike

-- 
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] Search Query

2003-12-18 Thread Ford, Mike [LSS]
On 18 December 2003 05:26, Ng Hwee Hwee wrote:

 Dear all,
 
 i need help with my search query statement.. what is wrong
 with my code?

Nothing obvious that I can see, except a little inefficiency.  Where do
$keyword and $table come from? -- is this a register_globals issue?

 
 snip
   $word = split( , $keyword);
   $num_words = count($word);
   $word_str = ;
   $criteria = ;
 
   for ($i=0; $i$num_words; $i++)
   {
   if ($i)
  $word_str .= and colName like '%.$word[$i].%' ; 
  else $word_str .= colName like '%.$word[$i].%' ;
 } 
   $word_str .= and col2 = '$foo' ;
 
   $criteria .= $word_str ;

I'd replace all of the above with:

$criteria = colName like '%
   . str_replace(' '
, %' and colName like '%
, $keyword)
   . %'
   .  and col2 = '$foo' 

   $table .= db_table;
 
   $query = select * from .$table. where .$criteria; /snip
 
 when i try to echo $query, i get ---  select * from where
 
 and so of course MySQL gives me an error 1064 near ' where '
 
 what happened?

What's your error_reporting level?  HAve you tried cranking it up to E_ALL
to see if any relevant warnings are being generated that you're not
currently seeing?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] How do I get quotes around strings to display?

2003-10-22 Thread Ford, Mike [LSS]
On 22 October 2003 00:41, [EMAIL PROTECTED] wrote:

 $fieldarray = array(one,Two, three, four);
 $line = \.implode(\,\,$fieldarray) .\;

Eck, eck, eck!!  Definitely a construct crying out for single quotes rather than 
double:

$line = ''.implode(',',$fieldarray) .'';

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Dynamic sites, to appear static...?

2003-09-04 Thread Ford, Mike [LSS]
On 04 September 2003 11:18, [EMAIL PROTECTED] wrote:

 I've been building web sites that use a database backend for
 some time
 now.
 I typically use the format.
 http://www.mysite.com/index.php?page=contact
 http://www.mysite.com/index.php?page=home
 http://www.mysite.com/index.php?page=aboutus
 etc
 
 My most recent job wants to use differnt pages, so the search engines
 will pick up the url's as clearly defined, and not dynamic, as I
 normally do...
 
 Is there a way I can still admin the pages, and allow my client to
 add/delete pages, but use static links , without '?page=home' etc...
 
 I hope I've made sence...
 I've discused this with my client, and he said a friend of
 his claimed
 'that webserver software should have a module or plugin that
 will do this'
 I've never heard of that, have I been living under a rock?

Not even a module (well, except for php!) or plugin.  If you're using Apache as your 
Web server with mod_php, anything looking like path information following the script 
name is passed to your script in $_SERVER['PATH_INFO'].  Take a look at, for example:

http://www.lmu.ac.uk:8082/lco/php/support.php/visitors/welcome

Note the position of support.php in that URL -- this URL is processed by running 
support.php with $_SERVER['PATH_INFO'] set to '/visitors/welcome', which the script 
decodes to decide what it actually needs to display.

There's nothing particularly special in my httpd.conf file to make this work -- the 
relevant section is simply:

Directory /lco/php/
AddType application/x-httpd-php .php
Order allow,deny
/Directory

As a refinement, if you don't want people to see the .php on the script name, so that 
the URL could be (say):

http://www.lmu.ac.uk:8082/lco/php/support/visitors/welcome

you can tweak this to:

Directory /lco/php/
AddType application/x-httpd-php .php
DefaultType application/x-httpd-php  # or ForceType if you prefer
/Directory

Then you either need a relevant AliasMatch or Rewrite so the above still gets to call 
support.php, or you simply upload all your scripts to the server with their bare name 
to match.

I believe IIS is capable of passing PATH_INFO information, too, if you set it up 
right, but as I don't use it I can't be sure (or tell you how it might work!).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] include_path problem

2003-09-03 Thread Ford, Mike [LSS]
On 03 September 2003 01:32, Bruce Levick contributed these pearls of wisdom:

 Well yes I have restarted my webserver, and the php.ini file
 is under the
 windows directory (shown in phpinfo page) and I am
 definatelty editing it.
 
 The current value for my include_path is .;c:\php\includes
 which is different to whats showing up on the phpinfo page and
 also 
 the error that is
 coming up.
 
 The wierd thing is I can change anything else in the php.ini
 file and it
 updates on the phpinfo page. Just not the include_path
 attributes. Its as if
 I am not changing the correct service as there is nothing in
 the php.ini
 file that relates to the directory .;c:\php4\pear.

Couple more stabs in the dark, then:

- Check there is only one entry for include_path.
- Make sure it's not commented out! (No ; at the start of the line.)

Also, just to be absolutely sure, can you post exactly what your phpinfo shows for the 
php.ini setting?

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] Consider upgrading MySQL client .... how do I do this?

2003-09-03 Thread Ford, Mike [LSS]
On 03 September 2003 10:51, Vinoaj Vijeyakumaar contributed these pearls of
wisdom:

 Hi,
 
 Just this morning I upgraded to MySQL 4.1.0 alpha and PHP
 4.3.3.  I'm also
 running Apache 2 on a WinXP machine.  The main reason for the
 upgrade was so that I could make use of 4.1.0's sub-select
 feature rather than attempt learning JOINs.  It is now 7 hours
 later, and I keep getting the following error when trying to
 connect to my database: 
 
 Warning: mysql_connect(): Client does not support
 authentication protocol
 requested by server. Consider upgrading MySQL client
 
 
 My question, therefore, is - is there a way to upgrade the
 MySQL client in PHP 4.3.3?  If not, what are the alternatives
 (apart from reverting back to MySQL 4.0.x of course).

I don't believe so, although I'm not absolutely certain as I don't use MySQL
myself.  My understanding, however, is that support for MySQL 4.1 will not
be available until PHP 5.0.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] include_path problem

2003-09-03 Thread Ford, Mike [LSS]
On 03 September 2003 14:10, Bruce Levick contributed these pearls of wisdom:

 There is an include_path for unix and an include_path for
 windows. They both
 differ slightly but aren't of the same value that is being
 returned in the
 php info page or the error that I am receiving.
 
 This is the info displayed for my php.ini file. My OS is on G:.
 
 G:\WINDOWS\php.ini
 
 This is the Include_path directory shown in the phpinfo page.
 .;c:\php4\pear 
 
 Thanks very much for your help on this. Let me know if you
 need me to post
 anything else that might help.

Well, I think I'm about out of ideas then -- so long as the ini file you're editing is 
G:\WINDOWS\php.ini, this all looks spot on.

Just as a very last resort, can you post an extract from your G:\WINDOWS\php.ini that 
shows the lines which set include_path, plus a few lines either side -- just to check 
that there's nothing in their context that might be mucking things up.

I suppose it might also be interesting to see the entire line from your phpinfo that 
shows the include_path settings (i.e. both master and local values).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] include_path problem

2003-09-02 Thread Ford, Mike [LSS]
On 02 September 2003 08:00, Bruce Levick wrote:

 Hi guys,
 I am re-developing the look and feel of a site and trying to set it up
 localy. Its all setup and ready to go but I am getting a
 pear.php include
 failure.
 
 Warning: main(/PEAR.php): failed to open stream: No such file
 or directory
 in G:\Inetpub\wwwroot\DB.php on line 25
 
 Fatal error: main(): Failed opening required '/PEAR.php'
 (include_path='.;c:\php4\pear') in G:\Inetpub\wwwroot\DB.php
 on line 25
 
 
 The include path c:\php4\pear is incorrect. This is showing up in my
 phpinfo file and I can't seem to get it to change in my
 php.ini file. There
 are include_path options in the php.ini file but nothing like
 the directory
 path in the error I am receiving.

OK; '.;c:\php4\pear' is the default value for include_path, so PHP is not
seeing your edited php.ini.  Let's try a couple of basic questions (forgive
me if these are obvious to you, but you haven't covered them in your
message):

1) Did you restart your Web server after editing php.ini?

2) Where does the phpinfo() output say your php.ini file should be (look at
the Configuration File (php.ini) Path entry right near the top)?  And is
your php.ini there?

If the answer to both of these is yes, and you're still having problems, get
back to the list with some more detail and maybe someone will have some
other bright ides.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] To slash or not to slash....

2003-09-02 Thread Ford, Mike [LSS]
On 02 September 2003 16:45, Craig Cameron wrote:

 Ok simple problem I hope.
 
 
 Have the following code, used to store the location and a few
 details about meeting minutes.
 
 snip
   $connection = mssql_connect(server,user,password);
   mssql_select_db(DocumentManager,$connection);
 
   $AlteredMinutesLocation =
 str_replace(\\,\,$MinutesLocation);
 
   $SQL_STRING = INSERT INTO tblMeetingMinutes
 VALUES('$Date','$Type','$AlteredMinutesLocation','$Centre');
 
   $Result = mssql_query($SQL_STRING,$connection);
   mssql_close($connection);
 
 /snip


This script cannot possibly run -- it should have a parse error.  Due to the
way PHP handles backslashes in literal strings, the function call

   str_replace(\\,\,$MinutesLocation);

has a string containing 1 (one) backslash, and an unterminated string
containing
a double-quote and then everything up to the next double-quote (which is
actually part-way through the next line).

 Problem is the backslashes. When I collect the filepath
 ($Location) it puts \\ into the db. However, when I change
 this it stops dead. Basically due to the escape
 charateristics of the backslash. I can get around this with
 single quotes of course but can't put these in the SQL_STRING
 as it falls down there then!

I'm not sure I exactly follow what you're saying, but yes, there is
definitely a problem caused by the escape characteristics of the \.
However, I'm not sure it's where you think it is.  The problem I can see in
your supplied script is that you haven't properly expressed in the replace()
call strings representing \\ and \.  Since \ is the escape character, every
\ has to be escaped by itself, so the correct way of writing this is:

  $AlteredMinutesLocation = str_replace(,\\,$MinutesLocation);

(Note that single-quotes make no difference here, as ' (and \ itself, of
course) are just about the only characters escaped by \ in a single-quoted
string!!)

None of this should be relevant to the interpolation of
$AlteredMinutesLocation into $SQL_STRING, since variable interpolation just
inserts whatever is in the variable, without any backslash escaping or other
fancy footwork.

Or another option might be stripslashes().

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Beta 2 of plPHP released.

2003-08-29 Thread Ford, Mike [LSS]
On 29 August 2003 05:27, Joshua D. Drake wrote:

 Hello,
 
   Beta 2 of plPHP has been released. This version contains many bug
 fixes. For example, if you write bad plphp code and try to
 execute it,
 the code will no longer crash PostgreSQL ;).

It would be nice if you told us what plPHP actually is as part of this message -- save 
those of us who have no interest in whatever it is having to make an unnecessary click 
through to your Web site.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] weird php error

2003-08-29 Thread Ford, Mike [LSS]
On 29 August 2003 06:39, OpenSource wrote:

 Hi guys,
 
 This is weird to me..
 I got this script
 --- ?php
 
 if ($_GET[login] == 'forgot')
 {
 echo Sorry  I forgot my password;  
 } else { echo you are good to go; }
 
  
 -
 when ran, it gives me this error
 
 
 Notice: Use of undefined constant login - assumed 'login' in
 G:\Inetpub\wwwroot\test\index.php on line 3

This is because you haven't quoted the array subscript -- PHP thinks you're
trying to refer to a constant called login, but on not finding that assumes
that you meant the string 'login' instead.  To suppress this notice, supply
the subscript correctly as a string:

if ($_GET['login'] == 'forgot')

 
 Notice: Undefined index: login in G:\Inetpub\wwwroot\test\index.php
 on line 3

This means that there was no login= parameter on the URL that called this
script.  If this is a permissible condition, you need to allow for it in
your code.  One way is simply to suppress the error message with the @
operator:

if (@$_GET['login'] == 'forgot')

Another is to do more explicit checking:

if (isset($_GET['login'])  $_GET['login'] == 'forgot')

Which you use is really down to personal preference.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Populating an array from mysql db

2003-08-28 Thread Ford, Mike [LSS]
On 28 August 2003 17:25, mike karthauser wrote:

 on 28/8/03 5:00 pm, CPT John W. Holmes at
 [EMAIL PROTECTED] wrote:
 
   Thanks for this - I ended up rehashing my query to this:
   
   ?
   $result = mysql_query(SELECT * FROM dates WHERE bookcode =
   '$bookcode' ORDER BY date1,$db); 
   
   
   // loop to populate array
   
   $myrow = mysql_fetch_array($result);
   
   $i = 1;
   while ($i = '30') {
   
   if ($myrow['date'.$i]  '-00-00')
  
  You're making PHP do some extra work here. You're testing to see if
  one string is greater than another... how can strings be greater
  than or less than? Why don't you just check for $myrow['date'.$i]
  != '-00-00' ?? 
 
 Thanks. I'll make your change.

While you're about it, remove the quotes from

while ($i = '30') {

as well -- saves a conversion from string to integer each time round the loop (well, 
unless PHP optimises it out of the loop, but why take the chance?!).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Maximum execution time of 30 seconds exceeded

2003-08-14 Thread Ford, Mike [LSS]
On 11 August 2003 07:02, Michael Cortes wrote:

 I am using the Konqueror browser and browing to
 http://localhost/my.php
 
 Howerver, the script I wrote, doing various queries and lookups,
 inserts, etc..  takes a while to complete.   That is fine with
 me.  I'll wait. However, the server and/or browser will not wait.
 
 I believe the server is the one which will not wait because I have
 one echo line at the beginning of the script which put a title
 Udate Students athe the top center of the page and that writes then
 there is a pause while the queries are run and then I get the
 following error in my browser 
 
 Fatal error: Maximum execution time of 30 seconds exceeded in
 /var/www/html/student_info/ps2follett.php on line 139

That's your PHP script timing out.  Take a look at
http://www.php.net/set_time_limit

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Searching a file for text surrounded by brackets

2003-07-16 Thread Ford, Mike [LSS]
 -Original Message-
 From: Jamie Saunders [mailto:[EMAIL PROTECTED]
 Sent: 16 July 2003 11:20
 
 Hi, I need a way of searching a file for text between two 
 brackets, below
 is an example of a couple of lines from the file I'm searching:
 
 trtdfont size=2{L_LOGIN}/font/td/tr
 trtdfont size=2{L_LOGOUT}/font/td/tr
 
 So I'll need to search the above for text between the '{' and 
 '}' brackets
 and read each into an array.

preg_match_all() (see http://www.php.net/preg_match_all) should do what you
want -- something like:

 preg_match_all('/{([^}])+}/', $file_contents, $matches);

should give you an array of matched tags (excluding the braces) in
$matches[1].

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] problem with starting a session

2003-07-15 Thread Ford, Mike [LSS]
 -Original Message-
 From: Ahmed Abdelaliem [mailto:[EMAIL PROTECTED]
 Sent: 15 July 2003 08:54
 
 i have a problem with starting a session in the page that 
 validates the user 
 input and sends it tothe database,
 when the user clicks register he gets this error
 
 Warning: session_start(): Cannot send session cookie - 
 headers already sent 
 by (output started at 
 c:\inetpub\wwwroot\ads4u\data_valid_fns.php:25) in 
 c:\inetpub\wwwroot\ads4u\register_new.php on line 89
 
 Warning: session_start(): Cannot send session cache limiter - headers 
 already sent (output started at 
 c:\inetpub\wwwroot\ads4u\data_valid_fns.php:25) in 
 c:\inetpub\wwwroot\ads4u\register_new.php on line 89
 
 
 and here is the code i wrote :

There must be  approximately 73 lines before this, as the error message says
the session_start() is on line 89.  Your problem is that one of those lines
is an include/require for data_valid_fns.php, and line 25 of that file
outputs something that can't be output before the session_start().  Take a
look there and work out how you can fix that.
 
 ?
  $email=$HTTP_POST_VARS['email'];
  $passwd=$HTTP_POST_VARS['passwd'];
  $passwd2=$HTTP_POST_VARS['passwd2'];
  $title=$HTTP_POST_VARS['title'];
  $name1=$HTTP_POST_VARS['name1'];
  $name2=$HTTP_POST_VARS['name2'];
  $phone=$HTTP_POST_VARS['phone'];
  $mobile=$HTTP_POST_VARS['mobile'];
  $address1=$HTTP_POST_VARS['address1'];
  $address2=$HTTP_POST_VARS['address2'];
  $town=$HTTP_POST_VARS['town'];
  $pb=$HTTP_POST_VARS['pb'];
  $country=$HTTP_POST_VARS['country'];
  $occupation=$HTTP_POST_VARS['occupation'];
 
 session_start();


Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] error checking question

2003-06-27 Thread Ford, Mike [LSS]
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: 26 June 2003 20:22
 
 What I would like to do is somehow have a redundant error 
 check on the server
 side and then display an error message above the form on the 
 main page should
 fields be left blank or forbidden characters entered. Since I 
 have access to the
 $_POST['variables'] on the form processing page, I've already 
 written some code
 to detect the presence of error characters, etc...and no 
 query is performed if
 there is an error.  But how do I pass a flag variable back 
 to the main page to
 echo an appropriate message above the form?

One simple way:

   header(Location: http:/your.server.name/path/to/main_page.php?err=$errcode);
   exit();

And then emit an error in main_page.php if $_GET['err'] is set.

If you're using sessions, another way would be to set an error variable in the session.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


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



RE: [PHP-DB] latest version of php only cgi?

2003-06-27 Thread Ford, Mike [LSS]
 -Original Message-
 From: Doug Finch [mailto:[EMAIL PROTECTED]
 Sent: 26 June 2003 21:12
 
 Is the newest version of php 4 only available as a cgi-based program?
 DF

No.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] moving though an array..SOLVED

2003-06-26 Thread Ford, Mike [LSS]
 -Original Message-
 From: Aaron Wolski [mailto:[EMAIL PROTECTED]
 Sent: 26 June 2003 16:12
 
 Solved my problem!
 
 Here's the code in case anyone really cares :P
 
   $col = explode(,,$threadsColumn);
 
   $col_search = (;
   for ($i=0;$icount($col);$i++) {
   
   $col_search .= $col[$i]. LIKE
 '%$threadsName%';
   if ($i != (count($col) - 1)) {
   $col_search .=  OR ;
}
   }
 
   $col_search .= );

Yes, that's about how I'd do it -- you may, however, be interested in this variation 
on the theme:

$col = explode(,,$threadsColumn);

$col_search = array();

foreach ($col as $col_name) {   
$col_search[] = $col_name LIKE '%$threadsName%';

$col_search = ( . implode(' OR ', $col_search) . );


A completely different approach might be to do it like this:

$col_search = (
 . str_replace(',',
  LIKE '%$threadsName%' OR ,
 $threadsColumn)
 .  LIKE '%$threadsName%'
 . );

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] setting session variables via a form

2003-06-16 Thread Ford, Mike [LSS]
 -Original Message-
 From: Hutchins, Richard [mailto:[EMAIL PROTECTED]
 Sent: 16 June 2003 17:08
 
   session_start();
   session_register(isRegistering);
 
   $_SESSION[isRegistering] = true;

B't!  If you're using the $_SESSION array, then you MUST NOT use 
session_register() and friends.

(Well, ok, maybe that's overstating it a bit, but you still shouldn't do it!)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Help Please!! Oracle/PHP connection

2003-06-11 Thread Ford, Mike [LSS]
 -Original Message-
 From: Matthew Moldvan [mailto:[EMAIL PROTECTED]
 Sent: 11 June 2003 01:03
 
 Have you tried the built in Oracle functions in PHP?
 
 http://us3.php.net/oracle

That's only for Oracle up to version 7.

For Oracle 8 or 9, use the OCI extension http://www.php.net/oci8.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

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



RE: [PHP-DB] Is this query even possible?

2003-06-10 Thread Ford, Mike [LSS]
 -Original Message-
 From: Susan Ator [mailto:[EMAIL PROTECTED]
 Sent: 10 June 2003 16:18
 
  This is what I am trying to do:
  
  if ($FUNC==(USERPOST) || $FUNC==(MODU)) {
  $sql = UPDATE newdacs
  SET emailfwd='$emailfwd',
  mformat='$mformat',
  filter_code='$filter_code'
  if ($FUNC=='USERPOST') {
  ,unote='$unote'
  }
  WHERE user_id='$user_id';
  $set_newdacs_result = mysql_query($sql) or print
  mysql_error();
  }

Well, you're burying a PHP conditional inside what should be the SQL query,
which ain't gonna work very well.  Try separating it out -- two possible
ways are to (i) use the ?: conditional operator, like this:

$sql = UPDATE newdacs
.  SET emailfwd='$emailfwd'
. ,mformat='$mformat'
. ,filter_code='$filter_code'
. ($FUNC=='USERPOST' ? ,unote='$unote' : '')
.  WHERE user_id='$user_id';

or (ii) a fully-blown if(), like this:

$sql = UPDATE newdacs
.  SET emailfwd='$emailfwd'
. ,mformat='$mformat'
. ,filter_code='$filter_code';
if ($FUNC=='USERPOST'):
$sql .= ,unote='$unote'
endif;
$sql .=  WHERE user_id='$user_id';

There are probably umpteen other ways of approaching this -- use whatever
floats your boat! ;)


Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 



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



RE: [PHP-DB] Count database-values

2003-06-10 Thread Ford, Mike [LSS]
 -Original Message-
 From: Becoming Digital [mailto:[EMAIL PROTECTED]
 Sent: 10 June 2003 12:15
 
 I screwed up my own code.  Silly me.  It should read:

Surely your first attempt is the right one?  There's only ever going to be 1 Total, so 
why waste a while loop trying to read more than one result row?
 
 $query = SELECT SUM(bedrag) AS Total FROM finance WHERE 
 posneg = 'af';
 $result = mysql_query( $query );
 while ( $total = mysql_fetch_array( $result ) )
 {
 $total = $total['Total'];
 }
 
 Edward Dudlik
 Becoming Digital
 www.becomingdigital.com
 
 
 - Original Message - 
 From: Becoming Digital [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, 10 June, 2003 06:43
 Subject: Re: [PHP-DB] Count database-values
 
 
  So far no problems, but I want to count all these values.
  I tried with SUM but with the following code it doesn't work:
 
  $squery = SELECT SUM(bedrag) AS Total FROM finance WHERE 
 posneg = 'af';
 
  any suggestions how to do? I want to store it in a 
 variabele ($total)
  so I can echo it. (E.g.: $total = 93.63 in this case)
 
 If you want the total, you need to do something like the following:
 
 $query = SELECT SUM(bedrag) AS Total FROM finance WHERE 
 posneg = 'af';
 $result = mysql_query( $query );
 $total = mysql_fetch_array( $result );
 $total = $total['Total'];
 

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Is this query even possible?

2003-06-10 Thread Ford, Mike [LSS]
 -Original Message-
 From: Matthew Moldvan [mailto:[EMAIL PROTECTED]
 Sent: 10 June 2003 16:50
 
 As for the line breaks, I've used SQL formatted that way before and it
 hasn't cause me any problems.

It's a matter of preference, but I prefer to keep my query strings as lean as possible 
-- bear in mind that this version:

 $sql = UPDATE newdacs
 SET emailfwd='$emailfwd',
 mformat='$mformat',
 filter_code='$filter_code';

will include not only the linebreaks but also all the leading whitespace on every line.

Personally, I like the technique of breaking my query up logically onto multiple 
lines, but I also prefer not to include unnecessary whitespace in the constructed 
query.  In addition, it seems to me that the repetitive inclusion of $sql .=  on 
every line is not only distracting but also slightly inefficient, as you perform a 
concatenation and assignment for every line -- by using the form I showed in my 
previous response, you can reduce this to just a concatenation per line, and a single 
assignment:

$sql = UPDATE newdacs
  . SET emailfwd='$emailfwd',
  . mformat='$mformat',
  . filter_code='$filter_code';

Of course, this is all completely IMHO, and I wouldn't say that any of the other ways 
of doing it is absolutely wrong.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] while - if - problem

2003-06-05 Thread Ford, Mike [LSS]
 -Original Message-
 From: Earl [mailto:[EMAIL PROTECTED]
 Sent: 04 June 2003 22:04
 To: PHP-DB
 
 FYI
 this was beginning to bug me out... so I decided to try the 
 trim function
 and walla... it worked.
 
 Thanks for ya'll assistance.

I was going to say this even before you added the trim() calls in , but this
really does look like an excellent situation for using the switch construct
(just look at all those trim() calls and array accesses you save!):


while($cols=ifx_fetch_row($eventQuery)) 
{
  switch (trim($cols['out_type']))
  {
case '0': 
  $r_away['linetype']='L';
  $r_home['linetype']='L';
  break;
  
case '1':
  $r_away['linetype']='H';
  $r_home['linetype']='H';
  break;
  }
  
  switch (trim($cols[s_acro]))
  {
case 'CF':
case 'PF': 
  $r_away['sport']='1';
  $r_home['sport']='1';
  $s_lt='PS';
  $t_lt='TP';
  break;

case 'PB':
case 'CB':
  $r_away['sport']='2';
  $r_home['sport']='2';
  $s_lt='PS';
  $t_lt='TP';
  break;

case 'B':
  $r_away['sport']='3';
  $r_home['sport']='3';
  $s_lt='ML';
  $t_lt='TM';
  break;
   
case 'H':
  $r_away['sport']='4';
  $r_home['sport']='4';
  $s_lt='ML';
  $t_lt='TM';
  break;
  }

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Array Pointer

2003-06-04 Thread Ford, Mike [LSS]
 -Original Message-
 From: Ian Fingold [mailto:[EMAIL PROTECTED]
 Sent: 03 June 2003 16:58
 
 Ok I'm trying to write this function to up date some fields 
 in my database
 so i'm grabbing some info from a query and throwing it into 
 an array (with
 mysql_fetch_array).
 
 one of the values i'm puting into that array is the table id. I'm then
 comparing the table id with the value of $i in my loop. Now 
 my problem is
 when I loop through and the table id is not equal to $i I 
 need to add 1 to
 $i but I need to move the array pointer back one.
 
 In the code below I used prev() but i'm getting warnings 
 about the Passed
 variable is not an array.
 http://55yardline.cflmain.com/55main/2003/fantasy/tests/update.php
 
 I'm thinking that prev() must not view an array fetch from a 
 database the
 same or something. But what else can I use besides prev() to 
 rewind the
 pointer by 1?
 
 Thanks,
 
 
 ?php
 
 include function.php;
 connect1();
 
 //query roster database and put results into an array.
 $num1 = mysql_query(SELECT * FROM roster);
 $num2 = mysql_fetch_array($num1);
 //set i to zero
 $i = 0;
 
 //start loop to determine if $i matches the current roster id
 do {
   $i = $i + 1;
   if ($num2[ros_id] == $i) {
 //if a match is found, query the fan_roster database 
 where the play_id =
 $i
 //and put the results into a array
 $upd = mysql_query(SELECT * FROM fan_roster WHERE play_id='$i');
 $updr = mysql_fetch_array($upd);
 //loop through the passing field and add them up
 do {
 $passing = $passing + $updr[pass_yrd1];
 } while($updr = mysql_fetch_array($upd));
 
 //Print feedback
 echo Player:$i total Passing: $passing $updr[play_id]br;
 
 //update the roster table with the total $passing where ros_id=$i
 $upd1 = mysql_query(UPDATE roster SET pass_yrd='$passing' WHERE
 ros_id='$i');
 //reset passing for next loop
 $passing = 0;
   } else {
 //if there isn't a match, add 1 to $i
 $i = $i + 1;
 
 //print feedback
 echo $i no playerbr;
 
 //put the array pointer back one for next loop
 $num2 = prev($num2[ros_id];

(1) prev() takes an array as its argument, not an individual element, so prev($num2) 
would be syntactically correct (but I doubt it's what you really mean).
(2) anyway, this whole statement is pointless as you immediately do:

   }
 } while($num2 = mysql_fetch_array($num1));

Which promptly overwrites the value of $num2 you just put there!

What are you *really* trying to do?
 ?
 
 
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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



RE: [PHP-DB] PHP sort from a database variable..?

2003-06-04 Thread Ford, Mike [LSS]
 -Original Message-
 From: heilo [mailto:[EMAIL PROTECTED]
 Sent: 03 June 2003 23:35
 
 sorry, needed some time to hack this one ::)
 
 as your print_r shows that you have to sort an array which 
 includes objects
 (in this case an ingress-class - whatever this is). i tried 
 to simulate your
 environement and endet up with this:

This looks a bit like a sledgehammer to crack a nut -- why not just use
usort, like this:

   function obj_date_compare($a, $b) {
  return strcmp($a-publisertLang, $b-publisertLang);
   }

   ...

   if($ingresser = array_merge($i1 ,$i2))
   {
  $ingresser = usort($ingresser, 'obj_date_compare');
  listIngresser($ingresser);
   }

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Multiple inserts revisited

2003-05-29 Thread Ford, Mike [LSS]
 -Original Message-
 From: Becoming Digital [mailto:[EMAIL PROTECTED]
 Sent: 28 May 2003 23:38
 
 My other option, as I saw it, was to loop through the items, 
 appending value
 data to the query text with each iteration.  If that seems 
 cryptic, here's a
 basic idea of what I mean.
 
 ?
 $query = INSERT INTO specials VALUES (
 foreach ( $specials as $item ) {
 $query = substr_replace( $query, $item., , strlen( $query ) );
 }
 $query = substr_replace( $query, ), strlen( $query )-2 );
 ?
 
 If $specials was an array with the values spec1, spec2, and 
 spec3, the final
 value of $query would be:
 INSERT INTO specials VALUES (spec1, spec2, spec3)

I'm actually slightly dubious that this query *does* do what you want, but if you've 
double-checked it and it does, then this is a somewhat more compact way of producing 
it:

  $query = INSERT INTO specials VALUES ( . implode(',', $specials) . ')'

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Re: deleting records using a checkbox

2003-03-21 Thread Ford, Mike [LSS]
 -Original Message-
 From: Paul Burney [mailto:[EMAIL PROTECTED]
 Sent: 20 March 2003 15:22
 
 on 3/20/03 1:45 AM, olinux at [EMAIL PROTECTED] appended the 
 following bits to
 my mbox:
 
  [ and ] are illegal characters. #javascript
 
 I'm coming into this a bit late, so I'm not sure exactly what 
 you wish to
 do.
 
 You can use JavaScript to refer to checkbox items in the format:
 
 document.forms[formindex].elements[elementindex].property

You can also use the form and element names in the brackets, so:

  document.forms[formname].elements[elementname].property

This is more human-friendly, and doesn't require you to change the index
number if you add or remove elements (or forms!).

However, if you prefer, you don't even need the .forms or .elements
parts.  Since, in JavaScript, *by definition*

  x.y === x[y]

if you have a form element defined as:

  form name=example ... 

  input type=checkbox name=delete ... /

   /form

you can refer to this as

   document.example.delete

or

   document.example[delete]

or

   document[example].delete

or

   document[example][delete]

And, of course, an obvious extension of this is that if the input element on
your form is:

  input type=checkbox name=delete[] ... /

you can refer to this as:

   document.example[delete[]]

This is just a basic recipe -- add your own ingredients, and mix and cook to
suit!

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Re: Does Php support Flash files ?

2003-03-20 Thread Ford, Mike [LSS]
 -Original Message-
 From: Matthew Moldvan [mailto:[EMAIL PROTECTED]
 Sent: 19 March 2003 18:32
 
 I am assuming English isn't your first language.
 
 Yes, fuck is definitely swearing, cursing, or whatever else 
 you would like
 to call it.  And yes, it is considered rude in our culture. :D

Not only rude, but, to someone of my age and upbringing, extremely offensive.  Even 
though it has become more commonly used over the 30 years since the one and only time 
I used it in the presence of my father, I still wince mentally every time I hear or 
see it.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



RE: [PHP-DB] Final Date Question :-)

2003-02-20 Thread Ford, Mike [LSS]
 -Original Message-
 From: Chris Payne [mailto:[EMAIL PROTECTED]]
 Sent: 20 February 2003 01:52
 
 OK here is a final date question.  It's complex (Atleast to 
 me :-( but i'm totally stumped.  Here's what I need to do.  
 Say September is Summer and October is winter, now getting 
 the dates for each month is easy.
 
 Now, say in September each day is worth $50 but in October 
 each day of the month is worth $70.
 
 Now finally, say you choose 2 days in September and 2 in 
 October (And this is what stumps the living crap out of me - 
 pardon les francais :-) the system has to know He chose 2 in 
 september so that's $100 in total, but hold on, wait a 
 minute, he chose 2 in october and these are worth $140 for 2 
 days) - so how can I get it to do that?  I know how to get it 
 to do the september, but finding that it ran into October and 
 that Octobers 2 days are worth more than septembers just 
 totally goes over my head :-(

Well, you must have a start date and an end date -- and you must be able to
work out in which season each one lies.  So check whether the start date is
in the same season as the end date -- if it is, all is hunky-dory; if not,
then you have to work out how many days are in each season, calculate the
subtotals for each group of days, and then add them back together to get a
grand total.

I would commend to you the construction mktime(12, 0, 0, 0, $month+1, $year)
for finding the timestamp for midday of the last day of $month in $year --
works even when $month represents December!  (Note: you need to watch out
for daylight savings timeshifts if appropriate; you may prefer to do all
your day-offset calculations using an appropriate time of day with
gmmktime() so as to eliminate DST shift vagaries entirely!)

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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




RE: [PHP-DB] More help with mysql -- solved (bizarre)

2003-02-18 Thread Ford, Mike [LSS]
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: 18 February 2003 08:26
 
 If I remove the '|| die' part from the mysql_query() 
 statement, it works
 fine. This is bizarre, but there it is.
 
 ie, if I have:
 
 $result = mysql_query(SELECT * FROM SOME_TABLE);
 
 it works.
 
 If I have:
 
 $result = mysql_query(SELECT * FROM SOME_TABLE) || die 
 (Unable to execute
 SQL query);
 
 it doesn't work. It gives me:  Supplied argument is not a valid MySQL
 result resource

The || and OR operators, although both doing a Boolean or, have different priorities, 
so:

  $result = mysql_query(...) or die(...);

is the same as

  ($result = mysql_query(...)) or die(...);

whilst

  $result = mysql_query(...) || die(...);

is the same as

  $result = (mysql_query(...) || die(...));

In the first case, the result of mysql_query() is assigned into $result, and if it 
returns FALSE the die() is performed.  In the second case, the result of applying the 
|| operator to the mysql_query() and the die() is assigned to $result; because PHP 
uses short-circuit evaluation, the die() is still only executed if mysql_query returns 
FALSE, but the || operator still returns a simple Boolean to be assigned to $result -- 
which, if the die() hasn't fired, must be TRUE (which PHP generally prints as 1).  QED.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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




RE: [PHP-DB] Re: problems with variables

2003-02-04 Thread Ford, Mike [LSS]
 -Original Message-
 From: Mark [mailto:[EMAIL PROTECTED]]
 Sent: 04 February 2003 14:38
 
 Just a quick correction... if the q part is static, I believe you
 should use $(q$i) rather than ${$q . $i} 

Well, actually, I think you want ${'q'.$i} -- or even ${q$i}

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

 --- [EMAIL PROTECTED] wrote:
  OK, now I get it:
  
  $input = 'input type=hidden name=q' . $i . ' value=' .
   ${$q . $i} . ' . \n;
  
  print($input);
  
  This one isn't well known so don't forget it!!  ;)
  
  Larry
  
  
  Marcel [EMAIL PROTECTED] wrote:
   Sorry, I see that I've got the a's and q's mixed up.
   I'll try to clarify it some more by giving an example with 2
  variables.
  
   $q1 = first_var;
   $q2 = second_var;
   for($i=1;$i=2;$i++)
   {
  echo input type=\hidden\ name=\q$i\ value=\$q$i\\n;
   }
   The output should now be:
   input type=hidden name=q1 value=first_var
   input type=hidden name=q2 value=\second_var
  
   Hope you can help me,
   Marcel
  
  -- 
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 
 =
 Mark Weinstock
 [EMAIL PROTECTED]
 ***
 You can't demand something as a right unless you are 
 willing to fight to death to defend everyone else's right to 
 the same thing.
 -Stolen from the now-defunct Randy's Random mailing list.
 ***
 
 __
 Do you Yahoo!?
 Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
 http://mailplus.yahoo.com
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 

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




  1   2   >