[PHP] php fop (XSLFO)

2009-03-09 Thread Tom Sparks

is there a php Fop (XSLFO)?
if not are there any that are not java based and can be run o a website that 
has php support only?


tom_a_sparks

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html


  Stay connected to the people that matter most with a smarter inbox. Take 
a look http://au.docs.yahoo.com/mail/smarterinbox

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



Re: [PHP] assign array values to variables

2009-03-09 Thread Jim Lucas

PJ wrote:

Jochem Maas wrote:

PJ schreef:

Seems it should be simple, but how does one extract values from an array
and assign them to a variable?
foreach ($categoriesIN as $category) {

1. if $categoriesIN comes from a POST, use $_POST['categoriesIN'] instead.

It does, but results are the same. Maybe it has something to do with
SESSIONS.

better yet use the filter extension (part of the core) to retrieve the
input.

2. validate  santize your input (the reason to use the filter extension)

I imagine it is duplicate work but since I am learning and want to
concentrate on 1 thing at a time, I am leaving the sanitizing part as
the lest task before validating the whole script (page).

3. WHY do you want to extract the values and assign them to vars?

shows you I don't know what i'm doing...
Her is what finally worked and that's where I learned that the values
are saved as arrays. =-O
$autoId = mysql_insert_id($result);// this was recovered earlier in page
foreach($categoriesIN as $category){
print $categorybr /;
$insert_category = INSERT INTO book_categories (book_id, categories_id)
VALUES ($autoid, $category);
mysql_query($insert_category,$db);
}

Here's the problem...
the values saved interesect the book_variables with variables and books.
I believe the variabless are saved as arrays (1 entry per fiels -e.g.
there are 4 categories for 1 book) I have to recover the names of the
categories (field category in categories table) and display them in an
HTML table with hrefs to the correesponding pages. What I am trying to
figure out is how to select and echo the categories for each book.

here is part of the select statement concerning the categories:
(the rest of the select works, but since there are several categories,
my table shows several entries for 1 book that has several categories)
snip...
LEFT JOIN book_publisher as abc ON b.id = abc.bookID
LEFT JOIN publishers AS c ON abc.publishers_id = c.id
LEFT JOIN book_categories AS d ON b.id = d.book_id
LEFT JOIN categories AS e ON d.categories_id = e.id
ORDER BY title ASC ;

I suppose that
LEFT JOIN categories AS e ON d.categories_id = e.id
needs some qualifier that will output the categories as
cat1, cat2, cat3, cat4... for count($rows)... or something like that; in
other words, as 1 row instead of 1 row per category.
Hope I'm not too confusing.

since you don't know the number of entries there is no point in creating
a stack of variables of which you have no idea what they are even called
or how many there are. instead loop the array or use an index into the
array to find the data your looking for. you don't have to create a
specific variable to use a piece of data the given element of an array
is just as valid.

4. there is the extract() function ... use at your own risk.
5. do something like this:

foreach ($array as $key = $val)
$$key = $val;

.. again use at your own risk.


echo $categorybr;
}
or
if(!empty($_POST['categoriesIN'])){
foreach( $_POST['categoriesIN'] as $key = $value) {
echo value = $valuebr;
}
both show the values entered in the form but do not create a variable.
Since the number of entries will vary, I cannot assign a number of
variable names before knowing how many entries there may be.








After I sent that last email a few hours ago, I started thinking that you were 
using a JOIN in your SQL.

Since you were complaining that you were getting duplicate entries for each book that had more then one category 
assigned to it.


The problem is with the JOIN.

What you need to do it execute 1 SQL call to the books table and 1 call to the 
book_categories table.

All the following code it typed directly into my email client.  It is 
completely untested.

Hopefully it works for you.

?php

# Do your db setup...
$dblink = mysql_connect(.);

# call to your books table (without a join to the books_categories table)
$SQL = SELECT id, title, author, etc... FROM books ORDER BY author, title LIMIT 
10;

$books = array();

if ( ( $results = mysql_query($SQL, $dblink) ) !== false ) {

# loop through results, place in array.
while ( $row = mysql_fetch_assoc($results, $dblink) ) {
$books[] = $row;
}

# we must have one book, otherwise this will return false and we would 
not need to call for other information
if ( $books ) {

$book_categories = array();

# call to your books_categories table
# ( do an ORDER BY in your SQL so the categories always show up 
in the same order)
$SQL = SELECT book_id, cat_id FROM books_categories ORDER BY 
category;

# loop through results, place in array
if ( ( $results = mysql_query($SQL, $dblink) ) !== false ) {
while ( $row = mysql_fetch_assoc($results) ) {
$book_categories[$row['book_id']][] = 
$row['cat_id'];
}
}

# we must have one book2cat 

Re: [PHP] DOM recursion

2009-03-09 Thread Jochem Maas
Jochem Maas schreef:
 Joanne Lane schreef:
 I am trying to create a class that recursively iterates over an array an
 creates XML tree to reflect a multidimensional array.
 I am not really a PHP coder, but am trying my hand.
 
 I've seen 'real coders' write stuff thats leagues worse.
 
 This is what I have so far.
 http://pastie.org/private/w75vyq9ub09p0uawteyieq

 I have tried a few methods, but I keep failing.
 Currently, all elements are appended to the root node.
 

.. yes my pleasure, glad I could help, not a problem. phffft.

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



Re: [PHP] Opendir on site root directory?

2009-03-09 Thread Stuart
2009/3/8 Clancy clanc...@cybec.com.au

 On Sun, 8 Mar 2009 12:33:15 +, stut...@gmail.com (Stuart) wrote:

 2009/3/8 Clancy clanc...@cybec.com.au
 
  On Sun, 8 Mar 2009 09:01:18 +, stut...@gmail.com (Stuart) wrote:
 
  2009/3/8 Clancy clanc...@cybec.com.au
  
   I want to index the files on a website recursively. The program will
 run
  in
   the site root
   directory, which GETCWD reports as D:/Websites/Website_1.  I can open
  any
   file in the root
   directory simply using its file name; Joe.dat, for example, and I can
   opendir for any
   subdirectory; eg
  
  opendir(Subdirectory_1);
  
   but opendir () does not seem to work, and the only way I can find to
  open
   the root
   directory is to give its full path; eg
  
  opendir (D:/Websites/Website_1);
  
   I have got the program working by using the full path to open the
 root
   directory, and then
   using relative paths to open the subdirectories and individual files,
  but
   this seems
   rather a kludge, and I am wondering if there is a way to open the
 root
   directory without
   specifying an absolute path?
  
  
  The current working directory cannot be trusted to be right. The best
  option is to use dirname(__FILE__) and add '/..' as many times as
 needed
  to
  get from the current file to the document root you're after.
 
  It has always worked for me.  But then I never change directory. But
 both
  give a hardware
  dependent answer;
 
  echo 'pCurrent directory is '.__FILE__.', CWD is '.getcwd().'/p';
 gives
 
  Current directory is D:\Websites\Corybas\Cydaldev\Dev\Testbed_2.php, CWD
 is
  D:\Websites\Corybas.
 
 
 Not sure what you mean by a hardware-dependent answer. The current working
 directory for any given script is determined by the web server and so it
 cannot be assumed to be the location of the current script.
 dirname(__FILE__) will give you the directory the current script is in.

 I agree that 'hardware dependent' was not the right word, but what I meant
 was that if I
 am running the local version of my program getcwd() will return
 'D:\Websites\Corybas',
 where as if I am running the remote version it will return
 'home/Corybasftp/www'.


This should be irrelevant in your code, something you can achieve using
dirname(__FILE__).

My webpage is always launched by loading index.php from the root directory,
 and I don't
 think I ever change the working directory, so although the code actually
 being executed at
 any given time is usually in a subdirectory, getcwd() will reliably return
 the (system
 dependent) long definition of the root directory.


Either I'm not explaining this well enough or you're just not getting it.
Ignore the current working directory - it's not reliable. If every page is
created by a single script then the solution is to define a constant at the
top of that script that gives you the directory that script is in

define('ROOT_DIR', dirname(__FILE__));

Then when you need to refer to another file in your directory structure you
do so relative to the location of index.php. So if you have a directory
named arse in the same folder as index.php you'd refer to that like so...

ROOT_DIR.'/arse'

If that's not clear maybe this will help:
http://dev.stut.net/php/dirname.php

Based on that the following should work in your particular situation, but

rather than just using this I encourage you to understand why it works...
 opendir(dirname(__FILE__).'/../Cydaldev');

 Looking into this I did find that 'opendir('Albums/../');', where 'Albums'
 can be any
 subdirectory I know to be present, will reliably open the root directory.


You clearly haven't looked into this at all since you're still not using
dirname(__FILE__), and if this email complete with the example script above
doesn't get the point across I give up. Have you even looked up dirname in
the manual? http://php.net/dirname

As a result of what seems to me to be an oversight in the design of
 opendir(), in that
 opendir(Fred) and opendir(Fred/Nurg) will open the appropriate sub
 directories but
 opendir() will not open the root directory, I can readily index all the
 subdirectories by
 giving their relative paths, but I have to resort to a kludge to index the
 root directory,
 and another kludge to eliminate this kludge from the index.


As in the example script I've posted above you can refer to the current
working directory with a single period (.), but this is still relying on the
current working directory being what you expect it to be.


 If, as it seems, I have to accept this it is fairly immaterial which kludge
 I actually
 use.


There is no need to use a kludge. I encourage you to read my replies
carefully if you're still not getting it.

-Stuart

-- 
http://stut.net/


[PHP] Line Break Problem

2009-03-09 Thread Alice Wei

Hi, 

  I have a question regarding using line breaks in PHP. I have the code 
something like:

   echo 1 . \t  . $x . \t . $y . \r\n;

When I run the code, it looks like a whole blob of text, but when I use View 
Source, the line breaks are formatted then correctly. 
Anyone can please tell me if this is what this is supposed to be? 
If so, how can I get the user to see the line break as they are, do I have to 
use br?

Thanks for your help.

Alice







_
Use Messenger to talk to your IM friends, even those on Yahoo!
http://ideas.live.com/programpage.aspx?versionId=7adb59de-a857-45ba-81cc-685ee3e858fe

Re: [PHP] Line Break Problem

2009-03-09 Thread Stuart
2009/3/9 Alice Wei aj...@alumni.iu.edu

  I have a question regarding using line breaks in PHP. I have the code
 something like:

   echo 1 . \t  . $x . \t . $y . \r\n;

 When I run the code, it looks like a whole blob of text, but when I use
 View Source, the line breaks are formatted then correctly.
 Anyone can please tell me if this is what this is supposed to be?
 If so, how can I get the user to see the line break as they are, do I have
 to use br?


This has nothing to do with PHP. HTML does not show carriage returns or
repeated white-space. If you want carriage returns or tabs you need to use
appropriate tags and/or CSS.

-Stuart

-- 
http://stut.net/


Re: [PHP] Line Break Problem

2009-03-09 Thread Jochem Maas
Stuart schreef:
 2009/3/9 Alice Wei aj...@alumni.iu.edu
 
  I have a question regarding using line breaks in PHP. I have the code
 something like:

   echo 1 . \t  . $x . \t . $y . \r\n;

 When I run the code, it looks like a whole blob of text, but when I use
 View Source, the line breaks are formatted then correctly.
 Anyone can please tell me if this is what this is supposed to be?
 If so, how can I get the user to see the line break as they are, do I have
 to use br?
 

you can also wrap the output in question in a pre tag:

pre
1   X   Y
2   X   Y
/pre

alternatively use the nl2br() function ... but that won't help
with displaying the tabs.

note that there is a difference between the output of your script
(which you can view using 'View Source' when the output is sent to
the browser) and the representation of that same source
(by which I mean how the the source is rendered [in the browser, in this
case).

HTML rendering ignores tabs, carriage returns and multiple consecutive spaces
found in the source (with the exception of the pre tag, possibly the code 
tag,
additionally the CSS attribute 'whitespace', IIRC, can be used to force 
rendering
all whitespace chars.

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



RE: [PHP] Line Break Problem

2009-03-09 Thread Alice Wei



 Date: Mon, 9 Mar 2009 13:28:19 +0100
 From: joc...@iamjochem.com
 To: stut...@gmail.com
 CC: aj...@alumni.iu.edu; php-general@lists.php.net
 Subject: Re: [PHP] Line Break Problem
 
 Stuart schreef:
  2009/3/9 Alice Wei aj...@alumni.iu.edu
  
   I have a question regarding using line breaks in PHP. I have the code
  something like:
 
echo 1 . \t  . $x . \t . $y . \r\n;
 
  When I run the code, it looks like a whole blob of text, but when I use
  View Source, the line breaks are formatted then correctly.
  Anyone can please tell me if this is what this is supposed to be?
  If so, how can I get the user to see the line break as they are, do I have
  to use br?
  
 
 you can also wrap the output in question in a pre tag:
 
 pre
 1 X   Y
 2 X   Y
 /pre
 
 alternatively use the nl2br() function ... but that won't help
 with displaying the tabs.
 
 note that there is a difference between the output of your script
 (which you can view using 'View Source' when the output is sent to
 the browser) and the representation of that same source
 (by which I mean how the the source is rendered [in the browser, in this
 case).
 
 HTML rendering ignores tabs, carriage returns and multiple consecutive spaces
 found in the source (with the exception of the pre tag, possibly the code 
 tag,
 additionally the CSS attribute 'whitespace', IIRC, can be used to force 
 rendering
 all whitespace chars.

Hi, all:



  Thanks to all who replied. It looks like that a simple pre tag works great. 
  Looks like I didn't realize that \r\n does not reflect itself to the screen.

  

Alice


_
All-in-one security and maintenance for your PC.  Get a free 90-day trial!
http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail

Re: [PHP] PHP includes

2009-03-09 Thread tedd

At 1:06 PM -0400 3/8/09, Gary wrote:

I'm working on learning php and have been toying with includes, and I am
trying to figure the advantages/disadvantages to using them.

I know that using them eliminates the need to put the files once altered
as with a template, however, is that the only advantage.

My particular concerns are with SEO and if the search engines and the bots
can read the page if it is made completely on includes?

Any and all comments would be appreciated.

Gary



Gary:

A demo might help:

http://sperling.com/examples/include-demo/

As for SEO, includes neither help nor hurt. Includes deliver code as 
requested for both bot and human alike. They are completely 
transparent to whatever/whomever are requesting them.


Cheers,

tedd



--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Hi Nathan,

Thanks a lot for the suggestion. It is working fine for an example code 
I have used to test it. The code I have written after your suggestion is 
as follows.

?php
$location=C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg;
header('Content-Type: image/jpeg');
imagejpeg(imagecreatefromjpeg($location));
?
The above code is yielding me a picture. Now, When I tried to use it in 
my original code it is not giving me the image. Instead it is giving me 
this warning *Warning*: Cannot modify header information - headers 
already sent by (output started at C:\wamp\www\mysqli.php:65) in 
*C:\wamp\www\mysqli.php* on line *221*
and a lot binary characters again instead of the image. I know something 
about this warning that we should not output anything to the browser 
before the header. But I cannot do that, since I need the user input 
using a html form and I use the input to fetch the data and dispaly it 
in a table along with the image. I am posting the whole code below. 
Please do let me know about any changes, corrections or modifications 
that are needed. The image display code is towards the last.


Thanks,
Sashi

html
body
form action=mysqli.php method=post
br
div align=center
Building Name:select name=name
option value= Select a Building/option
option value=Williams HallWilliams Hall/option
option value=Women's Softball FieldWomen's Softball Field/option
option value=Wright HouseWright House/option
/select
/div
  input type=submit /
/form
?php
// Connects to your Database
$host=*;
$user=*;
$password=*;
$dbname=*;
$cxn=mysqli_connect($host, $user, $password, $dbname) ;
if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
  {
  $error=mysqli_error($cxn);
  echo $error;
  die();
  }
else
  {
  echo Connection established successfully;
  }
//Define the variables for Day and Month
$Today=date(l);
$Month=date(F);
$build=$_POST[name];
$low_speed=2.5;
$high_speed=4;
$hour=date(G);
$minute=date(i);
if ($minute=00  $minute=14)
  {
  $minute=00;
  }
elseif ($minute=15  $minute=29)
  {
  $minute=15;
  }
elseif ($minute=30  $minute=44)
  {
  $minute=30;
  }
else
  {
  $minute=45;
  }
$times=10:$minute;
$sql=SELECT buildingname, parking_lot_name, empty_spaces, distance, 
round(distance/($low_speed*60),1) AS low_time, 
round(distance/($high_speed*60),1) AS high_time, Location FROM 
buildings, buildings_lots, parkinglots, occupancy2, Image where 
(buildings.buildingcode=occupancy2.building AND  
buildings.buildingcode=buildings_lots.building_code AND 
parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND 
parkinglots.parking_lot_code=occupancy2.parking_lot AND 
Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND 
month='$Month' AND day='Monday' AND Time='$times';

$data = mysqli_query($cxn,$sql);
if (!$data=mysqli_query($cxn,$sql))
  {
  $error=mysqli_error($cxn);
  echo $error;
  die();
  }
else
  {
  echo br;
  echo Query sent successfully;
  }
echo br;
echo h1 PARKING LOT INFORMATION h1;
echo table border='1' cellspacing='5' cellpadding='2';
echo tr\n
  thBuilding/th\n
  thParking Lot/th\n
  thEstimated Number of Empty Spaces/th\n
  thDistance (Feet)/th\n
  thEstimated walking time to the building/th\n
  /tr\n;
while ($row=mysqli_fetch_array($data))
  {
  extract($row);
$building = $row[0];
$parking_lot = $row[1];
$Number_of_Empty_Spaces = $row[2];
$Distance = $row[3];
$time_l = $row[4];
$time_h=$row[5];
$location=$row[6];   echo tr\n
td$building/td\n
td$parking_lot/td\n   
td$Number_of_Empty_Spaces/td\n

td$Distance/td\n
td$time_h - $time_l mins/td\n
td$location/td\n
/tr\n;
  }
  echo /table\n;
header('Content-Type: image/jpeg');
imagejpeg(imagecreatefromjpeg($location));
?
/body
/html

Nathan Nobbe wrote:

On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram sashi...@vt.edu wrote:

  

The thing is, I do not have a website or a place where I am storing my
images. I am storing the images on my local PC in folder as mentioned in my
earlier post. I have tried using only the

else {
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
}

Which you have suggested. This is the piece of code which is returning all
the binary character stuff. The code is definitely fetching the image. But
it is not able to deliver to the browser in the form of an image. I am
trying to read the image file as binary, evident from the FILE_BINARY
command. So may be, that is causing the image to be displayed as binary. Is
there any way we can convert the binary content to jpeg/jpg content again.
This is my guess after having gone through the code again.




i spent 2 minutes working on it and read this in the manual,

the first param of imagejpeg(),

An image resource, returned by one of the image creation functions, such as

Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Hi Nathan,

Thanks a lot for the suggestion. It is working fine for an example code 
I have used to test it. The code I have written after your suggestion is 
as follows.

?php
$location=C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg;
header('Content-Type: image/jpeg');
imagejpeg(imagecreatefromjpeg($location));
?
The above code is yielding me a picture. Now, When I tried to use it in 
my original code it is not giving me the image. Instead it is giving me 
this warning *Warning*: Cannot modify header information - headers 
already sent by (output started at C:\wamp\www\mysqli.php:65) 
in *C:\wamp\www\mysqli.php* on line *221*
and a lot binary characters again instead of the image. I know something 
about this warning that we should not output anything to the browser 
before the header. But I cannot do that, since I need the user input 
using a html form and I use the input to fetch the data and dispaly it 
in a table along with the image. I am posting the whole code below. 
Please do let me know about any changes, corrections or modifications 
that are needed. The image display code is towards the last.


Thanks,
Sashi

html
body
form action=mysqli.php method=post
br
div align=center
Building Name:select name=name
option value= Select a Building/option
 option value=Williams HallWilliams Hall/option
 option value=Women's Softball FieldWomen's Softball Field/option
 option value=Wright HouseWright House/option
/select
/div
   input type=submit /
/form
?php
// Connects to your Database
$host=*;
$user=*;
$password=*;
$dbname=*;
$cxn=mysqli_connect($host, $user, $password, $dbname) ;
if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
   {
   $error=mysqli_error($cxn);
   echo $error;
   die();
   }
else
   {
   echo Connection established successfully;
   }
//Define the variables for Day and Month
$Today=date(l);
$Month=date(F);
$build=$_POST[name];
$low_speed=2.5;
$high_speed=4;
$hour=date(G);
$minute=date(i);
if ($minute=00  $minute=14)
   {
   $minute=00;
   }
elseif ($minute=15  $minute=29)
   {
   $minute=15;
   }
elseif ($minute=30  $minute=44)
   {
   $minute=30;
   }
else
   {
   $minute=45;
   }
$times=10:$minute;
$sql=SELECT buildingname, parking_lot_name, empty_spaces, distance, 
round(distance/($low_speed*60),1) AS low_time, 
round(distance/($high_speed*60),1) AS high_time, Location FROM 
buildings, buildings_lots, parkinglots, occupancy2, Image where 
(buildings.buildingcode=occupancy2.building AND  
buildings.buildingcode=buildings_lots.building_code AND 
parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND 
parkinglots.parking_lot_code=occupancy2.parking_lot AND 
Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND 
month='$Month' AND day='Monday' AND Time='$times';

$data = mysqli_query($cxn,$sql);
if (!$data=mysqli_query($cxn,$sql))
   {
   $error=mysqli_error($cxn);
   echo $error;
   die();
   }
else
   {
   echo br;
   echo Query sent successfully;
   }
echo br;
echo h1 PARKING LOT INFORMATION h1;
echo table border='1' cellspacing='5' cellpadding='2';
echo tr\n
   thBuilding/th\n
   thParking Lot/th\n
   thEstimated Number of Empty Spaces/th\n
   thDistance (Feet)/th\n
   thEstimated walking time to the building/th\n
   /tr\n;
while ($row=mysqli_fetch_array($data))
   {
   extract($row);
$building = $row[0];
 $parking_lot = $row[1];
 $Number_of_Empty_Spaces = $row[2];
 $Distance = $row[3];
 $time_l = $row[4];
 $time_h=$row[5];
 $location=$row[6];   
echo tr\n

 td$building/td\n
 td$parking_lot/td\n  
 td$Number_of_Empty_Spaces/td\n

 td$Distance/td\n
 td$time_h - $time_l mins/td\n
td$location/td\n
 /tr\n;
   }
   echo /table\n;
header('Content-Type: image/jpeg');
imagejpeg(imagecreatefromjpeg($location));
?
/body
/html
Nathan Nobbe wrote:

On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram sashi...@vt.edu wrote:

  

The thing is, I do not have a website or a place where I am storing my
images. I am storing the images on my local PC in folder as mentioned in my
earlier post. I have tried using only the

else {
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
}

Which you have suggested. This is the piece of code which is returning all
the binary character stuff. The code is definitely fetching the image. But
it is not able to deliver to the browser in the form of an image. I am
trying to read the image file as binary, evident from the FILE_BINARY
command. So may be, that is causing the image to be displayed as binary. Is
there any way we can convert the binary content to jpeg/jpg content again.
This is my guess after having gone through the code again.




i spent 2 minutes working on it and read this in the manual,

the first param of imagejpeg(),

An image resource, returned by 

[PHP] Re: php fop (XSLFO)

2009-03-09 Thread Nathan Rixham

Tom Sparks wrote:

is there a php Fop (XSLFO)?
if not are there any that are not java based and can be run o a website that 
has php support only?



Hi Tom,

Not XSLFO as such, this was split up years ago in to it's comprising 
parts - XSLT, XSL and XPath, all of which PHP supports with the 
fantastic addition of a full DOM API for XML based documents.


http://php.net/dom (includes DOMXPath)
http://php.net/xsl (XSLTProcessor)

example:
?php
// load xsl
$XSLDocument = new DOMDocument();
$XSLDocument-load(xsl_document.xsl);

// load xml
$XMLDocument = new DOMDocument();
$XMLDocument-load('xml_document.xml');

//run xslt transformation
$XSLTProcessor = new XSLTProcessor();
$XSLTProcessor-importStylesheet($XSLDocument);
$NEWDoc = $XSLTProcessor-transformToDoc($XMLDocument);

// echo the new document
echo $NEWDoc-saveXML();
?

Regards :)

Nathan

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



Re: [PHP] verify data in fields

2009-03-09 Thread haliphax
On Sun, Mar 8, 2009 at 4:52 PM, PJ af.gour...@videotron.ca wrote:
 Ashley Sheridan wrote:
 On Sun, 2009-03-08 at 10:25 -0500, PJ wrote:

 My mysql table contains data. But I don't know how to verify what
 exactly is the data... is it an array, an integer, an alphanumeric
 character or what?
 vardump($whatever) returns null; the structure of the table is no null
 for the column fields and has been filled like this:
 $autoid = 1;
 $test = $_POST['categoriesIN']; // this can be several selections from form
 $tstring = implode(',' , $test);
 echo $tstring.'br /';
 $insert_category = INSERT INTO book_categories (book_id, categories_id)
 VALUES ($autoid, $tstring.);
 mysql_query($insert_category,$db);

 retrieval of data is:

 from SELECT ...snip...
 LEFT JOIN book_publisher as abc ON b.id = abc.bookID
 LEFT JOIN publishers AS c ON abc.publishers_id = c.id
 LEFT JOIN book_categories AS d ON b.id = d.book_id
 LEFT JOIN categories AS e ON d.categories_id = e.id

 I have included the publisher stuff - it works, whereas the category
 stuff does not...

 Surely if it is your table, you already know what types of data each
 field contains?

 I did and do.. I just was not getting the output I was expecting...so I
 panicked and looked for ways to verify all... bit, by bit I went over
 all my little lessons of the past weeks and ...  of course, taking my
 sweet time and lack of knowledge it took me a while to figure out that
 the problem was a missing SELECT table.column from the query. When I
 found the error, everything fell into place.
 But there remains the problem of how to select and display several
 categories from the query. If there isi only one category, there is no
 problem; with more than one I can't figure out how to retrieve it
 without the output showing as many entries for the same book as there
 are categories. Everything is output (echoed) correctly but the books
 are echoed in their entirety along with the category... what could I
 post to analyse the prolem.  I'm sure it's something simple, like
 imploding the array so it isn't repeated... ??

I think you'll probably have to use an ORDER BY clause in your query,
and only output a new book name when it changes during iteration. For
instance:

1. grab book categories (book id, book name, category id, category
name) with a JOIN
2. set last book name to  (empty string)
3. for each row in the result set
3a. if book name is different than last book name, output it
3b. output category
3c. next

HTH,


-- 
// Todd

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



Re: [PHP] DOM recursion

2009-03-09 Thread Nathan Rixham

Jochem Maas wrote:

Jochem Maas schreef:

Joanne Lane schreef:

I am trying to create a class that recursively iterates over an array an
creates XML tree to reflect a multidimensional array.
I am not really a PHP coder, but am trying my hand.

I've seen 'real coders' write stuff thats leagues worse.


This is what I have so far.
http://pastie.org/private/w75vyq9ub09p0uawteyieq

I have tried a few methods, but I keep failing.
Currently, all elements are appended to the root node.


.. yes my pleasure, glad I could help, not a problem. phffft.


all too often the case man, I'm sure free-w...@lists.php.net points here

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



Re: [PHP] Line Break Problem

2009-03-09 Thread Nathan Rixham

Alice Wei wrote:




Date: Mon, 9 Mar 2009 13:28:19 +0100
From: joc...@iamjochem.com
To: stut...@gmail.com
CC: aj...@alumni.iu.edu; php-general@lists.php.net
Subject: Re: [PHP] Line Break Problem

Stuart schreef:

2009/3/9 Alice Wei aj...@alumni.iu.edu


 I have a question regarding using line breaks in PHP. I have the code
something like:

  echo 1 . \t  . $x . \t . $y . \r\n;

When I run the code, it looks like a whole blob of text, but when I use
View Source, the line breaks are formatted then correctly.
Anyone can please tell me if this is what this is supposed to be?
If so, how can I get the user to see the line break as they are, do I have
to use br?

you can also wrap the output in question in a pre tag:

pre
1   X   Y
2   X   Y
/pre

alternatively use the nl2br() function ... but that won't help
with displaying the tabs.

note that there is a difference between the output of your script
(which you can view using 'View Source' when the output is sent to
the browser) and the representation of that same source
(by which I mean how the the source is rendered [in the browser, in this
case).

HTML rendering ignores tabs, carriage returns and multiple consecutive spaces
found in the source (with the exception of the pre tag, possibly the code 
tag,
additionally the CSS attribute 'whitespace', IIRC, can be used to force 
rendering
all whitespace chars.


Hi, all:



  Thanks to all who replied. It looks like that a simple pre tag works great. 
  Looks like I didn't realize that \r\n does not reflect itself to the screen.


  


Alice


_
All-in-one security and maintenance for your PC.  Get a free 90-day trial!
http://www.windowsonecare.com/purchase/trial.aspx?sc_cid=wl_wlmail


just a little side-note \r\n is windows specific, \n is linux but 
also works in many windows applications - the best option though is to 
use the php constant PHP_EOL as such which will use the correct end of 
line terminator for whichever platform your app is on, thus making your 
scripts portable and saving you future headaches :)


echo 1 . \t  . $x . \t . $y . PHP_EOL;

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



Re: [PHP] PHP includes

2009-03-09 Thread Virgilio Quilario
 I'm working on learning php and have been toying with includes, and I am
 trying to figure the advantages/disadvantages to using them.

 I know that using them eliminates the need to put the files once altered
 as with a template, however, is that the only advantage.

 My particular concerns are with SEO and if the search engines and the bots
 can read the page if it is made completely on includes?

 Any and all comments would be appreciated.


hi Gary,

It doesn't matter to SEO because search engines and the bots reads the
output of your php scripts.
whatever you see when you browse your page, same thing bots would see.

Includes is a way to modularize your scripts instead of monolithic or
repeated codes everywhere in your php file.

Virgil
http://www.jampmark.com

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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread haliphax
On Sun, Mar 8, 2009 at 11:57 PM, Micah Gersten
news.php@micahscomputing.com wrote:
 Chetan Rane wrote:
 HI

 I also was looking for various frameworks and came across a very nice
 framework, which is feature rich as well as very fast

 You can see more details at http://www.yiiframework.com/


 -Original Message-
 From: Micah Gersten [mailto:news.php@micahscomputing.com]
 Sent: Monday, March 09, 2009 9:52 AM
 To: php-general@lists.php.net
 Subject: [PHP] Re: PHP Frameworks

 HallMarc Websites wrote:
 First time caller; long time listener..

 I have been looking at various PHP MVC frameworks; Limb3, Symphony,
 Mojavi,
 Navigator, WACT, etc.

 I'm looking for any input anyone might have regarding which framework
 seems
 to be the most promising?


 I'm currently using Zend PHP Framework + Doctrine ORM.  Symfony has a
 little better integration with Doctrine.  I chose the Zend PHP Framework
 because of the rapid release schedule and large feature set.

 You might want to check the archives as this discussion has come up before.


 Please keep on list by hitting reply-all.  Someone else already
 mentioned yii framework.

Yes, this discussion has been hashed and rehashed more times than most
of us care to think about. The only thing I have to add since the last
time this came up was that I have been using CodeIgniter lately on a
personal project of mine, and I find it quite pleasant. It's like
Cake, only slimmer--but not lacking in important core features. Pretty
quick little bugger, too, and very easy to learn.


-- 
// Todd

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



Re: [PHP] Opendir on site root directory?

2009-03-09 Thread Nathan Rixham

Stuart wrote:

2009/3/8 Clancy clanc...@cybec.com.au


On Sun, 8 Mar 2009 12:33:15 +, stut...@gmail.com (Stuart) wrote:


2009/3/8 Clancy clanc...@cybec.com.au


On Sun, 8 Mar 2009 09:01:18 +, stut...@gmail.com (Stuart) wrote:


2009/3/8 Clancy clanc...@cybec.com.au


I want to index the files on a website recursively. The program will

run

in

the site root
directory, which GETCWD reports as D:/Websites/Website_1.  I can open

any

file in the root
directory simply using its file name; Joe.dat, for example, and I can
opendir for any
subdirectory; eg

   opendir(Subdirectory_1);

but opendir () does not seem to work, and the only way I can find to

open

the root
directory is to give its full path; eg

   opendir (D:/Websites/Website_1);

I have got the program working by using the full path to open the

root

directory, and then
using relative paths to open the subdirectories and individual files,

but

this seems
rather a kludge, and I am wondering if there is a way to open the

root

directory without
specifying an absolute path?


The current working directory cannot be trusted to be right. The best
option is to use dirname(__FILE__) and add '/..' as many times as

needed

to

get from the current file to the document root you're after.

It has always worked for me.  But then I never change directory. But

both

give a hardware
dependent answer;

echo 'pCurrent directory is '.__FILE__.', CWD is '.getcwd().'/p';

gives

Current directory is D:\Websites\Corybas\Cydaldev\Dev\Testbed_2.php, CWD

is

D:\Websites\Corybas.


Not sure what you mean by a hardware-dependent answer. The current working
directory for any given script is determined by the web server and so it
cannot be assumed to be the location of the current script.
dirname(__FILE__) will give you the directory the current script is in.

I agree that 'hardware dependent' was not the right word, but what I meant
was that if I
am running the local version of my program getcwd() will return
'D:\Websites\Corybas',
where as if I am running the remote version it will return
'home/Corybasftp/www'.



This should be irrelevant in your code, something you can achieve using
dirname(__FILE__).

My webpage is always launched by loading index.php from the root directory,

and I don't
think I ever change the working directory, so although the code actually
being executed at
any given time is usually in a subdirectory, getcwd() will reliably return
the (system
dependent) long definition of the root directory.



Either I'm not explaining this well enough or you're just not getting it.
Ignore the current working directory - it's not reliable. If every page is
created by a single script then the solution is to define a constant at the
top of that script that gives you the directory that script is in

define('ROOT_DIR', dirname(__FILE__));

Then when you need to refer to another file in your directory structure you
do so relative to the location of index.php. So if you have a directory
named arse in the same folder as index.php you'd refer to that like so...

ROOT_DIR.'/arse'

If that's not clear maybe this will help:
http://dev.stut.net/php/dirname.php


Based on that the following should work in your particular situation, but



rather than just using this I encourage you to understand why it works...

opendir(dirname(__FILE__).'/../Cydaldev');

Looking into this I did find that 'opendir('Albums/../');', where 'Albums'
can be any
subdirectory I know to be present, will reliably open the root directory.



You clearly haven't looked into this at all since you're still not using
dirname(__FILE__), and if this email complete with the example script above
doesn't get the point across I give up. Have you even looked up dirname in
the manual? http://php.net/dirname

As a result of what seems to me to be an oversight in the design of

opendir(), in that
opendir(Fred) and opendir(Fred/Nurg) will open the appropriate sub
directories but
opendir() will not open the root directory, I can readily index all the
subdirectories by
giving their relative paths, but I have to resort to a kludge to index the
root directory,
and another kludge to eliminate this kludge from the index.



As in the example script I've posted above you can refer to the current
working directory with a single period (.), but this is still relying on the
current working directory being what you expect it to be.



If, as it seems, I have to accept this it is fairly immaterial which kludge
I actually
use.



There is no need to use a kludge. I encourage you to read my replies
carefully if you're still not getting it.

-Stuart



lol stut! - just-in-case I'll add in that __FILE__ is a magic php 
constant holding the path to the file it is used in, and not just 
stuarts way of saying put your filename here


regards!

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



Re: [PHP] PHP includes

2009-03-09 Thread Nathan Rixham

Virgilio Quilario wrote:

I'm working on learning php and have been toying with includes, and I am
trying to figure the advantages/disadvantages to using them.

I know that using them eliminates the need to put the files once altered
as with a template, however, is that the only advantage.

My particular concerns are with SEO and if the search engines and the bots
can read the page if it is made completely on includes?

Any and all comments would be appreciated.



hi Gary,

It doesn't matter to SEO because search engines and the bots reads the
output of your php scripts.
whatever you see when you browse your page, same thing bots would see.

Includes is a way to modularize your scripts instead of monolithic or
repeated codes everywhere in your php file.

Virgil
http://www.jampmark.com


everybody is correct, include = server side include - all happens on 
the server, client never knows


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



Re: [PHP] Line Break Problem

2009-03-09 Thread Virgilio Quilario
 Hi,

  I have a question regarding using line breaks in PHP. I have the code 
 something like:

       echo 1 . \t  . $x . \t . $y . \r\n;

 When I run the code, it looks like a whole blob of text, but when I use View 
 Source, the line breaks are formatted then correctly.
 Anyone can please tell me if this is what this is supposed to be?
 If so, how can I get the user to see the line break as they are, do I have to 
 use br?

 Thanks for your help.

Hi Alice,

I see that you are using a browser to view the result.
Use br / to cause a break at end of every line.

echo 1 . \t  . $x . \t . $y . \r\nbr /;

that way, the lines are properly break even when viewing the HTML source.

Virgil
http://www.jampmark.com

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



RE: [PHP] How Much Data Can Be Written to a Database In One Instance?

2009-03-09 Thread Alice Wei




 Date: Wed, 4 Mar 2009 15:29:19 -0500
 Subject: Re: [PHP] How Much Data Can Be Written to a Database In One Instance?
 From: danbr...@php.net
 To: rob...@interjinn.com
 CC: aj...@alumni.iu.edu; php-general@lists.php.net
 
 On Wed, Mar 4, 2009 at 15:26, Robert Cummings rob...@interjinn.com wrote:
 
  See this setting in your php.ini:
 
  memory_limit = ???M
 
 Also let us know what you're using for the database and how you're
 doing it.  You mention that the .dat files are 4-5MB, but don't say if
 that's the database you're using, or if you're reading from those and
 entering the data in MySQL, or what.
 
 For example, if you're inserting data from there into MySQL, it's
 probably a MySQL issue that could be fixed by adjusting the packet
 size in your /etc/my.cnf (or equivalent) configuration file.
 
 -- 
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

Hi, Daniel:

  I went back to my problem and looks like I could change the output_buffering 
and the query timeout time. 

Alice

_
Use Messenger to talk to your IM friends, even those on Yahoo!
http://ideas.live.com/programpage.aspx?versionId=7adb59de-a857-45ba-81cc-685ee3e858fe

Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 1:29 AM, Sashikanth Gurram sashi...@vt.edu wrote:
 Hi Nathan,

 Thanks a lot for the suggestion. It is working fine for an example code I
 have used to test it. The code I have written after your suggestion is as
 follows.
 ?php
 $location=C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg;
 header('Content-Type: image/jpeg');
 imagejpeg(imagecreatefromjpeg($location));
 ?
 The above code is yielding me a picture. Now, When I tried to use it in my
 original code it is not giving me the image. Instead it is giving me this
 warning *Warning*: Cannot modify header information - headers already sent
 by (output started at C:\wamp\www\mysqli.php:65) in *C:\wamp\www\mysqli.php*
 on line *221*
 and a lot binary characters again instead of the image. I know something
 about this warning that we should not output anything to the browser before
 the header. But I cannot do that, since I need the user input using a html
 form and I use the input to fetch the data and dispaly it in a table along
 with the image. I am posting the whole code below. Please do let me know
 about any changes, corrections or modifications that are needed. The image
 display code is towards the last.

 Thanks,
 Sashi

 html
 body
 form action=mysqli.php method=post
 br
 div align=center
 Building Name:select name=name
 option value= Select a Building/option
     option value=Williams HallWilliams Hall/option
     option value=Women's Softball FieldWomen's Softball Field/option
     option value=Wright HouseWright House/option
 /select
 /div
                   input type=submit /
 /form
 ?php
 // Connects to your Database
 $host=*;
 $user=*;
 $password=*;
 $dbname=*;
 $cxn=mysqli_connect($host, $user, $password, $dbname) ;
 if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
   {
       $error=mysqli_error($cxn);
       echo $error;
       die();
   }
 else
   {
       echo Connection established successfully;
   }
 //Define the variables for Day and Month
 $Today=date(l);
 $Month=date(F);
 $build=$_POST[name];
 $low_speed=2.5;
 $high_speed=4;
 $hour=date(G);
 $minute=date(i);
 if ($minute=00  $minute=14)
   {
       $minute=00;
   }
 elseif ($minute=15  $minute=29)
   {
       $minute=15;
   }
 elseif ($minute=30  $minute=44)
   {
       $minute=30;
   }
 else
   {
       $minute=45;
   }
 $times=10:$minute;
 $sql=SELECT buildingname, parking_lot_name, empty_spaces, distance,
 round(distance/($low_speed*60),1) AS low_time,
 round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
 buildings_lots, parkinglots, occupancy2, Image where
 (buildings.buildingcode=occupancy2.building AND
  buildings.buildingcode=buildings_lots.building_code AND
 parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
 parkinglots.parking_lot_code=occupancy2.parking_lot AND
 Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
 month='$Month' AND day='Monday' AND Time='$times';
 $data = mysqli_query($cxn,$sql);
 if (!$data=mysqli_query($cxn,$sql))
   {
       $error=mysqli_error($cxn);
       echo $error;
       die();
   }
 else
   {
       echo br;
       echo Query sent successfully;
   }
 echo br;
 echo h1 PARKING LOT INFORMATION h1;
 echo table border='1' cellspacing='5' cellpadding='2';
 echo tr\n
       thBuilding/th\n
       thParking Lot/th\n
       thEstimated Number of Empty Spaces/th\n
       thDistance (Feet)/th\n
       thEstimated walking time to the building/th\n
   /tr\n;
 while ($row=mysqli_fetch_array($data))
   {
       extract($row);
 $building = $row[0];
     $parking_lot = $row[1];
     $Number_of_Empty_Spaces = $row[2];
     $Distance = $row[3];
     $time_l = $row[4];
     $time_h=$row[5];
     $location=$row[6];   echo tr\n
             td$building/td\n
             td$parking_lot/td\n
 td$Number_of_Empty_Spaces/td\n
             td$Distance/td\n
             td$time_h - $time_l mins/td\n
 td$location/td\n
             /tr\n;
   }
   echo /table\n;
 header('Content-Type: image/jpeg');
 imagejpeg(imagecreatefromjpeg($location));
 ?
 /body
 /html
 Nathan Nobbe wrote:

 On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram sashi...@vt.edu wrote:



 The thing is, I do not have a website or a place where I am storing my
 images. I am storing the images on my local PC in folder as mentioned in
 my
 earlier post. I have tried using only the

 else {
 header('Content-Type: image/jpeg');
 imagejpeg($img);
 imagedestroy($img);
 }

 Which you have suggested. This is the piece of code which is returning
 all
 the binary character stuff. The code is definitely fetching the image.
 But
 it is not able to deliver to the browser in the form of an image. I am
 trying to read the image file as binary, evident from the FILE_BINARY
 command. So may be, that is causing the image to be displayed as binary.
 Is
 there any way we can convert the binary content to jpeg/jpg content
 again.
 This is my guess after having gone through the code again.




Re: [PHP] web refreshing problem

2009-03-09 Thread Nathan Rixham

Andrew Williams wrote:

Hi,

my php program does not display current result of submitted form
instead the previous content is shown until you refresh manually
(which means resubmitting the form).

Can someone help me out because, I want to display the result of the
latest form result and not the old one.

I am using apache server on windows. Please help.


have you per chance got all data saved in the session and are using a 
script like


if( something in session ) {
  show session
}
else if( something in post ) {
  add form data to session
}
else {
  show only the form
}

three common causes are:
1- you're not actually processing the new form data
2- your browser isn't sending the form data second time round
3- your browser is caching the page (very very unlikely)

regards

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



Re: [PHP] stdin, stdout, stderr, 3

2009-03-09 Thread Daniel Brown
On Sun, Mar 8, 2009 at 22:35, Richard Lynch c...@l-i-e.com wrote:
 I have a program sending/receiving data to/from my CLI script using:

 0 stdin
 1 stdout
 2 stderr
 3 ??

UNIX Channel 3 is a non-standard stream resource, though I don't
believe it's even yet been given a name, so we'll have to change that.
 Let's call it STDOPT, because it's pretty much a STandarD OPTion that
you have available to use for your own desires (depending on the
distro and some other variables, you may not have STDOPT by default,
so as someone used to always sign their signature here, YMMV.)

 0, 1, and 2 are trivial.

 How do I access 3?

The same as you would in accessing channels 0, 1, and 2.  The
simplest way is to redirect STDOPT to STDOUT to view it on the screen:

?php
exec('./someCommand argument1 argument2 etc 31',$ret,$err);
print_r($ret); // Now contains a combination of STDOUT  STDOPT
print_r($err); // Still just STDERR.
?

Or you redirect STDOPT output to a file:

?php
exec('./someCommand argument1 argument2 etc 3stdopt.txt',$ret,$err);
print_r($ret); // STDOUT (Channel 1)
print_r($err); // STDERR (Channel 2)
echo file_get_contents('stdopt.txt'); // STDOPT (Channel 3)
?

 I tried /dev/fd/3 and failed to open it...

 Got no error messages about why it failed to open, it just failed.

 Am I missing something?

Make sure you have 'udev' installed on there, and also be sure
that /dev/fd exists, and /dev/fd/3 exists.  Also make sure that, when
you're checking it, STDERR isn't already being redirected somewhere
else, and that you're not missing some bad file descriptor errors in
the mix.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



[PHP] Error in Building an XML File

2009-03-09 Thread Joe Harman
Hello,

I am using PHP to build an XML file, but I keep on getting an XML
error when open the file in Google Chrome.
-
This page contains the following errors:

error on line 30 at column 318: Entity 'iuml' not defined
Below is a rendering of the page up to the first error.


is this something to do with document encoding?

I am using these as headers for the script

header(content-type:text/xml;charset=utf-8);
header(Content-Disposition:attachment;filename=google_feed.xml);


Thanks
Joe

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



Re: [PHP] Opendir on site root directory?

2009-03-09 Thread Virgilio Quilario
   I want to index the files on a website recursively. The program will
 run
  in
   the site root
   directory, which GETCWD reports as D:/Websites/Website_1.  I can open
  any
   file in the root
   directory simply using its file name; Joe.dat, for example, and I can
   opendir for any
   subdirectory; eg
  
          opendir(Subdirectory_1);
  
   but opendir () does not seem to work, and the only way I can find to
  open
   the root
   directory is to give its full path; eg
  
          opendir (D:/Websites/Website_1);
  
   I have got the program working by using the full path to open the
 root
   directory, and then
   using relative paths to open the subdirectories and individual files,
  but
   this seems
   rather a kludge, and I am wondering if there is a way to open the
 root
   directory without
   specifying an absolute path?
  
  
  The current working directory cannot be trusted to be right. The best
  option is to use dirname(__FILE__) and add '/..' as many times as
 needed
  to
  get from the current file to the document root you're after.
 
  It has always worked for me.  But then I never change directory. But
 both
  give a hardware
  dependent answer;
 
  echo 'pCurrent directory is '.__FILE__.', CWD is '.getcwd().'/p';
 gives
 
  Current directory is D:\Websites\Corybas\Cydaldev\Dev\Testbed_2.php, CWD
 is
  D:\Websites\Corybas.
 
 
 Not sure what you mean by a hardware-dependent answer. The current working
 directory for any given script is determined by the web server and so it
 cannot be assumed to be the location of the current script.
 dirname(__FILE__) will give you the directory the current script is in.

 I agree that 'hardware dependent' was not the right word, but what I meant
 was that if I
 am running the local version of my program getcwd() will return
 'D:\Websites\Corybas',
 where as if I am running the remote version it will return
 'home/Corybasftp/www'.


 This should be irrelevant in your code, something you can achieve using
 dirname(__FILE__).

 My webpage is always launched by loading index.php from the root directory,
 and I don't
 think I ever change the working directory, so although the code actually
 being executed at
 any given time is usually in a subdirectory, getcwd() will reliably return
 the (system
 dependent) long definition of the root directory.


 Either I'm not explaining this well enough or you're just not getting it.
 Ignore the current working directory - it's not reliable. If every page is
 created by a single script then the solution is to define a constant at the
 top of that script that gives you the directory that script is in

 define('ROOT_DIR', dirname(__FILE__));

 Then when you need to refer to another file in your directory structure you
 do so relative to the location of index.php. So if you have a directory
 named arse in the same folder as index.php you'd refer to that like so...

 ROOT_DIR.'/arse'

 If that's not clear maybe this will help:
 http://dev.stut.net/php/dirname.php

Based on that the following should work in your particular situation, but

rather than just using this I encourage you to understand why it works...
 opendir(dirname(__FILE__).'/../Cydaldev');

 Looking into this I did find that 'opendir('Albums/../');', where 'Albums'
 can be any
 subdirectory I know to be present, will reliably open the root directory.


 You clearly haven't looked into this at all since you're still not using
 dirname(__FILE__), and if this email complete with the example script above
 doesn't get the point across I give up. Have you even looked up dirname in
 the manual? http://php.net/dirname

 As a result of what seems to me to be an oversight in the design of
 opendir(), in that
 opendir(Fred) and opendir(Fred/Nurg) will open the appropriate sub
 directories but
 opendir() will not open the root directory, I can readily index all the
 subdirectories by
 giving their relative paths, but I have to resort to a kludge to index the
 root directory,
 and another kludge to eliminate this kludge from the index.


 As in the example script I've posted above you can refer to the current
 working directory with a single period (.), but this is still relying on the
 current working directory being what you expect it to be.


 If, as it seems, I have to accept this it is fairly immaterial which kludge
 I actually
 use.


 There is no need to use a kludge. I encourage you to read my replies
 carefully if you're still not getting it.

 -Stuart

 --
 http://stut.net/


Hi Clancy,

I think you want to traverse all files in a directory and its sub directories.

Here is a link to scandir() a php function for reading files and sub
directories of the target directory in your case the root web folder.
It has examples and explanations on how it works.
http://www.php.net/manual/en/function.scandir.php

Virgil
http://www.jampmark.com

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



RE: [PHP] Re: PHP Frameworks

2009-03-09 Thread Marc Christopher Hall
@todd; Micah - Precisely why I presented the question anew. Not only do I not 
have enough time to troll through the archives; I was looking for a fresher set 
of responses based on today's smorgasbord. Thank you for your input; I have 
looked at both YII and CI and they look promising. I love the statement about 
PEAR! That gave me a chuckle. With PHP 5.3 around the corner and looking 
forward to both PHP/MySQL 6; I am ISO a framework that is just as forward 
looking. I have already worked with Sapphire/SilverStripe for a client of mine 
and I find it comes with a lot of overhead. It does seem to be a promising 
future contender.


Thanks - Marc
Measure twice and cut once.

-Original Message-
From: haliphax [mailto:halip...@gmail.com] 
Sent: Monday, March 09, 2009 10:00 AM
To: php-general@lists.php.net
Subject: Re: [PHP] Re: PHP Frameworks

On Sun, Mar 8, 2009 at 11:57 PM, Micah Gersten
news.php@micahscomputing.com wrote:
 Chetan Rane wrote:
 HI

 I also was looking for various frameworks and came across a very nice
 framework, which is feature rich as well as very fast

 You can see more details at http://www.yiiframework.com/


 -Original Message-
 From: Micah Gersten [mailto:news.php@micahscomputing.com]
 Sent: Monday, March 09, 2009 9:52 AM
 To: php-general@lists.php.net
 Subject: [PHP] Re: PHP Frameworks

 HallMarc Websites wrote:
 First time caller; long time listener..

 I have been looking at various PHP MVC frameworks; Limb3, Symphony,
 Mojavi,
 Navigator, WACT, etc.

 I'm looking for any input anyone might have regarding which framework
 seems
 to be the most promising?


 I'm currently using Zend PHP Framework + Doctrine ORM.  Symfony has a
 little better integration with Doctrine.  I chose the Zend PHP Framework
 because of the rapid release schedule and large feature set.

 You might want to check the archives as this discussion has come up before.


 Please keep on list by hitting reply-all.  Someone else already
 mentioned yii framework.

Yes, this discussion has been hashed and rehashed more times than most
of us care to think about. The only thing I have to add since the last
time this came up was that I have been using CodeIgniter lately on a
personal project of mine, and I find it quite pleasant. It's like
Cake, only slimmer--but not lacking in important core features. Pretty
quick little bugger, too, and very easy to learn.


-- 
// Todd

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


__ Information from ESET Smart Security, version of virus signature 
database 3920 (20090309) __

The message was checked by ESET Smart Security.

http://www.eset.com


 

__ Information from ESET Smart Security, version of virus signature 
database 3920 (20090309) __

The message was checked by ESET Smart Security.

http://www.eset.com
 


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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Nathan Nobbe
On Sun, Mar 8, 2009 at 11:29 PM, Sashikanth Gurram sashi...@vt.edu wrote:

 Hi Nathan,

 Thanks a lot for the suggestion. It is working fine for an example code I
 have used to test it. The code I have written after your suggestion is as
 follows.
 ?php
 $location=C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg;
 header('Content-Type: image/jpeg');
 imagejpeg(imagecreatefromjpeg($location));
 ?
 The above code is yielding me a picture. Now, When I tried to use it in my
 original code it is not giving me the image. Instead it is giving me this
 warning *Warning*: Cannot modify header information - headers already sent
 by (output started at C:\wamp\www\mysqli.php:65) in *C:\wamp\www\mysqli.php*
 on line *221*


read the manual on header(),

http://us.php.net/header

youve probly echo'd some output to the browser prior to calling header().

-nathan


Re: [PHP] web refreshing problem

2009-03-09 Thread Virgilio Quilario
 Hi,

 my php program does not display current result of submitted form
 instead the previous content is shown until you refresh manually
 (which means resubmitting the form).

 Can someone help me out because, I want to display the result of the
 latest form result and not the old one.

 I am using apache server on windows. Please help.

 have you per chance got all data saved in the session and are using a script
 like

 if( something in session ) {
  show session
 }
 else if( something in post ) {
  add form data to session
 }
 else {
  show only the form
 }

 three common causes are:
 1- you're not actually processing the new form data
 2- your browser isn't sending the form data second time round
 3- your browser is caching the page (very very unlikely)

 regards


Hi Nathan,

Most likely your form is using POST method and your browser is
caching the page.

Virgil
http://www.jampmark.com

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Hi,

Yes, the problem was solved, but It did not work fine when I used the 
same code in my larger file. Now it makes sense. Let me just repeat what 
you have said just to make sure that I did not misread you.
So you say that the solution to this problem is to create another php 
file with the image fetching header and just write an img tag  img 
src=myimagescript.php?id=1234 / in my original php file (with the 
html tags). This is what I have understood.
Regarding the point you have mentioned ( If you set the content type 
using header() to image/jpeg, do not use HTML tags to display your 
image!), I definitely need the HTML tags, because this application works 
based on the user input. So unless there is not input through a html 
form, it wont work.


Thanks,
Sashi

On Mon, Mar 9, 2009 at 1:29 AM, Sashikanth Gurram sashi...@vt.edu wrote:
  

Hi Nathan,

Thanks a lot for the suggestion. It is working fine for an example code I
have used to test it. The code I have written after your suggestion is as
follows.
?php
$location=C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg;
header('Content-Type: image/jpeg');
imagejpeg(imagecreatefromjpeg($location));
?
The above code is yielding me a picture. Now, When I tried to use it in my
original code it is not giving me the image. Instead it is giving me this
warning *Warning*: Cannot modify header information - headers already sent
by (output started at C:\wamp\www\mysqli.php:65) in *C:\wamp\www\mysqli.php*
on line *221*
and a lot binary characters again instead of the image. I know something
about this warning that we should not output anything to the browser before
the header. But I cannot do that, since I need the user input using a html
form and I use the input to fetch the data and dispaly it in a table along
with the image. I am posting the whole code below. Please do let me know
about any changes, corrections or modifications that are needed. The image
display code is towards the last.

Thanks,
Sashi

html
body
form action=mysqli.php method=post
br
div align=center
Building Name:select name=name
option value= Select a Building/option
option value=Williams HallWilliams Hall/option
option value=Women's Softball FieldWomen's Softball Field/option
option value=Wright HouseWright House/option
/select
/div
  input type=submit /
/form
?php
// Connects to your Database
$host=*;
$user=*;
$password=*;
$dbname=*;
$cxn=mysqli_connect($host, $user, $password, $dbname) ;
if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
  {
  $error=mysqli_error($cxn);
  echo $error;
  die();
  }
else
  {
  echo Connection established successfully;
  }
//Define the variables for Day and Month
$Today=date(l);
$Month=date(F);
$build=$_POST[name];
$low_speed=2.5;
$high_speed=4;
$hour=date(G);
$minute=date(i);
if ($minute=00  $minute=14)
  {
  $minute=00;
  }
elseif ($minute=15  $minute=29)
  {
  $minute=15;
  }
elseif ($minute=30  $minute=44)
  {
  $minute=30;
  }
else
  {
  $minute=45;
  }
$times=10:$minute;
$sql=SELECT buildingname, parking_lot_name, empty_spaces, distance,
round(distance/($low_speed*60),1) AS low_time,
round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
buildings_lots, parkinglots, occupancy2, Image where
(buildings.buildingcode=occupancy2.building AND
 buildings.buildingcode=buildings_lots.building_code AND
parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
parkinglots.parking_lot_code=occupancy2.parking_lot AND
Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
month='$Month' AND day='Monday' AND Time='$times';
$data = mysqli_query($cxn,$sql);
if (!$data=mysqli_query($cxn,$sql))
  {
  $error=mysqli_error($cxn);
  echo $error;
  die();
  }
else
  {
  echo br;
  echo Query sent successfully;
  }
echo br;
echo h1 PARKING LOT INFORMATION h1;
echo table border='1' cellspacing='5' cellpadding='2';
echo tr\n
  thBuilding/th\n
  thParking Lot/th\n
  thEstimated Number of Empty Spaces/th\n
  thDistance (Feet)/th\n
  thEstimated walking time to the building/th\n
  /tr\n;
while ($row=mysqli_fetch_array($data))
  {
  extract($row);
$building = $row[0];
$parking_lot = $row[1];
$Number_of_Empty_Spaces = $row[2];
$Distance = $row[3];
$time_l = $row[4];
$time_h=$row[5];
$location=$row[6];   echo tr\n
td$building/td\n
td$parking_lot/td\n
td$Number_of_Empty_Spaces/td\n
td$Distance/td\n
td$time_h - $time_l mins/td\n
td$location/td\n
/tr\n;
  }
  echo /table\n;
header('Content-Type: image/jpeg');
imagejpeg(imagecreatefromjpeg($location));
?
/body
/html
Nathan Nobbe wrote:


On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram sashi...@vt.edu wrote:


  

The thing is, I do not have a website or a place where I am storing my
images. I am storing the images on my local PC in folder as 

Re: [PHP] assign array values to variables

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 9:25 AM, Jim Lucas li...@cmsws.com wrote:
 haliphax wrote:

 On Mon, Mar 9, 2009 at 2:22 AM, Jim Lucas li...@cmsws.com wrote:

 PJ wrote:

 PJ, this looks like your third thread for this same question. It might
 be easier to get a straight answer if your request isn't scattered all
 over the mailing list discussions.



 Actually, I think this is only the second for this specific topic.

 But, for his current project, this is like the 6th or 7th thread.

This particular JOIN and its surrounding circumstances are being
discussed in three threads. This is one of them. Anyway, I digress, as
I'm wasting just as much bandwidth with this reply. :P


-- 
// Todd

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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 9:25 AM, Marc Christopher Hall
m...@hallmarcwebsites.com wrote:
 @todd; Micah - Precisely why I presented the question anew. Not only do I not 
 have enough time to troll through the archives; I was looking for a fresher 
 set of responses based on today's smorgasbord. Thank you for your input; I 
 have looked at both YII and CI and they look promising. I love the statement 
 about PEAR! That gave me a chuckle. With PHP 5.3 around the corner and 
 looking forward to both PHP/MySQL 6; I am ISO a framework that is just as 
 forward looking. I have already worked with Sapphire/SilverStripe for a 
 client of mine and I find it comes with a lot of overhead. It does seem to be 
 a promising future contender.

Perhaps I should have phrased it a bit more concise: This has been
discussed many times--often, and RECENTLY. Anyway, since I'm already
writing this, I'll say that overhead/bloat vs. productivity of the
developer is a trade-off you're going to have to make for ANY of the
frameworks out there.


-- 
// Todd

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



[PHP] Re: Error in Building an XML File

2009-03-09 Thread Nathan Rixham

Joe Harman wrote:

Hello,

I am using PHP to build an XML file, but I keep on getting an XML
error when open the file in Google Chrome.
-
This page contains the following errors:

error on line 30 at column 318: Entity 'iuml' not defined
Below is a rendering of the page up to the first error.


is this something to do with document encoding?

I am using these as headers for the script

header(content-type:text/xml;charset=utf-8);
header(Content-Disposition:attachment;filename=google_feed.xml);


Thanks
Joe


looks like you have and  in the file right before iuml which is 
making the browser think it is an entity - ie invalid xml - ie make sure 
all 's are actually amp; - should fix you up


nathan

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Virgilio Quilario
 I am using a WAMP server for my coding purposes. My MySQL Version is
 5.0.51b, PHP version is 5.2.6 and Apache version is 2.2.8

 I have created a database with one of the tables containing a location of
 the image. Using PHP I am trying to retrieve the location of the image (from
 the mysql db) and display it in a browser. I have, with help from php-db
 mailing list user's help, created a code to do the same. Now, the problem
 is, the code is extracting the location details of the image exactly and it
 is even getting the image details. But it is simply not dispalying the
 image. Instead of displaying the image, it is printing a hell lot of binary
 characters (For example: 2!
 !22ÿÀ   ^          ÿÄ
            ÿĵ             }       !1A  Qa q 2 ‘¡ #B±Á RÑð$3br‚
  %'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyzƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤¥¦§¨©ª²³´µ¶·¸¹ºÂÃÄÅÆÇÈÉÊÒÓÔÕÖ×ØÙÚáâãäåæçèéêñòóôõö÷øùúÿÄ
                     ÿĵ              w      !1  AQ aq 2   B‘¡±Á #3Rð brÑ
 $4á%ñ    '()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz‚ƒ„…†‡ˆ‰Š’“”•–—˜™š¢£¤)

 I have tried in two forums and mailing lists but none of them have
 completely answered my question. How do I get rid of these signs and display
 the original image in its place? And to display the image successfully, is
 it really necessary to create the image retrieval and displaying code in a
 seperate PHP file? Any PHP gurus, enthusiasts, newbies out there, Please
 help me out.

 I am posting the code below so that you can directly see what I have done
 till now. The name of the php file is mysqli.php. The location of the image
 is stored to the variable $location. The image retrieval code is present
 towards end of the file.

 Thanks,
 Sashi

 html
 body
 form action=mysqli.php method=post
 br
 div align=center
 Building Name:select name=name
 option value= Select a Building/option
 option value=Williams HallWilliams Hall/option
 option value=Women's Softball FieldWomen's Softball Field/option
 option value=Wright HouseWright House/option
 /select
 /div
 input type=submit /
 /form
 ?php
 // Connects to your Database
 $host=***;
 $user=***;
 $password=***;
 $dbname=***;
 $cxn=mysqli_connect($host, $user, $password, $dbname) ;
 if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
 {
 $error=mysqli_error($cxn);
 echo $error;
 die();
 }
 else
 {
 echo Connection established successfully;
 }
 //Define the variables for Day and Month
 $Today=date(l);
 $Month=date(F);
 $build=$_POST[name];
 $low_speed=2.5;
 $high_speed=4;
 $hour=date(G);
 $minute=date(i);
 if ($minute=00  $minute=14)
 {
 $minute=00;
 }
 elseif ($minute=15  $minute=29)
 {
 $minute=15;
 }
 elseif ($minute=30  $minute=44)
 {
 $minute=30;
 }
 else
 {
 $minute=45;
 }
 $times=$hour:$minute;
 $sql=SELECT buildingname, parking_lot_name, empty_spaces, distance,
 round(distance/($low_speed*60),1) AS low_time,
 round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
 buildings_lots, parkinglots, occupancy2, Image where
 (buildings.buildingcode=occupancy2.building AND
 buildings.buildingcode=buildings_lots.building_code AND
 parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
 parkinglots.parking_lot_code=occupancy2.parking_lot AND
 Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
 month='$Month' AND day='$Today' AND Time='$times';
 $data = mysqli_query($cxn,$sql);
 if (!$data=mysqli_query($cxn,$sql))
 {
 $error=mysqli_error($cxn);
 echo $error;
 die();
 }
 else
 {
 echo br;
 echo Query sent successfully;
 }
 echo br;
 echo h1 PARKING LOT INFORMATION h1;
 echo table border='1' cellspacing='5' cellpadding='2';
 echo tr\n
 thBuilding/th\n
 thParking Lot/th\n
 thEstimated Number of Empty Spaces/th\n
 thDistance (Feet)/th\n
 thEstimated walking time to the building/th\n
 /tr\n;
 while ($row=mysqli_fetch_array($data))
 {
 extract($row);
 $building = $row[0];
 $parking_lot = $row[1];
 $Number_of_Empty_Spaces = $row[2];
 $Distance = $row[3];
 $time_l = $row[4];
 $time_h=$row[5];
 $location=$row[6];
 echo tr\n
 td$building/td\n
 td$parking_lot/td\n
 td$Number_of_Empty_Spaces/td\n
 td$Distance/td\n
 td$time_h - $time_l mins/td\n
 td$location/td\n
 /tr\n;
 }
 echo /table\n;
 $err=1;
 if ($img = file_get_contents($location, FILE_BINARY))
 {
 if ($img = imagecreatefromstring($img)) $err = 0;
 }
 if ($err)
 {
 header('Content-Type: text/html');
 echo 'htmlbodyp style=font-size:9pxError getting
 image.../p/body/html';
 }
 else
 {
 header('Content-Type: image/jpeg');
 imagejpeg($img);
 echo 'img src=mysqli.php?img=' . $location . ' border=1 height=150
 width=200 alt=' . $build . '';
 imagedestroy($img);
 }
 ?
 /body
 /html


Hi Sashikanth,

here is how to do it.
change
td$location/td\n
into
tdimg src='$location' /td\n

then // to comment the useless php code.

see the changes below:


while ($row=mysqli_fetch_array($data))
{
extract($row);
$building = $row[0];
$parking_lot = $row[1];
$Number_of_Empty_Spaces = 

Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 9:32 AM, Sashikanth Gurram sashi...@vt.edu wrote:
 On Mon, Mar 9, 2009 at 1:29 AM, Sashikanth Gurram sashi...@vt.edu wrote:


 Hi Nathan,

 Thanks a lot for the suggestion. It is working fine for an example code I
 have used to test it. The code I have written after your suggestion is as
 follows.
 ?php
 $location=C:\wamp\bin\apache\apache2.2.8\htdocs\Bldgs_lots\SQUIRES.jpg;
 header('Content-Type: image/jpeg');
 imagejpeg(imagecreatefromjpeg($location));
 ?
 The above code is yielding me a picture. Now, When I tried to use it in
 my
 original code it is not giving me the image. Instead it is giving me this
 warning *Warning*: Cannot modify header information - headers already
 sent
 by (output started at C:\wamp\www\mysqli.php:65) in
 *C:\wamp\www\mysqli.php*
 on line *221*
 and a lot binary characters again instead of the image. I know something
 about this warning that we should not output anything to the browser
 before
 the header. But I cannot do that, since I need the user input using a
 html
 form and I use the input to fetch the data and dispaly it in a table
 along
 with the image. I am posting the whole code below. Please do let me know
 about any changes, corrections or modifications that are needed. The
 image
 display code is towards the last.

 html
 body
 form action=mysqli.php method=post
 br
 div align=center
 Building Name:select name=name
 option value= Select a Building/option
    option value=Williams HallWilliams Hall/option
    option value=Women's Softball FieldWomen's Softball Field/option
    option value=Wright HouseWright House/option
 /select
 /div
                  input type=submit /
 /form
 ?php
 // Connects to your Database
 $host=*;
 $user=*;
 $password=*;
 $dbname=*;
 $cxn=mysqli_connect($host, $user, $password, $dbname) ;
 if (!$cxn=mysqli_connect($host, $user, $password, $dbname))
  {
      $error=mysqli_error($cxn);
      echo $error;
      die();
  }
 else
  {
      echo Connection established successfully;
  }
 //Define the variables for Day and Month
 $Today=date(l);
 $Month=date(F);
 $build=$_POST[name];
 $low_speed=2.5;
 $high_speed=4;
 $hour=date(G);
 $minute=date(i);
 if ($minute=00  $minute=14)
  {
      $minute=00;
  }
 elseif ($minute=15  $minute=29)
  {
      $minute=15;
  }
 elseif ($minute=30  $minute=44)
  {
      $minute=30;
  }
 else
  {
      $minute=45;
  }
 $times=10:$minute;
 $sql=SELECT buildingname, parking_lot_name, empty_spaces, distance,
 round(distance/($low_speed*60),1) AS low_time,
 round(distance/($high_speed*60),1) AS high_time, Location FROM buildings,
 buildings_lots, parkinglots, occupancy2, Image where
 (buildings.buildingcode=occupancy2.building AND
  buildings.buildingcode=buildings_lots.building_code AND
 parkinglots.parking_lot_code=buildings_lots.parking_lot_code AND
 parkinglots.parking_lot_code=occupancy2.parking_lot AND
 Buildings.BuildingCode=Image.BuildingCode) AND buildingname='$build' AND
 month='$Month' AND day='Monday' AND Time='$times';
 $data = mysqli_query($cxn,$sql);
 if (!$data=mysqli_query($cxn,$sql))
  {
      $error=mysqli_error($cxn);
      echo $error;
      die();
  }
 else
  {
      echo br;
      echo Query sent successfully;
  }
 echo br;
 echo h1 PARKING LOT INFORMATION h1;
 echo table border='1' cellspacing='5' cellpadding='2';
 echo tr\n
      thBuilding/th\n
      thParking Lot/th\n
      thEstimated Number of Empty Spaces/th\n
      thDistance (Feet)/th\n
      thEstimated walking time to the building/th\n
  /tr\n;
 while ($row=mysqli_fetch_array($data))
  {
      extract($row);
 $building = $row[0];
    $parking_lot = $row[1];
    $Number_of_Empty_Spaces = $row[2];
    $Distance = $row[3];
    $time_l = $row[4];
    $time_h=$row[5];
    $location=$row[6];   echo tr\n
            td$building/td\n
            td$parking_lot/td\n
 td$Number_of_Empty_Spaces/td\n
            td$Distance/td\n
            td$time_h - $time_l mins/td\n
 td$location/td\n
            /tr\n;
  }
  echo /table\n;
 header('Content-Type: image/jpeg');
 imagejpeg(imagecreatefromjpeg($location));
 ?
 /body
 /html
 Nathan Nobbe wrote:


 On Sat, Mar 7, 2009 at 9:36 PM, Sashikanth Gurram sashi...@vt.edu
 wrote:

 The thing is, I do not have a website or a place where I am storing my
 images. I am storing the images on my local PC in folder as mentioned
 in
 my
 earlier post. I have tried using only the

 else {
 header('Content-Type: image/jpeg');
 imagejpeg($img);
 imagedestroy($img);
 }

 Which you have suggested. This is the piece of code which is returning
 all
 the binary character stuff. The code is definitely fetching the image.
 But
 it is not able to deliver to the browser in the form of an image. I am
 trying to read the image file as binary, evident from the FILE_BINARY
 command. So may be, that is causing the image to be displayed as
 binary.
 Is
 there any way we can convert the binary content to jpeg/jpg content
 again.
 This is my guess after having gone through the 

Re: [PHP] Error in Building an XML File

2009-03-09 Thread Virgilio Quilario
 I am using PHP to build an XML file, but I keep on getting an XML
 error when open the file in Google Chrome.
 -
 This page contains the following errors:

 error on line 30 at column 318: Entity 'iuml' not defined
 Below is a rendering of the page up to the first error.
 

 is this something to do with document encoding?

 I am using these as headers for the script

 header(content-type:text/xml;charset=utf-8);
 header(Content-Disposition:attachment;filename=google_feed.xml);



hi Joe,

the document encoding has nothing to do with the error.
maybe you have  just before the iuml.
make it amp;iuml.
or maybe copy and paste that line here because i suspect there is
something else.

Virgil
http://www.jampmark.com

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



RE: [PHP] Error in Building an XML File

2009-03-09 Thread Bob McConnell
From: Joe Harman
 
 I am using PHP to build an XML file, but I keep on getting an XML
 error when open the file in Google Chrome.


-
 This page contains the following errors:
 
 error on line 30 at column 318: Entity 'iuml' not defined
 Below is a rendering of the page up to the first error.



 
 is this something to do with document encoding?

Entity errors are almost always caused by a bare ampersand in a URL. You
need to convert them to amp;. Since this error occurs, there may also
be other errors in the encoding. You need to read up on URL and HTML
sanitization.

Bob McConnell

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



[PHP] Re: PHP includes

2009-03-09 Thread Gary
Thank you to everybody that replied...but it almost seems it is making extra 
work.

I can understand using an include for a menu, since they tend to change 
often and it is on every page, but the normal content I am not understanding 
the benefit.  If I have a page that has unique content on it, that is to say 
no other page has this content, why would I want to create a separate file 
to be included on the page, why would I not simple put the content directly 
on the page itself?

What is the best type of file to be used as an include (.txt, .php).

Thanks again for all your help.

Gary
Gary gwp...@ptd.net wrote in message 
news:8a.64.51087.33bf3...@pb1.pair.com...
 I'm working on learning php and have been toying with includes, and I am 
 trying to figure the advantages/disadvantages to using them.

 I know that using them eliminates the need to put the files once altered 
 as with a template, however, is that the only advantage.

 My particular concerns are with SEO and if the search engines and the bots 
 can read the page if it is made completely on includes?

 Any and all comments would be appreciated.

 Gary
 



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



Re: [PHP] web refreshing problem

2009-03-09 Thread Virgilio Quilario
  my php program does not display current result of submitted form
  instead the previous content is shown until you refresh manually
  (which means resubmitting the form).
 
  Can someone help me out because, I want to display the result of the
  latest form result and not the old one.
 
  I am using apache server on windows. Please help.
 
  have you per chance got all data saved in the session and are using a
  script
  like
 
  if( something in session ) {
   show session
  }
  else if( something in post ) {
   add form data to session
  }
  else {
   show only the form
  }
 
  three common causes are:
  1- you're not actually processing the new form data
  2- your browser isn't sending the form data second time round
  3- your browser is caching the page (very very unlikely)
 
  regards
 

 Hi Nathan,

 Most likely your form is using POST method and your browser is
 caching the page.


yes my form is using post method but how do you stop catching the page

hi Andrew,

use the code below. it is from this page
http://www.php.net/header
look for Example #2 Caching directives.

?php
header(Cache-Control: no-cache, must-revalidate); // HTTP/1.1
header(Expires: Sat, 26 Jul 1997 05:00:00 GMT); // Date in the past
?

to be sure, put them as the first 2 lines at the top.

Virgil
http://www.jampmark.com

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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread Virgilio Quilario
 m...@hallmarcwebsites.com wrote:
 @todd; Micah - Precisely why I presented the question anew. Not only do I 
 not have enough time to troll through the archives; I was looking for a 
 fresher set of responses based on today's smorgasbord. Thank you for your 
 input; I have looked at both YII and CI and they look promising. I love the 
 statement about PEAR! That gave me a chuckle. With PHP 5.3 around the corner 
 and looking forward to both PHP/MySQL 6; I am ISO a framework that is just 
 as forward looking. I have already worked with Sapphire/SilverStripe for a 
 client of mine and I find it comes with a lot of overhead. It does seem to 
 be a promising future contender.

 Perhaps I should have phrased it a bit more concise: This has been
 discussed many times--often, and RECENTLY. Anyway, since I'm already
 writing this, I'll say that overhead/bloat vs. productivity of the
 developer is a trade-off you're going to have to make for ANY of the
 frameworks out there.


hi,

all php frameworks have overheads which you don't have to worry about.
those overhead codes are there to make things easy for you so you can
focus on building your application.
for me, the most important factor in choosing the right php framework
is the size of its community.
the bigger the better because there will be more people to exchange ideas with.

Virgil
http://www.jampmark.com

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



RE: [PHP] Re: PHP includes

2009-03-09 Thread Mayer, Jonathan

Thank you to everybody that replied...but it almost seems it is making
extra 
work.

I can understand using an include for a menu, since they tend to change

often and it is on every page, but the normal content I am not
understanding 
the benefit.  If I have a page that has unique content on it, that is
to say 
no other page has this content, why would I want to create a separate
file 
to be included on the page, why would I not simple put the content
directly 
on the page itself?

What is the best type of file to be used as an include (.txt, .php).

Thanks again for all your help.

There are some circumstances where that could be useful. I don't do it
often, but one site I made a while ago was based on a standard main page
with the content included in. The content pages then had absolutely
nothing except the unique text, so that redesigns to the site were made
easier in the futurem, because only one page needed to be edited. So the
entire site was based around a page.php?ID=x with the ID specifying the
include required.

Such as an example might be a little out of date now, what with CSS and
so forth, but it was useful at the time.

If I am including a file with password details, I usually make it
something random (.inc, .sec, whatever) and hide it away somewhere
inacessible

Gary
Gary gwp...@ptd.net wrote in message 
news:8a.64.51087.33bf3...@pb1.pair.com...
 I'm working on learning php and have been toying with includes, and I
am 
 trying to figure the advantages/disadvantages to using them.

 I know that using them eliminates the need to put the files once
altered 
 as with a template, however, is that the only advantage.

 My particular concerns are with SEO and if the search engines and the
bots 
 can read the page if it is made completely on includes?

 Any and all comments would be appreciated.

 Gary
 






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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Nathan Nobbe
On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram sashi...@vt.edu wrote:

 Hi,

 Yes, the problem was solved, but It did not work fine when I used the same
 code in my larger file. Now it makes sense.


right, just track down where you started sending the output, and remember if
youre going to use header() calls in your scripts, that all of them must
come before sending any of the standard content.


 Let me just repeat what you have said just to make sure that I did not
 misread you.
 So you say that the solution to this problem is to create another php file
 with the image fetching header and just write an img tag  img
 src=myimagescript.php?id=1234 / in my original php file (with the html
 tags).


what i explained in my first response is that youre mixing 2 different
approaches, and it was unclear what you were going for exactly.  if you want
to have an image included in a page of html, then theres no need for the
header() call (refer to my first response for the remaining details).  there
are however legitimate use cases for the use of header()  the
aforementioned image methods, i think between mine and some of the other
posts on this thread, its explained clearly.


 This is what I have understood.
 Regarding the point you have mentioned ( If you set the content type using
 header() to image/jpeg, do not use HTML tags to display your image!),


correct


 I definitely need the HTML tags, because this application works based on
 the user input. So unless there is not input through a html form, it wont
 work.


right, then just configure your webserver such that you can first access the
image directly via an http url, then integrate these links into your dynamic
pages as i explained in my first response.

good luck,

-nathan


Re: [PHP] stdin, stdout, stderr, 3

2009-03-09 Thread Per Jessen
Daniel Brown wrote:

 On Sun, Mar 8, 2009 at 22:35, Richard Lynch c...@l-i-e.com wrote:
 I have a program sending/receiving data to/from my CLI script using:

 0 stdin
 1 stdout
 2 stderr
 3 ??
 
 UNIX Channel 3 is a non-standard stream resource, though I don't
 believe it's even yet been given a name, so we'll have to change that.

UNIX Channel 3 ?? 
It's just file descriptor 3, that's all. In the old days, it was
occasionally called stdaux, but AFAIK that's not used any more. 


/Per

-- 
Per Jessen, Zürich (4.9°C)


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



RE: [PHP] Re: PHP includes

2009-03-09 Thread Bob McConnell
From: Gary
 
 Thank you to everybody that replied...but it almost seems it is making
extra 
 work.
 
 I can understand using an include for a menu, since they tend to
change 
 often and it is on every page, but the normal content I am not
understanding 
 the benefit.  If I have a page that has unique content on it, that is
to say 
 no other page has this content, why would I want to create a separate
file 
 to be included on the page, why would I not simple put the content
directly 
 on the page itself?
 
 What is the best type of file to be used as an include (.txt, .php).
 

We include template files for the head block, a banner across the top
of every page, the footer across the bottom, the menu and images in the
left sidebar, and the advertisement banners across the top and bottom.
Even the core section of each page is included from the initial file.
That way we can change the appearance, or modify the links to our
disclaimers and help files just once and every page gets updated. We
also have configuration flags to prevent some of those files from being
included in a specific virtual domain, so our clients can provide their
own templates instead of using ours.

File extensions for includes are up to you. Just make sure your
IDE/Editor know that they are PHP files. We use .lia for the libraries
of functions we use throughout the site. None of our files have .php as
the extension.

Bob McConnell

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Hi,
Thanks a lot for all the patient replies. All the suggestions led me in 
a positive direction. Finally, instead of using the header() in my main 
PHP file (with HTML tags), I have used it in a secondary file and called 
it using  a tagimg src=imgtest.php. It is working fine. But, the 
image I need to display is also dynamic and needs a user input. So, is 
there any way in which I can transfer a particular variable (the user 
input) from my main php file (say A.php) to my secondary file containing 
the header () (say B.php)


Thanks,
Sashi

Nathan Nobbe wrote:



On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram sashi...@vt.edu 
mailto:sashi...@vt.edu wrote:


Hi,

Yes, the problem was solved, but It did not work fine when I used
the same code in my larger file. Now it makes sense.


right, just track down where you started sending the output, and 
remember if youre going to use header() calls in your scripts, that 
all of them must come before sending any of the standard content.
 


Let me just repeat what you have said just to make sure that I did
not misread you.
So you say that the solution to this problem is to create another
php file with the image fetching header and just write an img tag
 img src=myimagescript.php?id=1234 / in my original php file
(with the html tags).


what i explained in my first response is that youre mixing 2 different 
approaches, and it was unclear what you were going for exactly.  if 
you want to have an image included in a page of html, then theres no 
need for the header() call (refer to my first response for the 
remaining details).  there are however legitimate use cases for the 
use of header()  the aforementioned image methods, i think between 
mine and some of the other posts on this thread, its explained clearly.
 


This is what I have understood.
Regarding the point you have mentioned ( If you set the content
type using header() to image/jpeg, do not use HTML tags to
display your image!),


correct
 


I definitely need the HTML tags, because this application works
based on the user input. So unless there is not input through a
html form, it wont work.


right, then just configure your webserver such that you can first 
access the image directly via an http url, then integrate these links 
into your dynamic pages as i explained in my first response.


good luck,

-nathan




--
~
~
Sashikanth Gurram
Graduate Research Assistant
Department of Civil and Environmental Engineering
Virginia Tech
Blacksburg, VA 24060, USA


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



RE: Re: [PHP] stdin, stdout, stderr, 3

2009-03-09 Thread Bob McConnell
From: Per Jessen
 Daniel Brown wrote:
 
 On Sun, Mar 8, 2009 at 22:35, Richard Lynch c...@l-i-e.com wrote:
 I have a program sending/receiving data to/from my CLI script using:

 0 stdin
 1 stdout
 2 stderr
 3 ??
 
 UNIX Channel 3 is a non-standard stream resource, though I don't
 believe it's even yet been given a name, so we'll have to change
that.
 
 UNIX Channel 3 ?? 
 It's just file descriptor 3, that's all. In the old days, it was
 occasionally called stdaux, but AFAIK that's not used any more. 

AUX and PRN for 3 and 4 were standard for a serial port and printer
interface respectively on CP/M and then PC-DOS 1.0. Both were carried
through to later versions of MS-DOS, but not used nor referenced very
much. I don't recall seeing them in a Unix context at all.

Bob McConnell

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



RE: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Bob McConnell
From: Sashikanth Gurram
 
 Hi,
 Thanks a lot for all the patient replies. All the suggestions led me
in 
 a positive direction. Finally, instead of using the header() in my
main 
 PHP file (with HTML tags), I have used it in a secondary file and
called 
 it using  a tagimg src=imgtest.php. It is working fine. But, the 
 image I need to display is also dynamic and needs a user input. So, is

 there any way in which I can transfer a particular variable (the user 
 input) from my main php file (say A.php) to my secondary file
containing 
 the header () (say B.php)

Well, you are really trying to use one page to do two different tasks.
First to display the input form, then to show an image selected by that
input. So, either you need two code paths, or two pages. You can start
off by checking the input fields and if they are empty, simply display
the form. Then the next time through, when the fields are populated,
insert the selected image.

Bob McConnell

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram sashi...@vt.edu wrote:
 Nathan Nobbe wrote:


 On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram sashi...@vt.edu
 mailto:sashi...@vt.edu wrote:

    Hi,

    Yes, the problem was solved, but It did not work fine when I used
    the same code in my larger file. Now it makes sense.


 right, just track down where you started sending the output, and remember
 if youre going to use header() calls in your scripts, that all of them must
 come before sending any of the standard content.

    Let me just repeat what you have said just to make sure that I did
    not misread you.
    So you say that the solution to this problem is to create another
    php file with the image fetching header and just write an img tag
     img src=myimagescript.php?id=1234 / in my original php file
    (with the html tags).


 what i explained in my first response is that youre mixing 2 different
 approaches, and it was unclear what you were going for exactly.  if you want
 to have an image included in a page of html, then theres no need for the
 header() call (refer to my first response for the remaining details).  there
 are however legitimate use cases for the use of header()  the
 aforementioned image methods, i think between mine and some of the other
 posts on this thread, its explained clearly.

    This is what I have understood.
    Regarding the point you have mentioned ( If you set the content
    type using header() to image/jpeg, do not use HTML tags to
    display your image!),


 correct

    I definitely need the HTML tags, because this application works
    based on the user input. So unless there is not input through a
    html form, it wont work.


 right, then just configure your webserver such that you can first access
 the image directly via an http url, then integrate these links into your
 dynamic pages as i explained in my first response.

 Thanks a lot for all the patient replies. All the suggestions led me in a
 positive direction. Finally, instead of using the header() in my main PHP
 file (with HTML tags), I have used it in a secondary file and called it
 using  a tagimg src=imgtest.php. It is working fine. But, the image I
 need to display is also dynamic and needs a user input. So, is there any way
 in which I can transfer a particular variable (the user input) from my main
 php file (say A.php) to my secondary file containing the header () (say
 B.php)

Yes. Use the Query String of your image-producing PHP script to pass
values. If you had an image tag like this:

img src=imagescript.php?id=1234 /

Then you could grab the value of $_GET['id'] in your PHP script and
react accordingly.

HTH,


-- 
// Todd

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



Re: [PHP] Error in Building an XML File

2009-03-09 Thread Joe Harman
On Mon, Mar 9, 2009 at 9:53 AM, Bob McConnell r...@cbord.com wrote:
 From: Joe Harman

 I am using PHP to build an XML file, but I keep on getting an XML
 error when open the file in Google Chrome.

 
 -
 This page contains the following errors:

 error on line 30 at column 318: Entity 'iuml' not defined
 Below is a rendering of the page up to the first error.

 
 


Okay, Thanks... appears the problem is that I have foreign language
entities in my HTML... Ugh

I am sure this is not really the most efficient way to do this, but I
tried using the following to get rid of these, but it appears that it
just converts them to this i¿½...

$search = 
explode(,,ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u);
$replace = 
explode(,,c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u);
$decode_string = str_replace($search, $replace,
html_entity_decode($row_rsFeed['full_desc']))

I am going to read up some more on sanitizing HTML

Joe

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



Re: [PHP] stdin, stdout, stderr, 3

2009-03-09 Thread Daniel Brown
On Mon, Mar 9, 2009 at 11:14, Per Jessen p...@computer.org wrote:

 UNIX Channel 3 ??

Sorry, Per, I must've stuttered.  Yes, I said, UNIX Channel 3.
For lack of a better reference.  That not withstanding, the direct
response to Lynch's question still holds true.

 It's just file descriptor 3, that's all. In the old days, it was
 occasionally called stdaux, but AFAIK that's not used any more.

Now that you mention it, I do seem to recall the term STDAUX,
but I'm not sure if it's an actual memory or just one of those things
that looks familiar after reading it.  Either way, the streams are
also referred to as channels, and the virtual reference to that is
known as the file descriptor.

 Per Jessen, Zürich (4.9°C)

It's about 43F (~6C) here in Scranton today much more
acceptable than the 5F (-15C) we had just a short time ago.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread Sashikanth Gurram

Thanks a lot everyone, particularly Haliphax, Nathan, Virgilio and Bob.

I will try it and will come back to you.

Thanks,
Sashi

haliphax wrote:

On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram sashi...@vt.edu wrote:
  

Nathan Nobbe wrote:


On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram sashi...@vt.edu
mailto:sashi...@vt.edu wrote:

   Hi,

   Yes, the problem was solved, but It did not work fine when I used
   the same code in my larger file. Now it makes sense.


right, just track down where you started sending the output, and remember
if youre going to use header() calls in your scripts, that all of them must
come before sending any of the standard content.

   Let me just repeat what you have said just to make sure that I did
   not misread you.
   So you say that the solution to this problem is to create another
   php file with the image fetching header and just write an img tag
img src=myimagescript.php?id=1234 / in my original php file
   (with the html tags).


what i explained in my first response is that youre mixing 2 different
approaches, and it was unclear what you were going for exactly.  if you want
to have an image included in a page of html, then theres no need for the
header() call (refer to my first response for the remaining details).  there
are however legitimate use cases for the use of header()  the
aforementioned image methods, i think between mine and some of the other
posts on this thread, its explained clearly.

   This is what I have understood.
   Regarding the point you have mentioned ( If you set the content
   type using header() to image/jpeg, do not use HTML tags to
   display your image!),


correct

   I definitely need the HTML tags, because this application works
   based on the user input. So unless there is not input through a
   html form, it wont work.


right, then just configure your webserver such that you can first access
the image directly via an http url, then integrate these links into your
dynamic pages as i explained in my first response.
  

Thanks a lot for all the patient replies. All the suggestions led me in a
positive direction. Finally, instead of using the header() in my main PHP
file (with HTML tags), I have used it in a secondary file and called it
using  a tagimg src=imgtest.php. It is working fine. But, the image I
need to display is also dynamic and needs a user input. So, is there any way
in which I can transfer a particular variable (the user input) from my main
php file (say A.php) to my secondary file containing the header () (say
B.php)



Yes. Use the Query String of your image-producing PHP script to pass
values. If you had an image tag like this:

img src=imagescript.php?id=1234 /

Then you could grab the value of $_GET['id'] in your PHP script and
react accordingly.

HTH,


  



--
~
~
Sashikanth Gurram
Graduate Research Assistant
Department of Civil and Environmental Engineering
Virginia Tech
Blacksburg, VA 24060, USA


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



Re: [PHP] Retrieving Image Location in PHP from MySQL

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 10:52 AM, Sashikanth Gurram sashi...@vt.edu wrote:
 haliphax wrote:

 On Mon, Mar 9, 2009 at 10:24 AM, Sashikanth Gurram sashi...@vt.edu
 wrote:


 Nathan Nobbe wrote:


 On Mon, Mar 9, 2009 at 7:32 AM, Sashikanth Gurram sashi...@vt.edu
 mailto:sashi...@vt.edu wrote:

   Hi,

   Yes, the problem was solved, but It did not work fine when I used
   the same code in my larger file. Now it makes sense.


 right, just track down where you started sending the output, and
 remember
 if youre going to use header() calls in your scripts, that all of them
 must
 come before sending any of the standard content.

   Let me just repeat what you have said just to make sure that I did
   not misread you.
   So you say that the solution to this problem is to create another
   php file with the image fetching header and just write an img tag
    img src=myimagescript.php?id=1234 / in my original php file
   (with the html tags).


 what i explained in my first response is that youre mixing 2 different
 approaches, and it was unclear what you were going for exactly.  if you
 want
 to have an image included in a page of html, then theres no need for the
 header() call (refer to my first response for the remaining details).
  there
 are however legitimate use cases for the use of header()  the
 aforementioned image methods, i think between mine and some of the other
 posts on this thread, its explained clearly.

   This is what I have understood.
   Regarding the point you have mentioned ( If you set the content
   type using header() to image/jpeg, do not use HTML tags to
   display your image!),


 correct

   I definitely need the HTML tags, because this application works
   based on the user input. So unless there is not input through a
   html form, it wont work.


 right, then just configure your webserver such that you can first access
 the image directly via an http url, then integrate these links into your
 dynamic pages as i explained in my first response.


 Thanks a lot for all the patient replies. All the suggestions led me in a
 positive direction. Finally, instead of using the header() in my main PHP
 file (with HTML tags), I have used it in a secondary file and called it
 using  a tagimg src=imgtest.php. It is working fine. But, the image I
 need to display is also dynamic and needs a user input. So, is there any
 way
 in which I can transfer a particular variable (the user input) from my
 main
 php file (say A.php) to my secondary file containing the header () (say
 B.php)


 Yes. Use the Query String of your image-producing PHP script to pass
 values. If you had an image tag like this:

 img src=imagescript.php?id=1234 /

 Then you could grab the value of $_GET['id'] in your PHP script and
 react accordingly.

 Thanks a lot everyone, particularly Haliphax, Nathan, Virgilio and Bob.

 I will try it and will come back to you.

You're very welcome. This page [1] may help you get started. It's a
bit dated, but the information still holds true today.

1. http://whn.vdhri.net/2005/10/how_to_use_the_query_string_in_php.html


-- 
// Todd

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



Re: [PHP] stdin, stdout, stderr, 3

2009-03-09 Thread Per Jessen
Daniel Brown wrote:

 It's just file descriptor 3, that's all. In the old days, it was
 occasionally called stdaux, but AFAIK that's not used any more.
 
 Now that you mention it, I do seem to recall the term STDAUX,
 but I'm not sure if it's an actual memory or just one of those things
 that looks familiar after reading it.  Either way, the streams are
 also referred to as channels, and the virtual reference to that is
 known as the file descriptor.

Hmm, I know I have never heard streams or file descriptors referred to
as channels.  Well, certainly not in UNIX.  

As for stdaux, I don't think it's being used any more at all.  Like Bob
suggested, I think it might very well be a DOS reference. 



-- 
Per Jessen, Zürich (1.8°C)


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



Re: [PHP] Re: PHP includes

2009-03-09 Thread Sudheer Satyanarayana

Gary wrote:
Thank you to everybody that replied...but it almost seems it is making extra 
work.


I can understand using an include for a menu, since they tend to change 
often and it is on every page, but the normal content I am not understanding 
the benefit.  If I have a page that has unique content on it, that is to say 
no other page has this content, why would I want to create a separate file 
to be included on the page, why would I not simple put the content directly 
on the page itself?
  
There are several advantages of using include. I can't imagine an 
application without include/require/autoload.


I create the database adapter only once per request. I store several 
application configuration items in a config file and load this 
configuration information only once per request. I have one layout for 
the application. Only the content and the menus change. So, I would 
simply include various sections of the web page in relevant positions.

Example:
layout.php
?php
include 'header.php';
include 'menu.php'; // menu.php is also dynamic. menu.php determines 
what to display on the current page.
include 'sidebar.php'; // within sidebar.php I would include 
block_a.php, block_b.php, etc

include 'footer.php';
?

I put the utility functions and classes in a library file. I would 
simply include the library.php and use the functions available in it.


I hope you get the point of using include.

What is the best type of file to be used as an include (.txt, .php).

  


--

With warm regards,
Sudheer. S
Business: http://binaryvibes.co.in, Tech stuff: http://techchorus.net, 
Personal: http://sudheer.net


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



Re: [PHP] Error in Building an XML File

2009-03-09 Thread Nathan Rixham

Joe Harman wrote:

On Mon, Mar 9, 2009 at 9:53 AM, Bob McConnell r...@cbord.com wrote:

From: Joe Harman

I am using PHP to build an XML file, but I keep on getting an XML
error when open the file in Google Chrome.



-

This page contains the following errors:

error on line 30 at column 318: Entity 'iuml' not defined
Below is a rendering of the page up to the first error.






Okay, Thanks... appears the problem is that I have foreign language
entities in my HTML... Ugh

I am sure this is not really the most efficient way to do this, but I
tried using the following to get rid of these, but it appears that it
just converts them to this i¿½...

$search = 
explode(,,ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u);
$replace = 
explode(,,c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u);
$decode_string = str_replace($search, $replace,
html_entity_decode($row_rsFeed['full_desc']))

I am going to read up some more on sanitizing HTML

Joe


you need to be dealing with encodings here; whats the encoding of the 
original content? iso-8859-1? - in short what you need is to convert all 
text to be utf-8, more than likely utf8_encode($whatchaNeed) will get 
you going in right direction.


regards!

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



[PHP] Re: PHP includes

2009-03-09 Thread Nathan Rixham

Gary wrote:
Thank you to everybody that replied...but it almost seems it is making extra 
work.


I can understand using an include for a menu, since they tend to change 
often and it is on every page, but the normal content I am not understanding 
the benefit.  If I have a page that has unique content on it, that is to say 
no other page has this content, why would I want to create a separate file 
to be included on the page, why would I not simple put the content directly 
on the page itself?


What is the best type of file to be used as an include (.txt, .php).

Thanks again for all your help.

Gary
Gary gwp...@ptd.net wrote in message 
news:8a.64.51087.33bf3...@pb1.pair.com...
I'm working on learning php and have been toying with includes, and I am 
trying to figure the advantages/disadvantages to using them.


I know that using them eliminates the need to put the files once altered 
as with a template, however, is that the only advantage.


My particular concerns are with SEO and if the search engines and the bots 
can read the page if it is made completely on includes?


Any and all comments would be appreciated.

Gary






Hi Gary,

I think this thread is at risk of getting confusing and not addressing 
the problem at its root.


An include is typically used to allow storing reusable code in a file 
all by itself, this could be a settings (config) file, a class, an html 
template or whatever - purpose being of course to keep you all nice and 
organised, with each thing in its place.


Leaving out everything else and focusing only on why we'd use 
include/require in an application, let's take a simple example:


Simple PHP Site with 3 Pages.
1 - / (the homepage)
2 - /?page=about (the about us page)
3 - /?page=contact (the contact us page)

in the above scenario then your index.php could look like this

?php

//set the default page to be home
$page = 'home';

//check if a page has been specified
if( isset($_GET['page']) ) {
  $page = $_GET['page'];
}

if( $page == 'home' )
{
  include 'home.php';
}
elseif ( $page == 'about' )
{
  include 'about.php';
}
else( $page == 'contact' )
{
  include 'contact.php';
}
else
{
  include 'page-not-found.php';
}

?

very simple, but works; now let's expand it a bit.. in a real world 
scenario we probably have a good chunk of script at the top of index.php 
that holds database settings, database connection etc. and in each of 
our pages we probably have much of the html repeated (site header, 
footer, navigation) - we can then abstract these in to there own files 
to keep it all nice and clean.. as such


?php
$page = 'home';
if( isset($_GET['page']) ) {
  $page = $_GET['page'];
}

// get site  database settings
require 'config.php';

// get our database class
require 'classes/class.database.php';

// start out database
$database = new DatabaseClass($settings_from_config);

// load the site header
include 'templates/header.php';

// load the content for the requested page
if( $page == 'home' )
{
  include 'content/home.php';
}
elseif ( $page == 'about' )
{
  include 'content/about.php';
}
else( $page == 'contact' )
{
  include 'content/contact.php';
}
else
{
  include 'content/page-not-found.php';
}

// load the site footer
include 'templates/footer.php';

?

now everything is in its rightful place and we have lots of easy files 
to work with, for example now you can let a designer work on the 
about.php page knowing that they won't be able to break the whole 
application, as it's just a bit of html content.


also, you can now change the header image in one file 
(templates/header.php) and the whole site will update.


most PHP websites are simply far more complex versions of the above, 
look complicated but the principals are the same.


now the only thing I didn't cover is which to use.. it's often the case 
that require_once and include_once should be used over include and 
require; because in most cases (certainly with classes) you just want to 
ensure the code is available. both of the _once statements will only 
load the file if it hasn't been already, thus ensuring no errors such as 
class already defined because it's already been included!


On the other hand if the code in the file has been designed to be used 
many times on a page then include would be the better choice - a 
really stupid example but consider a file containing a fancy horizontal 
bar; you may want to include this many times on a page.


Finally, require and require_once will kill the script with an error if 
the file isn't found, whereas include will throw an error and simply 
keep on going if the files isn't found.


Think that covers everything in the scope of this :)

Regards!

Nathan

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



[PHP] Re: PHP includes

2009-03-09 Thread Nathan Rixham

Gary wrote:
Thank you to everybody that replied...but it almost seems it is making extra 
work.


What is the best type of file to be used as an include (.txt, .php).



new I forgot something! the best type of file to be used as an include 
differs on a case by case basis.


name the files correctly and forget about dictating in advance, file 
extensions are there so people can easily identify what's in the file - 
and when you have 10,000 files you'll really appreciate this :p


some_code.php
some_html.html
some_text.txt

all of them can be included, and even reading the list you can pretty 
much guess what each contains.


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



[PHP] Hi!! I Joined the PHP Mailing List

2009-03-09 Thread Picu Priya
Hello Everyone, I have just joined the PHP Community.. I hope, I will spend
good time here.. I am already a PHP programmer, and Love to learn a lot of
new php tricks while helping others, as best of my knowledge. :)

-- 
http://www.iniad.com : Iniad Link Xchange System


[PHP] Re: Hi!! I Joined the PHP Mailing List

2009-03-09 Thread Shawn McKenzie
Picu Priya wrote:
 Hello Everyone, I have just joined the PHP Community.. I hope, I will spend
 good time here.. I am already a PHP programmer, and Love to learn a lot of
 new php tricks while helping others, as best of my knowledge. :)
 

Welcome!  You are the designated helper for PJ.

-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Re: Hi!! I Joined the PHP Mailing List

2009-03-09 Thread Eric Butera
On Mon, Mar 9, 2009 at 2:07 PM, Shawn McKenzie nos...@mckenzies.net wrote:
 Picu Priya wrote:
 Hello Everyone, I have just joined the PHP Community.. I hope, I will spend
 good time here.. I am already a PHP programmer, and Love to learn a lot of
 new php tricks while helping others, as best of my knowledge. :)


 Welcome!  You are the designated helper for PJ.

 --
 Thanks!
 -Shawn
 http://www.spidean.com

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



Hah!  :)

-- 
http://www.voom.me | EFnet: #voom

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



Re: [PHP] web refreshing problem

2009-03-09 Thread Andrew Williams
Hi everyone,

I discovered that error  and warning messages from my program does not
display automatically unless you refresh the page. and page also has the
same problem.   Does it has anything to do with the PHP - Apache  settings.

I have added the below message to it but its not making no difference.

 ?php
  header(Cache-Control: no-cache, must-revalidate); // HTTP/1.1
  header(Expires: Sat, 26 Jul 1997 05:00:00 GMT); // Date in the past
  ?

help please

On Mon, Mar 9, 2009 at 3:09 PM, Virgilio Quilario 
virgilio.quila...@gmail.com wrote:

  hi,

 that wouldn't be a problem.
 it will just tell the browser not to cache the html output.

 Virgil
 http://www.jampmark.com

 On Mon, Mar 9, 2009 at 11:03 PM, Andrew Williams
 and...@stocksignals.com wrote:
  part of the program needs to store data data on he catch memory. would
 that
  be a problem?
 
  On Mon, Mar 9, 2009 at 2:57 PM, Virgilio Quilario
  virgilio.quila...@gmail.com wrote:
 
my php program does not display current result of submitted form
instead the previous content is shown until you refresh manually
(which means resubmitting the form).
   
Can someone help me out because, I want to display the result of
the
latest form result and not the old one.
   
I am using apache server on windows. Please help.
   
have you per chance got all data saved in the session and are
 using
a
script
like
   
if( something in session ) {
 show session
}
else if( something in post ) {
 add form data to session
}
else {
 show only the form
}
   
three common causes are:
1- you're not actually processing the new form data
2- your browser isn't sending the form data second time round
3- your browser is caching the page (very very unlikely)
   
regards
   
  
   Hi Nathan,
  
   Most likely your form is using POST method and your browser is
   caching the page.
 
 
  yes my form is using post method but how do you stop catching the page
 
  hi Andrew,
 
  use the code below. it is from this page
  http://www.php.net/header
  look for Example #2 Caching directives.
 
  ?php
  header(Cache-Control: no-cache, must-revalidate); // HTTP/1.1
  header(Expires: Sat, 26 Jul 1997 05:00:00 GMT); // Date in the past
  ?
 
  to be sure, put them as the first 2 lines at the top.
 
  Virgil
  http://www.jampmark.com
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 
  --
  Best Wishes
  Andrew Williams
 
 
 




-- 
Best Wishes
Andrew Williams


Re: [PHP] web refreshing problem

2009-03-09 Thread Nathan Rixham

Andrew Williams wrote:

Hi everyone,

I discovered that error  and warning messages from my program does not
display automatically unless you refresh the page. and page also has the
same problem.   Does it has anything to do with the PHP - Apache  settings.


post your code - limited in what help we can give without it.

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



[PHP] Re: Hi!! I Joined the PHP Mailing List

2009-03-09 Thread Nathan Rixham

Picu Priya wrote:

Hello Everyone, I have just joined the PHP Community.. I hope, I will spend
good time here.. I am already a PHP programmer, and Love to learn a lot of
new php tricks while helping others, as best of my knowledge. :)



welcome :-)

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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread Jason Norwood-Young

haliphax wrote:

Perhaps I should have phrased it a bit more concise: This has been
discussed many times--often, and RECENTLY. Anyway, since I'm already
writing this, I'll say that overhead/bloat vs. productivity of the
developer is a trade-off you're going to have to make for ANY of the
frameworks out there.
  


I disagree somewhat. A good framework should actually reduce bloat. It 
encourages you to implement proper MVC architecture, helps you avoid 
those rambling function.php files, and if it's well built, things like 
DB connectivity should already be optimised. I like CI because it does 
all of that fairly well, and tends to perform faster than something some 
coder (like myself) hacked together in the smallest time-frame possible. 
I use it on some pretty big sites - one with DB's with 10's of millions 
of records, and one site with over 1.5 million users a month. Personal 
thumbs up for CI, but use whatever suits your skill level, timeframe and 
requirements. Some frameworks will increase bloat, but sometimes that's 
worth it to get the project out the door in a given timeframe. If you're 
doing a blog on caring for chickens, throw it up in an hour with 
WordPress. If you're planning on being the next NY Times, WordPress will 
not be a kind mistress.


There are down sides to CI too, but it suits my needs for the types of 
sites I produce.


J

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



Re: [PHP] Re: Hi!! I Joined the PHP Mailing List

2009-03-09 Thread 9el
Welcome here as well :)

www.twitter.com/nine_L
www.lenin9l.wordpress.com






Re: [PHP] Hi!! I Joined the PHP Mailing List

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 12:54 PM, Picu Priya iniad...@gmail.com wrote:
 Hello Everyone, I have just joined the PHP Community.. I hope, I will spend
 good time here.. I am already a PHP programmer, and Love to learn a lot of
 new php tricks while helping others, as best of my knowledge. :)

Hello, and welcome! Just a little FYI--the mailing list archives are
at http://marc.info/?l=php-general ... lots of useful information in
there, and you may find the solution to your problem before you even
need to ask a question!

Happy programming, and again, welcome to the list.


-- 
// Todd

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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 1:26 PM, Jason Norwood-Young
ja...@freespeechpub.co.za wrote:
 haliphax wrote:

 Perhaps I should have phrased it a bit more concise: This has been
 discussed many times--often, and RECENTLY. Anyway, since I'm already
 writing this, I'll say that overhead/bloat vs. productivity of the
 developer is a trade-off you're going to have to make for ANY of the
 frameworks out there.


 I disagree somewhat. A good framework should actually reduce bloat. It
 encourages you to implement proper MVC architecture, helps you avoid those
 rambling function.php files, and if it's well built, things like DB
 connectivity should already be optimised. I like CI because it does all of
 that fairly well, and tends to perform faster than something some coder
 (like myself) hacked together in the smallest time-frame possible. I use it
 on some pretty big sites - one with DB's with 10's of millions of records,
 and one site with over 1.5 million users a month. Personal thumbs up for CI,
 but use whatever suits your skill level, timeframe and requirements. Some
 frameworks will increase bloat, but sometimes that's worth it to get the
 project out the door in a given timeframe. If you're doing a blog on caring
 for chickens, throw it up in an hour with WordPress. If you're planning on
 being the next NY Times, WordPress will not be a kind mistress.

 There are down sides to CI too, but it suits my needs for the types of sites
 I produce.

Framework = Overhead (when compared to vanilla PHP). Period. I'm not
saying it's overhead that will cripple your application, or that
frameworks should be avoided... quite the contrary, in fact. I have
recently fallen in love with CodeIgniter myself--I'm just saying that
one should be at least respectfully aware of the overhead that comes
hand-in-hand with a(ny) framework, and weigh those against what you
feel is acceptable for your purpose.


-- 
// Todd

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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread Nathan Rixham

Jason Norwood-Young wrote:

haliphax wrote:

Perhaps I should have phrased it a bit more concise: This has been
discussed many times--often, and RECENTLY. Anyway, since I'm already
writing this, I'll say that overhead/bloat vs. productivity of the
developer is a trade-off you're going to have to make for ANY of the
frameworks out there.
  


I disagree somewhat. A good framework should actually reduce bloat. It 
encourages you to implement proper MVC architecture, helps you avoid 
those rambling function.php files, and if it's well built, things like 
DB connectivity should already be optimised. I like CI because it does 
all of that fairly well, and tends to perform faster than something some 
coder (like myself) hacked together in the smallest time-frame possible. 
I use it on some pretty big sites - one with DB's with 10's of millions 
of records, and one site with over 1.5 million users a month. Personal 
thumbs up for CI, but use whatever suits your skill level, timeframe and 
requirements. Some frameworks will increase bloat, but sometimes that's 
worth it to get the project out the door in a given timeframe. If you're 
doing a blog on caring for chickens, throw it up in an hour with 
WordPress. If you're planning on being the next NY Times, WordPress will 
not be a kind mistress.


There are down sides to CI too, but it suits my needs for the types of 
sites I produce.


J


I agree with you're disagreement, a good framework will indeed reduce 
code bloat.


 fork post 

prong 1:
*jumps on* the MVC thing, you can't just say mvc is the appropriate 
architecture for php applications; true many the frameworks follow the 
whole pythonesque MVC thing; but that doesn't make it any more the 
correct choice than any other architecture or design pattern. There is 
no fits all and all too often you see people trying to overstretch 
there framework of choice to something it just doesn't do and wasn't 
designed for (not as common as trying to fit drupal in a square hole 
though :p)


prong 2:
However IMHO there are other benefits which outweigh this:
- multi other developers will be familiar with the codebase and be able 
to on board rapidly should the project expand
- the client won't be left with some unknown codebase that only you 
really know (unless of course you want to tie the client in)
- you learn well known re-usable code that you can take to other 
projects (and add to the cv)
- bugs in code move from being a headache to an opportunity for 
improvement and benefit the community (and often fixed by others)

- your code base is ever improving without you doing any work
- and all the obvious stuff..

prong 3:
If you're planning on being the next NY Times, WordPress will not be a 
kind mistress. - lol, I wish all clients understood this.


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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread Jason Norwood-Young

haliphax wrote:

On Mon, Mar 9, 2009 at 1:26 PM, Jason Norwood-Young
ja...@freespeechpub.co.za wrote:
  

haliphax wrote:


Perhaps I should have phrased it a bit more concise: This has been
discussed many times--often, and RECENTLY. Anyway, since I'm already
writing this, I'll say that overhead/bloat vs. productivity of the
developer is a trade-off you're going to have to make for ANY of the
frameworks out there.

  

I disagree somewhat. A good framework should actually reduce bloat. It
encourages you to implement proper MVC architecture, helps you avoid those
rambling function.php files, and if it's well built, things like DB
connectivity should already be optimised. I like CI because it does all of
that fairly well, and tends to perform faster than something some coder
(like myself) hacked together in the smallest time-frame possible. I use it
on some pretty big sites - one with DB's with 10's of millions of records,
and one site with over 1.5 million users a month. Personal thumbs up for CI,
but use whatever suits your skill level, timeframe and requirements. Some
frameworks will increase bloat, but sometimes that's worth it to get the
project out the door in a given timeframe. If you're doing a blog on caring
for chickens, throw it up in an hour with WordPress. If you're planning on
being the next NY Times, WordPress will not be a kind mistress.

There are down sides to CI too, but it suits my needs for the types of sites
I produce.



Framework = Overhead (when compared to vanilla PHP). Period. I'm not
saying it's overhead that will cripple your application, or that
frameworks should be avoided... quite the contrary, in fact. I have
recently fallen in love with CodeIgniter myself--I'm just saying that
one should be at least respectfully aware of the overhead that comes
hand-in-hand with a(ny) framework, and weigh those against what you
feel is acceptable for your purpose.
  
And I'm saying that using vanilla PHP sometimes (I'd say more often than 
not - especially with a group of developers of varying skill and 
experience) leads to sloppy programming, bad architecture and monolithic 
libraries, which in turn can lead to more overhead than simply starting 
with a framework. Not that a framework will save you from bad code - but 
it should point you in the right direction and make it obvious how you 
*should* do things.



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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread Nathan Rixham

Jason Norwood-Young wrote:

haliphax wrote:

On Mon, Mar 9, 2009 at 1:26 PM, Jason Norwood-Young
ja...@freespeechpub.co.za wrote:
 

haliphax wrote:
   

Perhaps I should have phrased it a bit more concise: This has been
discussed many times--often, and RECENTLY. Anyway, since I'm already
writing this, I'll say that overhead/bloat vs. productivity of the
developer is a trade-off you're going to have to make for ANY of the
frameworks out there.

  

I disagree somewhat. A good framework should actually reduce bloat. It
encourages you to implement proper MVC architecture, helps you avoid 
those

rambling function.php files, and if it's well built, things like DB
connectivity should already be optimised. I like CI because it does 
all of

that fairly well, and tends to perform faster than something some coder
(like myself) hacked together in the smallest time-frame possible. I 
use it
on some pretty big sites - one with DB's with 10's of millions of 
records,
and one site with over 1.5 million users a month. Personal thumbs up 
for CI,
but use whatever suits your skill level, timeframe and requirements. 
Some

frameworks will increase bloat, but sometimes that's worth it to get the
project out the door in a given timeframe. If you're doing a blog on 
caring
for chickens, throw it up in an hour with WordPress. If you're 
planning on

being the next NY Times, WordPress will not be a kind mistress.

There are down sides to CI too, but it suits my needs for the types 
of sites

I produce.



Framework = Overhead (when compared to vanilla PHP). Period. I'm not
saying it's overhead that will cripple your application, or that
frameworks should be avoided... quite the contrary, in fact. I have
recently fallen in love with CodeIgniter myself--I'm just saying that
one should be at least respectfully aware of the overhead that comes
hand-in-hand with a(ny) framework, and weigh those against what you
feel is acceptable for your purpose.
  
And I'm saying that using vanilla PHP sometimes (I'd say more often than 
not - especially with a group of developers of varying skill and 
experience) leads to sloppy programming, bad architecture and monolithic 
libraries, which in turn can lead to more overhead than simply starting 
with a framework. Not that a framework will save you from bad code - but 
it should point you in the right direction and make it obvious how you 
*should* do things.




that's assuming the developer actually looks at the code; all too often 
if they can't even be arsed learning a more robust framework then 
they're not going to.. I'm sure you follow.


learn by example works for me though :)

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



