[PHP] RE: [PHP-DB] [PHP] PHP Database Problems -- Code Snippets - Any more Ideas?

2012-05-04 Thread Gavin Chalkley
Ethan,

You have been given advise and break down on your code.

Have you taken the advise given?

Which part of the code isn't working? Not which chunk, but break it down and
show which part

BR,

Gav

-Original Message-
From: Ethan Rosenberg [mailto:eth...@earthlink.net] 
Sent: 04 May 2012 15:10
To: php-db-lists.php.net; php-general@lists.php.net
Subject: [PHP-DB] [PHP] PHP  Database Problems -- Code Snippets - Any more
Ideas?

I am sending this again to see if more ideas for solution of this problem
are available.

Ethan
===
Dear list -

Sorry for the attachment.  Here are code snippets ---

GET THE DATA FROM INTAKE3:

 function handle_data()
 {
global $cxn;
$query = select * from Intake3 where  1;



if(isset($_Request['Sex']) trim($_POST['Sex']) != '' )
{
 if ($_REQUEST['Sex'] === 0)
 {
$sex = 'Male';
 }
 else
 {
$sex = 'Female';
 }
}

 }

 $allowed_fields = array
(  'Site' =$_POST['Site'], 'MedRec' = $_POST['MedRec'], 'Fname' =
$_POST['Fname'], 'Lname' = $_POST['Lname'] ,
  'Phone' = $_POST['Phone'] , 'Sex' = $_POST['Sex']  ,
'Height' = $_POST['Height']  );

 if(empty($allowed_fields))
 {
   echo ouch;
 }

 $query = select * from Intake3  where  1 ;

 foreach ( $allowed_fields as $key = $val )
 {
if ( (($val != '')) )

 {
$query .=  AND ($key  = '$val') ;
 }
$result1 = mysqli_query($cxn, $query);
 }

 $num = mysqli_num_rows($result1);
 if(($num = mysqli_num_rows($result1)) == 0)
 {
?
 br /br /centerbp style=color: red; font-size:14pt; No
Records Retrieved #1/center/b/style/p ?php
 exit();
 }

DISPLAY THE INPUT3 DATA:

  THIS SEEMS TO BE THE ROUTINE THAT IS FAILING 

 centerbSearch Results/b/centerbr /

 centertable border=4 cellpadding=5 
cellspacing=55  rules=all  frame=box
 tr class=\heading\
 thSite/th
 thMedical Record/th
 thFirst Name/th
 thLast Name/th
 thPhone/td
 thHeight/td
 thSex/td
 thHistory/td
 /tr

?php

while ($row1 = mysqli_fetch_array($result1, MYSQLI_BOTH))
{
 print_r($_POST);
global $MDRcheck;
$n1++;
echo br /n1 br /;echo $n1;
 {
if (($n1  2)  ($MDRcheck == $row1[1]))
{
 echo 2==  ;
 echo $MDRcheck;
 echo td $row1[0] /td\n;
 echo td $row1[1] /td\n;
 echo td $row1[2] /td\n;
 echo td $row1[3] /td\n;
 echo td $row1[4] /td\n;
 echo td $row1[5] /td\n;
 echo td $row1[6] /td\n;
 echo td $row1[7] /td\n;
 echo /tr\n;
}
elseif (($n1  2)  ($MDRcheck != $row1[1]))
{
 echo 2!=  ;

 echo $MDRcheck;


 continue;
}
elseif ($n1 == 2)
{

 define( MDR ,  $row1[1]);
 echo br /row1 br;echo $row1[1];
 echo tr\n;

 $_GLOBALS['mdr']= $row1[1];
 $_POST['MedRec'] = $row1[1];
 $MDRold = $_GLOBALS['mdr'];
 echo td $row1[0] /td\n;
 echo td $row1[1] /td\n;
 echo td $row1[2] /td\n;
 echo td $row1[3] /td\n;
 echo td $row1[4] /td\n;
 echo td $row1[5] /td\n;
 echo td $row1[6] /td\n;
 echo td $row1[7] /td\n;
 echo /tr\n;
}

 }
}

?

SELECT AND DISPLAY DATA FROM VISIT3 DATABASE

?php
 $query2 = select * from Visit3 where  1 AND (Site = 'AA')  AND (MedRec
= $_GLOBALS[mdr]);
 $result2 = mysqli_query($cxn, $query2);
 $num = mysqli_num_rows($result2);


 global $finished;
 $finished = 0;


 while($row2 = mysqli_fetch_array($result2, MYSQLI_BOTH))
 {
global $finished;
echo tr\n;
echo td $row2[0] /td\n;
echo td $row2[1] /td\n;
echo td $row2[2] /td\n;
echo td $row2[3] /td\n;
echo td $row2[4] /td\n;
echo td $row2[5] /td\n;
echo td $row2[6] /td\n;
echo /tr\n;

 }

echo /table;

