Re: [PHP] parse error

2002-04-30 Thread Steve Cayford

Looks like your problem is on line 24. See below.

-Steve

On Tuesday, April 30, 2002, at 12:48  PM, Jule wrote:

 Hey guys, i'm writing this guestbook script for my site, and i'm 
 getting a
 random parse error where i think everything is normal, it gives it on 
 line 26
 which is

 echo Your entry will be posted!;

 my script follows

 Jule

 --SCRIPT--

 ?php
   $Guestbook[dateadd] = date(F j, Y H:i:s);
   $Guestbook[name] = trim($Guestbook[name]);
   $Guestbook[town] = trim($Guestbook[town]);
   $Guestbook[email] = trim($Guestbook[email]);
   $Guestbook[website] = trim($Guestbook[website]);
   $Guestbook[favsong] = trim($Guestbook[favsong]);
   $Guestbook[comments] = trim($Guestbook[comments]);
   $Guestbook[mailinglist] = trim($Guestbook[mailinglist]);

   $Host = localhost;
   $User = ;
   $Password = *;
   $DBName = blindtheory;
   $TableName = guestbook;
   $TableName2 = mailinglist;
   $Pattern = .+@.+..+;
   $Pattern2 = (http://)?([^[:space:]]+)([[:alnum:]\.,-_?/=]);

   $Link = mysql_connect ($Host, $User, $Password);
   $Query = INSERT into $TableName values('0', '$Guestbook[dateadd]',
 '$Guestbook[name]', '$Guestbook[town]', '$Guestbook[email]',
 '$Guestbook[website]','$Guestbook[favsong]', '$Guestbook[comments]');
   $Link2 = mysql_connect ($Host, $User, $Password);
   $Query2 = INSERT into $TableName2 values('0', '$Guestbook[dateadd]',
 '$Guestbook[name]', '$Guestbook[email]');

You're missing a final double quote here ^.


   if (mysql_db_query ($DBName, $Query, $Link)) {
   echo Your entry will be added;
   } else {
   echo There was an error in during the posting, please contact 
a
 href=\mailto:[EMAIL PROTECTED]\;me/a and I will fix the
 problem.br;
   }
   
   if (isset($Guestbook[mailinglist])) {

   if (mysql_db_query ($DBName, $Query2, $Link2)) {
   echo Your e-mail address was sucessfully added to 
 our mailinglist;
   } else {
   echo There was an error in during the posting, please 
contact a
 href=\mailto:[EMAIL PROTECTED]\;me/a and I will fix the
 problem.br;
   }
   }
   mysql_close ($Link);
   mysql_close ($Link2);
 ?
 --
 Jule Slootbeek
 [EMAIL PROTECTED]
 http://blindtheory.cjb.net

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



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




Re: [PHP] Cannot add header information

2002-04-29 Thread Steve Cayford


On Monday, April 29, 2002, at 12:02  PM, Bo Pritchard wrote:

 I know without the accompanying code there's no way to help me...But 
 without
 having to get real specific what does the following message tell me is
 wrong?

 Thanks

 Warning: Cannot add header information - headers already sent by (output
 started at /home/omnidevi/omnidevices-www/s-cart/form.phtml:4) in
 /home/omnidevi/omnidevices-www/s-cart/shop-head.phtml on line 44


In shop-head.phtml on line 44 you're apparently trying to do something 
that sends an http header (like starting a session, setting a cookie, 
etc.), however, all http headers must be sent before any html is goes 
out and the error says html output already started in form.phtml on line 
4.

Note this is about http headers which are different than the html head 
stuff.

-Steve


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




Re: [PHP] Array Question

2002-04-18 Thread Steve Cayford


On Thursday, April 18, 2002, at 04:38  PM, Jason Lam wrote:

 $arr2 is a 2d array.

 $arr1[0] = 1;
 $arr1[1] = 10;
 $arr2[0] = $arr1;
 print $arr2[0][1];

 Result will be 10

 But,

 $arr1[0] = 1;
 $arr1[1] = 10;
 $arr2[0] = $arr1;
 $arr3 = each($arr2);
 print $arr3[1];

What are you expecting? Check out the documentation for each() at 
http://www.php.net/manual/en/function.each.php

At this point $arr3 should look like this (I think, but try 
print_r($arr3) to be sure):

{
0 = 0,
1 = array (
0 = array (
0 = 1,
1 = 10
)
),
key = 0,
value = array (
0 = array (
0 = 1,
1 = 10
)
)
}


 Result is not 10. So, function each is not taking the whole $arr2[0]
 out..

 My question is what function should I use to iterate array elements 
 (with
 arrays in it)?


How about foreach()?

-Steve

 Jay


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



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




Re: [PHP] Please Help

2002-04-16 Thread Steve Cayford

Check out the bottom of each message...

-Steve

On Tuesday, April 16, 2002, at 10:43  AM, Omland Christopher m wrote:

 Can anyone tell me how to unsubscribe. There is just a bit too much 
 volume
 for me.
 Thanks.
 -Chris


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



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




Re: [PHP] What date/time was it 7 hours ago?

2002-04-15 Thread Steve Cayford

You could convert it to a timestamp using strtotime(), subtract 7*60*60, 
then convert it back to a string with strftime().

-Steve

On Monday, April 15, 2002, at 09:50  AM, Torkil Johnsen wrote:

 What date/time was it 7 hours ago?

 I'm just trying to make a log using mysql/php
 This log is kinda supposed to show the time, local to the user.

 So I store datetime on the format -MM-DD HH:MM:SS in a datetime 
 field.
 Using the php date function to get the date.

 This will store the time that right then ON THE SERVER.

 Now, when fetching data from the mysql table, I want to display what the
 time WAS, LOCALLY (where I'm at, not the server) when the log entry was
 made.

 So. How do I make a function that takes in -MM-DD HH:MM:SS and 
 spits out
 the -MM-DD HH:MM:SS minus... for instance, 7 hours?

 What date/time was it 7 hours ago?



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



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




Re: [PHP] calculating US holidays

2002-04-15 Thread Steve Cayford

You could port Date::Calc from perl... or just call a perl script to do 
the calculation. Probably the easiest way to figure out Easter (for the 
extreme example) that I can think of.

-Steve

On Monday, April 15, 2002, at 03:05  PM, Tom Beidler wrote:

 That's fine for fixed dates, and I have that figured out, but presidents
 day, memorial day, labor day and thanksgiving fall on different days 
 each
 year. Presidents day is the third monday of February. How do I calculate
 that?

 From: Tyler Longren [EMAIL PROTECTED]
 Organization: Captain Jack Communications
 Date: Mon, 15 Apr 2002 14:48:15 -0500
 To: Tom Beidler [EMAIL PROTECTED], php list
 [EMAIL PROTECTED]
 Subject: Re: [PHP] calculating US holidays

 ?
 $month = date(m);
 $day = date(d);
 if ($month == 10  $day == 31) {
 print It's Halloween!;
 }
 ?

 you could do something similar to that.

 tyler

 - Original Message -
 From: Tom Beidler [EMAIL PROTECTED]
 To: php list [EMAIL PROTECTED]
 Sent: Monday, April 15, 2002 2:17 PM
 Subject: [PHP] calculating US holidays


 I need to calculate the date to see if it's a holiday, i.e. is today
 presidents day, which happens to be the third monday of february. Can
 someone point me to some code that can do that?


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






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



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




Re: [PHP] How to sort by 3rd row in an 2d-Array

2002-04-12 Thread Steve Cayford

Or try the usort() function?

?php
...
myArray[1][firstname] = Joe;
myArray[1][lastname] = Smith;
myArray[1][company] = Bullock;
myArray[1][email] = [EMAIL PROTECTED];
myArray[2][firstname] = Jim;
myArray[2][lastname] = Cords;
myArray[2][company] = Jamen;
myArray[2][email] = [EMAIL PROTECTED];
...

function companyCmp ($a, $b) {
return strcmp($a[company],$b[company]);
}

usort ($myArray, companyCmp);

...
?

-Steve

On Friday, April 12, 2002, at 12:26  PM, Kevin Stone wrote:

 This is a terribly inneficient way of handling your situation but I 
 believe
 it would work.

 // First we're going to make a list of all company values
 for($i=0; $icount($myarray); $i++)
 {
 $company_values[] = $myarray[$i][company];
 }

 // Then we're going to order the array using a standard function.
 natsort($company_values);

 // Then we're going to go through $myarray  looking for each matching
 // value and build a new array based on the order of the sorted list.
 for($i=0; $icount($company_values); $i++)
 {
 for ($j=0; $j=count($myarray); $j++)
 {
 if ($company_values[$i] == $myarray[$j][company])
 {
 $mynewarray[] = $myarray[$j];
 }
 }
 }

 // bada bing bada boom you gots your company sorted list... I think
 $myarray = $mynewarray;

 I wrote this off the top of my head in like three minutes so any and all
 corrections would be most welcome.  ;)
 -Kevin

 - Original Message -
 From: SED [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Friday, April 12, 2002 10:25 AM
 Subject: [PHP] How to sort by 3rd row in an 2d-Array


 Hi,

 I'm trying to sort an array like following

 myArray[1][firstname] = Joe;
 myArray[1][lastname] = Smith;
 myArray[1][company] = Bullock;
 myArray[1][email] = [EMAIL PROTECTED];
 myArray[2][firstname] = Jim;
 myArray[2][lastname] = Cords;
 myArray[2][company] = Jamen;
 myArray[2][email] = [EMAIL PROTECTED];
 etc...

 by the company name. How can I do it?

 I found the solution on php.net
 (http://www.php.net/manual/en/function.array-multisort.php) but it 
 sorts
 only the first row:

 foreach ($myArray as $val) {
 $sortarray[] = $val['nafn'];
 echo $val['stadur'];
 }
 array_multisort($myArray, $sortarray);

 Thanks in advance!

 SED


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





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



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




Re: [PHP] Wanting a better understanding of classes in PHP...

2002-04-12 Thread Steve Cayford

Well, start here probably:

http://www.php.net/manual/en/language.oop.php

-Steve

On Friday, April 12, 2002, at 12:50  PM, Chuck PUP Payne wrote:

 Hi, I was up on freshmeat and I saw a TON of php classes. I like to 
 know how
 can I use them? And is a class a bit of code that you are always using? 
 If
 so, how can I create my own classes.

 Chuck PUP Payne
 Sr. System Administrator
 GDI Engineering, Inc.
 2075-E West Park Place Blvd.
 Stone Mountain, GA 30087
 ---
 (678) 476-0747 ext. 18 (Phone)
 (770) 498-1590 (Fax)
 (404) 451-3579 (Mobile)
 (800) 631-1371 (Alpha Page)
 [EMAIL PROTECTED]  (Text Pager)
 [EMAIL PROTECTED] (E-Mail)
 ---
 http://www.gdieng.com
 http://www.gditelecommunication.com
 http://www.softmeta.com



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



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




Re: [PHP] Classes??

2002-04-04 Thread Steve Cayford

Yeah, sure.

-Steve

On Thursday, April 4, 2002, at 10:42  AM, Gerard Samuel wrote:

 Maybe a simple question.
 But can one file contain 2 or more classes??
 Thanks


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



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




Re: [PHP] English/Arabic Mysql problem...

2002-04-04 Thread Steve Cayford

Are you using unicode? I don't know the answer for you - maybe check the 
mysql site - but I'd be interested in hearing an answer as well if 
anyone has one.

-Steve

On Thursday, April 4, 2002, at 12:11  AM, Dhaval Desai wrote:

 Hello people,

 I am making a bilingual website English/Arabic. I am facing some 
 problem with this. The problem is that I am not able to insert arabic 
 lanaguage characters ionto Mysql databse. It gets junk 
 characters...when I try to display it...

 Thank You

 Best Regards,
 Dhaval Desai



 _
 Send and receive Hotmail on your mobile device: http://mobile.msn.com


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



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




Re: [PHP] objects handling objects

2002-04-04 Thread Steve Cayford


On Thursday, April 4, 2002, at 04:21  PM, Erik Price wrote:

 I looked in the manual, but didn't see anything about this.  I've read 
 that PHP isn't a true object-oriented language, but rather simulates 
 elements of object-oriented programming.  Can I write a class that 
 performs operations and manipulates objects?  Can objects be placed 
 into arrays etc?

 Erik

The real hindrance I've come up against is that you can't do chained 
method calls, otherwise objects perform pretty well as expected. Keep in 
mind the difference between passing by reference and by copy, though, or 
you'll find yourself updating a copy of an object somewhere instead of 
the original.

-Steve

Here's some code I was just playing around with:

?php

class classA {
 function method1() {
 return 1;
 }
 function method2() {
 return 2;
 }
}

class classB {
 function method1($num = 0) {
 return $num + 10;
 }
 function method2($num = 0) {
 return $num+20;
 }
}

class classC {
 function echoMethod($object) {
 return $object;
 }
}

class classD {
 function otherMethod1($object) {
 return $object-method1();
 }
 function otherMethod2($object) {
 return $object-method2();
 }
}

$a = new classA;
$b = new classB;
$c = new classC;
$d = new classD;

print(a1:  . $a-method1() . br /\n);
print(a2:  . $a-method2() . br /\n);
print(b1:  . $b-method1($a-method1()) . br /\n);
print(b2:  . $b-method2($a-method2()) . br /\n);
print(d1:  . $d-otherMethod1($b) . br /\n);
print(d2:  . $d-otherMethod2($c-echoMethod($a)) . br /\n);

// this next line would generate a parse error
// print(c:a1:  . $c-echo($a)-method1() . br /\n);

// this outputs:
// a1: 1
// a2: 2
// b1: 11
// b2: 22
// d1: 10
// d2: 2

?





 

 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]


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



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




Re: [PHP] objects handling objects

2002-04-04 Thread Steve Cayford

Doh, typo:

// this next line would generate a parse error
// print(c:a1:  . $c-echo($a)-method1() . br /\n);

should read

// this next line would generate a parse error
// print(c:a1:  . $c-echoMethod($a)-method1() . br /\n);


On Thursday, April 4, 2002, at 05:25  PM, Steve Cayford wrote:


 On Thursday, April 4, 2002, at 04:21  PM, Erik Price wrote:

 I looked in the manual, but didn't see anything about this.  I've read 
 that PHP isn't a true object-oriented language, but rather simulates 
 elements of object-oriented programming.  Can I write a class that 
 performs operations and manipulates objects?  Can objects be placed 
 into arrays etc?

 Erik

 The real hindrance I've come up against is that you can't do chained 
 method calls, otherwise objects perform pretty well as expected. Keep 
 in mind the difference between passing by reference and by copy, 
 though, or you'll find yourself updating a copy of an object somewhere 
 instead of the original.

 -Steve

 Here's some code I was just playing around with:

 ?php

 class classA {
 function method1() {
 return 1;
 }
 function method2() {
 return 2;
 }
 }

 class classB {
 function method1($num = 0) {
 return $num + 10;
 }
 function method2($num = 0) {
 return $num+20;
 }
 }

 class classC {
 function echoMethod($object) {
 return $object;
 }
 }

 class classD {
 function otherMethod1($object) {
 return $object-method1();
 }
 function otherMethod2($object) {
 return $object-method2();
 }
 }

 $a = new classA;
 $b = new classB;
 $c = new classC;
 $d = new classD;

 print(a1:  . $a-method1() . br /\n);
 print(a2:  . $a-method2() . br /\n);
 print(b1:  . $b-method1($a-method1()) . br /\n);
 print(b2:  . $b-method2($a-method2()) . br /\n);
 print(d1:  . $d-otherMethod1($b) . br /\n);
 print(d2:  . $d-otherMethod2($c-echoMethod($a)) . br /\n);

 // this next line would generate a parse error
 // print(c:a1:  . $c-echo($a)-method1() . br /\n);

 // this outputs:
 // a1: 1
 // a2: 2
 // b1: 11
 // b2: 22
 // d1: 10
 // d2: 2

 ?





 

 Erik Price
 Web Developer Temp
 Media Lab, H.H. Brown
 [EMAIL PROTECTED]


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



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



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




Re: [PHP] Loop, array, life....

2002-04-03 Thread Steve Cayford

On your first email you loop through all the news in the $newsfetch 
resource. I think you need to then do a mysql_data_seek() call against 
that to reset it for the next time through the loop. Otherwise you'll 
just get a null result because you're already at the end of the data.

-Steve

On Wednesday, April 3, 2002, at 02:30  PM, Gerard Samuel wrote:

 (made a correction in sudo code)

 Ok, this one is breaking my back all day.
 First some sudo-code -

 fuction email_to_user() {
  $sql = 'select distinct(email) from user';
  $emailfetch = mysql_query($sql);

  $sql = 'select news, date from news order by sid desc limit 10';
  $newsfetch = mysql_query($sql);

  while ($data = mysql_fetch_row($emailfetch)) {
  $container = array();
  $container[] = 'htmlheadtitle/headbody';

  $message = 'Have a nice day';
  $container[] = $message;
 // PROBLEM IN THIS WHILE LOOP MAYBE //
  while (list($news, $date) = mysql_fetch_row($newsfetch)) {
  $container[] = 'a href='newslink.php'' . $news . '/a';
  $container[] = 'brhrbr';
  }
  $container[] = '/body/html';
  $message2 = '';
  foreach($container as $foo) {
  $message2 .= $foo;
  }
  mail(Send mail to $data[0], $message2);
  unset($container);
  }
 }

 Basically it grabs all the user's email addresses, then loop them.
 On each loop grab all news items.
 Then emails results to the user and moves on to the next user.

 Im running this on my test box, that only has two users, but the 2nd
 user never gets the expected results.
 The first user get the message and the news.
 The second only gets the message.
 The code structure is pretty much unchanged from a working example till
 I started using $container to hold array elements.

 Could anyone see bad logic in the above code??
 Thanks



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



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




Re: [PHP] session

2002-04-02 Thread Steve Cayford

Try putting session_start() in your retief.php script as well as 
piet.php.

-Steve

On Wednesday, April 3, 2002, at 01:06  PM, R. Lindeman wrote:

 okay i've posted something before here are my scripts either you tell me
 what i do wrong or i'll go beserk

 you can check the outcome of the code on the following adress

 http://www.filenexus.com/piet.php

 here's the code for piet.php :

 ?php

 // open session and begin registering values

 session_start();

 session_register(fubar1);
 session_register(fubar2);
 session_register(fubar3);

 $fubar1=Remko;

 $fubar2=Lindeman;

 $fubar3=I3M1I;

 header(Location: retief.php?.SID);

 ?

 here's the code for retief.php :

 ?php

 // begin the retrieval of propagated values

 $remko   = $HTTP_SESSION_VARS[fubar1];
 $lindeman = $HTTP_SESSION_VARS[fubar2];
 $klas   = $HTTP_SESSION_VARS[fubar3];

 echo $remko;
 echo $lindeman;
 echo $klas;

 ?


 the problem is that the values don't get registered



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



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




Re: [PHP] Parsing error

2002-04-01 Thread Steve Cayford

It looks like you've got a closing curly bracket } for your switch 
statement, but not for your while statement.

Also, have you read up on the switch statement? Keep in mind that if 
something matches your case 1, it will also fall through and execute 
case 2, case 3, etc... unless you include break statements. e.g. try 
this:

switch ($row)
{
   case 1:
 {
   $vignette = $data[$c];
   break;
 }
   case 2:
 {
   $photo = $data[$c];
   break;
 }
...
...
...

-Steve


On Monday, April 1, 2002, at 10:44  AM, news.php.net wrote:

 Hi,

 I'm real new in php and trying to read a txt file

 this is my code :

 ?php
  $row = 1;
  $fp = fopen (lecteurs.txt,r);
   while ($data = fgetcsv ($fp, 1000, ;))
   {
 $num = count ($data);
 $row++;
 for ($c=0; $c$num; $c++)
 switch ($row)
  {
  case 1 :
   {
   $vignette = $data[$c];
   }
  case 2 :
{
$photo= $data[$c];
}
case 3 :
{
$marque= $data[$c];
}
   case 4 :
{
$nom = $data[$c];
}
   case 5 :
{
$pdfproduit= $data[$c];
}
   case 6 :
{
$commprod = $data[$c];
}
 }
   fclose ($fp);
   echo $vignette;
   echo $photo;
   echo $marque;
   echo $nom;
   echo $pdfproduit;
   echo $commprod;
 ?

 and when i run it i get : Parse error: parse error in essai.php on line 
 45

 here' my txt file (just 1 line for probe)

 petitimage;photo;marque;Nom;lepdf;commproduit

 Can someone help me to go thru

 TIA

 Hubert





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



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




Re: [PHP] Where is php.ini on Mac OS X?

2002-03-27 Thread Steve Cayford

On mine it's in /usr/local/lib, but I seem to recall discussion earlier 
about some OSX installations lacking the ini file.

-Steve

On Tuesday, March 26, 2002, at 04:53  PM, Chuck PUP Payne wrote:

 Can some one please tell me where php.ini is located on Mac OS X?

 Thanks,

 Chuck Payne
 Magi Design and Support


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



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




Re: [PHP] Driving me nuts, need one second of your time

2002-03-15 Thread Steve Cayford

It looks like your sql query failed, so the result is invalid.

Assuming that this is really the whole script, then you're counting on 
the mysql_db_query function to open a connection to the database db 
using the default connection values which (according to the manual) are 
host: localhost, user: (whatever user is running the script, probably 
'www', 'apache', or 'nobody' depending on your system), and password: 
(blank). Do you really have your mysql database setup to allow access 
with these defaults?

I'd recommend trying mysql_connect() first, then if that works continue 
on to the mysql_query(). At least you'll know better which aspect failed.

-Steve

On Friday, March 15, 2002, at 05:14  PM, cosmin laslau wrote:

 ?
 $query = SELECT * from mytable;
 $result = mysql_db_query(db, $query);

 while ($myarray = mysql_fetch_array($result))
 {
 $title = $myarray[title];
 echo $titlebr;
 }
 ?

 Can someone PLEASE tell me why the coding above gives the following 
 error:


 Warning: Supplied argument is not a valid MySQL result resource in 
 /var/web/somesite.com/html/index.php on line 5


 It's absurd. It's driving me nuts. I'm about to introduce my computer 
 to the pavement 40 feet below.

 Thanks in advance for whoever sees what I am sure is a glaring and 
 obvious flaw in the coding. I've been looking at it for an hours and 
 just can't get anything from where I'm standing, maybe a different 
 perpective will help.



 _
 Get your FREE download of MSN Explorer at 
 http://explorer.msn.com/intl.asp.


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



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




Re: [PHP] contents of fetch array into a string

2002-03-06 Thread Steve Cayford


On Wednesday, March 6, 2002, at 12:13  PM, Kris Vose wrote:

 I have a problem with reading the contents of $r[1] into a string 
 called = $mail.  Does anyone have any suggestions?  Any help is greatly 
 appreciated.

 Kris Vose


 if ($czero != )
 {

 $t = mysql_query(SELECT * FROM AddExisting);

$t is now a resource variable, not an array. If you want to know the 
number of rows returned
use mysql_num_rows($t) not count($t)


 $number_of_customers = count($t);

 while($r = mysql_fetch_array($t))

Note: you'll loop through this section $number_of_customer times, 
pulling one table row into $r
each time through.

 {
 extract($r);

Why are you using extract here?

   for ($i = 0; $i$number_of_customers; $i++)

You're looping through $number_of_customers columns on each row in the 
table. Is this what you want?  Is your table really $number_of_customers 
wide?

   {
 echo $r[1]., ;
Do you mean $r[$i] ?
   }

 }

Now you've dropped out of both loops. $r will be holding the last row 
you retrieved from the database table.

 $mail = ' ';
 foreach($r[1] as $mailline)

$r[1] is not an array here. What are you trying to do?

 {
 $mail.=$mailline;
 }

 }



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




Re: [PHP] Perl and PHP

2002-03-06 Thread Steve Cayford

If you're running a perl script on the command line you would use
/path/to/perl/script.pl value1 value2 value3 ...

In your perl script $ARGV[1] should hold value1, $ARGV[2] should hold 
value2, etc.

-Steve

On Wednesday, March 6, 2002, at 02:48  PM, [EMAIL PROTECTED] wrote:

 I need to pass a variable to Perl from a PHP script.  I am somewhat know
 PHP but I do NOT know perlI am running my perl script off of the
 command line.  I tried /path/to/somewhere/script.pl?var=var

 but it did not work.

 I would love any help you could provide me

 Thanks,
 Michael


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



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




Re: [PHP] Perl and PHP

2002-03-06 Thread Steve Cayford

If the value you want to send back to php is an integer you could just 
say

exit $number;

from perl and that will be put into your $var.

Otherwise use exec() instead of system.

exec(/path/to/perlscript.pl, $scriptOutputArray, $scriptExitValue);

Anything that gets printed from the perl script should show up in the 
$scriptOuputArray.

-Steve

On Wednesday, March 6, 2002, at 04:19  PM, Michael Hess wrote:



 Thanks,

 Ok,
 I got it to work.now how do I take a varaible back into PHP


 I do a $var = system(/path/to/cgi $varforCGI)
 and in the CGI script I do a print $varforPHP

 however it prints the varforPHP to the broswer, I need it saved it var

 Any (more) help would be great!!

 Michael

 On
 Wed, 6
 Mar 2002, Steve Cayford wrote:

 If you're running a perl script on the command line you would use
 /path/to/perl/script.pl value1 value2 value3 ...

 In your perl script $ARGV[1] should hold value1, $ARGV[2] should hold
 value2, etc.

 -Steve

 On Wednesday, March 6, 2002, at 02:48  PM, [EMAIL PROTECTED] wrote:

 I need to pass a variable to Perl from a PHP script.  I am somewhat 
 know
 PHP but I do NOT know perlI am running my perl script off of the
 command line.  I tried /path/to/somewhere/script.pl?var=var

 but it did not work.

 I would love any help you could provide me

 Thanks,
 Michael


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





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




Re: [PHP] Is there Any way to call Non-Existent function in PHP

2002-01-17 Thread Steve Cayford

You could wrap your function calls, maybe. Like

function my_Draw_Image() {
if(function_exists('Draw_Image')) {
return Draw_Image(func_get_args());
} else {
// do whatever...
}
}

Haven't tested this at all, but it seems plausible. Might be possible to 
wrap generic function calls like this using call_user_func() or eval(). 
Again, I haven't tested it.

-Steve


On Thursday, January 17, 2002, at 12:07  AM, S. Murali Krishna wrote:

 Hi!
   Thanks for your kind response. The solution given by u is fine.
 But Iam asking just more than that. See whenever I call a function
 like
   Draw_Image();

 ( In language construct level )
 Is there anything to checks this non-existence  of Draw_Image() and call
 some default function.

 I don't want to manually check if it exist or not.

 Thanks for Ur Solution.


 On Wed, 16 Jan 2002, Neil Freeman wrote:

 You can use function_exists() to check whether a function actually 
 exists:

 eg:
 if (function_exists('imap_open')) {
 echo IMAP functions are available.br\n;
 } else {
 echo IMAP functions are not available.br\n;
 }

 HTH

 Neil

 S. Murali Krishna wrote:

 Hai ALL
 Is there any way to capture function call in PHP
 and redirect to some other function if that function doesn't exists.

 Perl programmers remind   AUTOLOAD method in a package.

 S.Murali Krishna
 [EMAIL PROTECTED]
 =
 We grow slow trying to be great

- E. Stanley Jones
 -

 --
 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: php-list-
 [EMAIL PROTECTED]

 ***
  This message was virus checked with: SAVI 3.52
  last updated 8th January 2002
 ***

 --
 
  Email:  [EMAIL PROTECTED]
  [EMAIL PROTECTED]
 



 S.Murali Krishna
 [EMAIL PROTECTED]
 =
 We grow slow trying to be great
   
  - E. Stanley Jones
 -


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




Re: [PHP] variable variables

2002-01-17 Thread Steve Cayford


On Thursday, January 17, 2002, at 10:11  AM, Mike Krisher wrote:

 I can not wrap my head around variable variables today, not awake yet or
 something.

 For instance I trying something like this:

 while ($i$loopcounter) {
   $temp = size;
   $valueofsize = $$temp$i;

try $valueofsize = ${$temp$i};

   $i++;
 }

 this doesn't work obviously, $valueofsize ends up with a literal value 
 of
 $size1. But I need it to equal the value of a variable named $size1. 
 Do I
 need to use a eval() or something?

 Thanks in advance,
 » Michael Krisher
   [EMAIL PROTECTED]


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




Re: [PHP] Error

2002-01-08 Thread Steve Cayford


On Tuesday, January 8, 2002, at 09:37  AM, Dean Ouellette wrote:

 Hi I am learning php with Sams leanr php in 24 hours.

 This is one example
 ?php
   function addNums($firstnum, $secondnum)
   {
   $result = $firstnum + $secondnum;
   return $result;11:  } // this is line 13

that should be:
  return $result; }

what's the 11: doing in there?

-Steve

   print addNums (3,5);
   
 ?

 When I run it get error line 13

 any  ideas?


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




Re: [PHP] counting with dates (help!)

2002-01-07 Thread Steve Cayford

Well, I'll chime in as well. I'd recommend doing all your calculations 
in timestamps in seconds, then convert the results into days, dates, or 
whatever. If you only have a date to start with then convert to a 
timestamp, do the calculation, and convert back. You could wrap it in a 
function like this:

?php
function dateDiffInDays($date1,$date2) {
 $date1Tm = strtotime($date1);
 $date2Tm = strtotime($date2);
 $diff = abs($date1Tm - $date2Tm) / 86400;
 return $diff;
}

$today = date(Ymd,mktime(0,0,0, date(m), date(d), date(Y)));
$last_week = date(Ymd, mktime(0,0,0, date(m), date(d)-7, 
date(Y)));

print(today: $today br\n);
print(last_week: $last_week br\n);
print(diff in days:  . dateDiffInDays($last_week, $today) . br\n);
?


On Thursday, February 7, 2002, at 04:21  PM, Sander Peters wrote:

 Hello,


 This is my problem:

 $today = date(Ymd, mktime(0,0,0, date(m),date(d),date(Y)));
 $last_week = date(Ymd, mktime(0,0,0, date(m),date(d)-7,date(Y)));
 echo ($today - $last_week);
 The result is a number like 8876 (20020107-20011231 = 8876)
 But in date thinking it should be 7!

 How can I let php count in real days/month/years in stead of numbers?

 Maybe this is a silly question, but anyone who has the answer would help
 me very much!

 Thanks in advance!


 --
 Met vriendelijke groet / With Greetings,

 Sander Peters

site: http://www.visionnet.nl/
   email: mailto:[EMAIL PROTECTED]
 webmail: mailto:[EMAIL PROTECTED]



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




Re: [PHP] PHP Doesn't Crash but show blank page

2002-01-03 Thread Steve Cayford

Two other lines to look for in your php.ini file:

display_errors = On
log_errors = Off

If display_errors is on the error will be displayed on the web page, if 
log_errors is on the error will be logged--assuming you're using Linux 
check /var/log/messages, but you can change this with the 
error_log = ... option.

-Steve


On Wednesday, January 2, 2002, at 05:11  AM, [@-!-%] wrote:


 Hello everyone!

 I'm having issues with my php pages. When I have errors, Instead of
 crashing or showing  errors, the browser shows a blank page.

 For example, if I leave the left bracket in my if statement, like

 if(blah blah)
---missing left bracket '{'

 do this

 }else {
  do that
 }

 or, I leave the semiconlon at the end of a line, like

 $myvar=  this is my line -- missing ';'

 PHP does not report the error.

 My php.ini is configured as

 error_reporting =
 E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR|E_USER_ERROR|E_USER_WARNING|E_USER_NOTICE

 My system has
 PHP 4.0.6, MySQL 3.23.46-nt, Win2000

 Anyone knows why it's doing that?

 -john

 __John Monfort_
 _+---+_
  P E P I E  D E S I G N S
www.pepiedesigns.com
 The world is waiting, are you ready?
 -+___+-



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




Re: [PHP] Regular Expression

2002-01-03 Thread Steve Cayford

You can do as Jim says here or go back and read the manual section again 
for eregi and ereg. What you're trying to do should be written more like 
this:

?php
$str = 'body bgcolor=#ff';
$numMatches = eregi('(body)(.*)()',$str,$results);
print(numMatches: $numMatches br\n);
print(body contents: $results[2] br\n);
print(all results: );
print_r($results);
?

-Steve


On Thursday, January 3, 2002, at 12:15  PM, Jim Lucas [php] wrote:

 I have seen this question reposted for the past week.  now why don't you
 just work with the entire thing.

 get the body  ...  

 now once you have that, do this

 $str = preg_replace(body, , $str)
 $str = preg_replace(, , $str)

 now your $str var will only have the properties.

 Jim
 - Original Message -
 From: [-^-!-%- [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, January 02, 2002 12:45 PM
 Subject: [PHP] Regular Expression



 Hello everyone!

 I'm trying to get the text inside the BODY tag, using regular
 expression.

 $area = eregi('(body)(.*))',$str);

 Where $str is the string containing
 body bgcolor=#99 tex=#... ...

 When I print  $area, the string contains the entire content of $str. I
 get something like:

 body ...
 p
 .
 .
 .
 /body
 /html



 __John Monfort_
 _+---+_
  P E P I E  D E S I G N S
www.pepiedesigns.com
 The world is waiting, are you ready?
 -+___+-




 --
 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: php-list-
 [EMAIL PROTECTED]




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




Re: [PHP] Error while calling a function

2001-12-18 Thread Steve Cayford

I don't know all the details about how PHP compiles a program, but 
having your function definitions in an if-else statement that may not be 
executed looks suspicious to me.

You've got
if(!$Phone)
{
 do something
}
else
{
 function is_phone() { ...blah, blah...}
}

is_phone($Phone);

If you don't hit the else block, your is_phone function is probably not 
defined.

-Steve

On Tuesday, December 18, 2001, at 07:26  AM, J.F.Kishor wrote:

 hi all,

   I have got a problem, when I execute the following script it gives
 a Fatal error, could any one tell me why is it ?, If this is a silly
 problem please execuse me but, plz do reply me.

 The script is
 -
 html
 body
 ?
 if(!$Phone)
 {
   ?
  form action=?echo $PHP_SELF? method=post
 br
 Telephone Number : input type=text name=Phone value=
 br
 input type=submit
 script language=php
 }
 else
 {

   function is_allnumbers ($text)
 {
   if( (gettype($text)) == integer)
   {
   print the value is an integer;
 return true;
   }

   $Bad = $this-strip_numbers($text);

   if(empty($Bad))
   {
   print the value is  empty;
 return true;
   }
   return false;
 }

   function clear_error ()
 {
   $this-ERROR = this is an error;
 }


   function is_phone ($Phone =)
 {
   if($this-CLEAR)
   {
 $this-clear_error();
   }

   if(empty($Phone))
   {
 $this-ERROR = is_phone: No Phone number
 submitted;
 return false;
   }

   $Num = $Phone;
   $Num = $this-strip_space($Num);
   $Num = eregi_replace((\(|\)|\-|\+),,$Num);
   if(!$this-is_allnumbers($Num))
   {
 $this-ERROR = is_phone: bad data in phone
 number;
 return false;
   }

   if ( (strlen($Num))  7)
   {
   print the number is less then 7;
 $this-ERROR = is_phone: number is too short
 [$Num][$Phone];
 return false;
   }

   if( (strlen($Num))  13)
   {
   print the number is  then 13;
 $this-ERROR = is_phone: number is too long
 [$Num][$Phone];
 return false;
   }

   return true;
 }
 }
 $result = is_phone($Phone);
 if($result == true)
 {
  echo success;
 }
 else
 {
   echo failure;
 }

 /script
 /body
 /html

 The error is
 
 Fatal error: Call to undefined function: is_phone() in
 /home/kuruvi1/kishor/public_html/IMS/ADMIN/test/is_phone.php on line 87


 Thanks for your tolerance,

   - JFK
  kishor



 --
 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 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] Class methods and inheritance...

2001-12-11 Thread Steve Cayford

Hi. Is there a way to find the class name of a method when called in the 
class::method() format? If called on an object (eg. object-method()) I 
could just ask for get_class($this), but when called as class::method(), 
$this should not be defined. Anyway around this?

Thanks.

-Steve


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




Re: [PHP] Date formatting

2001-12-11 Thread Steve Cayford


On Monday, December 10, 2001, at 09:35  PM, phantom wrote:

 What would be an easy what to format a date value into month day year??
 I want to specially display a date stored in mysql in date format
 -MM-DD

 The manual says: string date (string format, int [timestamp])

 I tried $FormattedDate = date(F y, Y,${StoredDate})


try $FormattedDate = date(F y, Y,strtotime($StoredDate));

strtotime will convert your -MM-DD string into a unix timestamp.

 1999-04-15 spit out December 31, 1969 when I had hoped for April 15,
 1999.

 Apparently -MM-DD is not a valid timestamp... i tried mysql formats
 of timestamp(8) and timestamp(14) and that didn't work either




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




Re: [PHP] Finding num of days b/t two dates.

2001-12-07 Thread Steve Cayford

Here's one way to do it by converting dates into timestamps.
?php

$date1 = mktime(0,0,0,10,1,2001); // in the form (hours, minutes, 
seconds, month, day, year)
$date2 = mktime(0,0,0,10,1,2000);
$timedif = $date1 - $date2;

print(strftime(date 1 is %b %d, %Y, $date1) . br\n);
print(strftime(date 2 is %b %d, %Y, $date2) . br\n);
print(the difference in seconds is  . $timedif . br\n);
print(the difference in days is  . ($timedif / (60 * 60  * 24)) . 
br\n);
?

-Steve

On Friday, December 7, 2001, at 04:48  PM, Alex Fritz wrote:

 If somebody could help me with this, it would save me a lot of 
 heartache.  I
 thought that this would be simple, but I can't seem to find a function
 anywhere in PHP that has this capability and I can't seem to find any
 external libraries for anything actually.  I need to be able to give 
 PHP a
 start date and an end date and have it return the number of days 
 between the
 dates.  If the first date is more recent than the second, I need it to 
 give
 me a negative number.  Can somebody please help?

 Alex



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




Re: [PHP] Display BLOB Image

2001-12-06 Thread Steve Cayford

This is what I used to do what you're trying:

header(Content-Type: image/ . $imagetype); // $imagetype is jpeg or gif
header(Content-Length:  . strlen($image));
echo $image;

Note that Type is capitalized in Content-Type, and include the 
Content-Length as well.

-Steve


On Thursday, December 6, 2001, at 02:45  PM, phantom wrote:

 I have successfully placed images (jpg,gif,png) into a MySQL database
 BLOB field, now I want to be able to pull the data out and diplay it.

 based on tutorial at
 http://www.zdnet.com/devhead/stories/articles/0,4413,2644827,00.html

 after Querying the DB I have the following lines:

 $ImgFile = mysql_result($Results,0,ImgFile); \\ image data;
 $ImgType = mysql_result($Results,0,ImgType);  \\ image type (image/jpeg,
 image/gif);
 header(Content-type: ${ImgType});
 echo $ImgFile;

 Problem: This method, when it pulls up an image, it shows no image but a
 bunch of greek code.  Example
 http://www.phantomcougar.com/strawberrypie_com/mem/show_img.php?PNum=8
 ((be sure to view page source)




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




Re: [PHP] Why are slashes automatically stripped from db result?

2001-12-04 Thread Steve Cayford


On Monday, December 3, 2001, at 06:16  PM, Tyler Longren wrote:

 I believe you're correct Martin.  I think newer versions of MySQL
 automatically strip them out.  Just use php's stripslashes() and
 addslashes() functions when you need them.

Interesting. A bit unnerving at first, though.

Thanks.

-Steve



 Good luck Steve,
 Tyler Longren

 - Original Message -
 From: Martin Towell [EMAIL PROTECTED]
 To: 'Steve Cayford' [EMAIL PROTECTED];
 [EMAIL PROTECTED]
 Sent: Monday, December 03, 2001 6:04 PM
 Subject: RE: [PHP] Why are slashes automatically stripped from db 
 result?


 maybe mysql is stripping the slashes and not php ??

 -Original Message-
 From: Steve Cayford [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, December 04, 2001 10:57 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Why are slashes automatically stripped from db result?


 Hey all. I'm storing some jpeg images in a mysql database using the 
 PEAR
 classes. Before inserting the image into the db I call addslashes() on
 the data, I was, accordingly, calling stripslashes() on the data after
 pulling the image back out of the database, but the image was getting
 mangled. I finally realized that the slashes were already stripped from
 my query results so stripping them again was removing legitimate 
 slashes.

 The question is: why are the slashes already stripped out of the db
 results? I call set_magic_quotes_runtime(0) at the beginning of the
 scripts to turn off magic quoting. What else would cause this?

 Thanks for any suggestions.

 -Steve


 --
 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: php-list-
 [EMAIL PROTECTED]



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




Re: [PHP] 'Running' a file from PHP script

2001-12-04 Thread Steve Cayford


On Tuesday, December 4, 2001, at 02:22  AM, George Pitcher wrote:

 Hi all,

 I'm a PHP newbie, my main scipring being done in Blueworld's Lasso.

 I have used php fro time to time with Lasso to do some file handling.

 My question is: 'Can I run a file from a PHP script?'

 The file in question would be a Filemaker database file. I want to be 
 able
 to open the file in the Filemaker application if the file is not already
 running.


If you mean can you open the Filemaker application on the client's 
machine using PHP, then no. Keep in mind that PHP is only running on the 
server(*), all the client machine sees is the HTML output from your PHP 
script. Maybe you could use javascript to do this, but I haven't used 
javascript much.

-Steve

(*) Assuming you're using PHP in its normal web-server scripting mode.


 MTIA

 George in Edinburgh



 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


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




Re: [PHP] Cannot use a scalar value as an array

2001-12-04 Thread Steve Cayford


On Tuesday, December 4, 2001, at 06:04  AM, Xavier Antoviaque wrote:


 Hello all,

 I have a problem with a php script, which I want to use to fetch two 
 data
 (integer) from a MySQL table, divide the first by the second, and store 
 the
 value resulting in an double array. That seems not very difficult, but I
 always have the error 'Cannot use a scalar value as an array' when I 
 use my
 script.

 Here it is :

   $result = mysql_query(SELECT timestamp_c,connectes,num FROM
 stats_serveurs WHERE timestamp_c LIKE '.$date.%' AND serveur='.
 $serveur.', $link);

   $max = 0;
   $reps = mysql_num_rows($result);
   for($i = 1; $i=$reps; $i++){
 $row = mysql_fetch_row($result);
 $serveur[$i]['heure'] = $row[0];
 $serveur[$i]['connectes'] = (int) ($row[1] / $row[2]); // Error!
 $max = max($max, $serveur[$i]['connectes']);
   }


How does the operator precedence work in the statement ($row[1] / 
$row[2]) ? You might try (($row[1]) / ($row[2])) instead, or pull those 
into scalar variables before trying the division.

-Steve

 Any help is welcome ! :-)

 --
 Xavier.

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




Re: [PHP] 'Running' a file from PHP script

2001-12-04 Thread Steve Cayford

Ah, well, can't help you there, sorry.

-Steve

On Tuesday, December 4, 2001, at 09:40  AM, George Pitcher wrote:

 Steve,

 Thanks for the response, but it's a server-side 'run' I'm looking for, 
 not
 client-side (they get web access to the db).

 Basically I want to be able to test that the db is running and if it 
 isn't
 then I want to 'run' it. Platform is NT, server is IIS4

 George

 - Original Message -
 From: Steve Cayford [EMAIL PROTECTED]
 To: George Pitcher [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Tuesday, December 04, 2001 3:39 PM
 Subject: Re: [PHP] 'Running' a file from PHP script



 On Tuesday, December 4, 2001, at 02:22  AM, George Pitcher wrote:

 Hi all,

 I'm a PHP newbie, my main scipring being done in Blueworld's Lasso.

 I have used php fro time to time with Lasso to do some file handling.

 My question is: 'Can I run a file from a PHP script?'

 The file in question would be a Filemaker database file. I want to be
 able
 to open the file in the Filemaker application if the file is not 
 already
 running.


 If you mean can you open the Filemaker application on the client's
 machine using PHP, then no. Keep in mind that PHP is only running on 
 the
 server(*), all the client machine sees is the HTML output from your PHP
 script. Maybe you could use javascript to do this, but I haven't used
 javascript much.

 -Steve

 (*) Assuming you're using PHP in its normal web-server scripting mode.


 MTIA

 George in Edinburgh



 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


 --
 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: php-list-
 [EMAIL PROTECTED]



 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


 --
 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 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] Why are slashes automatically stripped from db result?

2001-12-03 Thread Steve Cayford

Hey all. I'm storing some jpeg images in a mysql database using the PEAR 
classes. Before inserting the image into the db I call addslashes() on 
the data, I was, accordingly, calling stripslashes() on the data after 
pulling the image back out of the database, but the image was getting 
mangled. I finally realized that the slashes were already stripped from 
my query results so stripping them again was removing legitimate slashes.

The question is: why are the slashes already stripped out of the db 
results? I call set_magic_quotes_runtime(0) at the beginning of the 
scripts to turn off magic quoting. What else would cause this?

Thanks for any suggestions.

-Steve


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




Re: [PHP] query works in mysql, but not from php

2001-11-19 Thread Steve Cayford

You don't need to put in the final semi-colon when running a query from 
php. Take that out and you should be fine.

-Steve

On Monday, November 19, 2001, at 04:58  PM, Olav Drageset wrote:

 Hi

 $sql = SELECT user FROM persons WHERE user = '$firstName' and domain = 
 '$domainName' ; ;
 $result = mysql_query($sql,$connection ) or die(mysql_error());

 Calling above lines from php returns: You have an error in SQL 
 syntax near ';'  at line 1

 Issuing the command

 SELECT user FROM persons WHERE user = 'fred' AND domain = 
 'company.net' ;

 in mysql give a proper result.

 Can anyone explain what might be causing the error???
 regards Olav


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




Re: [PHP] Anyone ever done this - sort a multi-dimensional array

2001-11-15 Thread Steve Cayford

You can roll your own fairly easily:

function mycmp($a,$b) {
 return strcmp($a[1],$b[1]);
}
usort($array, 'mycmp');

...something like that at any rate.

-Steve

On Thursday, November 15, 2001, at 10:07  AM, Richard S. Crawford wrote:

 Of the type...

 $array[0][0] = !row of c's;
 $array[0][1] = ;
 $array[1][0] = row of a's;
 $array[1][1] = ;
 $array[2][0] = a row of b's;
 $array[2][1] = ;


 such that you sort on the value of the y-column?

 In this case, it would end up as:

 +--+--+
 | row of a's   |  |
 | a row of b's |  |
 | !row of c's  |  |
 +--+--+

 Strange that I've been working with PHP this long and have never come 
 across this problem.



 Sliante,
 Richard S. Crawford

 http://www.mossroot.com
 mailto:[EMAIL PROTECTED]
 AIM: Buffalo2K   ICQ: 11646404  Y!: rscrawford
 It is only with the heart that we see rightly; what is essential is 
 invisible to the eye.  --Antoine de Saint Exupéry

 Push the button, Max!


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




Re: [PHP] very weird PHP behaviour...

2001-11-14 Thread Steve Cayford

Sure sounds like you're hitting this function twice by accident. Are you 
sure you're only calling it once? That would explain why you only get 
one output with the die(), but two without it.

-Steve

On Wednesday, November 14, 2001, at 10:34  AM, Christian Dechery wrote:

 I don't know what it is... but PHP is acting very weird today... or I 
 am becoming crazy... can anyone tell me which one?

 I have this function:
 function 
 Upload($source_file,$source_filename,$dest_dir,$allowed_types=array())
 {
 global $upload_errmsg;

 if( count($allowed_types) )
 {
   $file_ext=ArquivoExt($source_filename);
   $ext_found=in_array($file_ext,$allowed_types);
   //die(source=$source_filename);
   //var_dump($ext_found);
   //die;
   if( !$ext_found )
   {
 $upload_errmsg=O arquivo \$source_filename\ não está entre os 
 tipos autorizados;
 //die(errmsg=$upload_errmsg);
 return false;
   }
 }
 ... some more code here ..
 return true;
 }

 the first crazy behaviour is... I use a test file called something.jpg, 
 ArquivoExt() returns me the extension of a given filename, in this case 
 jpg. $allowed_types contains gif,jpg and png so that in_array() 
 should return true... and it does... but get this... if I uncomment 
 that var_dump() guess what it outputs?

 bool(true) bool(false)

 very weird... how can one var_dump() call gives me two outputs?
 This double output doesn't occur if I uncomment the die after the 
 var_dump(). It only outputs bool(true) in that case.

 Now for the second weird behaviour... since no matter what, $ext_found 
 will always be false (due to the previous weirdness) it will always 
 enter the IF... but the weird thing is when the caller of Upload() 
 prints $upload_errmsg it only outputs:

 O arquivo  não está entre os tipos autorizados

 where is the filename? I've checked it tons of times... If I uncomment 
 the second die, right after the $upload_errmsg assignment, it outputs 
 ok, with the filename.

 Now, can someone explain me this VERY WEIRD behaviour??



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




Re: [PHP] Sessions Header PROBLEM again!

2001-11-02 Thread Steve Cayford

Don't know offhand what the problem is, but a couple thoughts:

1. Why are you using session_name(mysession) instead of 
session_name('mysession')?

2. Assuming you have register_globals on, you're trying to pass $count 
both as a session variable and a post variable. One of these is going to 
get overwritten by the other if I'm not mistaken.

3. Why not have the page 1 form action point directly at page 2 instead 
of being redirected through page 1? Do posted variables follow a 
redirect?

4. If posted variables do follow a redirect then page 1 will see that 
$submit is set and redirect to page 2, which will redirect to page 3, 
which will redirect to page 1, etc... Can you get an infinite 
redirection loop?

5. The form on page 1 includes a hidden count variable, page 2 and page 
3 don't.

What happens when you run this?

-Steve

On Friday, November 2, 2001, at 08:49  AM, Alessandro BOSSI wrote:

 Why in these 3 linked page the var count
 does not go through the page if I have the browser sessions disabled???

 Where is the mistake?

 I see the session_id, changing at every page!

 Someone can help me?
 Many thank
 Alessandro Bossi

 -
 ?php /* First.php */
 session_name(mysession);
 session_start();
 session_register (count);

 if (isset($submit)){
  header(Location: Seconda.php?.SID);
 }else{
  $count++;
 }

 print session_encode= .session_encode().BR;

 ?

 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
 HTMLHEADTITLE First Page/TITLE/HEAD
 BODY BGCOLOR=#A2BBAF

 H4First Page/H4
 Hello visitor, you have seen this page ?=$count; ? times.p
 count = ?= $HTTP_SESSION_VARS[count] ?BR
 P

 FORM METHOD=POST ACTION=?= $PHP_SELF ?
 INPUT TYPE=hidden NAME=count value=?=$count?
 INPUT TYPE=submit name=submit value=Go to the SECOND page
 /FORM

 /BODY/HTML
 -
 ?php /* Second.php */

 session_name(mysession);
 session_start();
 session_register('count');

 if (isset($submit)){
  header(Location: Third.php?.SID);
 }
 print session_encode= .session_encode().BR;

 ?

 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
 HTMLHEADTITLESecond Page/TITLE/HEAD
 BODY BGCOLOR=#A2BBAF

 H4Second Page/H4
 Hello visitor, you have seen this page ?=$count; ? times.p
 count = ?= $HTTP_SESSION_VARS[count] ?
 P
 FORM METHOD=POST ACTION=?= $PHP_SELF ?
 INPUT TYPE=submit name=submit value=Go to the THIRD Page 
 /FORM

 /BODY
 /HTML
 -
 ?php /* Third.php */

 session_name(mysession);
 session_start();
 session_register (count);


 if (isset($submit)){
   header(Location: First.php?.SID);
 }
 print session_encode= .session_encode().BR;
 ?

 !DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN
 HTML
 HEAD
 TITLEThird Page/TITLE
 /HEAD

 BODY BGCOLOR=#A2BBAF
 H4Third Page/H4
 Hello visitor, you have seen this page ?=$count; ? times.p
 Count = ?= $HTTP_SESSION_VARS[count] ?
 P

 FORM METHOD=POST ACTION=?= $PHP_SELF ?
 INPUT TYPE=submit name=submit value=Go to the FIRST Page 
 /FORM

 /BODY
 /HTML


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




Re: [PHP] Re: header(Location:);

2001-10-30 Thread Steve Cayford


On Tuesday, October 30, 2001, at 11:41  AM, Henrik Hansen wrote:

 [EMAIL PROTECTED] (Alberto) wrote:

 Ok, it works fine for me, i can redirection, but I don't want the 
 browser to
 load another page, I want to IF A THEN RUN A.PHP, IF B THEN RUN 
 B.PHP, I
 know i can use include('a.php') or require('a.php') but I'm sure 
 theres a
 way to say php parser to run one or another script without changing 
 URL to
 the client.

 use include as you say or html frames.


Yeah, why not
if($A) {
include('a.php');
} elseif ($B) {
include('b.php');
}

 --
 Henrik Hansen

 --
 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 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] Confused object in session variable.

2001-10-25 Thread Steve Cayford

Well, it's probably me that's confused. I have an authenticate() 
function which should start a session and if the user is not logged in 
then show the login screen otherwise return after storing and 
registering a user object in a session variable. This object has 
accessor methods to get the login name, access level, etc... This seems 
to work okay--within the authenticate function I can access the object 
in the HTTP_SESSION_VARS array. But as soon as I return to the main 
script it's gone. I must be doing something wrong with the scoping, but 
I can't see what. Any thoughts? Here's the code:

?php
/* - */
/* index.php */
/* - */

require_once('ucautho/ucautho.inc');

authenticate();

print(From index testUser:  . $testUser-getLogin() . br\n);
print(From index HTTP_SESSION_VARS['ucAuthoUser']: );
print($HTTP_SESSION_VARS['ucAuthoUser']-getLogin() . br\n); //this 
is line 12

?

?php
/* --- */
/* ucautho/ucautho.inc */
/* --- */

function authenticate($appName=) {
 global $HTTP_SESSION_VARS, $HTTP_POST_VARS;
 global $testUser;
 session_name(UCAutho);
 session_start();

 if (isset($HTTP_SESSION_VARS['ucAuthoUser'])  
$HTTP_SESSION_VARS['ucAuthoUser']-isValid()) {
 return;
 } else {
 if (isset($HTTP_POST_VARS['authoSubmit'])) {
 $HTTP_SESSION_VARS['ucAuthoUser'] =
 new 
UcAuthoUser($HTTP_POST_VARS['authoLogin'],$HTTP_POST_VARS['authoPword']);
 if ($HTTP_SESSION_VARS['ucAuthoUser']-isValid()) {
 session_register('ucAuthoUser');
 $testUser = $HTTP_SESSION_VARS['ucAuthoUser'];
 print(From authenticate testUser:  . 
$testUser-getLogin() . br\n);
 print(From authenticate 
HTTP_SESSION_VARS['ucAuthoUser']: );
 print($HTTP_SESSION_VARS['ucAuthoUser']-getLogin() . 
br\n);
 return;
 }
 }
 showLogin($appName);
 }
}

/* more functions and the class declaration snipped */

?

Here's what I get when I login as 'steve' with a good password:

 From authenticate testUser: steve
 From authenticate HTTP_SESSION_VARS['ucAuthoUser']: steve
 From index testUser: steve
 From index HTTP_SESSION_VARS['ucAuthoUser']:
Fatal error: Call to a member function on a non-object in 
/home/httpd/html/ucdamage/index.php on line 12

Note the testUser works in both instances, the session var only works 
inside the function.

-Steve


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




Re: [PHP] Confused object in session variable.

2001-10-25 Thread Steve Cayford

An update...
I had register_globals turned off. Now that I've turned register_globals 
on and changed my references from $HTTP_SESSION_VARS['ucAuthoUser'] to 
$ucAuthoUser it works as I expect.

I'm not real happy with having register_globals on, though, and I'd like 
to figure out what I was doing wrong.

Thanks for any suggestions.

-Steve

On Thursday, October 25, 2001, at 12:07  PM, Steve Cayford wrote:

 Well, it's probably me that's confused. I have an authenticate() 
 function which should start a session and if the user is not logged in 
 then show the login screen otherwise return after storing and 
 registering a user object in a session variable. This object has 
 accessor methods to get the login name, access level, etc... This seems 
 to work okay--within the authenticate function I can access the object 
 in the HTTP_SESSION_VARS array. But as soon as I return to the main 
 script it's gone. I must be doing something wrong with the scoping, but 
 I can't see what. Any thoughts? Here's the code:

 ?php
 /* - */
 /* index.php */
 /* - */

 require_once('ucautho/ucautho.inc');

 authenticate();

 print(From index testUser:  . $testUser-getLogin() . br\n);
 print(From index HTTP_SESSION_VARS['ucAuthoUser']: );
 print($HTTP_SESSION_VARS['ucAuthoUser']-getLogin() . br\n); //this 
 is line 12

 ?

 ?php
 /* --- */
 /* ucautho/ucautho.inc */
 /* --- */

 function authenticate($appName=) {
 global $HTTP_SESSION_VARS, $HTTP_POST_VARS;
 global $testUser;
 session_name(UCAutho);
 session_start();

 if (isset($HTTP_SESSION_VARS['ucAuthoUser'])  
 $HTTP_SESSION_VARS['ucAuthoUser']-isValid()) {
 return;
 } else {
 if (isset($HTTP_POST_VARS['authoSubmit'])) {
 $HTTP_SESSION_VARS['ucAuthoUser'] =
 new 
 UcAuthoUser($HTTP_POST_VARS['authoLogin'],$HTTP_POST_VARS['authoPword']);
 if ($HTTP_SESSION_VARS['ucAuthoUser']-isValid()) {
 session_register('ucAuthoUser');
 $testUser = $HTTP_SESSION_VARS['ucAuthoUser'];
 print(From authenticate testUser:  . 
 $testUser-getLogin() . br\n);
 print(From authenticate 
 HTTP_SESSION_VARS['ucAuthoUser']: );
 print($HTTP_SESSION_VARS['ucAuthoUser']-getLogin() . 
 br\n);
 return;
 }
 }
 showLogin($appName);
 }
 }

 /* more functions and the class declaration snipped */

 ?

 Here's what I get when I login as 'steve' with a good password:

 From authenticate testUser: steve
 From authenticate HTTP_SESSION_VARS['ucAuthoUser']: steve
 From index testUser: steve
 From index HTTP_SESSION_VARS['ucAuthoUser']:
 Fatal error: Call to a member function on a non-object in 
 /home/httpd/html/ucdamage/index.php on line 12

 Note the testUser works in both instances, the session var only works 
 inside the function.

 -Steve


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




Re: [PHP] function names

2001-10-25 Thread Steve Cayford


On Thursday, October 25, 2001, at 02:08  PM, Martín Marqués wrote:

 On Jue 25 Oct 2001 15:36, you wrote:
 Hello php-general,

   I have such code:

   class A
   {
 var $xxx;

 function print()
 {
  echo $xxx;

 $xxx is internal to the print function. Instead you need $this-xxx 
 which
 will give you the value of the $xxx of the A class.

 }
   }

   And that's what I get:
 Parse error: parse error, expecting `T_STRING' in xxx.php on line 
 nn

   Php doesn't let any function or class member have a name which is
   already used by another function (or only function from library),
   am I right? Or maybe print has special status. Maybe that's
   because print() is actually not a function? Can anyone tell me
   something about that, please?

 Th print function of PHP has nothing to do with this, just because 
 print is
 internal to the A class, and has nothing with the PHPs internal print
 function.

Hmm. I think you're wrong here. I made this test script:
?php

class test {
 var $a;

 function test() {
 $this-a = hello;
 }

 function print() { // this is line 10
 echo $this-a;
 }
}

$obj = new test;
$obj-print();

?
Which gives this:

Parse error: parse error, expecting `T_STRING' in 
/home/httpd/html/ucdamage/test.php on line 10

If I change the name of the print() method it works okay.

-Steve


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




Re: [PHP] Setting A MySQL Column to NO DUPLICATES

2001-10-25 Thread Steve Cayford

I think you want UNIQUE.

create table sometable (
somecolumn char(40),
someothercolum int,
unique somecolumn
)

...something like that. I haven't messed with it much.

-Steve

On Thursday, October 25, 2001, at 04:31  PM, Jeff Gannaway wrote:

 Does anyone know how to set a column in a MySQL table to disallow any
 duplicate entries.

 I've already got a PRIMARY KEY defined for this table.  I tried setting 
 the
 other field to a MUL KEY, hoping that it would not permit duplicates, 
 but
 it does.

 I've searched the MySQL docs without success. I wish their site was a 
 good
 as PHP.net.

 Later,
 Jeff Ganaway
 ___

 Save 15% on 2002 Calendars and Holiday Cards!

 http://www.AvantGifts.com
 Discount Code: hopper22ct
 Offer Good Through October 31, 2001
 ___


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




Re: [PHP] Re: require include

2001-10-23 Thread Steve Cayford

So both include() and require() *are* subject to conditional statements 
in the code? Guess I missed that.

Thanks.

-Steve

On Tuesday, October 23, 2001, at 01:00  AM, Rasmus Lerdorf wrote:

 That's outdated.  The only difference today is that if a file can't be
 included/required for some reason it is a fatal error with require and a
 warning with include.

 -Rasmus

 On Tue, 23 Oct 2001, Jason G. wrote:

  From the manual:

 Unlike include(), require() will always read in the target file, even 
 if
 the line it's on never executes. If you want to conditionally include a
 file, use include(). The conditional statement won't affect the 
 require().
 However, if the line on which the require() occurs is not executed, 
 neither
 will any of the code in the target file be executed.

 Similarly, looping structures do not affect the behaviour of require().
 Although the code contained in the target file is still subject to the
 loop, the require() itself happens only once.





 At 08:48 AM 10/23/2001 +0900, Yasuo Ohgaki wrote:
 Jtjohnston wrote:

 Coverting from perl ...
 What's the differencw between require and include? Where, when, why?


 I forgot from which version, but current PHP's require/include works 
 the
 same way except

 - require() raise fatal error, if it can't find file
 - include() raise warning, if it can't find file


 requrie_once()/include_once() works almost the same as 
 require()/include()
 except they include file only once. (Hash table is used to determine 
 if
 files are included or not)

 See also get_{required|included}_files()

 --
 Yasuo Ohgaki


 --
 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: php-list-
 [EMAIL PROTECTED]




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




Re: [PHP] require include

2001-10-22 Thread Steve Cayford

http://www.php.net/manual/en/function.require.php

require() pulls in the target file when the source file is 
parsed/compiled, include() pulls in the target file when the source file 
is executed. So an include() nested in an if statement will only be 
included if the if statement evaluates to true, a require() nested in an 
if statement will be included regardless.

Also check out include_once() and require_once().

-Steve

On Monday, October 22, 2001, at 05:15  PM, jtjohnston wrote:

 Coverting from perl ...
 What's the differencw between require and include? Where, when, why?

 John?

 
 Email post  reply always appreciated


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




Re: [PHP] Array Elements While Loops

2001-10-01 Thread Steve Cayford

Where is the closing brace for your while loop?

-Steve

On Monday, October 1, 2001, at 07:04  AM, Tom Churm wrote:

 hi,

 my problem is this:  i'm using a while loop to check elements in an
 Array for valid email syntax.  if $User[0] is a valid email address but
 $User[1] is not, the code for $User[0] is still executed before the die
 statement.  i need my loop to finish checking ALL array elements for
 validity, and to then die BEFORE any further code is executed.  here's
 what i have now (it doesn't work):

 //loop to check for bad email addresses:
 $j = 0;
 $flag = 0;
 while ($j  count($User)){
 if
 (($User[$j]!=)!eregi(^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-
 z0-9-]+(\.[a-z0-9-]+)*$,
 $User[$j]))
 {
   $flag = 1;
   $errorNo = $j + 1;
 }
 //die if flag is 1
 if ($flag = 1) {
 die (p align='center'bEmail #$errorNo is not a valid e-mail
 address!/bbrbrbra
 href='javascript:window.history.back();'Please return and correct
 this./a/p);
   }
 else {
 continue...
 }

 any suggestions would be great!

 thanks much,

 tom

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




Re: [PHP] Getting my head around nulls

2001-09-26 Thread Steve Cayford


On Wednesday, September 26, 2001, at 02:48  AM, [EMAIL PROTECTED] 
wrote:







 Steve Cayford [EMAIL PROTECTED] on 25/09/2001 17:28:57



 To:   [EMAIL PROTECTED]
 cc:   [EMAIL PROTECTED], [EMAIL PROTECTED]
 Subject:  Re: [PHP] Getting my head around nulls


 On Tuesday, September 25, 2001, at 10:30  AM, [EMAIL PROTECTED]
 wrote:


 Just had a look at manual, ifnull() seems close to useless.  However 
 if
 they had NVL(), as Oracle douse

 NVL( column|litrel, '*null*' )

 This takes a column or literal as its first arg and if arg is null
 returns
 2nd arg otherwise returns arg.  In other words if the column is null 
 it
 is
 replaces by arg2 otherwise it is simply returned.


 Um, that's what ifnull() does. At least it works for me.

 -Steve

 Verry true, sorry, was looking at nullif.  Also noticed the if function,
 can this have more than three parameters.  i.e

 if ( col, 'A', 'Accept', 'C', 'Complete', 'Unknown' )

 like Oracle decode. and if elseif else structure.

 Neb


Looks like you want the CASE statement. I haven't used it but it looks 
pretty much like what you're asking.

CASE value WHEN [compare-value] THEN result [WHEN [compare-value] THEN 
result ...] [ELSE result] END

Guess this discussion should really be on php-db :)

-Steve

-- 
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] Extract. Was Re: Feature?

2001-09-26 Thread Steve Cayford

Just looking up that extract function, the manual says it extracts into 
the current symbol table. I assume that means that within foo() the 
array would be extracted into local variables. Is that right?

-Steve

On Wednesday, September 26, 2001, at 06:50  AM, Alister wrote:

 Follow up to my own message:

 If you want to also skip even needing the empty 'array()' (new fianl
 example) - check if it is an array, and only do the first extract of
 the parameters if there's something there.

 ?php
 function foo($p='')
 {
   $foodefault = array(
   'foo_fred'= 'strongdefault fred/strong',
   'foo_banana' = 'strongdefault bananananana/strong',
   );
   if (is_array($p))
   extract ($p, EXTR_PREFIX_ALL, 'foo');   // get values
   extract ($foodefault, EXTR_SKIP, foo);// get defaults
   echo  $foo_fred / $foo_banana;
 }

 echo Both in place: ;
 foo(array('fred' = 'hello', 'banana' = 'world'));
 echo br / Now with a missing param: ;
 foo(array('fred' = 'hello'));
 echo br / Now both missing params: ;
 foo(array());
 echo br / and with no array: ;
 foo();
 ?

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




Re: [PHP] Building Dynamic Value list using ohp

2001-09-26 Thread Steve Cayford

Also look for missing semicolons and unclosed braces in the lines above 
22.

-Steve

On Wednesday, September 26, 2001, at 09:19  AM, Derek Mailer wrote:

 oops...I was going to add...

 2) -

 $result = mysql_query($query, $mysql_link);

 doesn't require the $mysql_link argument, try

 $result = mysql_query($query);

 Another general comment is that you have copied a bit of your code that
 seems to include the root password to mysql.  Not a good idea - you 
 should
 check and edit your code if necessary before posting.

 Hope this helps - good luck

 Derek

 - Original Message -
 From: George Pitcher [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Sent: Wednesday, September 26, 2001 2:54 PM
 Subject: Re: [PHP] Building Dynamic Value list using ohp


 Thanks Gottfried, but that doesn't change the response I get.

 Any more suggestions.

 George P in Edinburgh

 PS I am hoping to come over to Frankfurt for the conference in November
 (boss might pay)

 - Original Message -
 From: [EMAIL PROTECTED]
 To: George Pitcher [EMAIL PROTECTED]
 Sent: Wednesday, September 26, 2001 2:46 PM
 Subject: Re: [PHP] Building Dynamic Value list using ohp


 hi!

 try:

 $query = select HEI from heronuser; // line 22

 greetinx!
 gottfried

 Hi all,

 I'm having a problem with dynamically building a value list.

 My code:

 ?php
 mysql_connect ('localhost', 'root', 'monty');
 mysql_select_db ('Heronsql');
$query = (select HEI from heronuser); // LINE 22 on original
 script
$result = mysql_query($query, $mysql_link);
  if(mysql_num_rows($result)) {
// show all HEIs as options in select form
while($row = mysql_fetch_row($result))
{
   print(option value=\$row[0]\$row[0]/option);
}
  }
 ?

 But this generates:

 Parse error:  parse error in c:\program files\apache
 group\apache\htdocs\bizflyers\login.php on line 22

 Any suggestions?

 Regards

 George


 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


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


 --
 GMX - Die Kommunikationsplattform im Internet.
 http://www.gmx.net


 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


 --
 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: php-list-
 [EMAIL PROTECTED]




 *
 *
 This e-mail (and any attachment) is intended only for the attention
 of the addressee(s). Its unauthorised use, disclosure, storage
 or copying is not permitted. If you are not the intended recipient,
 please destroy all copies and inform the sender by return e-mail.
 This e-mail (whether you are the sender or the recipient) may be
 monitored, recorded and retained by Business Information
 Publications Limited (BiP). E-mail monitoring/ blocking software
 may be used, and e-mail content may be read at any time.You
 have a responsibility to ensure laws are not broken when composing
 or forwarding e-mails and their contents.
 *
 *


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




Re: [PHP] Feature?

2001-09-25 Thread Steve Cayford

Maybe this? A bit verbose, but functional.

-Steve

?php

function foo($p)
{
   if (empty($p['fred'])){
 $p['fred'] = 'hello';
   }
   if (empty($p['banana'])){
 $p['banana'] = 'world';
   }
   echo  $p['fred'] . $p['banana'];
}

foo(array('fred' = 'hello', 'banana' = 'world'));

?

On Tuesday, September 25, 2001, at 06:25  AM, Andrey Hristov wrote:

 Yeap, I know that. I thought about this bit of hack but this breaks the 
 conception on giving parameters. Also this trick cannot
 solve the problem with default parameters. If I have function with 5 
 params and all of them have default values and I want to pass
 value only to the second parameter what I have to do?

 Andrey Hristov
 IcyGEN Corporation
 http://www.icygen.com
 BALANCED SOLUTIONS


 - Original Message -
 From: [EMAIL PROTECTED]
 To: Andrey Hristov [EMAIL PROTECTED]
 Sent: Tuesday, September 25, 2001 1:14 PM
 Subject: Re: [PHP] Feature?


 On Tue, 25 Sep 2001 11:36:25 +0300, you wrote:

 In the case when I've few parameters I've to remember their order, so 
 why not
 $bar=foo('par2'=10);
 I want to pass value to only one or more but not to all params.
 Also this will make the code clearer I think.
 Comments are welcome!

 ?php

 function foo($p)
 {
   echo  $p['fred'] . $p['banana'];
 }

 foo(array('fred' = 'hello', 'banana' = 'world'));

 ?



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




Re: [PHP] Getting my head around nulls

2001-09-25 Thread Steve Cayford

On Tuesday, September 25, 2001, at 10:30  AM, [EMAIL PROTECTED] 
wrote:

 Thanks for correcting my misspelling, Andrey, IS NULL not IS_NULL.
 Another thing to look at, Ben, is IFNULL(). I would give you an 
 example,
 but
 I never got it to work like I thought it should ;) I think it is 
 supposed
 to
 return an alternate value for NULLs.

 Just had a look at manual, ifnull() seems close to useless.  However if
 they had NVL(), as Oracle douse

 NVL( column|litrel, '*null*' )

 This takes a column or literal as its first arg and if arg is null 
 returns
 2nd arg otherwise returns arg.  In other words if the column is null it 
 is
 replaces by arg2 otherwise it is simply returned.


Um, that's what ifnull() does. At least it works for me.

-Steve



 Next week I will sing the prases of the oracle decode statement -;)  The
 week after that I will get all exited about MySQL freetext indexes, yum,
 yum.

 Neb


 --
 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 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] Querying an object's functions