RE: [PHP] Re: PHP includes

2009-03-09 Thread Ashley Sheridan
On Mon, 2009-03-09 at 15:10 +, Mayer, Jonathan wrote:
 Thank you to everybody that replied...but it almost seems it is making
 extra 
 work.
 
 I can understand using an include for a menu, since they tend to change
 
 often and it is on every page, but the normal content I am not
 understanding 
 the benefit.  If I have a page that has unique content on it, that is
 to say 
 no other page has this content, why would I want to create a separate
 file 
 to be included on the page, why would I not simple put the content
 directly 
 on the page itself?
 
 What is the best type of file to be used as an include (.txt, .php).
 
 Thanks again for all your help.
 
 There are some circumstances where that could be useful. I don't do it
 often, but one site I made a while ago was based on a standard main page
 with the content included in. The content pages then had absolutely
 nothing except the unique text, so that redesigns to the site were made
 easier in the futurem, because only one page needed to be edited. So the
 entire site was based around a page.php?ID=x with the ID specifying the
 include required.
 
 Such as an example might be a little out of date now, what with CSS and
 so forth, but it was useful at the time.
 
 If I am including a file with password details, I usually make it
 something random (.inc, .sec, whatever) and hide it away somewhere
 inacessible
 
 Gary
 Gary gwp...@ptd.net wrote in message 
 news:8a.64.51087.33bf3...@pb1.pair.com...
  I'm working on learning php and have been toying with includes, and I
 am 
  trying to figure the advantages/disadvantages to using them.
 
  I know that using them eliminates the need to put the files once
 altered 
  as with a template, however, is that the only advantage.
 
  My particular concerns are with SEO and if the search engines and the
 bots 
  can read the page if it is made completely on includes?
 
  Any and all comments would be appreciated.
 
  Gary
  
 
 
 
 
 
 
