Re: [PHP] Session file not written, session variables messed up.

2004-11-12 Thread Klaus Reimer
Rodolfo wrote:
The weirdness comes when in one frame the script will print Agent Smith
while in the other frame of the same frameset the script which loads on it
will print Thomas Anderson... 
Are both frames loaded at the same time? It's not possible to have two 
concurrently running scripts access the same session at the same time 
(At least when using files as backend). But normally that only means 
that one script execution is delayed until the other script completes or 
closes the session manually. But I never used session.auto_start, I 
always use session_start() in the PHP code. Maybe the auto_start session 
 behaves differently. Maybe you can try disabling auto_start and start 
the session manually. I don't think it make a difference, but who knows. 
 ;-)

On the other hand: Have you checked that your disk has enough room for 
more sessions? Maybe you are working on the bleeding edge of your 
harddisk capacity.

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


[PHP] Current URL?

2004-11-12 Thread Jason Paschal
Trying to get the current viewed page's URL (query string intact).

this works, but infrequently:

$url = $_SERVER['URI']; 

and this ignores the query string:

$url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];

I'm certain there's a way,  that is browser-independent,  to get your
script to grab the current URL (even if the script is an include).

i'm just trying to get a log of users currently online, and which page
they are viewing, and while the $_SERVER['REMOTE_ADDR'] will
invariably grab the IP, $_SERVER['URI'] is often empty.

i welcome any and all suggestions.

thank you,
~jmp

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



[PHP] Creating a directory

2004-11-12 Thread Danny Brow
What's the best way to create a directory with PHP, I tried using:

if (array_exists('dir',$_POST)) {
$dir_name = test123;  
shell_exec('mkdir $dir_name'); 

I don't want to have to declare a variable, I would like to do this all
on one line. Like:
shell_exec('mkdir $_POST['dir']'); // but it don't work
} else {
print Get get some coffee!;
}

I'll be putting some error checking in later :)

Thanks,
Dan.

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



Re: [PHP] Current URL?

2004-11-12 Thread John Holmes
Jason Paschal wrote:
Trying to get the current viewed page's URL (query string intact).
this works, but infrequently:
$url = $_SERVER['URI']; 
How about $_SERVER['REQUEST_URI']
and this ignores the query string:
$url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
or you could add/check for $_SERVER['QUERY_STRING'] here.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Simple XML

2004-11-12 Thread John Holmes
Octavian Rasnita wrote:
Does anyone know if PHP has a library for getting the content of an XML file
like XML::Simple in perl?
In that perl library I can get the whole content of an XML file in a
reference to an array of arrays of arrays... with only 3 lines of code.
Is there such a simple method in PHP?
Uhmm... SimpleXML?
http://us2.php.net/simplexml
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Creating a directory

2004-11-12 Thread Pluance
Use mkdir in PHP Functions.
See Also: http://www.php.net/manual/en/function.mkdir.php

On Fri, 12 Nov 2004 03:54:52 -0500, Danny Brow [EMAIL PROTECTED] wrote:
 What's the best way to create a directory with PHP, I tried using:
 
 if (array_exists('dir',$_POST)) {
$dir_name = test123;
shell_exec('mkdir $dir_name');
 
 I don't want to have to declare a variable, I would like to do this all
 on one line. Like:
shell_exec('mkdir $_POST['dir']'); // but it don't work
 } else {
print Get get some coffee!;
 }
 
 I'll be putting some error checking in later :)
 
 Thanks,
 Dan.
 
 --
 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] Creating a directory