ENTER MORE DATA:

 function More_Data()
 {
$decision = 5;
?

 Do you Wish to Enter More Data?
 form method=post action=
 centerinput type=radio name=decision value=1 /Yes 
input type=radio name=decision value=0 /No/centerbr /
 centerinput type=submit value=Enter more Data //center
 input type=hidden name=next_step value=step10 /
  /form

?php
 } //end 

[PHP] RE: [PHP-DB] PHP Database Problems

2012-05-02 Thread Gavin Chalkley
Ethan,

Some coding you are using would be helpful (as far as i am aware attachments
are not support on the mailing list's)

Gav

-Original Message-
From: Ethan Rosenberg [mailto:eth...@earthlink.net] 
Sent: 02 May 2012 19:54
To: php-db-lists.php.net; php-general@lists.php.net
Subject: [PHP-DB] PHP  Database Problems

  have a database

mysql describe Intake3;
++-+--+-+-+---+
| Field  | Type| Null | Key | Default | Extra |
++-+--+-+-+---+
| Site   | varchar(6)  | NO   | PRI | |   |
| MedRec | int(6)  | NO   | PRI | NULL|   |
| Fname  | varchar(15) | YES  | | NULL|   |
| Lname  | varchar(30) | YES  | | NULL|   |
| Phone  | varchar(30) | YES  | | NULL|   |
| Height | int(4)  | YES  | | NULL|   |
| Sex| char(7) | YES  | | NULL|   |
| Hx | text| YES  | | NULL|   |
++-+--+-+-+---+
8 rows in set (0.00 sec)

mysql describe Visit3;
++--+--+-+-++
| Field  | Type | Null | Key | Default | Extra  |
++--+--+-+-++
| Indx   | int(4)   | NO   | PRI | NULL| auto_increment |
| Site   | varchar(6)   | YES  | | NULL||
| MedRec | int(6)   | YES  | | NULL||
| Notes  | text | YES  | | NULL||
| Weight | int(4)   | YES  | | NULL||
| BMI| decimal(3,1) | YES  | | NULL||
| Date   | date | YES  | | NULL||
++--+--+-+-++

and a program to enter and extract data.

I can easily extract data from the database. However, if I try to enter
data, it goes into the incorrect record.  Following are some screenshots.
The program is attached.  [pardon the comical names.  This is a test, and
any resemblance to true names is not intentional]

Let us say that I wish to deal with Medical Record 1:


This it data from Intake3:
Site Medical Record First Name Last Name Phone Height Sex History AA 1
David Dummy 845 365-1456 66 Male c/o obesity. Various treatments w/o success

This is data from Visit3:
Index Site Medical Record Notes Weight BMI Date
2322 AA 1 Second Visit. 170 27.4 2010-01-20
2326 AA 1 Third visit. Small progress, but pt is very happy. 165
26.6 2010-02-01


I then request to enter additional data:

Site Medical Record First Name Last Name Phone Height Sex History
AA 10003 Stupid Fool 325 563-4178 65 Male Has been convinced by his 
friends that he is obese. Normal BMI = 23.
Index Site Medical Record Notes Weight BMI Date

Notice that it is entered into record 10003

The data is First Try

Index Site Medical Record Notes Weight BMI Date
2590 AA 10003 First Try 189 31.4 02 May 2012

Help and advice, please.

Thanks.

Ethan



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



Re: [PHP] Boolean Assignment Operator

2009-02-02 Thread Gavin Hodge
Wow, thanks for the quick replies!

I hadn't realised that  was purely a bitwise operator.

In the strongly-typed Java world,  works as a non-lazy (exhaustive?)
boolean operator so it has to return a boolean for boolean inputs.
Thats the difference here, and Robert got it in one.

Gavin.

PS. A code restructure isn't really appropriate here. The original
executes several SQL statements inside a transaction and needs to know
whether to commit or rollback at the end. The example was simplified
to get the point across but thanks for the suggestions.

On Tue, Feb 3, 2009 at 12:26 AM, Edmund Hertle
edmund.her...@student.kit.edu wrote:
 2009/2/2 Robert Cummings rob...@interjinn.com

 On Tue, 2009-02-03 at 00:07 +1100, Gavin Hodge wrote:
  In Java / C# / C,
  $bool = $anotherBool;
  is shorthand for
  $bool = $bool  $anotherBool;
 
  So = forces a reference assignment?

 No, = forces reference assignment. = works as you have written.

 Cheers,
 Rob.

 Oh yeah... sorry, mixed it up...
 -eddy


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



[PHP] Boolean Assignment Operator

2009-02-02 Thread Gavin Hodge
Hi,

I'm fairly new to PHP, having migrated from the Java / C# world.

I wrote some code similar to the following:

$success = true;
$success = operation1();
$success = operation2();

if ($success === true) {
operation3(); // depends on 1 and 2 being successful
}

This didn't work as expected. After a bit of digging I found:
* The = operation isn't mentioned anywhere in the PHP documentation
* The = function seems to work as expected, however the following is
observed...
   $success = true;
   $success = true;
   print $success == true; // outputs 1
   print $sucesss === true; // no output
* The 'or' assignment operator |= causes no errors but doesn't work.

Can any PHP gurus explain why the = operator works at all, and why
=== seems to fail afterwards?

Cheers,
Gavin.

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



Re: [PHP] Boolean Assignment Operator

2009-02-02 Thread Gavin Hodge
In Java / C# / C,
$bool = $anotherBool;
is shorthand for
$bool = $bool  $anotherBool;

So = forces a reference assignment?

On Tue, Feb 3, 2009 at 12:03 AM, Edmund Hertle
edmund.her...@student.kit.edu wrote:
 2009/2/2 Gavin Hodge gavin.ho...@gmail.com

 Hi,

 I'm fairly new to PHP, having migrated from the Java / C# world.

 I wrote some code similar to the following:

 $success = true;
 $success = operation1();
 $success = operation2();

 if ($success === true) {
operation3(); // depends on 1 and 2 being successful
 }

 This didn't work as expected. After a bit of digging I found:
 * The = operation isn't mentioned anywhere in the PHP documentation
 * The = function seems to work as expected, however the following is
 observed...
   $success = true;
   $success = true;
   print $success == true; // outputs 1
   print $sucesss === true; // no output
 * The 'or' assignment operator |= causes no errors but doesn't work.

 Can any PHP gurus explain why the = operator works at all, and why
 === seems to fail afterwards?

 Cheers,
 Gavin.

 Hey,
 never heard of the |= operator. So I think php does not support it.
 I cannot say how = works in Java or C# but as of php it works like that
 (IMO) (reference instead of copy):
 $var1 = test1;
 $var2 = $var1;
 $var3 = $var1;
 $var1 = test2;
 echo var1; // test2
 echo var2; // test1
 echo var3; // test2



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



Re: [PHP] page suck attack

2008-05-21 Thread Gavin M. Roy
Search engines indexing your site?
On Wed, May 21, 2008 at 11:54 AM, robert [EMAIL PROTECTED] wrote:

 Hi
 Every so often my site is attacked in which all URLS on my site are
 retrieved in the span of minutes. What is this called?? I mean what do I
 google for? I don't know where to begin.

 I'm not sure if I am going to implement such at thing but I would like to
 be able to research it to know my options.

 thank you
 robert

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




Re: [PHP] Parsing Poor XML into to PHP

2007-09-17 Thread Gavin M. Roy
I'm not sure, but perhaps tidy can fix the broken elements of the xml
file... I don't remember if it will close your quotes or just drop the
element from the tag.

On 9/17/07, John Taylor-Johnston [EMAIL PROTECTED] wrote:

 Pour examples of xml, but this is what I want to do. I have a quiz.

 BASICALLY How do EXTRACT THE Contents and Values of these tags into
 strings and arrays I can work with.

 Depending upon the students answer, compared to the criterion below, I
 need to calculate a value = x/1. The score could very well be rounded
 down to 1/1, but at least each student will get the feedback, if a
 particular piece of feedback applies to the, If not, it will not appear
 on their evaluation sheet.
 I can pseudo cod ehtis in my head, but am wondering where to get
 started. Can someone help me take Instructions/Instrudtions into a
 string for example?
 Then take Criterion[0] through nmax = [5] into two arrays:
 CriterionValue and CriterionComment, as well as feedback 0=5 and
 organised the into arrays.

 The rest, I think I can do.

 John

 InstructionsTake the sentence below and transform it into a
 Information Question./Instructions
 QuestionHarry Potter went to Hogwarts School of Wizardry./Question
 AnswerWhere did Harry Potter go? /Answer



 Criterion name=Criterion[0] value=1Where did Harry Potter go to
 school?Criterion
 FeedbackThe answer was the exact answer we expected.)/Feedback
 Criterion name=Criterion[1] value=.9Where did Harry Potter go to
 school ?Criterion
 FeedbackThere was a syntax error using the ? question
 mark.)/Feedback
 Criterion name=Criterion[2] value=.2Where Criterion
 FeedbackThe answer contained the correct Question word.
 $Criterion[2]./Feedback
 Criterion name=Criterion[3] value=.2Where didCriterion
 FeedbackThe answer contained in $Criterion[3]./Feedback
 Criterion name=Criterion[4] value=.2Where did HarryCriterion
 FeedbackThe answer contained in $Criterion[4]./Feedback
 Criterion name=Criterion[5] value=.2Where did Harry goCriterion
 FeedbackThe answer contained in $Criterion[5]./Feedback



 Unforgivable stuff:



 Criterion name=Criterion[6] value=-.2Hogwarts School of
 WizardryCriterion

 FeedbackNo need to include the complement in a question that requires
 a complement./Feedback

 Criterion name=Criterion[7] value=-.2go at schoolCriterion

 FeedbackGo to school not go at school/Feedback








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