Just thought I'd point out that it's recommended against giving non-php
extensions to PHP code pages. Basically, making all of your include
files .inc without the server correctly configured to recognise all .inc
files as PHP files, you are opening yourself up to possible hacks where
people put the URL of your include directly in their browser and view
all your code. Best thing is usually to name files like this:
filename.inc.php or some-such, and not filename.inc. 


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Error in Building an XML File

2009-03-09 Thread Ashley Sheridan
On Mon, 2009-03-09 at 16:26 +, Nathan Rixham wrote:
 Joe Harman wrote:
  On Mon, Mar 9, 2009 at 9:53 AM, Bob McConnell r...@cbord.com wrote:
  From: Joe Harman
  I am using PHP to build an XML file, but I keep on getting an XML
  error when open the file in Google Chrome.
 
  
  -
  This page contains the following errors:
 
  error on line 30 at column 318: Entity 'iuml' not defined
  Below is a rendering of the page up to the first error.
 
  
  
  
  Okay, Thanks... appears the problem is that I have foreign language
  entities in my HTML... Ugh
  
  I am sure this is not really the most efficient way to do this, but I
  tried using the following to get rid of these, but it appears that it
  just converts them to this i¿½...
  
  $search = 
  explode(,,ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,e,i,ø,u);
  $replace = 
  explode(,,c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,e,i,o,u);
  $decode_string = str_replace($search, $replace,
  html_entity_decode($row_rsFeed['full_desc']))
  
  I am going to read up some more on sanitizing HTML
  
  Joe
 
 you need to be dealing with encodings here; whats the encoding of the 
 original content? iso-8859-1? - in short what you need is to convert all 
 text to be utf-8, more than likely utf8_encode($whatchaNeed) will get 
 you going in right direction.
 
 regards!