2004-11-12 Thread Jason Wong
On Friday 12 November 2004 08:54, Danny Brow wrote:
 What's the best way to create a directory with PHP, I tried using:

 if (array_exists('dir',$_POST)) {
  $dir_name = test123;

I'm 99% sure you mean 'test123'.

  shell_exec('mkdir $dir_name');

I'm 100% sure you meant to use  instead of '.

 } else {
 print Get get some coffee!;

I'm 50% sure that should be print RTFM.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
I like your SNOOPY POSTER!!
*/

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



Re: [PHP] Creating a directory

2004-11-12 Thread Danny Brow
Thanks, I should have looked that up. 4am, time for bed.

Thanks again,
Dan.

On Fri, 2004-11-12 at 18:01 +0900, Pluance wrote:
 Use mkdir in PHP Functions.
 See Also: http://www.php.net/manual/en/function.mkdir.php
 
 On Fri, 12 Nov 2004 03:54:52 -0500, Danny Brow [EMAIL PROTECTED] wrote:
  What's the best way to create a directory with PHP, I tried using:
  
  if (array_exists('dir',$_POST)) {
 $dir_name = test123;
 shell_exec('mkdir $dir_name');
  
  I don't want to have to declare a variable, I would like to do this all
  on one line. Like:
 shell_exec('mkdir $_POST['dir']'); // but it don't work
  } else {
 print Get get some coffee!;
  }
  
  I'll be putting some error checking in later :)
  
  Thanks,
  Dan.
  
  --
  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 /'s in urls

2004-11-12 Thread Dennis Seavers
The link offers a CGI error, which is admittedly an uninteresting result. 
I think you'll need to indicate what your previous results were and, if
different, what your desired results are.

Dennis


 [Original Message]
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Date: 11/11/2004 11:58:10 PM
 Subject: [PHP] parsing /'s in urls

 My host recently upgraded PHP.  I had a script, download.php, that would
 work like this

 http://www.myhost.com/download.php/30/file.torrent

 the download.php script would take the 30, look up the real filename in
the
 database, and readfile() it back.  this was a great setup because the
 browser just thought it was accessing a direct link to a file.

 But now download.php/30/file.torrent results in a 404.

 Is this something I can change back?

 Dan

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

2004-11-12 Thread Nunners
Does anyone know of a good syslog parser?

 

I've successfully got the syslog server to write to a mysql table, but I now
want to find something that will give me graphs, breakdowns etc for the
syslog.

 

Cheers

James



Re: [PHP] Creating a directory

2004-11-12 Thread Danny Brow
On Fri, 2004-11-12 at 17:12 +, Jason Wong wrote:
 On Friday 12 November 2004 08:54, Danny Brow wrote:
  What's the best way to create a directory with PHP, I tried using:
 
  if (array_exists('dir',$_POST)) {
   $dir_name = test123;
 
 I'm 99% sure you mean 'test123'.

I meant $dir_name = $_POST['dir']; This works with out the single quote.
but all my variables have single or double quotes around them.

 
   shell_exec('mkdir $dir_name');
 
 I'm 100% sure you meant to use  instead of '.

this is how I normally do this when declaring variables, but that maybe
the difference here. 

 
  } else {
  print Get get some coffee!;
 
 I'm 50% sure that should be print RTFM.

RTFM  /dev/null :)


I'm 25-50% sure that this was a complete waste of a reply to a question.


 
 -- 
 Jason Wong - Gremlins Associates - www.gremlins.biz
 Open Source Software Systems Integrators
 * Web Design  Hosting * Internet  Intranet Applications Development *
 --
 Search the list archives before you post
 http://marc.theaimsgroup.com/?l=php-general
 --
 /*
 I like your SNOOPY POSTER!!
 */
 

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



Re: [PHP] calling function from function?

2004-11-12 Thread Sebastian Mendel
Jason wrote:
Rick Fletcher wrote:
function db( $host, $user, $pass, $dbnam ) {
 $db = @mysql_pconnect( $host, $user, $pass )or die( mysql_error( $db 
));
   @mysql_select_db( $dbnam )or die( mysql_error( $db ) );
 return $db;
}

function logs() {
 global $defined;
 db( $defined[9], $defined[1], $defined[2], $defined[3] );
 ... do some processing ...
}
what am i missing here? i get errors if i try to pass $db to logs. 
i.e. logs( $db );

What's missing?  The error message.  Include it, and the offending 
line(s) of code, and ask again.

--Rick
There isnt an error at all.  According to the die() functions at the end 
of the mysql() functions it should give it there, instead I get blank as 
if the function has not successfully completed.  The reason I say this 
is if you try to access the mysql resource pointer ( $db, in this case ) 
I get nothing, a return code of 0.  Example in point...

function db( $host, $user, $pass, $dbnam ) {
 $db = @mysql_pconnect( $host, $user, $pass )or die( font 
face=\arial\bphpDHCPAdmin currently not active, is under repair or 
is not configured correctly./bbrbrError Number:  .  mysql_errno( 
$db ) . brError Message:  . mysql_error( $db ) . brEmail 
Administrator: a href=\mailto:$defined[5]\;$defined[5]/a/font );
   @mysql_select_db( $dbnam )or die( font face=\arial\bCould 
not connect to database: $defined[3]/bbrError Message:  . 
@mysql_error( $db ) . br . Error Number:  . @mysql_errno( $db ) . 
brEmail Administrator: a 
href=\mailto:$defined[5]\;$defined[5]/a/font );
 return $db;
}

function logs() {
 global $defined;
 db( $defined[9], $defined[1], $defined[2], $defined[3] );
 $pagecount = 1;
 $tble = logs;
 $sql = @mysql_query( SELECT * FROM $tble WHERE session = 
\$_SESSION[hash]\, $db )
$db is not defined,
$db is not required,
at least if you want to use $db you have to ctach the return from db() 
in $db:

$db = db( $defined[9], $defined[1], $defined[2], $defined[3] );
as i assume, logs() does nothing more than update one row with session 
data in the DB?

if you have a primary key on `session` you can just user REPLACE instead of
if SELECT INSERT ELSE UPDATE
logs()
{
db( $defined[9], $defined[1], $defined[2], $defined[3] );
$sql = 'REPLACE INTO logs VALUES ( ... )';
mysql_query( $sql ) or die( '...' );
}
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Which PHP for MySQL 4.1

2004-11-12 Thread Sebastian Mendel
C.F. Scheidecker Antunes wrote:
Hello,
I would like to migrate my MySQL servers from 4.0 to 4.1.
As I use PHP as well as Java with these servers I wonder what PHP 4 
version would be compatible with MySQL 4.1.

Has anyone used MySQL 4.1 with PHP yet?
I appreciate your thoughts.
Thanks.
i run 4.1.x for a while, without problems,
after upgrading you have to rebuild you php to use the new mysql_librarys
and you have to run mysql_fix_privilege_tables on the linux/unix shell
4.1. uses a new display-format for timestamps!
4.1. uses a new encryption method for password(), with this function are 
all mysql_passwords stored in the db, thats why you have to run 
mysql_fix_privilege_tables

read carefully through all 4.1. changelogs!
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: parsing /'s in urls

2004-11-12 Thread Sebastian Mendel
[EMAIL PROTECTED] wrote:
My host recently upgraded PHP.  I had a script, download.php, that would
work like this
http://www.myhost.com/download.php/30/file.torrent
the download.php script would take the 30, look up the real filename in the
database, and readfile() it back.  this was a great setup because the
browser just thought it was accessing a direct link to a file.
But now download.php/30/file.torrent results in a 404.
Is this something I can change back?
this is an apache related thing
http://httpd.apache.org/docs-2.0/mod/core.html#acceptpathinfo
--
Sebastian Mendel
www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Re: Help: Database Search

2004-11-12 Thread Stuart Felenstein

--- Sebastian Mendel [EMAIL PROTECTED] wrote:
 
 $where = array();
 
 if ( isset($_POST['Ind']) ) {
  $where[] = 'vendorjobs.Industry = ' . (int)
 $_POST['Ind'];
 }
 if ( isset($_POST['Days']) ) {
  $where[] = 'Date_Sub(Curdate(), interval ' .
 (int) $_POST['Days'] . 
 ' day) = PostStart';
 }
 
 $sql = '
   SELECT ...
 FROM vendorjobs
WHERE ' . implode( ' AND ', $where );
 
 
Sebastian, I meant to thank you for this code the
other day.  
What I'm trying to figure out is some of my elements
are arrays themselves.  So for example I have this :

$Ind = ;
$Ind = $HTTP_POST_VARS['Ind'];
if (count($Ind)  0 AND is_array($Ind)) {
 $Ind = '.implode(',', $Ind).';
}

So how would this code , or array get into what you
stated as:

 $where = array();
 
 if ( isset($_POST['Ind']) ) {
  $where[] = 'vendorjobs.Industry = ' . (int)
 $_POST['Ind'];
 }

I guess that is putting an array into an array ?
Not quite sure how the loop would go.

Thank you,
Stuart

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



[PHP] PHP / LDAP with Windows logon

2004-11-12 Thread Christopher . Wood
Hello, I have an issue with a PHP interface. We have many engineering users
who will be using a request ticket system developed in PHP here. We don't
know in advance who will be using the system and there may be new people in
all the time. Currently I have to create a login for each person who needs
to use the system, so I have to get a request for a login, create the login,
and fill in their contact information. Since we work with engineers on a
12-15 hour time difference, it might take a whole day or more to get the
login id request filled before they can open a ticket. Plus there's the
whole inconvenience of having to login to another website. The site is
inside our secure intranet, so we don't really need a double layer of
security. 

Since we normally logon to a Windows network, what I would like to do is to
detect the user's windows login id when he accesses the PHP page, and
automatically reference his contact information from the windows LDAP
server, so the user can be authenticated by his  current windows login
information, and not have to enter a separate login on the request page. Is
this possible, and what is an easy way to do this?

Thanks!

Chris


[PHP] Unsetting vars when not needed?

2004-11-12 Thread Jordi Canals
Hi all,

I was working now in a new site developed with PHP 5.0.2 and a wonder
came to me:

Is usefull and recommended to unset a class instance when not needed?

Specially when the class was instantiated inside a function and the
function ends. In this case, the system should  automatically destroy
the instance (as it is a local var inside a function).

If we manually unset the instance at the end of the function, does
this affect the PHP performance? I mean, will PHP have to do an extra
job unsetting the var?

Also, the same question arises with database results. Is it worth to
call mysql_free_result at the end of a function that uses it? Must
take into consideration that there are lots of functions that use lots
of MySQL results.

Thanks for any comment
Jordi.

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



RE: [PHP] Re: Help: Database Search

2004-11-12 Thread Graham Cossey

I think you're implode example is pretty close.

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

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

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

This should result in:

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

OR

WHERE vendorjobs.Industry = 2

HTH
Graham



 -Original Message-
 From: Stuart Felenstein [mailto:[EMAIL PROTECTED]
 Sent: 12 November 2004 12:42
 To: Sebastian Mendel; [EMAIL PROTECTED]
 Subject: Re: [PHP] Re: Help: Database Search



 --- Sebastian Mendel [EMAIL PROTECTED] wrote:
 
  $where = array();
 
  if ( isset($_POST['Ind']) ) {
   $where[] = 'vendorjobs.Industry = ' . (int)
  $_POST['Ind'];
  }
  if ( isset($_POST['Days']) ) {
   $where[] = 'Date_Sub(Curdate(), interval ' .
  (int) $_POST['Days'] .
  ' day) = PostStart';
  }
 
  $sql = '
SELECT ...
  FROM vendorjobs
 WHERE ' . implode( ' AND ', $where );
 

 Sebastian, I meant to thank you for this code the
 other day.
 What I'm trying to figure out is some of my elements
 are arrays themselves.  So for example I have this :

 $Ind = ;
 $Ind = $HTTP_POST_VARS['Ind'];
 if (count($Ind)  0 AND is_array($Ind)) {
  $Ind = '.implode(',', $Ind).';
 }

 So how would this code , or array get into what you
 stated as:

  $where = array();
 
  if ( isset($_POST['Ind']) ) {
   $where[] = 'vendorjobs.Industry = ' . (int)
  $_POST['Ind'];
  }

 I guess that is putting an array into an array ?
 Not quite sure how the loop would go.

 Thank you,
 Stuart

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



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



[PHP] Re: Current URL?

2004-11-12 Thread Matthew Weier O'Phinney
* Jason Paschal [EMAIL PROTECTED]:
 Trying to get the current viewed page's URL (query string intact).

 this works, but infrequently:

 $url = $_SERVER['URI']; 

 and this ignores the query string:

 $url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];

 I'm certain there's a way,  that is browser-independent,  to get your
 script to grab the current URL (even if the script is an include).

 i'm just trying to get a log of users currently online, and which page
 they are viewing, and while the $_SERVER['REMOTE_ADDR'] will
 invariably grab the IP, $_SERVER['URI'] is often empty.

Try:

$url = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];

-- 
Matthew Weier O'Phinney   | mailto:[EMAIL PROTECTED]
Webmaster and IT Specialist   | http://www.garden.org
National Gardening Association| http://www.kidsgardening.com
802-863-5251 x156 | http://nationalgardenmonth.org

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



RE: [PHP] Re: Help: Database Search

2004-11-12 Thread Stuart Felenstein

--- Graham Cossey [EMAIL PROTECTED] wrote:

 This should result in:
 
 WHERE vendorjobs.Industry IN (2,3,5)
 
 OR
 
 WHERE vendorjobs.Industry = 2
 
 HTH
 Graham

Not sure what you mean by the above ?

Stuart

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



RE: [PHP] Re: Help: Database Search

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

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

Graham

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

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



Re: [PHP] Unsetting vars when not needed?

2004-11-12 Thread Brent Baisley
I use mysql_free_result when I'm done with the particular query, but I 
don't really bother unsetting things unless I'm doing something that is 
using a lot of memory. PHP will clear everything at the end of the run 
anyway. I guess technically it's garbage collection, but PHP is wiping 
everything, so it doesn't have the overhead of checking what's been 
used, still in use or expired. It's just a wipe.
Unsetting is a good coding habit to get into, but I'm not sure of the 
performance benefits. There are lots of others areas I would focus on 
first to get better performance, like minimizing the number of 
connections you need to make to mysql, optimizing your queries, output 
buffering, etc.

On Nov 12, 2004, at 8:53 AM, Jordi Canals wrote:
Hi all,
I was working now in a new site developed with PHP 5.0.2 and a wonder
came to me:
Is usefull and recommended to unset a class instance when not needed?
Specially when the class was instantiated inside a function and the
function ends. In this case, the system should  automatically destroy
the instance (as it is a local var inside a function).
If we manually unset the instance at the end of the function, does
this affect the PHP performance? I mean, will PHP have to do an extra
job unsetting the var?
Also, the same question arises with database results. Is it worth to
call mysql_free_result at the end of a function that uses it? Must
take into consideration that there are lots of functions that use lots
of MySQL results.
Thanks for any comment
Jordi.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search  Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Syslog Parser

2004-11-12 Thread Greg Donald
On Fri, 12 Nov 2004 09:21:45 -, Nunners [EMAIL PROTECTED] wrote:
 I've successfully got the syslog server to write to a mysql table, but I now
 want to find something that will give me graphs, breakdowns etc for the
 syslog.

Perl has all kinds of log parsing modules, and you might also try freshmeat.

http://cpan.perl.org/
http://freshmeat.net/

For graphing in PHP I use JPGraph:

http://www.aditus.nu/jpgraph/index.php


-- 
Greg Donald
Zend Certified Engineer
http://gdconsultants.com/
http://destiney.com/

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



Re: [PHP] Session file not written, session variables messed up.

2004-11-12 Thread Rodolfo Gonzalez
Hi Klaus,

On Fri, 12 Nov 2004, Klaus Reimer wrote:
  The weirdness comes when in one frame the script will print Agent Smith
  while in the other frame of the same frameset the script which loads on it
  will print Thomas Anderson...

 Are both frames loaded at the same time? It's not possible to have two
 concurrently running scripts access the same session at the same time


Yes, both are loaded at the same time, I mean, in the same frameset. I
don't use trans_sid, and I don't pass the SID constant nor the
session_name()=session_id() as a GET to the frame src's referred from the
frameset, so I relay on cookies. Both scripts also do a check against a
database to see if the session id stored on it is the same as the session
id which the login script stored in the $_SESSION array, for that
username, so it is supposed that every username logged on the scripts
would have one unique session id...


 always use session_start() in the PHP code. Maybe the auto_start session
   behaves differently. Maybe you can try disabling auto_start and start
 the session manually. I don't think it make a difference, but who knows.


I should try it anyway, indeed. Also, do you think that with using another
session handler (mm perhaps) instead of files the execution could speed up
or avoid file problems?. The load of the servers is not that high anyway.

I forgot to mention, I'm also using Turck MMCache as cache and
optimizer... I don't know if this could cause something weird (wouldn't
sound logical, but...). Turck MMCache version is 2.4.6.


 On the other hand: Have you checked that your disk has enough room for
 more sessions? Maybe you are working on the bleeding edge of your