Re: [PHP] About MYSQL/PHP Shopping Cart's Product Quantity Change Input Forms

2007-09-14 Thread Gavin M. Roy
Name all your input boxes the same thing, and include a similar level hidden
input:
input type=hidden name=sku[] value=abc123 /
input type=text name=qty[] value=1 /
input type=hidden name=sku[] value=abc321 /
input type=text name=qty[] value=2 /

on your POST


$_POST['sku']  $_POST['qty'] will be arrays, and the ordering will be the
same so you can be sure of what index position/sku the qty is for.


On 9/14/07, Ji H. Park [EMAIL PROTECTED] wrote:

 *The question: How would you have multiple text input forms (on
 shopping cart page) with different inputted data (product quantities)
 submitted for querying the database (for changing the quantity of
 multiple products in the shopping cart at the same time)?***

 *Here is an ideal example to clarify the matter:*
 When a customer wants to change quantities of multiple products all at
 once in the shopping cart, all the quantities has to be changed at the
 same time just by clicking a button called (e.g. Update Quantity).

 *Issue*: Currently I have update quantity buttons for each product,
 which isn't convenient.

 I would appreciate any tips, techniques, comments, or reference to any
 website regarding this issue at your repository, thanks!



Re: [PHP] Public Announcement

2007-09-10 Thread Gavin M. Roy
On 9/10/07, Sascha Braun - CEO @ Braun Networks
[EMAIL PROTECTED] wrote:

 - The Google standard, of websites describes, that Query URL's
 like ?param1=XYZparam2=123 or as in $_SERVER['QUERY_STRING']
 are not human readable, which makes them not acceptable as valid
 content links.