Couple of ways to get round this:

1. Define the entity in a DTD for the XML
2. Put the raw character in the output (i.e. Ï)
3. Write the character as you have done, but put it inside a
![CDATA[  ]] block


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Re: PHP includes

2009-03-09 Thread Nathan Rixham

Ashley Sheridan wrote:

Just thought I'd point out that it's recommended against giving non-php
extensions to PHP code pages. Basically, making all of your include
files .inc without the server correctly configured to recognise all .inc
files as PHP files, you are opening yourself up to possible hacks where
people put the URL of your include directly in their browser and view
all your code. Best thing is usually to name files like this:
filename.inc.php or some-such, and not filename.inc. 



v well said - one thing you never want is your source showing!

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



Re: [PHP] Re: PHP includes

2009-03-09 Thread Larry Garfield
On Monday 09 March 2009 3:07:17 pm Nathan Rixham wrote:
 Ashley Sheridan wrote:
  Just thought I'd point out that it's recommended against giving non-php
  extensions to PHP code pages. Basically, making all of your include
  files .inc without the server correctly configured to recognise all .inc
  files as PHP files, you are opening yourself up to possible hacks where
  people put the URL of your include directly in their browser and view
  all your code. Best thing is usually to name files like this:
  filename.inc.php or some-such, and not filename.inc.

 v well said - one thing you never want is your source showing!