Yes, I thought it too, but it still has some Gb of free space. I also
checked for problems with available file handlers/excesive opened files on
the OS side, but everything seems normal.

Thank you,
Rodolfo.

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



[PHP] Re: Unsetting vars when not needed?

2004-11-12 Thread pete M
Unsetting class objects does take time and is really of no benefit 
unless there are memory problems

as for freeing resuslts - the same applies
pete
Jordi Canals wrote:
Hi all,
I was working now in a new site developed with PHP 5.0.2 and a wonder
came to me:
Is usefull and recommended to unset a class instance when not needed?
Specially when the class was instantiated inside a function and the
function ends. In this case, the system should  automatically destroy
the instance (as it is a local var inside a function).
If we manually unset the instance at the end of the function, does
this affect the PHP performance? I mean, will PHP have to do an extra
job unsetting the var?
Also, the same question arises with database results. Is it worth to
call mysql_free_result at the end of a function that uses it? Must
take into consideration that there are lots of functions that use lots
of MySQL results.
Thanks for any comment
Jordi.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Current URL?

2004-11-12 Thread pete M
$_SERVER['REQUEST_URI'];
Matthew Weier O'Phinney wrote:
* Jason Paschal [EMAIL PROTECTED]:
Trying to get the current viewed page's URL (query string intact).
this works, but infrequently:
$url = $_SERVER['URI']; 

and this ignores the query string:
$url = $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
I'm certain there's a way,  that is browser-independent,  to get your
script to grab the current URL (even if the script is an include).
i'm just trying to get a log of users currently online, and which page
they are viewing, and while the $_SERVER['REMOTE_ADDR'] will
invariably grab the IP, $_SERVER['URI'] is often empty.

Try:
$url = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] session.use_trans_sid

2004-11-12 Thread Jon Hill
Hello

I have a site that has session.use_trans_sid = 1.
It seems that the first time I visit a page when I open up my browser, URLs 
are getting rewritten even though a cookie IS being set. If I refresh or move 
on to another page, the problem goes away, i.e. no more session ids appended 
to URLs.

I don't want to turn off trans_sid for this site because I want people to able 
to use it without cookies being set.

For example

?php
session_start();
?
html
head
body
a href=index.phplink/a
/body
/html


The first time I request the page, a cookie gets set, AND the URL gets 
rewritten. After that, no more URL rewrites.

Can anyone point to where I might be going wrong, or this just an odd 
behaviour of session.use_trans_sid = 1

Cyril

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



[PHP] Re: session.use_trans_sid

2004-11-12 Thread Ben Ramsey
Jon Hill wrote:
I have a site that has session.use_trans_sid = 1.
It seems that the first time I visit a page when I open up my browser, URLs 
are getting rewritten even though a cookie IS being set. If I refresh or move 
on to another page, the problem goes away, i.e. no more session ids appended 
to URLs.

I don't want to turn off trans_sid for this site because I want people to able 
to use it without cookies being set.
When you first hit a page that creates a cookie, the cookie is not 
accessible to the application until the page is refreshed or you browse 
to another page in the same domain. This is why the SID is showing up in 
the URL when you first hit the site. Though the cookie is being saved to 
the browser, the application cannot yet access it until you browse to 
another page.

Read up on it here: http://www.php.net/setcookie
In particular: Cookies will not become visible until the next loading 
of a page that the cookie should be visible for.

--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
---
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] Question for the PHP consultants out there.

2004-11-12 Thread Daniel Lahey
What web based software project management tool do you use to keep 
track of projects, project tasks, customer requests, and bug reports?
You might try Ace Project:  http://www.aceproject.com/
An error is the more dangerous in proportion to the degree of truth 
which it contains. - Henri Frederic Amiel


Re: [PHP] Re: Which PHP for MySQL 4.1

2004-11-12 Thread Mario Bittencourt
I could not compile php 5.0.2 with the latest mysql 4.1.7.

I've installed the rpms (server,max,client,devel,shared) from mysql.com.

./configure --with-mnogosearch --with-xml  --with-mysql=/usr
--with-mysqli=/usr/bin/mysql_config --with-apxs2 --enable-soap

When I compile I get tons of messages like this

/usr/lib/mysql/libmysqlclient.a(net.o)(.text+0x250): first defined here
/usr/lib/mysql/libmysqlclient.a(net.o)(.text+0x330): In function
`net_write_command':

I have even tried only with mysqli or mysql and got the same result.

Any ideias ?

Fedora Core 3 Machine

On Fri, 12 Nov 2004 11:03:23 +0100, Sebastian Mendel
[EMAIL PROTECTED] wrote:
 
 
 C.F. Scheidecker Antunes wrote:
  Hello,
 
  I would like to migrate my MySQL servers from 4.0 to 4.1.
 
  As I use PHP as well as Java with these servers I wonder what PHP 4
  version would be compatible with MySQL 4.1.
 
  Has anyone used MySQL 4.1 with PHP yet?
 
  I appreciate your thoughts.
 
  Thanks.
 
 i run 4.1.x for a while, without problems,
 
 after upgrading you have to rebuild you php to use the new mysql_librarys
 
 and you have to run mysql_fix_privilege_tables on the linux/unix shell
 
 4.1. uses a new display-format for timestamps!
 4.1. uses a new encryption method for password(), with this function are
 all mysql_passwords stored in the db, thats why you have to run
 mysql_fix_privilege_tables
 
 read carefully through all 4.1. changelogs!
 
 --
 Sebastian Mendel
 
 www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
 www.sf.net/projects/phpdatetimewww.sf.net/projects/phptimesheet
 
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


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



Re: [PHP] Re: Which PHP for MySQL 4.1

2004-11-12 Thread John Nichel
Mario Bittencourt wrote:
I could not compile php 5.0.2 with the latest mysql 4.1.7.
I've installed the rpms (server,max,client,devel,shared) from mysql.com.
./configure --with-mnogosearch --with-xml  --with-mysql=/usr
--with-mysqli=/usr/bin/mysql_config --with-apxs2 --enable-soap
When I compile I get tons of messages like this
/usr/lib/mysql/libmysqlclient.a(net.o)(.text+0x250): first defined here
/usr/lib/mysql/libmysqlclient.a(net.o)(.text+0x330): In function
`net_write_command':
I have even tried only with mysqli or mysql and got the same result.
Any ideias ?
I'm betting you have mnogosearch compiled with MySQL support, right?  I 
had this problem last week.  Remove mnogosearch, recompile it without 
MySQL support, then configure/make/make install php.  After that's done, 
you can redo mnogosearch with MySQL support.

--
John C. Nichel
ÜberGeek
KegWorks.com
716.856.9675
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] PHP / LDAP with Windows logon

2004-11-12 Thread Michael Gallant
I am interested if anyone has ever determined a way to do this or if
it is technically impossible.

To my knowledge, I don't know of any way to do that from a non-windows server.


On Fri, 12 Nov 2004 08:40:03 -0500, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Hello, I have an issue with a PHP interface. We have many engineering users
 who will be using a request ticket system developed in PHP here. We don't
 know in advance who will be using the system and there may be new people in
 all the time. Currently I have to create a login for each person who needs
 to use the system, so I have to get a request for a login, create the login,
 and fill in their contact information. Since we work with engineers on a
 12-15 hour time difference, it might take a whole day or more to get the
 login id request filled before they can open a ticket. Plus there's the
 whole inconvenience of having to login to another website. The site is
 inside our secure intranet, so we don't really need a double layer of
 security.
 
 Since we normally logon to a Windows network, what I would like to do is to
 detect the user's windows login id when he accesses the PHP page, and
 automatically reference his contact information from the windows LDAP
 server, so the user can be authenticated by his  current windows login
 information, and not have to enter a separate login on the request page. Is
 this possible, and what is an easy way to do this?
 
 Thanks!
 
 Chris
 


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



RE: [PHP] PHP / LDAP with Windows logon

2004-11-12 Thread Christopher . Wood
I found this on the php site after some searching. I haven't been able to
test it yet since the PHP guy works nights:

 http://us2.php.net/manual/en/ref.ldap.php

If anyone else has tried this, or could the original author (Jon) comment
please?

Thanks!
Chris

jon dot caplinger at broadwing dot com
08-Nov-2002 10:44 
Here is an example of searching active directory in w2k. Active directory
requires a user account that has permissions to search the tree.

/* The following values are used for the example:
  1.  Domain =  microsoft.com
  2.  Server =  unstable
  3.  User = bgates
  4.  Password = iloveopensource
*/