Those are indeed SEO friendly, but it by no means is The Google standard

 - Yes, my system is the only application framework worldwide
 with its capabilities.

That's a fairly big claim, you've compared other application
frameworks?  Everything you've been talking about, btw has hinted
towards it being a CMS, not a framework.

 I hope I answered all your questions.

I think the biggest question is why post an announcement without
linking to that which you are announcing.  In addition, seeing a
working site (unlike braun-networks.com) using it would probably be a
good idea before drumming up interest.

Also you mention not using mod_rewrite.  If you're using Apache and
mod_php, are you using Error Documents?  Auto-generating html pages
(or yuck - php pages) ? Methodology is worth more to the technical
than concepts or bragging rights.

Regards,

Gavin

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



Re: [PHP] mail() takes too much time

2007-09-02 Thread Gavin M. Roy
You might want to consider a few things:

Queueing your email in a database table and sending it out in a
separate process.

or

Finding a mail daemon that will queue quickly for you and not send
directly on adding to the queue.

I use the first of the two options and it works quite well for us.

Gavin

On 9/2/07, shiplu [EMAIL PROTECTED] wrote:
 Hello everybody,

 I am maintaining a social network site.
 there each user can send other mail.
 these mails are not real mail rather message entry to database.
 I added a new feature so that every message is sent to me (admin/webmaster)
 via email (real e-mail).
 I used mail function.
 THis is a simple mail function. all it does sends mail with the message as
 the mail body to my address.
 Thats it. no extra complexity.
 But the problem is I got the mail very late. after 4-6 hours. That is  huge
 time difference.
 I shouldn't take more than 3-5 mins.
 Do you know the reason?
 my mail code is here,
 
 $headers  = MIME-Version: 1.0\r\n;
 $headers .= Content-type: text/html; charset=iso-8859-1\r\n;
 list($myname,$mydomain)=preg_split(/\@/,$myemail,2);
 $headers .= From: $myname $myemail\r\n;
 mail([EMAIL PROTECTED], message from XXX to YYY, $message_content,
 $headers);
 

 --
 shout at http://shiplu.awardspace.com/

 Available for Hire/Contract/Full Time


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



[PHP] [Job] Developer Position [50-100k] (New Hope, PA)

2007-08-27 Thread Gavin M. Roy
Are you tired of working on the same types of web apps?  Are you
looking for more of a challenge where you can put your code-fu to its
test working in a high-traffic, open-source friendly environment?  Can
you tackle any problem put in front of you, hacking your way through
problems you've not previously encountered?

myYearbook.com is looking to fill a primarily PHP development position
that reports directly to the CTO.  Applicant should have a strong
development background and problem solving skills, be a good
communicator and be willing to take direction.  This position is out
of our mainline development team and is for working on special
projects, be it infrastructure related, working on pre-existing open
source applications we use, bleeding edge development or
proof-of-concept applications.

Perks include being paid well to work on open source projects, free
gym membership, company stock options, health  dental insurance, and
don't forget pushing your development skills and knowledge in
different directions.

Requirements:

 * Strong knowledge of PHP and PostgreSQL
 * Some background in database design
 * Ability to demonstrate more than a base level knowledge of XML,
XSL, XHTML, CSS, JavaScript
 * Familiarity with Linux as a server or desktop
 * Past experience with SVN or other version control systems
 * Knowledge of C, C++ and other languages such as Ruby or Java a plus
 * Should not be intimidated by doing things you haven't done before
 * Solid work record with excellent references