Unless you're working in open source and then the source is showing anyway 
from the original download site.  And if simply knowing your source code is a 
security hole, then you have bad software.

Your config file with passwords and such, sure, keep that locked down tight.  
But don't rely on security through obscurity.

-- 
Larry Garfield
la...@garfieldtech.com

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



Re: [PHP] Re: PHP includes

2009-03-09 Thread Ashley Sheridan
On Mon, 2009-03-09 at 15:23 -0500, Larry Garfield wrote:
 On Monday 09 March 2009 3:07:17 pm Nathan Rixham wrote:
  Ashley Sheridan wrote:
   Just thought I'd point out that it's recommended against giving non-php
   extensions to PHP code pages. Basically, making all of your include
   files .inc without the server correctly configured to recognise all .inc
   files as PHP files, you are opening yourself up to possible hacks where
   people put the URL of your include directly in their browser and view
   all your code. Best thing is usually to name files like this:
   filename.inc.php or some-such, and not filename.inc.
 
  v well said - one thing you never want is your source showing!
 
 Unless you're working in open source and then the source is showing anyway 
 from the original download site.  And if simply knowing your source code is a 
 security hole, then you have bad software.
 
 Your config file with passwords and such, sure, keep that locked down tight.  
 But don't rely on security through obscurity.
 
 -- 
 Larry Garfield
 la...@garfieldtech.com
 