// Get name value to search for from submitted form.

if (isset($HTTP_GET_VARS[name])) {
 $name = $HTTP_GET_VARS[name];
}

$ldap_server = ldap://unstable.microsoft.com;;
$auth_user = [EMAIL PROTECTED];
$auth_pass = iloveopensource;

// Set the base dn to search the entire microsoft.com directory.

$base_dn = DC=microsoft, DC=com;

/* filter the search for all people in the microsoft.com tree that have a
name that matches any one of the following attributes name, displayname, or
cn. */
 
$filter = ((objectClass=user)(objectCategory=person)
(|(name=$name*)(displayname=$name*)(cn=$name*)));

// connect to server

if (!([EMAIL PROTECTED]($ldap))) {
 die(Could not connect to ldap server);
}

// bind to server

if (!([EMAIL PROTECTED]($connect, $auth_user, $auth_pass))) {
 die(Unable to bind to server);  
}

// search active directory

if (!([EMAIL PROTECTED]($connect, $base_dn, $filter))) {
 die(Unable to search ldap server); 
}

$number_returned = ldap_count_entries($connect,$search);
$info = ldap_get_entries($connect, $search);

echo The number of entries returned is . $number_returned;

for ($i=0; $i$info[count]; $i++) {
   echo Name is: . $info[$i][name];
   echo Display name is: . $info[$i][displayname][0];
   echo Email is: . $info[$i][mail][0];
   echo Telephone number is: . $info[$i][telephonenumber][0];
} 

