php-general Digest 9 Mar 2002 12:40:13 -0000 Issue 1216

Topics (messages 87835 through 87870):

Re: Graphing Question
        87835 by: Michael Kimsal

Re: Query bug, what is wrong?
        87836 by: hugh danaher

Re: session_id database
        87837 by: Andy

Finding variable names in strings, and replacing with values?
        87838 by: Nick Richardson
        87859 by: Jan Grafström

mysql_connect() help
        87839 by: Ellis M. Mendez-Hidaka
        87840 by: ruler

Re: patch installation
        87841 by: abw
        87850 by: Jason Wong

Checking to see what value error_reporting is set at?
        87842 by: eric.coleman.zaireweb.com

problem with mysql persistent connections; already read the FAQ!
        87843 by: Dustin Puryear
        87848 by: Michael Kimsal

Dynamically creating PHP before it is executed
        87844 by: Jonathan Duncan
        87846 by: Bogdan Stancescu
        87849 by: Jonathan Duncan
        87852 by: Jonathan Duncan

Can someone tell me about database....
        87845 by: GENESiS DESiGNS
        87853 by: Tyler Longren
        87854 by: hugh danaher

two different MySQL connections without always select_db?
        87847 by: PHP freak
        87856 by: Nick Richardson

Re: cal_days_in_month()
        87851 by: Jason Wong
        87855 by: David Robley

CSS
        87857 by: jtjohnston
        87858 by: Ashley M. Kirchner

Execute bash shell script in php
        87860 by: Your  Amit

Re: just a link in php email
        87861 by: Jan Grafström

error not understood
        87862 by: Kancha .
        87866 by: Jason Wong

need help converting code to more efficient loop
        87863 by: Timothy J. Luoma

Re: Database abstraction layer oci
        87864 by: Thies C. Arntzen

Re: uploading images
        87865 by: Filippo Veneri

HTML Writer library functions
        87867 by: S.Murali Krishna

gd-library ...
        87868 by: Marcel Besancon

Re: HTML Buffer
        87869 by: Nick Wilson

check for bigger link
        87870 by: Martin Kampherbeek

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Chris Seymour wrote:
> Hi All,
> Does anyone know of a graphing package that will allow a line graph with 
> labels on the data points?
> 
> Thanks in advance.
> 
> Chris
> 

Try JPGRAPH at:

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




Michael Kimsal
http://www.phphelpdesk.com
Taking the ? out of <?php
734-480-9961

--- End Message ---
--- Begin Message ---
I think it should be single quote marks around the variables like you've
used around the ok:

$query = "INSERT INTO projeto (nome,setor,arquivo,status) VALUES
>  ('$qname','$qdes','$qFILE','ok')";

Hope this helps,
Hugh

----- Original Message -----
From: "Robert V. Zwink" <[EMAIL PROTECTED]>
To: "Daniel F. Castro" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, March 08, 2002 6:22 AM
Subject: RE: [PHP] Query bug, what is wrong?