I was talking about includes that have things such as database
connection information and other sensitive things. By making it a PHP
file, you prevent the code from being seen, ergo you hide your password,
etc. phpMyAdmin does it this way, using a config.inc.php file for
holding the connection information to each database.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 2:50 PM, Nathan Rixham nrix...@gmail.com wrote:
 haliphax wrote:

 Framework = Overhead (when compared to vanilla PHP). Period. I'm not

 by vanilla do you mean vanilla from lussimo? [http://getvanilla.com/] ?

You know damn well I didn't. :)


-- 
// Todd

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



[PHP] Script execution

2009-03-09 Thread George Larson
Hi everybody.

The problem that I'm having is probably because I've got more of a Windows
background -- and it isn't so much a problem as a point of curiosity.

I've recently noticed that when I write a script that they seem to have
different permissions when executed at the command line.  Two that I have
written recently run just fine when you execute 'php scriptname.php' but
they are unable, at least, to write the data if I browse to them on
localhost.

Am I imagining things?  If not, how would I properly make them able to run
through a browser?

Thanks!
G


Re: [PHP] Script execution

2009-03-09 Thread Ashley Sheridan
On Mon, 2009-03-09 at 16:59 -0400, George Larson wrote:
 Hi everybody.
 
 The problem that I'm having is probably because I've got more of a Windows
 background -- and it isn't so much a problem as a point of curiosity.
 
 I've recently noticed that when I write a script that they seem to have
 different permissions when executed at the command line.  Two that I have
 written recently run just fine when you execute 'php scriptname.php' but
 they are unable, at least, to write the data if I browse to them on
 localhost.
 
 Am I imagining things?  If not, how would I properly make them able to run
 through a browser?
 
 Thanks!
 G
This is to do with the fact that the web browser runs as a different
user from you (usually apache, apache2 or wwwrun) What you could do is
make the directory where you want to write files with the script part of
a new group. Add the apache user to this group and you should then be
able to get it to run.


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Script execution

2009-03-09 Thread Daniel Brown
On Mon, Mar 9, 2009 at 16:59, George Larson george.g.lar...@gmail.com wrote:

 Am I imagining things?  If not, how would I properly make them able to run
 through a browser?

You're not imagining things.  In general, unless set up with
SuExec privileges, Apache (which is probably the HTTP server you're
using) will run as 'nobody,' 'apache,' 'www,' or 'daemon.'  If you
can't configure it to SuExec (check Google for some ideas on this
you'll need root access), you could use the less-secure (this, not
recommended) options of changing the file mode permissions to 0777 or
change the file ownership (if you have the right permissions yourself)
to be owned by the same user and/or group as which Apache runs.