2001-09-24 Thread Steve Cayford

Is there any way in PHP 4.0.6 to query an object for its member 
functions? For example I have a couple classes that have an htmlString() 
function to display themselves in some special way as html. I'd like to 
go through a list of various objects, find out if each can run 
htmlString() and if so use that, otherwise use some generic 
object-to-html function.

I could just put a member variable in the object and check for that, but 
it would be more elegant to be able to check for the function directly.

Thanks for any suggestions.

-Steve

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




Re: [PHP] Querying an object's functions

2001-09-24 Thread Steve Cayford

Thanks. Sorry for missing that.

-Steve

On Monday, September 24, 2001, at 05:54  PM, Rasmus Lerdorf wrote:

 http://www.php.net/manual/en/function.get-class-methods.php

 On Mon, 24 Sep 2001, Steve Cayford wrote:

 Is there any way in PHP 4.0.6 to query an object for its member
 functions? For example I have a couple classes that have an 
 htmlString()
 function to display themselves in some special way as html. I'd like to
 go through a list of various objects, find out if each can run
 htmlString() and if so use that, otherwise use some generic
 object-to-html function.

 I could just put a member variable in the object and check for that, 
 but
 it would be more elegant to be able to check for the function directly.

 Thanks for any suggestions.

 -Steve




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