> You probably need to wrap the strings you are trying to input with
quotation
> marks.
>
> Try modifying this line  (add \") :
>    $query = "INSERT INTO projeto (nome,setor,arquivo,status) VALUES
>  (\"$qname\",\"$qdes\",\"$qFILE\",'ok')";
>
> Robert Zwink
> http://www.zwink.net/daid.php
>
>
> -----Original Message-----
> From: Daniel F. Castro [mailto:[EMAIL PROTECTED]]
> Sent: Friday, March 08, 2002 8:29 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Query bug, what is wrong?
>
>
> <?php
>    $qname      = $HTTP_POST_VARS['ct_nome'];
>    $qkey       = $HTTP_POST_VARS['ct_kw'];
>    $qdia               = $HTTP_POST_VARS['ct_dia'];
>    $qmes       = $HTTP_POST_VARS['ct_mes'];
>    $qano       = $HTTP_POST_VARS['ct_ano'];
>    $qautor     = $HTTP_POST_VARS['ct_autor'];
>    $qeng       = $HTTP_POST_VARS['cS_eng'];
>    $qdes       = $HTTP_POST_VARS['cS_des'];
>    $qFILE      = "FILES";
>    $host       = localhost;
>    //Database Conection
>    $link = mysql_connect($host,"root","root")
>      or die("Not possible to connect");
>    print("Connection OK");
>    //Database Selection
>    mysql_select_db("test")
>      or die(mysql_error());
>    print("Selection OK");
>    $query = "INSERT INTO projeto (nome,setor,arquivo,status) VALUES
>  ($qname,$qdes,$qFILE,'ok')";
>    print "$qname";
>    print "$qkey";
>    print "$qautor";
>    print "$qdia/$qmes/$qano";
>    //My Query
>    mysql_query ($query)
>      or Die (mysql_error());
>    echo "Projecto registered";
>
>    // Closing connection
>    mysql_close($link);
>  ?>
>
>  Thanks you
>
>  Daniel Castro
>
>
>
>
> --
> 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
>

--- End Message ---
--- Begin Message ---
Hi Adrian,

there is an excellent article on that by:

 * ------------------------------------------------------------------------
 * PHP4 DBM Session Handler
 * Version 1.00
 * by Ying Zhang ([EMAIL PROTECTED])

Describing all you need. Check out www.phpbuilder.com or weberdev.com and
search for the name above.You could also check his website.

Good luck

Andy


"Mailing List" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I am new to PHP so please excuse my ignorance.  I want to manage and
> create session id's for my shopping cart with a MySQL database.  I have a
> database with a session_id column that is auto-increminting.  Is there any
> example of anyone using a mysql database to manage session_id's?
>
> Regards,
>
> Adrian Mcmanus
> IT Director
> The B&F System, Inc.
>


--- End Message ---
--- Begin Message ---
Been working on this one for quite awhile, and it's probably a fairly easy
solution, but i can't find it... so thought i would ask.

I'm opening a file, and going through it line by line.  I need for find
places where the line contains %value% and replace it with $value.

So if the line says <body bgcolor=%bgcolor% text=%textcolor%
link=%linkcolor%>, i need to replace the text where the %% stuff is and set
it to $bgcolor,$textcolor,or $linkcolor respectively. -

I'm sure this can be done, but i'm just no good w/ the pattern matching
stuff... so if anyone has any ideas on this, please let me know!!!

Thanks

//Nick Richardson
[EMAIL PROTECTED]
[EMAIL PROTECTED]
--------------------------------------------------------------
--   We must come to see that the end we seek, is a society --
-- at peace with itself.  A society that can live with its  --
-- concience.  That will be a day not of the white man, not --
-- of the black man... That will be the day of man, as man! --
--                          -Dr. Martin Luther King Jr.     --
--                                 -March 25th, 1965        --
--------------------------------------------------------------

--- End Message ---
--- Begin Message ---
Hi Nick!

http://www.php.net/manual/en/function.str-replace.php

Regards,
Jan
"Nick Richardson" <[EMAIL PROTECTED]> skrev i meddelandet
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Been working on this one for quite awhile, and it's probably a fairly easy
> solution, but i can't find it... so thought i would ask.
>
> I'm opening a file, and going through it line by line.  I need for find
> places where the line contains %value% and replace it with $value.
>
> So if the line says <body bgcolor=%bgcolor% text=%textcolor%
> link=%linkcolor%>, i need to replace the text where the %% stuff is and
set
> it to $bgcolor,$textcolor,or $linkcolor respectively. -
>
> I'm sure this can be done, but i'm just no good w/ the pattern matching
> stuff... so if anyone has any ideas on this, please let me know!!!
>
> Thanks
>
> //Nick Richardson
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> --------------------------------------------------------------
> --   We must come to see that the end we seek, is a society --
> -- at peace with itself.  A society that can live with its  --
> -- concience.  That will be a day not of the white man, not --
> -- of the black man... That will be the day of man, as man! --
> --                          -Dr. Martin Luther King Jr.     --
> --                                 -March 25th, 1965        --
> --------------------------------------------------------------
>

--- End Message ---
--- Begin Message ---
Greetings,
I'm a newbie with apache and PHP.
I was able to setup apache, php and mysql in RH Linux and have my
website running.
I was trying to test the BD connectivity capabilities of PHP but I keep
receiving this error message:
{
Warning: Can't connect to local MySQL server through socket
'/tmp/mysql.sock' (2) in /var/www/html/testdb.php on line 20

Warning: MySQL Connection Failed: Can't connect to local MySQL server
through socket '/tmp/mysql.sock' (2) in /var/www/html/testdb.php on line
20
Could not connect to DB
}

I tried looking at the documentation in php.net, but I don't see what
could be the problem.
Here is the code (line 20 is the mysql_connect() command):

<?php



 //build SELECT query
 $query = "SELECT * FROM divers";

 //Connect to MySQL
 // *************This line is the problem! :^(   ******************
 if( !($database1 = mysql_connect( "localhost","test1","psswd" ) ) )
  die( "Could not connect to DB" );

 //Open database
 if( !mysql_select_db( "divers", $database1 ) )
  die( "Could not open divers DB" );

 //Query DB
 if( !($result = mysql_query( $query, $databse1 ) ) )
 {
  print("Could not execute query! <br />" );
  die( mysql_error() );
 }

?>

My DB is running fine, and I even tested it with that ID and it shows
fine as well.....

I'm using PHP 4.0.6 and mysql is enabled.
Am I missing any settings I might not know?
Any help will be really appreciated.
Thank you

Ellis

--- End Message ---
--- Begin Message ---
What I did is made a symlink from /var/run/mysql.sock to /tmp/mysql.sock
example: ln -s /var/run/mysql.sock /tmp/mysql.sock

Or if /var/run/mysql.sock doesn't exist, find / -name "mysql.sock"
Then symlink that to /tmp

Hope that helps.
----- Original Message ----- 
From: "Ellis M. Mendez-Hidaka" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 08, 2002 8:43 PM
Subject: [PHP] mysql_connect() help


> Greetings,
> I'm a newbie with apache and PHP.
> I was able to setup apache, php and mysql in RH Linux and have my
> website running.
> I was trying to test the BD connectivity capabilities of PHP but I keep
> receiving this error message:
> {
> Warning: Can't connect to local MySQL server through socket
> '/tmp/mysql.sock' (2) in /var/www/html/testdb.php on line 20
> 
> Warning: MySQL Connection Failed: Can't connect to local MySQL server
> through socket '/tmp/mysql.sock' (2) in /var/www/html/testdb.php on line
> 20
> Could not connect to DB
> }
> 
> I tried looking at the documentation in php.net, but I don't see what
> could be the problem.
> Here is the code (line 20 is the mysql_connect() command):
> 
> <?php
> 
> 
> 
>  //build SELECT query
>  $query = "SELECT * FROM divers";
> 
>  //Connect to MySQL
>  // *************This line is the problem! :^(   ******************
>  if( !($database1 = mysql_connect( "localhost","test1","psswd" ) ) )
>   die( "Could not connect to DB" );
> 
>  //Open database
>  if( !mysql_select_db( "divers", $database1 ) )
>   die( "Could not open divers DB" );
> 
>  //Query DB
>  if( !($result = mysql_query( $query, $databse1 ) ) )
>  {
>   print("Could not execute query! <br />" );
>   die( mysql_error() );
>  }
> 
> ?>
> 
> My DB is running fine, and I even tested it with that ID and it shows
> fine as well.....
> 
> I'm using PHP 4.0.6 and mysql is enabled.
> Am I missing any settings I might not know?
> Any help will be really appreciated.
> Thank you
> 
> Ellis
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

--- End Message ---
--- Begin Message ---
I guess that would have been nice! Solaris 8 x86 with Apache 1.3.22.

Both servers use the same operating system and web server.

>what type of system are you running.  A little bit more information would be
>helpfull.
>
>Jim Lucas
>www.bend.com
>
>----- Original Message -----
>From: "abw" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Friday, March 08, 2002 1:21 PM
>Subject: [PHP] patch installation
>
>
> > I have downloaded the patch for the security bug found with the file
> > uploading. One server has php 4.0.6 and the other has 4.1.1, but my
>problem
> > is that the patch does not have any instructions.
> >
> > I was going to use the patch command, but I don't know what parameters to
>use.
> >
> > This question was asked on the mailing list a few days ago, but there were
> > no replies.
> >
> > Can anybody tell me how I might install the patch on the servers? Do I
>have
> > to install it over the source and recompile? What command line might I
>use?
> > It is a hot fix?
> >
> > Thank you in advance.
> > Aaron
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >

--- End Message ---
--- Begin Message ---
On Saturday 09 March 2002 05:21, abw wrote:
> I have downloaded the patch for the security bug found with the file
> uploading. One server has php 4.0.6 and the other has 4.1.1, but my problem
> is that the patch does not have any instructions.
>
> I was going to use the patch command, but I don't know what parameters to
> use.
>
> This question was asked on the mailing list a few days ago, but there were
> no replies.

There was, search the archives.

> Can anybody tell me how I might install the patch on the servers? Do I have
> to install it over the source and recompile? What command line might I use?
> It is a hot fix?

untar/unzip the file ---> rfc1867.c.diff-4.0.6

cd /path/to/source/php-4.0.06/main

You should have a file called rfc1867.c

then:

  patch rfc1867.c /path/to/where/you/extracted/rfc1867.c.diff-4.0.6

Then do the usual ./configure, make, etc.


-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
Don't feed the bats tonight.
*/
--- End Message ---
--- Begin Message ---
Is it possible to return what error_reporting is set at currently?  If not, think they 
would be able to throw it into the newest build of php?

Thanks,
Eric
--- End Message ---
--- Begin Message ---
We are running Apache 1.3.20 with PHP 4.0.6/rfc1876-patch built as a
module. We are using PHP on a load-sharing cluster with n web servers.
Our cluster supports an application that makes extensive use of mysql
connections via the PHP mysql_* functions.

The application was tested on a single web server, and the programmers
are trying to use persistent connections to increase efficiency.
First, I want to confirm in my own mind whether this will have any
real benefit in our situation because we are using a cluster
environment, correct?

Second, the programmers are using mysql_connect() and not
mysql_pconnect(). Does that mean they are in fact not using persistent
connections? (BTW, we do have persistent connections turned on in
php.ini.)

Finally, the programmers showed me how they see that persistent
connections are in fact working. On the development server they are
doing the following:

mysql_open()
mysql_query() 
...
mysql_close()
mysql_query()

On their server the second mysql_query() works! (They are using Apache
1.3.20 as well, but I was told they may have compiled PHP into Apache
rather than as a module, and I'm not exactly sure of the version, but
I'm pretty sure it is 4.0.6.) But on the cluster the second
mysql_query() returns:

Warning: 1 is not a valid MySQL-Link resource in /some/path/pers.php
on line 11 could not execute 'select zipcod from zip'

Should this be working on our cluster? If not, what do we need to do.
Can this work? Will persistent connections even be effective in a
cluster environment?

I did read the alt.comp.lang.php FAQ, but it didn't actually address
this issue.

Any help or information is appreciated!

Regards, Dustin

---
Dustin Puryear <[EMAIL PROTECTED]> 
Information Systems Contractor
http://members.telocity.com/~dpuryear
PGP Key available at http://www.us.pgp.net
In the beginning the Universe was created. 
This has been widely regarded as a bad move. - Douglas Adams
--- End Message ---
--- Begin Message ---
Dustin Puryear wrote:
> We are running Apache 1.3.20 with PHP 4.0.6/rfc1876-patch built as a
> module. We are using PHP on a load-sharing cluster with n web servers.
> Our cluster supports an application that makes extensive use of mysql
> connections via the PHP mysql_* functions.
> 
> The application was tested on a single web server, and the programmers
> are trying to use persistent connections to increase efficiency.
> First, I want to confirm in my own mind whether this will have any
> real benefit in our situation because we are using a cluster
> environment, correct?
> 
> Second, the programmers are using mysql_connect() and not
> mysql_pconnect(). Does that mean they are in fact not using persistent
> connections? (BTW, we do have persistent connections turned on in
> php.ini.)

If they are not using the mysql_pconnect functions, then you are not 
using persistent connections.  The .ini file setting simply allows them 
to be used or not - no version I've seen has an option to override to
always use them.



> 
> Finally, the programmers showed me how they see that persistent
> connections are in fact working. On the development server they are
> doing the following:
> 
> mysql_open()
> mysql_query() 
> ...
> mysql_close()
> mysql_query()
> 
> On their server the second mysql_query() works! 

What is the specific syntax they are using?  Is there any chance that 
they have opened more than one handle to mysql?  The mysql_close() would
only close one, and if there are more than one handles open, only one 
will close and others will be free to handle _query() functions.

I'm going to assume they are using mysql_connect() as I can't find 
refernce to a mysql_open() function.

The mysql_query function *may* be simply reopening another connection 
with the previous information.

 From the manual:
mysql_query() sends a query to the currently active database on the 
server that's associated with the specified link identifier. If 
link_identifier isn't specified, the last opened link is assumed. If no 
link is open, the function tries to establish a link as if 
mysql_connect() was called with no arguments, and use it.






(They are using Apache
> 1.3.20 as well, but I was told they may have compiled PHP into Apache
> rather than as a module, and I'm not exactly sure of the version, but
> I'm pretty sure it is 4.0.6.) But on the cluster the second
> mysql_query() returns:
> 
> Warning: 1 is not a valid MySQL-Link resource in /some/path/pers.php
> on line 11 could not execute 'select zipcod from zip'

Does that second machine have access to the database?  The database may 
be only allowing 'localhost' connections or connections from a specific IP.

> 
> Should this be working on our cluster? If not, what do we need to do.

Yes

> Can this work? 

Yes
 > Will persistent connections even be effective in a
> cluster environment?

It depends.  In the Apache situation, using persistent connections will 
cause *each* Apache child to hold a connection open to MySQL.  So if you 
have 150 apache processes on 3 servers, that's 450 connections the 
database server needs to have open for MySQL.  ~50k per connection, 
that's about 23 meg - should be doable on most machines to start.  If 
you're running lots of big queries, get loads of RAM.  You'll need to 
tune mysql to handle more than the default 100 concurrent connections, 
and make sure your OS can handle the maximum resources it may require as 
well.

Yes, they can be effective.  On a fast network with a light loaded 
machine using mysql, you often can't tell much of a difference between 
pconnect and connect.  As the load grows heavier, the pconnects come in 
more handy, but at a price of consuming resources you may otherwise need.

If 150 apache processes are serving up HTML and PHP and graphics, one 
server may end up holding 150 persistant connections open for a long 
time, even though you may only be serving 10-20-30 PHP pages at any one 
time.  Although the other Apache children are serving graphics/HTML, 
they may earlier have run a PHP script with pconnect and will now hold 
it open until they die.  We tell Apache children to only handle 
5000-10000 requests and then specifically die, which should kill the 
connection to mysql (some drivers seem to not handle this - freetds had 
a problem letting go of handles on the apache exit cycle).

In short, if you're looking to load balance a high load, pconnects can 
help, but smart web serving architecture can help too (possibly moreso 
all around).

> 
> I did read the alt.comp.lang.php FAQ, but it didn't actually address
> this issue.
> 
> Any help or information is appreciated!


Hope that helps some.

--------------------------
Michael Kimsal
http://www.phphelpdesk.com
Taking the ? out of <?php
734-480-9961

--- End Message ---
--- Begin Message ---
I am trying to figure out a way to dynamically create some lines of PHP code
and then have it executed.  This is because I want a page to display
different columns in a table depending on whatever link is clicked.  There
are hundreds of different combinations of column headings so I don't want to
make a different PHP page that is formated for each different combination.
The column headings are stored in a database.

So far what I have come up with is to have a starting page, that takes the
value of the link that is clicked, it queries the database for that value
and then does a while statement to make all the <TD>'s for the different
columns.  Each <TD> is populated with a different variable, one for each
column header.  Each iteration I append to a variable to hold all of these
<TD>'s.  Then I write the contents of that variable to a temporary include
file and call the page that will display the table.  That table then
includes those <TD>'s from the include file I wrote them to and executes the
PHP that runs another query on the database and fills in the variables in
those <TD>'s.

This seems like a lot of work.  Does what I am trying to do make sense to
anyone?  Does anyone have any idea how to do this an easier way?

Thanks
Jonathan Duncan


--- End Message ---
--- Begin Message ---
I don't quite understand why you chose such a complicated solution - I 
may be missing something, in which case sorry for wasting your time. But 
why don't you just dynamically build the select statement and then use 
the <whatever>_fetch_array() -- and walk that array instead?

Just my 2c

Bogdan

Jonathan Duncan wrote:

>I am trying to figure out a way to dynamically create some lines of PHP code
>and then have it executed.  This is because I want a page to display
>different columns in a table depending on whatever link is clicked.  There
>are hundreds of different combinations of column headings so I don't want to
>make a different PHP page that is formated for each different combination.
>The column headings are stored in a database.
>
>So far what I have come up with is to have a starting page, that takes the
>value of the link that is clicked, it queries the database for that value
>and then does a while statement to make all the <TD>'s for the different
>columns.  Each <TD> is populated with a different variable, one for each
>column header.  Each iteration I append to a variable to hold all of these
><TD>'s.  Then I write the contents of that variable to a temporary include
>file and call the page that will display the table.  That table then
>includes those <TD>'s from the include file I wrote them to and executes the
>PHP that runs another query on the database and fills in the variables in
>those <TD>'s.
>
>This seems like a lot of work.  Does what I am trying to do make sense to
>anyone?  Does anyone have any idea how to do this an easier way?
>
>Thanks
>Jonathan Duncan
>
>
>



--- End Message ---
--- Begin Message ---
Bogdan,

Thank you for your comment, it actually made me think of a possible solution
for something else I am working on.  However, it is just as I thought, I am
being too vague.  I am most likely making my whole situation more
complicated than I need.  Another idea is just to do a "select *" and run
the whole shebang through an IF/ELSE series to determine which headers are
being used.  However, to remain on my current train of thought, here is a
snippet of my code:

  include("inc/dbconnect.inc");
  $sql = "select columns from tablename where id=$someid";
  $sqlresult = mysql_query($sql, $connection) or die("Couldn't execute
query. (7)");
  $columns_array = explode(",", $sqlresults['columns']);
  while (list($col) = each($columns_array)) {
 $sql = "select coltitle from FreudColumns where colid='$col'";
    $result = mysql_query($sql, $connection) or die("Couldn't execute query.
(12)");
 $ch = mysql_fetch_array($result);
 // Set the column headers
 $headers .= "<TH CLASS=\"hlink\">$ch['coltitle']</TH>";
    // Set the item variables
 $setitemvar .= "\$$col = \$isr['$col'];";
    // Set the measurement columns
 $setitem .= "<TD CLASS=\"\$itemclass\">\$$col</TD>";
  }
Afterwhich I write $headers to a file, $setitemvar to a file, $setitem to a
file and call the page that is supposed to include these files I have just
writed so that the PHP code that I have just dynamically written will then
execute and the variables will be replaced.

Does this make any more sense?

Thank you,
Jonathan Duncan


"Bogdan Stancescu" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I don't quite understand why you chose such a complicated solution - I
> may be missing something, in which case sorry for wasting your time. But
> why don't you just dynamically build the select statement and then use
> the <whatever>_fetch_array() -- and walk that array instead?
>
> Just my 2c
>
> Bogdan
>
> Jonathan Duncan wrote:
>
> >I am trying to figure out a way to dynamically create some lines of PHP
code
> >and then have it executed.  This is because I want a page to display
> >different columns in a table depending on whatever link is clicked.
There
> >are hundreds of different combinations of column headings so I don't want
to
> >make a different PHP page that is formated for each different
combination.
> >The column headings are stored in a database.
> >
> >So far what I have come up with is to have a starting page, that takes
the
> >value of the link that is clicked, it queries the database for that value
> >and then does a while statement to make all the <TD>'s for the different
> >columns.  Each <TD> is populated with a different variable, one for each
> >column header.  Each iteration I append to a variable to hold all of
these
> ><TD>'s.  Then I write the contents of that variable to a temporary
include
> >file and call the page that will display the table.  That table then
> >includes those <TD>'s from the include file I wrote them to and executes
the
> >PHP that runs another query on the database and fills in the variables in
> >those <TD>'s.
> >
> >This seems like a lot of work.  Does what I am trying to do make sense to
> >anyone?  Does anyone have any idea how to do this an easier way?
> >
> >Thanks
> >Jonathan Duncan
> >
> >
> >
>
>
>


--- End Message ---
--- Begin Message ---
Sam,

The questions you write are good.  I am not sure why they can't.  I just
assumed that if I make lines of code like:

<TD CLASS=\"\$itemclass\">\$$col</TD>

and populate them like:

<TD CLASS="$itemclass">$column1</TD>
<TD CLASS="$itemclass">$column2</TD>
<TD CLASS="$itemclass">$column3</TD>

that I would have to then evaluate them on a different page.  Am I
incorrect?

Thanks,
Jonathan Duncan


----- Original Message -----
From: "Samuel Ottenhoff" <[EMAIL PROTECTED]>
To: "Jonathan Duncan" <[EMAIL PROTECTED]>
Sent: Friday, March 08, 2002 10:23 PM
Subject: Re: [PHP] Dynamically creating PHP before it is executed


> You make sense until the last paragraph.
>
> It sounds like you are making this way more complicated than it need be.
> Why write these out to files and then include them?  Why not just echo
your
> results out to the browser?  Why can't all of this code be contained
within
> one PHP page?
>
> Sam
>
>
>
"Jonathan Duncan" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Bogdan,
>
> Thank you for your comment, it actually made me think of a possible
solution
> for something else I am working on.  However, it is just as I thought, I
am
> being too vague.  I am most likely making my whole situation more
> complicated than I need.  Another idea is just to do a "select *" and run
> the whole shebang through an IF/ELSE series to determine which headers are
> being used.  However, to remain on my current train of thought, here is a
> snippet of my code:
>
>   include("inc/dbconnect.inc");
>   $sql = "select columns from tablename where id=$someid";
>   $sqlresult = mysql_query($sql, $connection) or die("Couldn't execute
> query. (7)");
>   $columns_array = explode(",", $sqlresults['columns']);
>   while (list($col) = each($columns_array)) {
>  $sql = "select coltitle from FreudColumns where colid='$col'";
>     $result = mysql_query($sql, $connection) or die("Couldn't execute
query.
> (12)");
>  $ch = mysql_fetch_array($result);
>  // Set the column headers
>  $headers .= "<TH CLASS=\"hlink\">$ch['coltitle']</TH>";
>     // Set the item variables
>  $setitemvar .= "\$$col = \$isr['$col'];";
>     // Set the measurement columns
>  $setitem .= "<TD CLASS=\"\$itemclass\">\$$col</TD>";
>   }
> Afterwhich I write $headers to a file, $setitemvar to a file, $setitem to
a
> file and call the page that is supposed to include these files I have just
> writed so that the PHP code that I have just dynamically written will then
> execute and the variables will be replaced.
>
> Does this make any more sense?
>
> Thank you,
> Jonathan Duncan
>
>
> "Bogdan Stancescu" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > I don't quite understand why you chose such a complicated solution - I
> > may be missing something, in which case sorry for wasting your time. But
> > why don't you just dynamically build the select statement and then use
> > the <whatever>_fetch_array() -- and walk that array instead?
> >
> > Just my 2c
> >
> > Bogdan
> >
> > Jonathan Duncan wrote:
> >
> > >I am trying to figure out a way to dynamically create some lines of PHP
> code
> > >and then have it executed.  This is because I want a page to display
> > >different columns in a table depending on whatever link is clicked.
> There
> > >are hundreds of different combinations of column headings so I don't
want
> to
> > >make a different PHP page that is formated for each different
> combination.
> > >The column headings are stored in a database.
> > >
> > >So far what I have come up with is to have a starting page, that takes
> the
> > >value of the link that is clicked, it queries the database for that
value
> > >and then does a while statement to make all the <TD>'s for the
different
> > >columns.  Each <TD> is populated with a different variable, one for
each
> > >column header.  Each iteration I append to a variable to hold all of
> these
> > ><TD>'s.  Then I write the contents of that variable to a temporary
> include
> > >file and call the page that will display the table.  That table then
> > >includes those <TD>'s from the include file I wrote them to and
executes
> the
> > >PHP that runs another query on the database and fills in the variables
in
> > >those <TD>'s.
> > >
> > >This seems like a lot of work.  Does what I am trying to do make sense
to
> > >anyone?  Does anyone have any idea how to do this an easier way?
> > >
> > >Thanks
> > >Jonathan Duncan
> > >
> > >
> > >
> >
> >
> >
>
>


--- End Message ---
--- Begin Message ---
Hello,

Can anyone tell me about database driven web sites? I want to learn how to do 
that. Thanks,


-GENESiS DESiGNS
-Sean Kennedy
-http://www.gdesigns.vcn.com

--- End Message ---
--- Begin Message ---
I suggest you buy a book.  There's too much to simply tell you how to do it.
I recommend PHP Essentials by Julie C. Meloni.  That was the first PHP book
I bought, and was really helpful.

tyler

----- Original Message -----
From: "GENESiS DESiGNS" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 08, 2002 2:57 PM
Subject: [PHP] Can someone tell me about database....


> Hello,
>
> Can anyone tell me about database driven web sites? I want to learn how to
do
> that. Thanks,
>
>
> -GENESiS DESiGNS
> -Sean Kennedy
> -http://www.gdesigns.vcn.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
Sean,

hen I first got interested in programming datadriven websites way back in
2001, I read the article at the attached link:
http://www.lycos.com/sitemap.asp.  Learned a lot.

Now that I know a bit more, why the hell would someone using ASP talk about
the virtues of php and mysql?

Hope this helps (or at least doesn't hurt),
Hugh
----- Original Message -----
From: "GENESiS DESiGNS" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 08, 2002 12:57 PM
Subject: [PHP] Can someone tell me about database....


> Hello,
>
> Can anyone tell me about database driven web sites? I want to learn how to
do
> that. Thanks,
>
>
> -GENESiS DESiGNS
> -Sean Kennedy
> -http://www.gdesigns.vcn.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>

--- End Message ---
--- Begin Message ---
How would you keep two different MySQL connections to two different MySQL databases 
(on two different MySQL servers) up and available with two different pointers (id), 
and not need to always do "select_db()" to switch between them?

I thought that if I did this:

----------- php: -------------
$aaa_link = mysql_pconnect("localhost", "u", "p");
mysql_select_db("apples", $aaa_link);

$zzz_link = mysql_pconnect("remotehost", "u", "p");
mysql_select_db("zebras", $zzz_link);
------------------------------

... that I'd be able to access both pretty easily. Like this:

----------- php: -------------
$aaa_result = mysql_query("select * from apples", $aaa_link);
$orchard = mysql_fetch_assoc($aaa_result);

$zzz_result = mysql_query("select * from zebras", $zzz_link);
$zoo = mysql_fetch_assoc($zzz_result);

$aaa_result = mysql_query("update apples set something='" . $zoo['zebrafur'] . "'", 
$aaa_link);
------------------------------

But it seems to tell me that $zzz_result is not a valid resource - unless I do the 
select_db thing inbetween the two commands.

Is there anyone doing this successfully?  Back-n-forth between two databases?

Thanks for any help.


--- End Message ---
--- Begin Message ---
i dont know if this will work, but you can try selecting them in the
query... i.e.:

select * from database.table

I am by no means a guru on sql queries, but it may work.

-----Original Message-----
From: PHP freak [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 08, 2002 8:39 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP] two different MySQL connections without always select_db?


How would you keep two different MySQL connections to two different MySQL
databases (on two different MySQL servers) up and available with two
different pointers (id), and not need to always do "select_db()" to switch
between them?

I thought that if I did this:

----------- php: -------------
$aaa_link = mysql_pconnect("localhost", "u", "p");
mysql_select_db("apples", $aaa_link);

$zzz_link = mysql_pconnect("remotehost", "u", "p");
mysql_select_db("zebras", $zzz_link);
------------------------------

... that I'd be able to access both pretty easily. Like this:

----------- php: -------------
$aaa_result = mysql_query("select * from apples", $aaa_link);
$orchard = mysql_fetch_assoc($aaa_result);

$zzz_result = mysql_query("select * from zebras", $zzz_link);
$zoo = mysql_fetch_assoc($zzz_result);

$aaa_result = mysql_query("update apples set something='" . $zoo['zebrafur']
. "'", $aaa_link);
------------------------------

But it seems to tell me that $zzz_result is not a valid resource - unless I
do the select_db thing inbetween the two commands.

Is there anyone doing this successfully?  Back-n-forth between two
databases?

Thanks for any help.



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

--- End Message ---
--- Begin Message ---
On Saturday 09 March 2002 03:29, CB wrote:
> Hi!
>
> I get an errormessage when trying to use cal_days_in_month(). "Fatal error:
> Call to undefined function: cal_days_in_month()"
>
> The server is runnig PHP 4.1.2, Apache 1.3.23 on some kind of Linux dist.

recompile php with the "--enable-calendar" option.

> When I run the same file on my laptop it works. The laptop is running PHP
> 4.1.1, Apache 1.3.20 on Windows 2000 Professional.
>
> Anyone got any idea?



-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
The less a statesman amounts to, the more he loves the flag.
                -- Kin Hubbard
*/
--- End Message ---
--- Begin Message ---
In article <[EMAIL PROTECTED]>, [EMAIL PROTECTED] says...
> Hi!
> 
> I get an errormessage when trying to use cal_days_in_month(). "Fatal error:
> Call to undefined function: cal_days_in_month()"
> 
> The server is runnig PHP 4.1.2, Apache 1.3.23 on some kind of Linux dist.
> 
> When I run the same file on my laptop it works. The laptop is running PHP
> 4.1.1, Apache 1.3.20 on Windows 2000 Professional.
> 
> Anyone got any idea?
> 
> /Örjan

>From the manual:

VI. Calendar functions
Introduction
The calendar extension presents a series of functions to simplify 
converting between different calendar formats. The intermediary or 
standard it is based on is the Julian Day Count. The Julian Day Count is 
a count of days starting way earlier than any date most people would need 
to track (somewhere around 4000bc). To convert between calendar systems, 
you must first convert to Julian Day Count, then to the calendar system 
of your choice. Julian Day Count is very different from the Julian 
Calendar! For more information on calendar systems visit 
http://genealogy.org/~scottlee/cal-overview.html. Excerpts from this page 
are included in these instructions, and are in quotes. 

Installation
To get these functions to work, you have to compile PHP with --enable-
calendar. 

So it would seem that your server doesn't have the necessary 
functionality compiled into php.

-- 
David Robley
Temporary Kiwi!

Quod subigo farinam
--- End Message ---
--- Begin Message ---
Has anyone any code that creates a CSS file? A GUI?

As in:

<style type="text/css">
<!--
body          {font-family: helvetica, arial, geneva, sans-serif;
font-size: small; color: #000000}
//-->
</style>


--- End Message ---
--- Begin Message ---
jtjohnston wrote:

> Has anyone any code that creates a CSS file? A GUI?

    You might want to read this:

    http://www.phpbuilder.com/columns/tim20000821.php3

--
H | "Life is the art of drawing without an eraser." - John Gardner
  +--------------------------------------------------------------------
  Ashley M. Kirchner <mailto:[EMAIL PROTECTED]>   .   303.442.6410 x130
  Director of Internet Operations / SysAdmin    .     800.441.3873 x130
  Photo Craft Laboratories, Inc.            .     3550 Arapahoe Ave, #6
  http://www.pcraft.com ..... .  .    .       Boulder, CO 80303, U.S.A.


--- End Message ---
--- Begin Message ---
hi folks,
i m trying to execute a plain shell script(bash shell) in php by 
using exec function(i tried even backtick operator).
It is displaying me the echo commands but not doing any other 
processing which is there in the script.
Moreover,the same scripts works when i execute it as a command 
line argument without using php.
Can somebody help for executing this script from with in php??
Thanks a lot for the help
Amit
--- End Message ---
--- Begin Message ---
Hi Andrea!

I use this.
$message="<a href=\"http://www.sever.com\";>link</a>";

$message = stripcslashes($message);
$headers .= "Return-Path: <[EMAIL PROTECTED]>\n";
$headers .= "Reply-To:$admail\n";
$headers .= "From: $admail\n";
$headers .= "X-Mailer: PHP\n";
$headers .= "Content-Type: text/html; charset=iso-8859-1\n";
mail($recipient, $subject, $message, $headers);

Regards,
Jan

"Andrea Caldwell" <[EMAIL PROTECTED]> skrev i meddelandet
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi All,
>
> I've been researching the mail() function and from what I've read, some
> people embed HTML into their mail() without using classes.  All I need to
do
> is add a link in an email... can anyone advise how I would do this?  Which
> headers would I need?  I was using:
>
> $headers = "MIME-Version: 1.0\r\n";
> $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
>
> but getting a wrong parameter count for mail.  How do I add more than one?
> Then how do I code the link in the $mailcontent?  I was using single
quotes
> for the anchor tags, is that correct?  Not sure if that works since my
> headers weren't working.
>
> Thanks for your help w/ a novice,
> ~AC
>
>
>
>
>

--- End Message ---
--- Begin Message ---
what does this error mean. What should i do to make it
portable to future version of php. I'm using version
4.1.0

Warning: Call-time pass-by-reference has been
deprecated - argument passed by value; If you would
like to pass it by reference, modify the declaration
of [runtime function name](). If you would like to
enable call-time pass-by-reference, you can set
allow_call_time_pass_reference to true in your INI
file. However, future versions may not support this
any longer. in /var/www/html/accounts.php on line 123


__________________________________________________
Do You Yahoo!?
Try FREE Yahoo! Mail - the world's greatest free email!
http://mail.yahoo.com/
--- End Message ---
--- Begin Message ---
On Saturday 09 March 2002 17:25, Kancha . wrote:
> what does this error mean. What should i do to make it
> portable to future version of php. I'm using version
> 4.1.0
>
> Warning: Call-time pass-by-reference has been
> deprecated - argument passed by value; If you would
> like to pass it by reference, modify the declaration
> of [runtime function name](). If you would like to
> enable call-time pass-by-reference, you can set
> allow_call_time_pass_reference to true in your INI
> file. However, future versions may not support this
> any longer. in /var/www/html/accounts.php on line 123

Do you get this error on code written by yourself or on someone else's code?

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk

/*
If you think the problem is bad now, just wait until we've solved it.
                -- Arthur Kasspe
*/
--- End Message ---
--- Begin Message ---

Hello!  I am trying to reduce the size of the code below, which I believe
can be simplified.

I checked the 'for' entry in the manual as well as googling for some
similar code, but did not have any luck.

Here is what I have:


$ICON_COUNT="0";

if ($SHOW_WAI_ICON != "no")
{
        $ICON_COUNT++ ;
}

if ($SHOW_BOBBY508_ICON != "no")
{
        $ICON_COUNT++ ;
}

if ($SHOW_W3_ICON != "no")
{
        $ICON_COUNT++ ;
}

if ($SHOW_CSS_ICON != "no")
{
        $ICON_COUNT++ ;
}


Now I would like to make that a 'for' loop, but I'm not sure how to do it
in PHP.

In case it is not clear what I am trying to do, this is what I would do if
PHP syntax were like bash:

variables="SHOW_CSS_ICON SHOW_W3_ICON SHOW_BOBBY508_ICON SHOW_WAI_ICON"

for i in $variables
do

        if [ "$i" != "no" ]
        then
                #increment icon_count here
        fi

done


I'm just not sure about the nested syntax in PHP.

Thanks for any help

TjL


-- 
Site: www.tntluoma.com                       mailto:[EMAIL PROTECTED]
Info: Apache/1.3.19 (Unix) with PHP/4.0.6

--- End Message ---
--- Begin Message ---
    hi,

    the fastest and most powerful is always to use the native
    api.

    i would use the PHP oci driver.

    tc

On Fri, Mar 08, 2002 at 09:00:17AM -0500, Andrew Hill wrote:
> I suggest simply using ODBC.
> 
> Best regards,
> Andrew Hill
> Director of Technology Evangelism
> http://www.openlinksw.com/virtuoso/whatis.htm
> OpenLink Virtuoso Internet Data Integration Server 
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, March 08, 2002 5:39 AM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] Database abstraction layer oci
> > 
> > 
> > 
> > Hi everybody.
> > 
> > I would like your opinion on the Database Abstraction Layer you prefer (I
> > will use it with Oracle 8i)
> > I know that there is Metabase end Pear DB
> > 
> > What's  your opinion on both or others ?
> > 
> > Laurent Drouet
> > 
> > 
> > 
> > -- 
> > 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
--- End Message ---
--- Begin Message ---
George Whiffen wrote:

> Wierd, sounds like it could be a bug.  What's the actual code you use
> for the upload?
> 
> I presume you are running vim from the command line of the box to which
> the image is
> uploaded.  Content-Type: image/jpeg is, of course, what Apache would add
> if you requested a .jpg file over
> the web.
> 
> Good Luck,
> 
> George

The code i use is a trivial variant of that presented in PHP
documentation. The exact same code works fine on the debian
i386 machine, which runs apache 1.3.9 + PHP 4.0.3pl1.

The powerpc linux box is my developement machine, not the
deployment one, so this is not a terrible problem. I still have
the debian to develop on. Besides that, the upcoming update from
yellowdog linux should solve my problem on the ppc box as well.

Thanks,

fbv
--- End Message ---
--- Begin Message ---

Hi All,
        Lets have a look at the following link to library functions
to write HTML tags in easy way. Its very easy to use interface including
documentation and Algorithm.

http://phpBuilder.com/snippet/download.php?type=snippet&id=948


<[EMAIL PROTECTED]> APU (A Php User)
-------------------------------------------------------------------
We must use time wisely and forever realize that the time is 
always ripe to do right."
            
                -- Nelson Mandela
-------------------------------------------------------------------

--- End Message ---
--- Begin Message ---
Hi,

    i'm trying to use the gd-library under windows, but it doesn't work. How
can I include the gd.dll? Where do I put this file? I tried some different
directories which are written in the php.ini as include-directories. What am
I doing wrong? Is there a way to use this library under windows???

Any hint can be useful.

Sincerely

Marcel

--
registered Fli4l-User #00000388


--- End Message ---
--- Begin Message ---
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


* and then Mario Montoya Martínez declared....
> I'm used to a function in ASP which is HTMLBuffer.

Never mind :-)

> This allows the script to send HTML code to the browser while
> the script is running.
> I've seen that PHP scripts don't send any HTML until the
> script finishes. I'd really like to see what's happening in my script
> while it is being executed.
> 
> Any ideas?

PHP has a whole bunch of stuff for this, try this 
http://www.php.net/manual/en/ref.outcontrol.php

Good luck!
- -- 
- -----------------------------------------------------------
 www.explodingnet.com   |    Projects, Forums and
                        +    Articles for website owners 
- -- Nick Wilson --     |    and designers.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE8ifMRHpvrrTa6L5oRAh5MAJ9Eto680D3JGxcd4nztA4eVi9VprgCePfqB
qpcQYrWUtMDDfYRa3zmJ2ek=
=p3GA
-----END PGP SIGNATURE-----
--- End Message ---
--- Begin Message ---
I made a script that looks in a URL for jpg's and their links.
So the result is:
s1.jpg links to b1.jpg
s2.jpg links to b2.jpg
etc etc

But now I would like to check if b1.jpg is bigger then s1.jpg, if not the script must 
stop. But I can't figure out to do this.

My script so far:
<? 
$fp=fopen('http://www.mydomain.com/test.htm','r'); 
$text=fread($fp,100000); 
fclose($fp); 
$preg='/ 
<a
[^>]*
href=
"?\'?
([^"\'>]*\.jpg)
[^>]* 
>
([^<]|<(?!a))*
<img 
[^>]*
src=
"?\'?
([^"\'>]*\.jpg)
[^>]* 
>
([^<]|<(?!a))*
<\/a
/siUx'; 
preg_match_all($preg,$text,$matches); 
for ($k=0;$k<count($matches[0]);$k++){ 
echo $matches[3][$k].' linkt naar '.$matches[1][$k].'<br>'; 
} 
?> 


--- End Message ---

Reply via email to