-Original Message-
From: Michael Gallant [mailto:[EMAIL PROTECTED]
Sent: Friday, November 12, 2004 3:10 PM
To: [EMAIL PROTECTED]
Subject: Re: [PHP] PHP / LDAP with Windows logon


I am interested if anyone has ever determined a way to do this or if
it is technically impossible.

To my knowledge, I don't know of any way to do that from a non-windows
server.


On Fri, 12 Nov 2004 08:40:03 -0500, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:
 Hello, I have an issue with a PHP interface. We have many engineering
users
 who will be using a request ticket system developed in PHP here. We don't
 know in advance who will be using the system and there may be new people
in
 all the time. Currently I have to create a login for each person who needs
 to use the system, so I have to get a request for a login, create the
login,
 and fill in their contact information. Since we work with engineers on a
 12-15 hour time difference, it might take a whole day or more to get the
 login id request filled before they can open a ticket. Plus there's the
 whole inconvenience of having to login to another website. The site is
 inside our secure intranet, so we don't really need a double layer of
 security.
 
 Since we normally logon to a Windows network, what I would like to do is
to
 detect the user's windows login id when he accesses the PHP page, and
 automatically reference his contact information from the windows LDAP
 server, so the user can be authenticated by his  current windows login
 information, and not have to enter a separate login on the request page.
Is
 this possible, and what is an easy way to do this?
 
 Thanks!
 
 Chris
 


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


[PHP] probably stupid, but...

2004-11-12 Thread Robert Sossomon
I have a form that sends 20 rows of data into a script, instead of having to 
write 20 separate add functions, I wrote this piece of code...

$i=1;
while ($i20)
{
 if ($_POST[book_title_$i]' != )
 {
  INSERT INTO `curriculum` VALUES 
('','$_POST[book_title_$i]','$_POST[book_level_$i]','$_POST[level_grades_$i]','$_POST[book_section_$i]','$_POST[chapter_$i]','$_POST[chapter_title_$i]','$_POST[lesson_title_$i]','$_POST[skill_$i]','$_POST[life_skill_$i]','$_POST[success_indicator_$i]','$_POST[ncscos_$i]','$_POST[subject_$i]','$_POST[pages_$i]','$_POST[c_kit_$i]');

  $message .= The entry  $i was entered
;
 $i++;
 }
 else
{  $i++; }
}
But I get THIS error in the log:
 [12-Nov-2004 14:59:19] PHP Parse error:  parse error, unexpected  T_VARIABLE, 
expecting ']' in  /home/public/html/depts/fourh/curriculum_form_post.php on line 19

-
How can I go about iterating through the script?  or do I just need to write 20 
if/else statements and separate inserts?

Thanks,
Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Sending Data with Ascii data

2004-11-12 Thread Dev
Hello,
I am working on a Socket script that needs to send a binary 0x1C to another 
applicaiton that is connected to the socket.  Any way in PHP to do this so 
that I do not have to go and learn C++ over the weekend

Does anyone have a clue what needs to be done to make this work?
--
UMPA
  Brian C. Doyle
Director, Internet Services
United Merchant Processing Association
http://www.umpa-us.comhttp://www.umpa-us.com
1-800-555-9665 ext 212


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

2004-11-12 Thread Jay Blanchard
[snip]
$i=1;
while ($i20)
{
  if ($_POST[book_title_$i]' != )
  {
   INSERT INTO `curriculum` VALUES 
('','$_POST[book_title_$i]','$_POST[book_level_$i]','$_POST[level_grades
_$i]','$_POST[book_section_$i]','$_POST[chapter_$i]','$_POST[chapter_tit
le_$i]','$_POST[lesson_title_$i]','$_POST[skill_$i]','$_POST[life_skill_
$i]','$_POST[success_indicator_$i]','$_POST[ncscos_$i]','$_POST[subject_
$i]','$_POST[pages_$i]','$_POST[c_kit_$i]');

   $message .= The entry  $i was entered;
  $i++;
  }
  else
{  $i++; }
}

But I get THIS error in the log:
  [12-Nov-2004 14:59:19] PHP Parse error:  parse error, unexpected
T_VARIABLE, 
expecting ']' in  /home/public/html/depts/fourh/curriculum_form_post.php
on line 19
[/snip]

Where is line 19? Is this it?

if ($_POST[book_title_$i]' != )

If so, remove the apostrophe after the ]

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



RE: [PHP] Sending Data with Ascii data

2004-11-12 Thread Jay Blanchard
[snip]
I am working on a Socket script that needs to send a binary 0x1C to
another 
applicaiton that is connected to the socket.  Any way in PHP to do this
so 
that I do not have to go and learn C++ over the weekend

Does anyone have a clue what needs to be done to make this work?
[/snip]

Are we to assume that you have RTFM http://www.php.net/sockets ?

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



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

2004-11-12 Thread Danny Brow
On Fri, 2004-11-12 at 15:08 -0500, Robert Sossomon wrote:
 I have a form that sends 20 rows of data into a script, instead of having to 
 write 20 separate add functions, I wrote this piece of code...
 
 $i=1;
 while ($i20)
 {
   if ($_POST[book_title_$i]' != ) 
// One problem maybe the quote you have at the end of your $_POST
request.

   {
INSERT INTO `curriculum` VALUES 

// You could probably simplify this with a while or for loop. But I'm no
PHP expert. Perhaps you could use an array to clean this up.

 ('','$_POST[book_title_$i]','$_POST[book_level_$i]','$_POST[level_grades_$i]','$_POST[book_section_$i]','$_POST[chapter_$i]','$_POST[chapter_title_$i]','$_POST[lesson_title_$i]','$_POST[skill_$i]','$_POST[life_skill_$i]','$_POST[success_indicator_$i]','$_POST[ncscos_$i]','$_POST[subject_$i]','$_POST[pages_$i]','$_POST[c_kit_$i]');
 
$message .= The entry  $i was entered
 ;
   $i++;
   }
   else
 {  $i++; }
 }
 

Sorry if I missed anything else :-

Dan.


 But I get THIS error in the log:
   [12-Nov-2004 14:59:19] PHP Parse error:  parse error, unexpected  
 T_VARIABLE, 
 expecting ']' in  /home/public/html/depts/fourh/curriculum_form_post.php on 
 line 19
 
 -
 
 How can I go about iterating through the script?  or do I just need to write 
 20 
 if/else statements and separate inserts?
 
 Thanks,
 Robert
 
 -- 
 Robert Sossomon, Business and Technology Application Technician
 4-H Youth Development Department
 200 Ricks Hall, Campus Box 7606
 N.C. State University
 Raleigh NC 27695-7606
 Phone: 919/515-8474
 Fax:   919/515-7812
 [EMAIL PROTECTED]
 

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



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

2004-11-12 Thread Robert Sossomon
Jay Blanchard is quoted as saying on 11/12/2004 3:28 PM:
 [snip]
Did that and it fixed only that piece (saw it right after I sent the email out 
to the group).  I am thinking that it is still somewhat of the iterations that 
are causing problems.  I am waiting on the server guy to get back with me as to 
what the new error message looks like.

Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

2004-11-12 Thread Chris W. Parker
Robert Sossomon mailto:[EMAIL PROTECTED]
on Friday, November 12, 2004 12:09 PM said:

 I have a form that sends 20 rows of data into a script, instead of
 having to write 20 separate add functions, I wrote this piece of
 code...

you've actually got quite a few mistakes.

   if ($_POST[book_title_$i]' != )

notice --^

there is an extra '. the line should really look like:

if (!empty($_POST['book_title_'.$i])
{
  ...

   {
INSERT INTO `curriculum` VALUES

('','$_POST[book_title_$i]','$_POST[book_level_$i]','$_POST[level_grades
_$i]','$_POST[book_section_$i]','$_POST[chapter_$i]','$_POST[chapter_tit
le_$i]','$_POST[lesson_title_$i]','$_POST[skill_$i]','$_POST[life_skill_
$i]','$_POST[success_indicator_$i]','$_POST[ncscos_$i]','$_POST[subject_
$i]','$_POST[pages_$i]','$_POST[c_kit_$i]');

and then here you don't even assign that sql statement to anything. PHP
doesn't know what to do with it.

also you need to wrap your array values in { } when an array is
referenced within a string. i.e.

// normal
$value = $_GET['something'];

// with { }
$value = Here is some data: {$_GET['something']};


hth,
chris.

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



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

2004-11-12 Thread Jay Blanchard
[snip]
Did that and it fixed only that piece (saw it right after I sent the
email out 
to the group).  I am thinking that it is still somewhat of the
iterations that 
are causing problems.  I am waiting on the server guy to get back with
me as to 
what the new error message looks like.
[/snip]

Have you echo'd the query out to see what it looks like?

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



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

2004-11-12 Thread Ben Ramsey
You've got some parsing errors going on. Nothing particularly wrong with 
the logic...

$i=1;
while ($i20)
{
 if ($_POST[book_title_$i]' != )
change the if statement to:
if ($_POST[book_title_$i] != )
The problem you have is that the $_POST var you're referencing, first of 
all, isn't included in quotation marks, so the code probably thinks it's 
a constant that's not defined. Second of all, because it's not included 
in quotation marks, it's having problems with adding the $i var to the 
end of the POST var name. You could also do: $_POST['book_title_' . $i] 
and achieve the same effect. Lastly, what's that single quotation mark 
doing in there? Get rid of it.

 {
  INSERT INTO `curriculum` VALUES 
('','$_POST[book_title_$i]','$_POST[book_level_$i]','$_POST[level_grades_$i]','$_POST[book_section_$i]','$_POST[chapter_$i]','$_POST[chapter_title_$i]','$_POST[lesson_title_$i]','$_POST[skill_$i]','$_POST[life_skill_$i]','$_POST[success_indicator_$i]','$_POST[ncscos_$i]','$_POST[subject_$i]','$_POST[pages_$i]','$_POST[c_kit_$i]'); 
First of all, you're trying to execute a SQL statement, but you're not 
saving it to a variable, nor are you executing it against any kind of 
database. So, it's doing nothing. Save it to a variable by doing:

$sql = INSERT INTO ...
The next thing you need to worry about is how to get your $_POST 
variables into the SQL statement. This problem is similar to what you 
have above. It should look something like this:

$sql = INSERT INTO `curriculum` VALUES ('',' . $_POST['book_title_' . 
$i] . ',' . $_POST['book_level_' . $i] . ',' . and so on

Lastly, you'll need to execute the statement against a database. Turn to 
the PHP manual for this help: http://www.php.net/mysql

I would suggest you read up on how variables get processed, as well. 
http://www.php.net/variables


  $message .= The entry  $i was entered
;
 $i++;
 }
 else
{  $i++; }
}
But I get THIS error in the log:
 [12-Nov-2004 14:59:19] PHP Parse error:  parse error, unexpected  
T_VARIABLE, expecting ']' in  
/home/public/html/depts/fourh/curriculum_form_post.php on line 19

-
How can I go about iterating through the script?  or do I just need to 
write 20 if/else statements and separate inserts?

--
Ben Ramsey
Zend Certified Engineer
http://benramsey.com
---
Atlanta PHP - http://www.atlphp.org/
The Southeast's premier PHP community.
---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] Sending Data with Ascii data

2004-11-12 Thread Dev
Actually yes I have.  Many times as a matter of fact.
What was happing was that the 0xC1 was being translated into it dec form of 28.
Thankfully i was able to resolve the issue by using:
pack(C,28)
But thanks Jay for the help!
At 03:29 PM 11/12/2004, Jay Blanchard wrote:
[snip]
I am working on a Socket script that needs to send a binary 0x1C to
another
applicaiton that is connected to the socket.  Any way in PHP to do this
so
that I do not have to go and learn C++ over the weekend
Does anyone have a clue what needs to be done to make this work?
[/snip]
Are we to assume that you have RTFM http://www.php.net/sockets ?

--
UMPA
  Brian C. Doyle
Director, Internet Services
United Merchant Processing Association
http://www.umpa-us.comhttp://www.umpa-us.com
1-800-555-9665 ext 212


[PHP] What am I doing wrong - PHP

2004-11-12 Thread Stuart Felenstein
Ok, hopefully I can explain this clearly, even though
I think I might be an idiot since Ive been going on
about this for a few days.

I have a table that holds values and labels 
i.e. 1 = New York
 2 = Boston
 3 = Kansas City
 4 = Amsterdam

I want to put this table into a multiple selection
list, that a user can choose from in a form
My code is drawing a blank though:

//This is my call to the table staindtypes
?php
mysql_select_db($database_lokale, $lokale);
$indque1 = SELECT * FROM staindtypes;
$inds = mysql_query($indque1, $lokale) or
die(mysql_error());
$row_inds = mysql_fetch_assoc($inds);
$totalRows_inds = mysql_num_rows($inds);
$row = mysql_fetch_row;
?


//Here is the element and the php to loop it
form name=form1 id=form1 method=post action=
  select name=Ind size=5 multiple=multiple
id=Ind
  option value=Please Select/option
?php
do {  
?
option value=?php echo
$rows['CareerIDs']??php echo
$row_$result['CareerCategories']?/option
?php
} while ($rows = mysql_fetch_assoc($inds));
  $rows = mysql_num_rows($inds);
  if($rows  0) {
  mysql_data_seek($inds, 0);
  $rows = mysql_fetch_assoc($inds);
  }
 ?

When I load the page it is blank.

Any help would be appreciated.

Stuart

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



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

2004-11-12 Thread Danny Brow
On Fri, 2004-11-12 at 14:35 -0600, Jay Blanchard wrote:
 [snip]
 Did that and it fixed only that piece (saw it right after I sent the
 email out 
 to the group).  I am thinking that it is still somewhat of the
 iterations that 
 are causing problems.  I am waiting on the server guy to get back with
 me as to 
 what the new error message looks like.
 [/snip]
 
 Have you echo'd the query out to see what it looks like?
 

It's probably a good idea to get the part of a reply that tells everyone
who your replying too. Not sure if it was me or Chris P.

Chris has a way better answer then I. So I assume your replying to mine.

Dan.

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



[PHP] HTML-PDF

2004-11-12 Thread Amanda Hemmerich
Is there a fairly straightforward way to generate a PDF out of a .php file
that's made up of includes and the includes are contructed dynamically
using data from mysql?  This page normally displays the info based on
parameters passed through the url or through a form.  I've been looking
for something I could download and just pass it the url, but if I had to
build something myself, I could, but I don't know if there are any php
modules to support it.  ANy tips?

Thanks.

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



Re: [PHP] Re: Which PHP for MySQL 4.1

2004-11-12 Thread Sebastian Mendel
Mario Bittencourt wrote:
I could not compile php 5.0.2 with the latest mysql 4.1.7.
I've installed the rpms (server,max,client,devel,shared) from mysql.com.
./configure --with-mnogosearch --with-xml  --with-mysql=/usr
--with-mysqli=/usr/bin/mysql_config --with-apxs2 --enable-soap
When I compile I get tons of messages like this
/usr/lib/mysql/libmysqlclient.a(net.o)(.text+0x250): first defined here
/usr/lib/mysql/libmysqlclient.a(net.o)(.text+0x330): In function
`net_write_command':
I have even tried only with mysqli or mysql and got the same result.
Any ideias ?
try one mysql-extension as shared:
--with-mysql=/usr,shared --with-mysqli=/usr/bin/mysql_config
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: What am I doing wrong - PHP

2004-11-12 Thread M. Sokolewicz
Stuart Felenstein wrote:
Ok, hopefully I can explain this clearly, even though
I think I might be an idiot since Ive been going on
about this for a few days.
I have a table that holds values and labels 
i.e. 1 = New York
 2 = Boston
 3 = Kansas City
 4 = Amsterdam

I want to put this table into a multiple selection
list, that a user can choose from in a form
My code is drawing a blank though:
//This is my call to the table staindtypes
?php
mysql_select_db($database_lokale, $lokale);
$indque1 = SELECT * FROM staindtypes;
$inds = mysql_query($indque1, $lokale) or
die(mysql_error());
$row_inds = mysql_fetch_assoc($inds);
why are you doing this?
$totalRows_inds = mysql_num_rows($inds);
$row = mysql_fetch_row;
that's supposed to be a function... no? But then... why is it used here?
?
//Here is the element and the php to loop it
form name=form1 id=form1 method=post action=
  select name=Ind size=5 multiple=multiple
id=Ind
  option value=Please Select/option
?php
do {  
why are you using do..while? It's far easier to just use while
?
option value=?php echo
$rows['CareerIDs']??php echo
$row_$result['CareerCategories']?/option
?php
} while ($rows = mysql_fetch_assoc($inds));
  $rows = mysql_num_rows($inds);
  if($rows  0) {
  mysql_data_seek($inds, 0);
  $rows = mysql_fetch_assoc($inds);
  }
 ?
When I load the page it is blank.
Any help would be appreciated.
Stuart
I would suggest writing it like this:
?php
mysql_select_db($database_lokale, $lokale);
$inds = mysql_query(SELECT * FROM staindtypes, $lokale) or 
die(mysql_error());
?
form name=form1 id=form1 method=POST action=self.php
select name=Ind size=5 multiple=multiple id=Ind
option selected=selected value=0Please Select/option
?php
while($ind = mysql_fetch_array($inds, MYSQL_ASSOC)) {
   echo 'option 
value='.$inds['CareerIDs'].''.$inds['CareerCategories'].'/option';
}
echo '/select/form';
mysql_free_result($inds);	// just in case
?

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


RE: [PHP] What am I doing wrong - PHP

2004-11-12 Thread Chris W. Parker
Stuart Felenstein mailto:[EMAIL PROTECTED]
on Friday, November 12, 2004 12:54 PM said:

 //This is my call to the table staindtypes
 ?php
 mysql_select_db($database_lokale, $lokale);
 $indque1 = SELECT * FROM staindtypes;
 $inds = mysql_query($indque1, $lokale) or
 die(mysql_error());
 $row_inds = mysql_fetch_assoc($inds);
 $totalRows_inds = mysql_num_rows($inds);
 $row = mysql_fetch_row;

   $rows = mysql_num_rows($inds);
   if($rows  0) {
   mysql_data_seek($inds, 0);
 $rows = mysql_fetch_assoc($inds);
   }
 
 
 When I load the page it is blank.
 
 Any help would be appreciated.

Well your code is a bit hard to follow (imo) but I notice that you have:

$row_inds = mysql_fetch_assoc($inds);

but then never refer to $row_inds again.

I would do the following:

?php

$row_inds = mysql_fetch_assoc($inds);
$row_inds_cnt = count($row_inds);

echo select ...\n;
if($row_inds_cnt  0)
{
  for($i = 0; $i  $row_inds_cnt; $i++)
  {
echo  option value=\...\.../option\n;
  }
}
else
{
  echo  option value=\empty\empty/option\n;
}
echo /select\n;

?



hth,
Chris.

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



RE: [PHP] What am I doing wrong - PHP

2004-11-12 Thread Mike Johnson
From: Stuart Felenstein [mailto:[EMAIL PROTECTED] 

 Ok, hopefully I can explain this clearly, even though
 I think I might be an idiot since Ive been going on
 about this for a few days.
 
 I have a table that holds values and labels 
 i.e. 1 = New York
  2 = Boston
  3 = Kansas City
  4 = Amsterdam
 
 I want to put this table into a multiple selection
 list, that a user can choose from in a form
 My code is drawing a blank though:
 
 //This is my call to the table staindtypes
 ?php
 mysql_select_db($database_lokale, $lokale);
 $indque1 = SELECT * FROM staindtypes;
 $inds = mysql_query($indque1, $lokale) or
 die(mysql_error());
 $row_inds = mysql_fetch_assoc($inds);
 $totalRows_inds = mysql_num_rows($inds);
 $row = mysql_fetch_row;
 ?
 
 
 //Here is the element and the php to loop it
 form name=form1 id=form1 method=post action=
   select name=Ind size=5 multiple=multiple
 id=Ind
   option value=Please Select/option
 ?php
 do {  
 ?
 option value=?php echo
 $rows['CareerIDs']??php echo
 $row_$result['CareerCategories']?/option


---^
I think your error is right here. Don't you want
$rows['CareerCategories']?

Aside from that, I'm not certain the code is exactly what you want, but
this should at least solve the blank page problem. I think PHP's barfing
on that but errors aren't being written to the browser.

Good luck!


-- 
Mike Johnson Smarter Living, Inc.
Web Developerwww.smarterliving.com
[EMAIL PROTECTED]   (617) 886-5539

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



[PHP] PDO __construct question (mysql)

2004-11-12 Thread M. Sokolewicz
hi,
currently I'm experimenting with PDO a bit. I run a local mysql server, 
version 4.1.4, so I tried connecting to that.

Here is my code at this point:
try {
$link = new PDO('mysql:dbname=mydb;host=localhost', 'me', 
'pw', array(PDO_ATTR_AUTOCOMMIT = 0, PDO_ATTR_PERSISTENT=0));
} catch(PDOException $e) {
echo 'Connection Error: 
'.$e-getMessage().\n.$e-getTraceAsString();
exit;
}

Now, it doesn't matter if the server is turned on or off, I am recieving:
Connection Error: [2017] Can't open named pipe to host: . pipe: MySQL (2)
At first, I thought that this was due to me writing the DSN incorrectly. 
 But after reading trough various documents, including Wez's Powerpoint 
Presentation at PHPWorks, I think the DSN I'm using IS correctly (or at 
least syntactically). After that, I figured it might be because 
PDO_mysql officially doesn't support mysql 4.1+, but when the server is 
turned OFF (the mysql server), it still reports EXACTLY the same error.

Does anyone have an idea what is wrong EXACTLY here? To me the message 
seems pretty strange, and I don't understand what it means.

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


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

2004-11-12 Thread Robert Sossomon
Ben Ramsey is quoted as saying on 11/12/2004 3:41 PM:
You've got some parsing errors going on. Nothing particularly wrong with 
the logic...
snip
OK, I took out the extra ' that I had at the beginning, and then I changed 
everything around to:

if (!empty($_POST['book_title_'.$i]))
   {
  $addtocart = INSERT INTO `curriculum` VALUES 
('',$_POST['book_title_'.$i],$_POST['book_level_'.$i],$_POST['level_grades_'.$i],$_POST['book_section_'.$i],$_POST['chapter_'.$i],$_POST['chapter_title_'.$i],$_POST['lesson_title_'.$i],$_POST['skill_'.$i],$_POST['life_skill_'.$i],$_POST['success_indicator_'.$i],$_POST['ncscos_'.$i],$_POST['subject_'.$i],$_POST['pages_'.$i],$_POST['c_kit_'.$i]);
  echo $addtocart;
  mysql_query($addtocart);

And it still is producing an empty page (not even echoing out the $addtocart 
variable) when I run it.

Unfortunately my server admins went AWOL, so I can get the exact error message, 
but I know it has to be some stupid that I just haven't put my finger on yet.

I could have had this done already doing it one line @ a time, however I want to 
be able to change either form at any time and have only 2 pieces of code to change.

Thanks for the help so far guys.
Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] HTML-PDF

2004-11-12 Thread Robert Sossomon
Amanda Hemmerich is quoted as saying on 11/12/2004 4:01 PM:
Is there a fairly straightforward way to generate a PDF out of a .php file
that's made up of includes and the includes are contructed dynamically
using data from mysql?  This page normally displays the info based on
parameters passed through the url or through a form.  I've been looking
SNIP
Here's what I used to use, and i know that there are better ways to do it now,
but it works for me:
a form to pass the data from, and then some includes
?php
//HTML2PDF by Clément Lavoillotte
include_once('/home/fpdf/fpdf/html2pdf.php');
//connect to database
include 'db.php';
include 'salesinfo.php';
$order_id = $_POST[order_id];
$faxnumber = $_POST[faxnum];
$html = ;
$time = -;
$time .= date(mdY-His);
$outtie = /saved_quotes/$user;
$title = Quote for $acct $uFname $uLname on $today;
$subject = Quote for $acct $uFname $uLname on $today;
$author = $uFname $uLname;
$outtie .= -;
$html .= html\nhead\ntitle;
$html .= $title;
$html .= /title\n/head\nbody bgcolor=\white\\n;
include 'order_header.php';
$html .= $header_block;
include 'views_order_head.php';
$html .= $view_head_block;
include 'views_order_body.php';
$html .= $display_block;
$html .= \n/body\n/html;
$outtie .= $num;
$outtie .= $time;
$tempfilename = $outtie;
$outps = $outtie;
$outps .= .ps;
$tempfilename .= .html;
$outtie .= .pdf;
$out_url = /saved_quotes/$user-$num$time.pdf;
$tempfile = fopen($tempfilename,'w');
fwrite($tempfile, $html);
fclose($tempfile);
$last_line = system(/usr/local/bin/html2ps $tempfilename  $outps, $retval);
$last_line = system(/usr/bin/ps2pdf $outps $outtie, $retval);
$last_line = system(/usr/bin/sendfax -n -d $faxnumber $outtie, $retval);
$ps_line = system(/bin/rm -f $outps, $retval);
//header(Location: $out_url);
//exit;
HTH,
Robert
--
Robert Sossomon, Business and Technology Application Technician
4-H Youth Development Department
200 Ricks Hall, Campus Box 7606
N.C. State University
Raleigh NC 27695-7606
Phone: 919/515-8474
Fax:   919/515-7812
[EMAIL PROTECTED]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] MySQL Excel

2004-11-12 Thread Sam Smith

I've got it working writing out a file (fopen) to CSV (comma delimited) and
the header('Content-Disposition: attachment; filename=myFile.csv')
method but it's clumsy for the user to figure out how to use the file.

Is there some totally slick way of spitting out a file that Excel can open
right up?

thanks

sam

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



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

2004-11-12 Thread Mike Johnson
From: Robert Sossomon [mailto:[EMAIL PROTECTED] 

 OK, I took out the extra ' that I had at the beginning, and 
 then I changed everything around to:
 
 if (!empty($_POST['book_title_'.$i]))
 {
$addtocart = INSERT INTO `curriculum` VALUES 
 ('',$_POST['book_title_'.$i],$_POST['book_level_'.$i],$_POST['
 level_grades_'.$i],$_POST['book_section_'.$i],$_POST['chapter_
 '.$i],$_POST['chapter_title_'.$i],$_POST['lesson_title_'.$i],$
 _POST['skill_'.$i],$_POST['life_skill_'.$i],$_POST['success_in
 dicator_'.$i],$_POST['ncscos_'.$i],$_POST['subject_'.$i],$_POS
 T['pages_'.$i],$_POST['c_kit_'.$i]);
echo $addtocart;
mysql_query($addtocart);
 
 And it still is producing an empty page (not even echoing out 
 the $addtocart variable) when I run it.

If this is just a snippet and you do close that if clause with a curly
brace later in the code, my guess is that the parser doesn't like the
$_POST['book_title_'.$i] syntax.

Try changing them all like this, if you're looking to eliminate that
possibility:

$_POST[book_title_{$i}]

Wish I had time to test my theory, but I'm strapped at the moment.   :)


-- 
Mike Johnson Smarter Living, Inc.
Web Developerwww.smarterliving.com
[EMAIL PROTECTED]   (617) 886-5539

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



Re: [PHP] MySQL Excel

2004-11-12 Thread Jennifer Goodie
 -- Original message --
From: Sam Smith [EMAIL PROTECTED]
 
 I've got it working writing out a file (fopen) to CSV (comma delimited) and
 the header('Content-Disposition: attachment; filename=myFile.csv')
 method but it's clumsy for the user to figure out how to use the file.
 
 Is there some totally slick way of spitting out a file that Excel can open
 right up?

Instead of opening a file and writing to it, just push excel headers and then 
just print like you would nomally do when generating a web page.  If you output 
an html table excel will render it like a spreadsheet.  I don't think I phrased 
that very well, so here's an example
?
//get your result set up here
if($sExport){
if ($sExport == 'xls'){
header(Content-Type: application/vnd.ms-excel);
header(Content-Disposition: attachment; filename=report.xls);
$joiner = /tdtd;
$begin = trtd;
$end = /td/tr\n;
print table border='1';
} else{
header(Content-Type: text/plain);
header(Content-Disposition: attachment; filename=report.csv);
$joiner = ,;
$begin = ;
$end = \n;
}

print $begin .implode($joiner, $aDisplayColumns).$end;  //prints out a 
header row with column name (stored in $aDisplayColumns with row name as key 
and display value as value)
while ($row = $dbObj-fetch_array($rs)){
unset ($push);
$push = array();
foreach ($aDisplayColumns as $key = $val)  { 
if ($sExport=='xls'){
$push[] = $row[$key];
}else{
$push[] = addslases($row[$key]);
}
}
print $begin .implode($joiner, $push).$end;
}
if ($sExport=='xls'){
print /table;
}
exit;
}

Hope that helps and is not too confusing.

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



[PHP] PHP File Upload Problem

2004-11-12 Thread Mike Walsh
I have a problem uploading files with PHP which has me stumped!  I am unable
to successfully upload files.  My simple test script is as follows:

?php

if (count($_FILES))
{
var_dump($_FILES) ;
}

if (is_uploaded_file($_FILES['toProcess']['tmp_name']))
{
print h3File successfully upload./h3 ;
print a href=\{$_SERVER['PHP_SELF']}\Try again?br ;
}
else
{
 print  __RAWHTML__
form enctype=multipart/form-data action={$_SERVER['PHP_SELF']}
method=post
input type=hidden name=MAX_FILE_SIZE value=1024
Filename:  input name=toProcess type=file
input type=submit value=upload
/form
__RAWHTML__;
 print bra href=\{$_SERVER['PHP_SELF']}\Try again?br ;
}

?


When I run it I get the following back:

array(1) { [toProcess]= array(5) { [name]= string(12) 100_2038.JPG
[type]= string(0)  [tmp_name]= string(0)  [error]= int(1)
[size]= int(0) } }

Obviously I have some sort of error as my tmp_name key is null and the
error key is 1.

Any ideas or suggestions?  I am running IIS with PHP 4.3.4.  I checked my
php.ini file and the settings for uploading files look good to me:


; File Uploads ;


; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if
not
; specified).
upload_tmp_dir = c:\windows\temp

; Maximum allowed size for uploaded files.
upload_max_filesize = 1G

Thanks for any help or suggestions.

Mike


-- 
Mike Walsh - mike_walsh at mindspring.com

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



[PHP] Re: PHP File Upload Problem

2004-11-12 Thread Mike Walsh

Mike Walsh [EMAIL PROTECTED] wrote in message news:0%ald.9258

[ ... snipped ... ]

 ; Maximum allowed size for uploaded files.
 upload_max_filesize = 1G


[ ... snipped ... ]

It turns out that 1G is not a valid value for this directive.  Not sure why
I haven't run into this problem previously but setting it to a megabyte
value solves my problem.

Mike

-- 
Mike Walsh - mike_walsh at mindspring.com

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



[PHP] Globally accessible objects without using 'global $obj;'

2004-11-12 Thread Chris W. Parker
Hello,

Ok so I'm trying to write an error reporting class and I'm just sort of
experimenting at this point (comments outside the scope of this email
are welcome btw) with how to best implement it. One idea I had (which
isn't working out as well as I'd hoped thus far) is to create an
instance of my error class (incidentally called 'Error') at the start of
each page and then reference that instance from within all other objects
and functions.

Maybe this would be best explained with some code:

?php

$e = new Error();

function my_function()
{
// do stuff
if($this == $that)
{
$e-RaiseError();
}
}

?

Of course, that doesn't work because my_function() doesn't know anything
about $e unless I put a special statement into my_function().

?php

function my_function()
{
// here's the new line
global $e;

// do stuff
...
}

?

I already don't like the idea of having to put 'global $e;' within each
and every function/method I write. Should I abandon this idea and try
something else? If so, what?

Here is my first idea just fyi.

?php

function my_function()
{
$e = new Error();

// do stuff
if($this == $that)
{
$e-RaiseError();
}
else
{
// continue like normal
}

// get ready to return a response
if($e-error_count  0)
{
return $e;
}
else
{
// return something else
}
}

?

Now to use my_function() within a page I have to always assign the
result to a variable so that I can determine whether or not any errors
occured within the function.

?php

$result = my_function();

if($result-error_count  0)
{
// an error occurred
$result-DisplayErrors();
}

?

But that also seems like a hassle (but maybe it's a completely necessary
hassle?). I've looked around the internets for a while but have not
found any REALLY useful documents on managing errors (could be that I've
not found the write article yet) and such so any
comments/pointers/links/etc. are very welcome.

What I'd ultimately like to do is be able to return more than just a
true/false from a function regarding it's end state. For example, a
function could fail for multiple reasons and just returning a plain
false for all situations does not suffice.


Thank you for making it this far.
Chris.

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



[PHP] Re: MySQL Excel

2004-11-12 Thread Manuel Lemos
Hello,
On 11/12/2004 07:44 PM, Sam Smith wrote:
I've got it working writing out a file (fopen) to CSV (comma delimited) and
the header('Content-Disposition: attachment; filename=myFile.csv')
method but it's clumsy for the user to figure out how to use the file.
Is there some totally slick way of spitting out a file that Excel can open
right up?
This class does exactly what you want just using 
fopen(xlsfile:/path/to/spreadsheet.xls,w) and then you use fwrite to 
send your rows of cells as serialized arrays:

http://www.phpclasses.org/xlsstream
--
Regards,
Manuel Lemos
PHP Classes - Free ready to use OOP components written in PHP
http://www.phpclasses.org/
PHP Reviews - Reviews of PHP books and other products
http://www.phpclasses.org/reviews/
Metastorage - Data object relational mapping layer generator
http://www.meta-language.net/metastorage.html
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


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

2004-11-12 Thread -{ Rene Brehmer }-
At 21:32 12-11-2004, Chris W. Parker wrote:
also you need to wrap your array values in { } when an array is
referenced within a string. i.e.
// normal
$value = $_GET['something'];
// with { }
$value = Here is some data: {$_GET['something']};
Is that actually in the manual ??? If it is, where ?
I've been learning PHP for a little over 2 years now, and I've kept jumping 
in and out of strings because I couldn't figure out how to make the darn 
thing replace array values within it.

The syntax section does not mention this that I've been able to find, nor 
does the variable section, and if it's in the array section then it's very 
well buried. I seriously think the basic syntax section needs to cover a 
bit more ground ... it would also solve our problem with recurring 
questions about very basic things.

I'm not saying that the manual should be a complete teach-it-yourself 
guide, but basic stuff that you need to use like all the time ought to be 
in there.

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


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

2004-11-12 Thread Chris W. Parker
-{ Rene Brehmer }- mailto:[EMAIL PROTECTED]
on Friday, November 12, 2004 3:53 PM said:

 At 21:32 12-11-2004, Chris W. Parker wrote:
 also you need to wrap your array values in { } when an array is
 referenced within a string. i.e.
 
 // normal
 $value = $_GET['something'];
 
 // with { }
 $value = Here is some data: {$_GET['something']};
 
 Is that actually in the manual ??? If it is, where ?

Yes.

http://us2.php.net/manual/en/language.types.array.php

Search for More examples to demonstrate this fact then go down near
the bottom of that box and you'll see it.



Chris.

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



[PHP] Re: Globally accessible objects without using 'global $obj;'

2004-11-12 Thread Red Wingate
Hi Chris,
Something that worked out very well for me was using a function that
would take care of the error handling ... kind of
?php
define ( 'ERR_TYPE_ERROR' , 1 ) ;
define ( 'ERR_TYPE_WARNING' , 2 ) ;
class Error {
// error handling code here
}
function _handleError ( $msg , $type ) {
   static $errClass ;
   if ( is_class ( $errClass ) === FALSE ) {
  $errClass = new Error();
   }
   // hand $msg to $errClass here ...
}
function raiseError ( $msg ) {
   return _handleError ( $msg , ERR_TYPE_ERROR ) ;
}
function raiseWarning ( $msg ) {
   return _handleError ( $msg , ERR_TYPE_WARNING ) ;
}
?
But today i prefer using PHPs build-in Error-Handling functions
using the 2 Errorlevels ( E_USER_NOTICE, E_USER_WARNING
and E_USER_ERROR ) for my debugging and error-handling.
But looking at PHP5's try-throw-catch constructs makes me think
about rewritting large parts of my current project :-/
 -- red
Chris W. Parker wrote:
Hello,
Ok so I'm trying to write an error reporting class and I'm just sort of
experimenting at this point (comments outside the scope of this email
are welcome btw) with how to best implement it. One idea I had (which
isn't working out as well as I'd hoped thus far) is to create an
instance of my error class (incidentally called 'Error') at the start of
each page and then reference that instance from within all other objects
and functions.
Maybe this would be best explained with some code:
?php
$e = new Error();
function my_function()
{
// do stuff
if($this == $that)
{
$e-RaiseError();
}
}
?
Of course, that doesn't work because my_function() doesn't know anything
about $e unless I put a special statement into my_function().
?php
function my_function()
{
// here's the new line
global $e;
// do stuff
...
}
?
I already don't like the idea of having to put 'global $e;' within each
and every function/method I write. Should I abandon this idea and try
something else? If so, what?
Here is my first idea just fyi.
?php
function my_function()
{
$e = new Error();
// do stuff
if($this == $that)
{
$e-RaiseError();
}
else
{
// continue like normal
}
// get ready to return a response
if($e-error_count  0)
{
return $e;
}
else
{
// return something else
}
}
?
Now to use my_function() within a page I have to always assign the
result to a variable so that I can determine whether or not any errors
occured within the function.
?php
$result = my_function();
if($result-error_count  0)
{
// an error occurred
$result-DisplayErrors();
}
?
But that also seems like a hassle (but maybe it's a completely necessary
hassle?). I've looked around the internets for a while but have not
found any REALLY useful documents on managing errors (could be that I've
not found the write article yet) and such so any
comments/pointers/links/etc. are very welcome.
What I'd ultimately like to do is be able to return more than just a
true/false from a function regarding it's end state. For example, a
function could fail for multiple reasons and just returning a plain
false for all situations does not suffice.
Thank you for making it this far.
Chris.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP] Re: Globally accessible objects without using 'global $obj;'

2004-11-12 Thread Greg Beaver
Chris W. Parker wrote:
What I'd ultimately like to do is be able to return more than just a
true/false from a function regarding it's end state. For example, a
function could fail for multiple reasons and just returning a plain
false for all situations does not suffice.
You could either return an object like PEAR_Error 
(http://pear.php.net/manual/en/core.pear.pear-error.php) or use a more 
customizable solution like PEAR_ErrorStack 
(http://pear.php.net/manual/en/core.pear.pear-errorstack.php).  Also, 
don't forget about built-in options like trigger_error and Exceptions in 
php5.

More important than what you use is planning for future growth.  Your 
applications will get larger.  It may seem like a time-saver to do a 
quickie fix that requires less initial typing, but I guarantee you will 
run into a brick wall when you do have to change things and be forced to 
rewrite everything - not exactly a timesaver, unless you simply give up 
on making your code better :)

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


[PHP] Display an image

2004-11-12 Thread John Taylor-Johnston
I have a longblob with a jpeg loaded in it. But how do I display it?

  `photo` longblob NOT NULL,

This doesn't work :) I need header information, etc. So what does?

  echo img src=.$mydata2-photo.\n;

I don't have an example to work with.

John

--snip-
$sql2 = select * from .$db...$table;

$news2 = mysql_query($sql2);

  echo img src=.$mydata2-photo.\n;
  echo h3$mydata2-Rank $mydata2-Name/h3\n;
  echo smalli$mydata2-biography/i/small\n;
  }

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



RE: [PHP] Display an image

2004-11-12 Thread nate

You'll need to create a separate php page called image.php or something and
retrieve the $mydata2-photo and output it to the browser.


img src='image.php?id=1'


image.php
---
$sql = select where id = '$id';
echo $mydata2-photo;



Nate

-Original Message-
From: John Taylor-Johnston [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 12, 2004 9:29 PM
To: [EMAIL PROTECTED]
Cc: John Taylor-Johnston
Subject: [PHP] Display an image

I have a longblob with a jpeg loaded in it. But how do I display it?

  `photo` longblob NOT NULL,

This doesn't work :) I need header information, etc. So what does?

  echo img src=.$mydata2-photo.\n;

I don't have an example to work with.

John

--snip-
$sql2 = select * from .$db...$table;

$news2 = mysql_query($sql2);

  echo img src=.$mydata2-photo.\n;
  echo h3$mydata2-Rank $mydata2-Name/h3\n;
  echo smalli$mydata2-biography/i/small\n;
  }

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

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



Re: [PHP] php mail() error

2004-11-12 Thread Curt Zirzow
* Thus wrote Jason Wong:
 On Wednesday 10 November 2004 12:36, Garth Hapgood - Strickland wrote:
  But when I get the following error back.:
Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for
  [EMAIL PROTECTED]
 
 ...
 
 This is a VERY FAQ.
 
 googling the error message will tell you what it means. Searching the 
 archives will give you some solutions.
 
 Or you can wait for Manuel Lemos' reply :) 

for some reason I find that very funny :)

Curt
-- 
Quoth the Raven, Nevermore.

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



Re: [PHP] Re: php mail() error

2004-11-12 Thread Curt Zirzow
* Thus wrote Manuel Lemos:
 Hello,
 
 On 11/10/2004 10:36 AM, Garth Hapgood - Strickland wrote:
 Im using the php mail() function to try send an email to a user that has
 just registered.
 
 mail($HTTP_POST_VARS['emailaddress1'], 'Matchmakers Website Registration' ,
 'Welcome');
 
 But when I get the following error back.:
   Warning: mail(): SMTP server response: 550 5.7.1 Unable to relay for
 [EMAIL PROTECTED]
 
 Can someone help me out, by telling me what it means or what Im doing 
 wrong?
 
 (Thank you Jason for the introduction! :-)
 
 That means your SMTP server requires authentication to relay messages. 
 The mail function does not support SMTP authentication.

for the record.. and to not mislead several people.. 550 simply
means the message was not accepted. There are several other reasons
why this will happen. The text after the 550 usually signifies what
exactly the problem is.

 [snip spam]

Curt
-- 
Quoth the Raven, Nevermore.

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



Re: [PHP] Re: Multiple session_start()s / Is it a problem??

2004-11-12 Thread Curt Zirzow
* Thus wrote elixon:
 I guess that session_id() method will return null if session is not 
 started (not tested) so theoreticaly you can use:
 
 if (!session_id()) session_start();

This is the best method.  relying that $_SESSION is set could
falsify your reliance that the session has been started. For
example, some code may be trying to clear all session data prior to
this with:

  $_SESSION = array(); 

Even though it is really set it doesn't mean that the session has
truely started.


Curt
-- 
Quoth the Raven, Nevermore.

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



Re: [PHP] Array to $_GET variable

2004-11-12 Thread Curt Zirzow
* Thus wrote Mike Smith:
 I am trying to cache a database recordset so users can sort, etc
 without hitting the database everytime. I'm using ADODB to access a
 MSSQL database.

I wouldn't even bother with this.

No matter what you do your going to have to retreive the data
somewhere, aka sessions, and thus move the load over to the
filesystem. A hit to the database isn't much of a concern.

 
 echo a href=\{$_SERVER['PHP_SELF']}?getvar=$v\Link/a\n;

If the data doesn't change very frequently, you might want to
create a script that does this when the data is actually changes,
and simply include() it when needed.



Curt
-- 
Quoth the Raven, Nevermore.

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



Re: [PHP] displaying repetitive results

2004-11-12 Thread Curt Zirzow
* Thus wrote Greg Donald:
 On Wed, 10 Nov 2004 09:04:27 -0900, Chris Lott [EMAIL PROTECTED] wrote:
  Given a database query thats returns results from a linking (or xref)
  table which includes repetition because of the joins:
  
  ++--+--+
  | id | title| subject  |
  ++--+--+
  |  1 | Collected Poems of Keats | poetry   |
  |  2 | Spy High | suspense |
  |  3 | Sci Fi Spies | suspense |
  |  3 | Sci Fi Spies | sci-fi   |
  ++--+--+
  
  What is the best way to go about displaying this for the user so that
  the record looks complete:
  
  ID: 3
  title: Sci Fi Spies
  Subjects: suspense, scifi
 
 You might normalize the data a bit.

agreed!



Curt
-- 
Quoth the Raven, Nevermore.

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



Re: [PHP] Evaluate String as Object

2004-11-12 Thread Curt Zirzow
* Thus wrote bubba:
 Hi,
 
 Is it possible to evaluate a string passed to a script as an object?

no.

Also, when asking a question, please dont simply reply to a message
and change the subject; Create a new message with subject and ask
your question.


Curt
-- 
Quoth the Raven, Nevermore.

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



Re: [PHP] inline_C installation

2004-11-12 Thread Rory Browne
Not really answering the question(considering that I'm not really sure
if the last reply answered it or not) at hand, but inline_c is infact
a pear package. It is written in Pure PHP. It works by writing the C
Code into a file, using standard php stream functions, and then using
the program exectution functions to compile it using the  standard
system compiler, before calling dl() to load it as a module. Needless
to say you need to have a compiler(usually gcc) installed for this to
work. I think you need to have make installed as well.

 I'm assuming that you're doing this on *nix. If you're using an RPM
based Linux distro, then make sure you install the php-devel package.
This I believe is php-dev on debian based, but I'm not too sure.

The best thing is probably to install PHP by from source. Then you're
(almost) sure to have whatever you need.

Regards
Rory

On Thu, 11 Nov 2004 15:47:01 -0600, Ryan King [EMAIL PROTECTED] wrote:
 On Nov 11, 2004, at 12:50 PM, Rayan Lahoud wrote:
 
  Does anybody knows how to install a pear package. i have the inline_C
  package that i want to install and use. And can i have some sample
  functions using this package?
 
 
 I believe the inline_c package is actually a pecl package
 [pecl.php.net], however it is still installed with the pear installer
 (I hope that makes sense).  Ok, first try typing
 
 pear -v
 
 on the command line. If this doesn't work (it returns command not
 found), try http://pear.php.net/manual/en/installation.php. If that
 succedes, you have a pear package manager installed. Now type:
 
 pear install inline_c
 
 this should install the package for you. You'll probably have to add
 the module to your php.ini script and restart apache.
 
 -ryan
 
 --
 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