It may sound a little confusing at first glance, but it's really
not.  Just keep in mind that UNIX and Linux (Mac and similar OS'es
fall in here, too) are simultaneous multi-user systems, meaning that
many users (including virtual users that the system uses as aliases
for individualized permissions) can be logged in and run processes
concurrently.


-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Re: PHP Frameworks

2009-03-09 Thread Nathan Rixham

haliphax wrote:

On Mon, Mar 9, 2009 at 2:50 PM, Nathan Rixham nrix...@gmail.com wrote:

haliphax wrote:

Framework = Overhead (when compared to vanilla PHP). Period. I'm not

by vanilla do you mean vanilla from lussimo? [http://getvanilla.com/] ?


You know damn well I didn't. :)



I'd love to lol - but really no I dunno what you mean but glad you said 
no to that one lolol


vanilla-mv.googlecode.com ? or?


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



[PHP] Re: Script execution

2009-03-09 Thread Shawn McKenzie
George Larson wrote:
 Hi everybody.
 
 The problem that I'm having is probably because I've got more of a Windows
 background -- and it isn't so much a problem as a point of curiosity.
 
 I've recently noticed that when I write a script that they seem to have
 different permissions when executed at the command line.  Two that I have
 written recently run just fine when you execute 'php scriptname.php' but
 they are unable, at least, to write the data if I browse to them on
 localhost.
 
 Am I imagining things?  If not, how would I properly make them able to run
 through a browser?
 
 Thanks!
 G
 

Are you just opening the file in a browser, or do you have a webserver
running that is configured with PHP?

If you have a webserver, do other php scripts work?

-- 
Thanks!
-Shawn
http://www.spidean.com

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



[PHP] Re: Script execution

2009-03-09 Thread Shawn McKenzie
George Larson wrote:
 Hi everybody.
 
 The problem that I'm having is probably because I've got more of a Windows
 background -- and it isn't so much a problem as a point of curiosity.
 
 I've recently noticed that when I write a script that they seem to have
 different permissions when executed at the command line.  Two that I have
 written recently run just fine when you execute 'php scriptname.php' but
 they are unable, at least, to write the data if I browse to them on
 localhost.

Is the script writing data to a file or do you mean write to the browser
(as output)?

 
 Am I imagining things?  If not, how would I properly make them able to run
 through a browser?
 
 Thanks!
 G
 


-- 
Thanks!
-Shawn
http://www.spidean.com

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



Re: [PHP] Script execution

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 4:04 PM, Daniel Brown danbr...@php.net wrote:
 On Mon, Mar 9, 2009 at 16:59, George Larson george.g.lar...@gmail.com wrote:

 Am I imagining things?  If not, how would I properly make them able to run
 through a browser?

    You're not imagining things.  In general, unless set up with
 SuExec privileges, Apache (which is probably the HTTP server you're
 using) will run as 'nobody,' 'apache,' 'www,' or 'daemon.'  If you
 can't configure it to SuExec (check Google for some ideas on this
 you'll need root access), you could use the less-secure (this, not
 recommended) options of changing the file mode permissions to 0777 or
 change the file ownership (if you have the right permissions yourself)
 to be owned by the same user and/or group as which Apache runs.

    It may sound a little confusing at first glance, but it's really
 not.  Just keep in mind that UNIX and Linux (Mac and similar OS'es
 fall in here, too) are simultaneous multi-user systems, meaning that
 many users (including virtual users that the system uses as aliases
 for individualized permissions) can be logged in and run processes
 concurrently.