This job is full-time, on-site in New Hope, PA.  Unfortunately we can
not sponsor H1-B visas.  We have a great office atmosphere and
benefits to match.  We are very invested in the Open Source community
and this position is a great way to leverage your open-source interest
into a important role in our organization.  You should be willing to
relocate and if you fit this role, we'll help pay for you to do  so.

Salary commensurate with experience.

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



Re: [PHP] Re: PHP 5.1 CVS Interface Question

2005-03-02 Thread Gavin Roy
Stolen from a oo reference site (who's URL I no longer have handy):

An object interface--or simply interface--defines methods that can be
implemented by a class. Interfaces are declared like classes, but
cannot be directly instantiated and do not have their own method
definitions. Rather, it is the responsibility of any class that
supports an interface to provide implementations for the interface's
methods. A variable of an interface type can reference an object whose
class implements that interface; however, only methods declared in the
interface can be called using such a variable.

That goes with my understanding as interfaces being one more level of
abstraction from abstract classes.  That is they define the rules for
the classes that implement them, but not any code (where an abstract
class can implement code).  I guess my understanding of an interface
is wrong?

The reason I want to use an interface is to define a preset definition
of what my classes should implement when they are designed using
specific design patterns.

Gavin

On Wed, 02 Mar 2005 03:17:59 +0100, Jochem Maas [EMAIL PROTECTED] wrote:
 Jason Barnett wrote:
  Gavin Roy wrote:
  ...
 
 Is this a bug, or a new intended behavior?
 
 Gavin
 
 
  To get the long answer you can search through the php.internals list for
  this topic.  The short answer is: this is the new intended behavior.
 
 
 the short reason(ing) is it doesn't make sense to implement an interface
 on something that isn't an object (i.e. a class). assume object == car, and
 class == idea, an idea can't have a steering wheel interface because its not
 a 'thing' (as such).
 
 if you have a collection of singleton objects that all implement a public
 interface then should those objects be singletons at all?
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



[PHP] PHP5 Static Object Function Issue

2005-03-01 Thread Gavin Roy
I believe there is  small problem in PHP5 with regard to static
functions in uninstanced classes.  From discussions in various php irc
channels and what I've read about it in the docs, I can not call a
static function in an uninstanced class via a variable.  For example:

 $class = MyClass;
 $instance = new $class();

works, but

 $class = MyClass;
 $instance = $class::getInstance();

doesnt, where

 $instance = MyClass::getInstance();

does.

I know that some people might consider it poor design, but basically
I'm trying to dynamically reference singleton patterned classes using
getInstance to internally create an object instance and use that
instance for all processing.  As of right now it doesn't seem that it
is possible.  Is there a reason why it's not supported?  Will it be
supported in the future?

Gavin

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



[PHP] PHP 5.1 CVS Interface Question

2005-03-01 Thread Gavin Roy
I have an interface:

  interface ISingleton
  {

static function getInstance();

  }

that works in 5.0.3 but in 5.1 CVS I get the following error:

Fatal error: Access type for interface method
ISingleton::getInstance() must be omitted ...

If I take out the static keyword then it doesnt match the classes that
implement it.

Is this a bug, or a new intended behavior?

Gavin

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



Re: [PHP] Re: PHP5 Static Object Function Issue

2005-03-01 Thread Gavin Roy
Well yes and no, conceivably, the system has no idea what singletons
are out there other than what is specified in a configuration file. 
You are in essence hard coding the class name in the switch.

Gavin


On Tue, 01 Mar 2005 17:47:24 -0500, Jason Barnett
[EMAIL PROTECTED] wrote:
 A switch statement can accomplish what you seek.
 
 ?php
 
 class MyClass {
 
   static $instance;
 
   protected function __construct() {}
 
   static function getInstance() {
 if (!self::$instance) {
   self::$instance = new MyClass();
 }
 return self::$instance;
   }
 
 }
 
 function getSingleton($class_singleton) {
   switch(strtoupper($class_singleton)) {
 case 'MYCLASS':
   $singleton = MyClass::getInstance();
   break;
 default:
   $singleton = Unable to load singleton for $class_singleton;
   break;
   }
   return $singleton;
 }
 
 for ($i = 0; $i 10; $i++) {
   $class = ((3  $i) ? 'MyClass' : null);
   $singleton[] = getSingleton($class);
 }
 
 var_dump($singleton);
 
 ?
 
 --
 Teach a man to fish...
 
 NEW? | http://www.catb.org/~esr/faqs/smart-questions.html
 STFA | http://marc.theaimsgroup.com/?l=php-generalw=2
 STFM | http://php.net/manual/en/index.php
 STFW | http://www.google.com/search?q=php
 LAZY |
 http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins
 
 


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



[PHP] [php] php.dat

2003-03-24 Thread Gavin Jackson
I had a look in the cgi-bin in the site that's hosting my files and it
contains a binary file called php.dat. Can anyone tell me what the
file is used for?

Regards

Gavin

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



[PHP] Missing session vars when doing var_dump()

2003-03-20 Thread Gavin Jackson
Hi

I have come across a strange problem. I have an application that a user
logs into and when I find the user in the database I load all the custom
info for that use which I store. By the time I'm done, the session array
has 18 key's. When I do a var_dump($_SESSION) I sometimes get
18 variables and sometimes I only get 16. The two fields that are missing
are TEXT fields from a MySQL database and they also appear to be
the last two keys when var_dump() returns all 18 keys.

Does anyone know what is causing this, it's driving me crazy at the
moment with many late nights. The PHP version running is 4.2.3

Regards

Gavin

Auckland, New Zealand


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



[PHP] Re: Missing session vars when doing var_dump()

2003-03-20 Thread Gavin Jackson
Thanks for your input Bobby

I was using mysql_fetch_array() but changed to mysql_fetch_assoc()
The funny thing is, I have a page that does the var_dump() and all
I'm doing is refreshing the page and sometimes I get 18 other times
16 variables


Gavin
Auckland, New Zealand

 -Original Message-
 From: Bobby Patel [SMTP:[EMAIL PROTECTED]
 Sent: Friday, March 21, 2003 11:29 AM
 To:   [EMAIL PROTECTED]
 Subject:  [PHP] Re: Missing session vars when doing var_dump()
 
 I would think that they are 16 key/value pairs when the MySQL (TEXT)
 fields
 are null thus the session variables are NOT set thus NOT present.
 
 Hypothsis: I believe that your are using
 mysql_fetch_array($query_resource),
 try using the second parameter as well ie.
 mysql_fetch_array($query_resource, TYPE_OF_ASSOCIATION) example
 mysql_fetch_array($query_resource, MYSQL_ASSOC) (please see php.net for
 details of mysql_fetch_array).
 
 By using the second parameter, even NULL values will has a variable set.
 
 Example say you had a field called FirstName in the MySQL database. If it
 was NULL, then without the additional parameter you would have NO key
 named
 'FirstName' exisiting (ie it is not set). But if you used the second
 parameter a key would be created with no value (ie it is set but empty).
 
 So remember, the second parameter is OPTIONAL, but it has different
 behaviors when you do (and do not) use it. Hopefully I cleared it up (or
 at
 least shed  some light).
 
 checkout : http://www.php.net/manual/en/function.mysql-fetch-array.php
 
 
 Gavin Jackson [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Hi
 
  I have come across a strange problem. I have an application that a user
  logs into and when I find the user in the database I load all the custom
  info for that use which I store. By the time I'm done, the session array
  has 18 key's. When I do a var_dump($_SESSION) I sometimes get
  18 variables and sometimes I only get 16. The two fields that are
 missing
  are TEXT fields from a MySQL database and they also appear to be
  the last two keys when var_dump() returns all 18 keys.
 
  Does anyone know what is causing this, it's driving me crazy at the
  moment with many late nights. The PHP version running is 4.2.3
 
  Regards
 
  Gavin
 
  Auckland, New Zealand
 
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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



[PHP] [php]: Loading from array

2003-03-20 Thread Gavin Jackson
Hi there

Is there anything I'm doing wrong in the following:

$Database = mysql_connect( host, user, password ) or
die(Could not connect to database);

mysql_select_db( dbname, $Database ) or die(Database does not
exist);

$Login = strtolower($_POST[Person]);
$Password = PASSWORD(\ . strtolower($_POST[Password]) . \);

$Query = SELECT
Ref,Programme,FirstName,LastName,Email,PointsBalance,PointsAvailable FROM
tbusers WHERE Login=\ . $Login . \ AND
Password= . $Password . ;;

$UserResult = mysql_query( $Query, $Database ) or die(Query
failed);

if ( mysql_num_rows( $UserResult ) == 1 )
{
$User = mysql_fetch_assoc($UserResult   
$ProgrammeRef = $User[Programme];
$_SESSION[UserRef] = $User[Ref];
... load rest of $User values into $_SESSION array
}


$Query = SELECT Ref, Programme, ProgrammeLogo, ProgrammeMessage,
Company, CompanyLogo,
CompanyMessage, Website, TableColour, TextColour, NavImage,
Conversion FROM tbprogrammes WHERE Ref= . $ProgrammeRef . ;;

$ProgrammeResult = mysql_query( $Query, $Database ) or die(Query
failed);

if ( mysql_num_rows( $ProgrammeResult ) == 1 )
 {
$ProgrammeInfo = mysql_fetch_assoc($ProgrammeResult);
$_SESSION[ProgRef] = $ProgrammeInfo[Ref];
$_SESSION[Programme] =
$ProgrammeInfo[Programme];
... load rest of $ProgrammeInfo into $_SESSION array
}

This is the code I'm using to load a total of 18 values into my $_SESSION
array. The initial problem I had
which was intermittent was the $ProgrammeInfo used to be called $Programme
but sometimes when loading
the variables into the $_SESSION array when the code got to
$_SESSION[Programme] = $ProgrammeInfo[Programme];
The $Programme[] array used to get screwed up, I could understand it if it
was something that happened all
the time, but it didn't and renaming from $Programme to $ProgrammeInfo seems
to have solved it.

The other point I'd like to make is that a single page is being used to dump
the $_SESSION array and all
I'm doing is refreshing the page and sometimes I get 16 and other times 18
values.

What could cause the two problems, I'm new to php and I like the syntax and
simplicity a lot but these two
problems have me tearing my hair out.

Gavin

Auckland, New Zealand


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



RE: [PHP] Re: Missing session vars when doing var_dump()

2003-03-20 Thread Gavin Jackson
Hi Bobby

The following is a copy and paste of the page I'm using to
generate the problem. I have 18 keys in the $_SESSION
variable and just by simply refreshing the page with the
following code, it returns either array(0){} or session info and
array(18){ will all the correct variables }. I must be doing
something fundamentally wrong somewhere.

Thanks very much for your willingness to help me.

?php
session_start();
?
html
head
/head
body
?php

foreach( $_SESSION as $key = $value )
{
echo font color=\FF9900\SESSION[$key] = $valuebr;
}
echo brbr;
var_dump( $_SESSION );
?
/body
/html





Gavin Jackson, RD Software Engineer, Tru-Test Ltd.
Phone: +64-9-9788757,  Fax: +64-9-979, [EMAIL PROTECTED]
Tru-Test Ltd, P.O. Box 51-078, Pakuranga, Auckland, New Zealand

 -Original Message-
 From: Bobby Patel [SMTP:[EMAIL PROTECTED]
 Sent: Friday, March 21, 2003 3:28 PM
 To:   [EMAIL PROTECTED]
 Subject:  Re: [PHP] Re: Missing session vars when doing var_dump()
 
 Are the queries the exact same every time you refresh them? This seems
 just
 to be programming logic (I guess). Post some code and maybe someone (or I)
 will be able to help you out.
 
 Gavin Jackson [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
  Thanks for your input Bobby
 
  I was using mysql_fetch_array() but changed to mysql_fetch_assoc()
  The funny thing is, I have a page that does the var_dump() and all
  I'm doing is refreshing the page and sometimes I get 18 other times
  16 variables
 
 
  Gavin
  Auckland, New Zealand
 
   -Original Message-
   From: Bobby Patel [SMTP:[EMAIL PROTECTED]
   Sent: Friday, March 21, 2003 11:29 AM
   To: [EMAIL PROTECTED]
   Subject: [PHP] Re: Missing session vars when doing var_dump()
  
   I would think that they are 16 key/value pairs when the MySQL (TEXT)
   fields
   are null thus the session variables are NOT set thus NOT present.
  
   Hypothsis: I believe that your are using
   mysql_fetch_array($query_resource),
   try using the second parameter as well ie.
   mysql_fetch_array($query_resource, TYPE_OF_ASSOCIATION) example
   mysql_fetch_array($query_resource, MYSQL_ASSOC) (please see php.net
 for
   details of mysql_fetch_array).
  
   By using the second parameter, even NULL values will has a variable
 set.
  
   Example say you had a field called FirstName in the MySQL database. If
 it
   was NULL, then without the additional parameter you would have NO key
   named
   'FirstName' exisiting (ie it is not set). But if you used the second
   parameter a key would be created with no value (ie it is set but
 empty).
  
   So remember, the second parameter is OPTIONAL, but it has different
   behaviors when you do (and do not) use it. Hopefully I cleared it up
 (or
   at
   least shed  some light).
  
   checkout : http://www.php.net/manual/en/function.mysql-fetch-array.php
  
  
   Gavin Jackson [EMAIL PROTECTED] wrote in message
   news:[EMAIL PROTECTED]
Hi
   
I have come across a strange problem. I have an application that a
 user
logs into and when I find the user in the database I load all the
 custom
info for that use which I store. By the time I'm done, the session
 array
has 18 key's. When I do a var_dump($_SESSION) I sometimes get
18 variables and sometimes I only get 16. The two fields that are
   missing
are TEXT fields from a MySQL database and they also appear to be
the last two keys when var_dump() returns all 18 keys.
   
Does anyone know what is causing this, it's driving me crazy at the
moment with many late nights. The PHP version running is 4.2.3
   
Regards
   
Gavin
   
Auckland, New Zealand
   
  
  
  
   --
   PHP General Mailing List (http://www.php.net/)
   To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

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



[PHP] Line breaks

2003-03-06 Thread Gavin Amm
Hi,

Please help me before I go insane...

I have a basic feedback form with:
  your name
  your e-mail address
  E-Mail Subject
  Message

The problem is the line breaks...

For example, they might type in the following (between the dashed
lines) into the Message textarea:
--
  Hi,

  Please send me some info.

  Thanks,
  Gav
--

When I receive the mail, however, it looks like this:
--
  Hi, Please send me some info. Thanks, Gav
--

This is fine for such a short message, but lengthy messages would be
horrid to read if all the line breaks were taken out... Not to mention
an unprofessional appearance...


I've tried looking at:

- wordwrap()
- preg_replace()
  (because sent from Linux machine to Win machine \r  \n)
- Different WRAP attributes for the textarea. Options are VIRTUAL,
PHYSICAL, and NONE/OFF (can't remember which).

Not sure if there are ways of doing this using the 1st 2? Couldn't
really see anything.

Cheers,
Gav

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



[PHP] session_start() causes Connection to Close.

2002-02-21 Thread Gavin McCullagh

Hi,

I'm using php-4.1.1 with 

Configure Command
'./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--enable-dbase'
'-- with-mysql=/usr/local/mysql' '--with-mm' '--with-openssl'
'--enable-sockets' '- -with-zlib' '--with-curl' '--enable-discard-path'

apache (w modssl): 

gavin@myhost apache bin/httpd -V   
Server version: Apache/1.3.23 (Unix)
Server built:   Feb 10 2002 20:43:12
Server's Module Magic Number: 19990320:11
Server compiled with
-D EAPI
-D HAVE_MMAP
-D HAVE_SHMGET
-D USE_SHMGET_SCOREBOARD
-D USE_MMAP_FILES
-D HAVE_FCNTL_SERIALIZED_ACCEPT
-D HAVE_SYSVSEM_SERIALIZED_ACCEPT
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D HTTPD_ROOT=/usr/local/apache
-D SUEXEC_BIN=/usr/local/apache/bin/suexec
-D DEFAULT_PIDLOG=logs/httpd.pid
-D DEFAULT_SCOREBOARD=logs/httpd.scoreboard
-D DEFAULT_LOCKFILE=logs/httpd.lock
-D DEFAULT_XFERLOG=logs/access_log
-D DEFAULT_ERRORLOG=logs/error_log
-D TYPES_CONFIG_FILE=conf/mime.types
-D SERVER_CONFIG_FILE=conf/httpd.conf
-D ACCESS_CONFIG_FILE=conf/access.conf
-D RESOURCE_CONFIG_FILE=conf/srm.conf


I have an SSL site running.  All of a sudden it's started misbehaving on a
a certain page.  The page involves s some mysql connections and curl use.
however, the first line of the script is:

?php
session_start();
...
...

And I get Host Closed Connection from the browser unless this
session_start() is commented out  Obviously this knackers up the rest of
the script.

Is there something I'm missing here?  If needs be I'll send more info.
Also, the browser is Opera for linux.  This was working four days ago.
I've redeveloped it in parallel and now the new and old (unchanged)
versions have both stopped on the same page.

Sorry if this is something obvious but I just can't see it.

Thanks
Gavin

PS here's my session info from php_info:

session 
Session Support enabled
Directive   Local Value Master Value
session.auto_start  Off Off
session.cache_expire180 180
session.cache_limiter   nocache nocache
session.cookie_domain   no valueno value
session.cookie_lifetime 0   0
session.cookie_path /   /
session.cookie_secure   Off Off
session.entropy_fileno valueno value
session.entropy_length  0   0
session.gc_maxlifetime  14401440
session.gc_probability  1   1
session.namePHPSESSID   PHPSESSID
session.referer_check   no valueno value
session.save_handlerfiles   files
session.save_path   /tmp/tmp
session.serialize_handler php   php
session.use_cookies On  On



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




[PHP] Re: redirect to php problem

2001-09-15 Thread Gavin

Yes, this HTML line will redirect the browser to the php page..

META http-equiv=refresh content=0;url=file.php

Gavin

Nikola Veber [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi !

 I'm having a problem with following : I'd like to activate a php file as a
home page,
 but without pointing directly to it(http://www.smth.com/file.php). I'd
like to know if it is
 possible to call it from a html file(index.htm for exp. )

 Thanks
 Nikola





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Passing arrays to other php routines in popup window

2001-09-14 Thread Gavin

I am using Apache with php version 4.0.4pl1.  I am trying to display data in
a popup window.  I want to pass there variables, one string and two normal
arrays.
Both the $name and $data variables contain valid data in the dispData
routine, however the $data2 array is always blank.

**
$name = urlencode($name);
$data = urlencode(serialize($data));
$data2 = urlencode(serialize($data2));

$return_value .= 'form';
$return_value .= 'input type=button
onClick=window.open(dispData.php?pass='.$title.'-'.$data.'-'.$data2.')
value=Graph';
$return_value .= '/form';
**

dispData.php
list ($name, $data, $data2) = split ('[=-]', $pass);

$name = urldecode($name);
$data = unserialize(urldecode($data));
$data2 = unserialize(urldecode($data2));

Any ideas?
  Thanks



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]