OP is a Windows user. I am assuming that they are using Windows.

George, if you are using IIS as your web server, PHP will be executed
(by default, anyway) under the IUSR_your computer name user account
(pre-Vista). The directories and files your PHP script will need to
mess with should be given the appropriate permissions as related to
that user.

HTH,


-- 
// Todd

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



Re: [PHP] Script execution

2009-03-09 Thread Daniel Brown
On Mon, Mar 9, 2009 at 17:17, haliphax halip...@gmail.com wrote:

 OP is a Windows user. I am assuming that they are using Windows.

Re-read the context of that first paragraph from the OP and you'll
see why I presume (as opposed to *ass*ume) that, despite his
experience with Windows, this is a *NIX-like setup.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Script execution

2009-03-09 Thread George Larson
Thanks everybody!

I guess I was a little vague.  I'm working on an OpenSUSE setup with Apache,
MySQL and PHP.  I just knew that my confusion was because of my Windows
up-bringing.

The writing I referred to was to a file.  One example is I had a script that
was pulling data from a database and using it to generate PDF files.  This
would work fine from the command line but _not_ if I pointed a browser at
it.  It wasn't an important difference because that script is a cronjob
anyway.  I just wanted to understand what was going on and how I could
change it -- if I find later that I need to.

Again, that's for the rapid and thorough help!
G

On Mon, Mar 9, 2009 at 5:17 PM, haliphax halip...@gmail.com wrote:

 On Mon, Mar 9, 2009 at 4:04 PM, Daniel Brown danbr...@php.net wrote:
  On Mon, Mar 9, 2009 at 16:59, George Larson george.g.lar...@gmail.com
 wrote:
 
  Am I imagining things?  If not, how would I properly make them able to
 run
  through a browser?
 
 You're not imagining things.  In general, unless set up with
  SuExec privileges, Apache (which is probably the HTTP server you're
  using) will run as 'nobody,' 'apache,' 'www,' or 'daemon.'  If you
  can't configure it to SuExec (check Google for some ideas on this
  you'll need root access), you could use the less-secure (this, not
  recommended) options of changing the file mode permissions to 0777 or
  change the file ownership (if you have the right permissions yourself)
  to be owned by the same user and/or group as which Apache runs.
 
 It may sound a little confusing at first glance, but it's really
  not.  Just keep in mind that UNIX and Linux (Mac and similar OS'es
  fall in here, too) are simultaneous multi-user systems, meaning that
  many users (including virtual users that the system uses as aliases
  for individualized permissions) can be logged in and run processes
  concurrently.

 OP is a Windows user. I am assuming that they are using Windows.

 George, if you are using IIS as your web server, PHP will be executed
 (by default, anyway) under the IUSR_your computer name user account
 (pre-Vista). The directories and files your PHP script will need to
 mess with should be given the appropriate permissions as related to
 that user.

 HTH,


 --
 // Todd



Re: [PHP] Script execution

2009-03-09 Thread Daniel Brown
On Mon, Mar 9, 2009 at 17:21, Daniel Brown paras...@gmail.com wrote:

    Re-read the context of that first paragraph from the OP and you'll
 see why I presume (as opposed to *ass*ume) that, despite his
 experience with Windows, this is a *NIX-like setup.

DISCLAIMER: This was supposed to be added to my seemingly-gruff
response: ;-P  Todd's alright by me.

George, a cron - if run as the same user that owns the files -
should work with no problem.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Script execution

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 4:28 PM, Daniel Brown paras...@gmail.com wrote:
 On Mon, Mar 9, 2009 at 17:21, Daniel Brown paras...@gmail.com wrote:

    Re-read the context of that first paragraph from the OP and you'll
 see why I presume (as opposed to *ass*ume) that, despite his
 experience with Windows, this is a *NIX-like setup.

    DISCLAIMER: This was supposed to be added to my seemingly-gruff
 response: ;-P  Todd's alright by me.

    George, a cron - if run as the same user that owns the files -
 should work with no problem.

No worries, Daniel... though I appreciate the gesture. :) What I meant
in my message was that I couldn't tell if he was talking POSIX or Win,
but I would offer my Windows information on the off-chance that he was
referring to Windows... so I suppose I'm guilty of being obscure.

Too many meetings today. Brain is turning to pudding.


-- 
// Todd

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



Re: [PHP] Script execution

2009-03-09 Thread George Larson
That's funny!

I've been watching this and a few other lists (MySQL, local Linux Users'
Group) for a few days - weeks and I had wondered why the PHP list seemed
more hostile.  :)

On Mon, Mar 9, 2009 at 5:28 PM, Daniel Brown paras...@gmail.com wrote:

 On Mon, Mar 9, 2009 at 17:21, Daniel Brown paras...@gmail.com wrote:
 
 Re-read the context of that first paragraph from the OP and you'll
  see why I presume (as opposed to *ass*ume) that, despite his
  experience with Windows, this is a *NIX-like setup.

 DISCLAIMER: This was supposed to be added to my seemingly-gruff
 response: ;-P  Todd's alright by me.

George, a cron - if run as the same user that owns the files -
 should work with no problem.

 --
 /Daniel P. Brown
 daniel.br...@parasane.net || danbr...@php.net
 http://www.parasane.net/ || http://www.pilotpig.net/
 50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1



Re: [PHP] Script execution

2009-03-09 Thread Michael A. Peters

George Larson wrote:

Thanks everybody!

I guess I was a little vague.  I'm working on an OpenSUSE setup with Apache,
MySQL and PHP.  I just knew that my confusion was because of my Windows
up-bringing.

The writing I referred to was to a file.  One example is I had a script that
was pulling data from a database and using it to generate PDF files.  This
would work fine from the command line but _not_ if I pointed a browser at
it.  It wasn't an important difference because that script is a cronjob
anyway.  I just wanted to understand what was going on and how I could
change it -- if I find later that I need to.


Give the user apache runs as permission to write to the directory where 
the PDF files are generated.


I don't know what use apache run as on SuSE but if it was, say, www - as 
root:


chown www /path/to/directory/where/you/want/the/output

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



Re: [PHP] Script execution

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 4:36 PM, George Larson george.g.lar...@gmail.com wrote:
 That's funny!

 I've been watching this and a few other lists (MySQL, local Linux Users'
 Group) for a few days - weeks and I had wondered why the PHP list seemed
 more hostile.  :)

In a word, I think familiarity sums it up.

That, or ***holes.

:-D


-- 
// Todd

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



Re: [PHP] Script execution

2009-03-09 Thread Daniel Brown
On Mon, Mar 9, 2009 at 17:39, haliphax halip...@gmail.com wrote:

 That, or ***holes.

That's what my name tag says.

-- 
/Daniel P. Brown
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
50% Off All Shared Hosting Plans at PilotPig: Use Coupon DOW1

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



Re: [PHP] Script execution

2009-03-09 Thread Nathan Rixham

Daniel Brown wrote:

On Mon, Mar 9, 2009 at 17:39, haliphax halip...@gmail.com wrote:

That, or ***holes.


That's what my name tag says.



you got shot in the nametag 3 times? i dunno if that's good or bad luck!

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



Re: [PHP] Script execution

2009-03-09 Thread haliphax
On Mon, Mar 9, 2009 at 4:55 PM, Nathan Rixham nrix...@gmail.com wrote:
 Daniel Brown wrote:

 On Mon, Mar 9, 2009 at 17:39, haliphax halip...@gmail.com wrote:

 That, or ***holes.

    That's what my name tag says.

 you got shot in the nametag 3 times? i dunno if that's good or bad luck!

Yep. Now nobody can tell it used to say ear holes anymore! :(


-- 
// Todd

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



Re: [PHP] Script execution

2009-03-09 Thread Nathan Rixham

George Larson wrote:

That's funny!

I've been watching this and a few other lists (MySQL, local Linux Users'
Group) for a few days - weeks and I had wondered why the PHP list seemed
more hostile.  :)


may be something to do with the fact 95% of posts here could be covered by:
 - a 5 question faq
 - rtfm

the only way to stay sane round here would be to develop alzheimer's

[zero offence intended in any way]

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



Re: [PHP] Script execution

2009-03-09 Thread Nathan Rixham

haliphax wrote:

On Mon, Mar 9, 2009 at 4:55 PM, Nathan Rixham nrix...@gmail.com wrote:

Daniel Brown wrote:

On Mon, Mar 9, 2009 at 17:39, haliphax halip...@gmail.com wrote:

That, or ***holes.

   That's what my name tag says.

you got shot in the nametag 3 times? i dunno if that's good or bad luck!


Yep. Now nobody can tell it used to say ear holes anymore! :(




warhole ^o)

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



[PHP] DOMDocument getElementsByAttribute ??

2009-03-09 Thread Michael A. Peters

Seems like such a function does not exist in php.
I can write my own function that does it using 
DOMElement-hasAttribute() - but I'm not sure how to get an array of 
every element in the DOM to test them for the attribute.


Any hints?

I'm sure it's simple, I'm just not seeing the function that does it.

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



Re: [PHP] Script execution

2009-03-09 Thread Ray
On Monday 09 March 2009 15:38:37 Michael A. Peters wrote:
 George Larson wrote:
  Thanks everybody!
 
  I guess I was a little vague.  I'm working on an OpenSUSE setup with
  Apache, MySQL and PHP.  I just knew that my confusion was because of my
  Windows up-bringing.
 
  The writing I referred to was to a file.  One example is I had a script
  that was pulling data from a database and using it to generate PDF files.
   This would work fine from the command line but not if I pointed a
  browser at it.  It wasn't an important difference because that script is
  a cronjob anyway.  I just wanted to understand what was going on and how
  I could change it -- if I find later that I need to.

 Give the user apache runs as permission to write to the directory where
 the PDF files are generated.

 I don't know what use apache run as on SuSE but if it was, say, www - as
 root:

 chown www /path/to/directory/where/you/want/the/output


I only scanned the thread, So apologies if someone else already said this.
Another problem I've come across is that the path variable is not the same 
when run under the browser as on the command line, so instead of issuing  
command   
you need
/path/to/command
Ray

 --
 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: DOMDocument getElementsByAttribute ??

2009-03-09 Thread Nathan Rixham

Michael A. Peters wrote:

Seems like such a function does not exist in php.
I can write my own function that does it using 
DOMElement-hasAttribute() - but I'm not sure how to get an array of 
every element in the DOM to test them for the attribute.


Any hints?

I'm sure it's simple, I'm just not seeing the function that does it.


DOMXPath :)

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



Re: [PHP] Opendir on site root directory?

2009-03-09 Thread Clancy
On Mon, 9 Mar 2009 10:07:33 +, stut...@gmail.com (Stuart) wrote:

...
As in the example script I've posted above you can refer to the current
working directory with a single period (.), but this is still relying on the
current working directory being what you expect it to be.

Thank you! This is what I had been looking for all along. I dimly remembered 
some such
trick, but it had become lost in the detritus at the back of my mind.

But why the obsession with avoiding getcwd()? When my site is loaded the 
current directory
is always the root directory of the page, and as I never change directory I can 
rely on it
staying there. (And, incidentally, since getcwd(), dirname(__FILE__), etc, all 
return the
complete path including system dependent information, if I really didn't know 
the current
directory it would not be a trivial task to determine what was the local root.)

For a couple of years I have been using getcwd() to determine whether or not I 
am running
on my local PC (if I am the path will start with 'D:'). If I am running on the 
local PC I
load various editing and other private facilities, otherwise I omit them. This 
is done in
such a way that there is nothing to indicate that anything is either missing or 
has been
omitted.

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



Re: [PHP] DOM recursion

2009-03-09 Thread Jochem Maas
Nathan Rixham schreef:
 Jochem Maas wrote:
 Jochem Maas schreef:
 Joanne Lane schreef:
 I am trying to create a class that recursively iterates over an
 array an
 creates XML tree to reflect a multidimensional array.
 I am not really a PHP coder, but am trying my hand.
 I've seen 'real coders' write stuff thats leagues worse.

 This is what I have so far.
 http://pastie.org/private/w75vyq9ub09p0uawteyieq

 I have tried a few methods, but I keep failing.
 Currently, all elements are appended to the root node.

 .. yes my pleasure, glad I could help, not a problem. phffft.
 
 all too often the case man, I'm sure free-w...@lists.php.net points here

yeah but those from php-women should know better :-)
my eye keeps picking up php-women since I had a very nice chat
with JRF (of phpwomen.org) at phpuk.

oh well it was a nice little exercise in DOM, something I
haven't fully mastered yet.

 


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



  1   2   >