php-windows Digest 12 Apr 2002 05:32:08 -0000 Issue 1089

Topics (messages 13032 through 13047):

Dynamic querys to SQl Server
        13032 by: R.S. Herhuth
        13034 by: Svensson, B.A.T. (HKG)
        13035 by: Mike Flynn

Re: whois servers
        13033 by: Arijit Chaudhuri

COM interop and recordsets
        13036 by: Fred Forsyth

Re: Another Newbie Question
        13037 by: Nik Alleyne

Another Question!
        13038 by: Nik Alleyne
        13039 by: Svensson, B.A.T. (HKG)
        13043 by: Mike Flynn

Session Errors
        13040 by: Scott Carr

Problem Connecting to AS400 using ODBC
        13041 by: Collins, Robert
        13042 by: Svensson, B.A.T. (HKG)
        13044 by: Collins, Robert

Problem with 4.0.6 through 4.2RC2
        13045 by: Scott Carr

Re: Apache 2 and PHP
        13046 by: Aasmund Sæter

Re: Configuring securely in IIS5 under Windows 2000 Server
        13047 by: Svensson, B.A.T. (HKG)

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

I'm new to php and I'm trying hard to get a grasp on pulling data from
SQL Server.

I'm looking for an efficient method for making dynamic queries to SQL server.



Basically what I have created so far is a page that dynamically builds
all of the column names of a database.  I have assigned each a unique
variable name.  When the user selects the check box next to the name and
submits the form, I am using the HTTP_POST_VARS() to explode out the
variables on the following page.  What I need to do though is create a
way to dynamically query the DB only returning the selected columns. 
What is an efficient way of doing this?

Does anyone know of any tutorials or examples that can get me close?

Ron
--- End Message ---
--- Begin Message ---
> From: R.S. Herhuth
> Sent: Thursday, April 11, 2002 4:41 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Dynamic querys to SQl Server
> 
> Basically what I have created so far is a page that dynamically builds
> all of the column names of a database.  I have assigned each a unique
> variable name.  When the user selects the check box next to the name and
> submits the form, I am using the HTTP_POST_VARS() to explode out the
> variables on the following page.  What I need to do though is create a
> way to dynamically query the DB only returning the selected columns. 
> What is an efficient way of doing this?
> 
> Does anyone know of any tutorials or examples that can get me close?

Effective and effective, and don't know if my suggestion is, but I (at
least the way I like to design things) is to pull all these things into
the database it self (but to be honest, it might mainly be because I
think it so bloody boring to write these web scripts.)

Anyhow, I uses the web server to passes (logical) messages to the data base,
and then the RDBMS resolves the requested "service" by performing some magical
dynamic bindings, e.g. looks up the proper stored procedure to execute, pass,
if needed, arguments and parameters to the stored procedure, and then BANG -
just feed back the answer to the web server, were the only purpose of the
web serer is to display whatever result set that was returned by the RDBMS.

So basically I view the web server only as a user interface management system,
and it purpose is only to display the information, and provide a communication
channel to the RDBMS to the enduser - no data processing is done at the webserer
end, mainly because the web server does have no clue what so ever what included
in the data base. 

What do I win with this? Well, I only once write a general communications
system at the web server end, and then I never ever need to do any more
programming at the webserver end since everything is controlled by the
RDBMS instead - no need for so called web-"programmers" anymore. A database
programmer is the only thing needed.

So the ingrediens for this cake is:

        one Web Server
        one RDBMS
        a bit of Dynamic Name Binding
        and lots of Information Hiding
--- End Message ---
--- Begin Message ---
If I understand you correctly, then you could try something like this:

=======Page 1:
Select info to view...
<input type="checkbox" name="columns[]" value="Name"> Name<br>
<input type="checkbox" name="columns[]" value="Email"> Email<br>
<input type="checkbox" name="columns[]" value="City"> City

=======Page 2:
$query  = 'SELECT ';
$first = true;
foreach ($columns AS $value) {
   if (!$first) {
     $query .= ', ';
   }
   else {
     $first = false;
   }
   $query .= $value;
}
$query .= 'FROM MyTable ';
$query .= 'ORDER BY Name';
$result = mysql_query($query);
echo '<table>';
while ($row = mysql_fetch_row($result)) {
   echo '<tr>';
   foreach ($row AS $value) {
     echo "<td>$value</td>";
   }
   echo '</tr>';
}
echo '</table>';

Obviously this is a pretty rough outline, but it gives you a basic idea of 
the way you could do this.  You can add bells & whistles and make it look 
nicer, add error checking, stuff like that.

-Mike

At 09:41 AM 4/11/2002 -0500, R.S. Herhuth wrote:

>I'm new to php and I'm trying hard to get a grasp on pulling data from
>SQL Server.
>
>I'm looking for an efficient method for making dynamic queries to SQL server.
>
>
>
>Basically what I have created so far is a page that dynamically builds
>all of the column names of a database.  I have assigned each a unique
>variable name.  When the user selects the check box next to the name and
>submits the form, I am using the HTTP_POST_VARS() to explode out the
>variables on the following page.  What I need to do though is create a
>way to dynamically query the DB only returning the selected columns.
>What is an efficient way of doing this?
>
>Does anyone know of any tutorials or examples that can get me close?
>
>Ron
>
>--
>PHP Windows Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php


Mike Flynn - Burlington, VT
http://www.mikeflynn.net/ - [EMAIL PROTECTED]
home=>work=>home=>store=>home [repeat daily]

--- End Message ---
--- Begin Message ---
Thanks! Got most of the whois servers except .la and .name. Not sure why the
client needs them - but the client is the boos neway.

Regards,
Arijit


"Piotr Pluciennik" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Hi,
> so, sending again - url with a lot of whois and other useful functions:
>
> http://combat.uxn.com/
>
> Greetings
> Piotr
>
> Arijit Chaudhuri wrote:
>
> > Thanks a lot. It looks good. Will also look forward to the other site
you
> > mentioned.
> >
> > Regards,
> > Arijit
> >
> > "Piotr Pluciennik" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Hi,
> > >
> > > try this: http://www.geektools.com/cgi-bin/proxy.cgi
> > >
> > > I also found a site with more options but today, at home computer I
don't
> > > remember and haven't got it... I'll try to check it in my office on
monday
> > and
> > > then will send to you.
> > >
> > > HTH
> > >
> > > Piotr
> > >
> > >
> > > Arijit Chaudhuri wrote:
> > >
> > > > Hi all,
> > > >
> > > > I am looking for whois servers, specially for new domains like .biz,
> > .name
> > > > and obscure ones like .la and .cc. Is there one server where I can
get
> > all?
> > > > Can look up registration details in separate registers but one
server
> > will
> > > > speed up the search.
> > > >
> > > > Regards,
> > > > Arijit
> > > >
> > > > --
> > > > PHP Windows Mailing List (http://www.php.net/)
> > > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>


--- End Message ---
--- Begin Message ---
I'm trying to write a PHP4 application that will connect to my Windows COM
object. It deals with recordsets a lot. What I would like to know is, what
do I need to do to interface with the methods (the recordsets are causing me
problems right now) and how can I import the enums from the typelib?

Has anyone had any experience with this? I'm using PHP 4.1.2 at the moment.

Cheers
Fred Forsyth
Software Engineer.


--- End Message ---
--- Begin Message ---
Thankx a million. It worked!




"Court Shrock" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Are you sure that the database server is called 'nik'.....if the same
system
> is both your web server and database server, I would recommend replacing
> 'nik' with 'localhost'.  I am thinking that your mysql_connect() should be
> as follows:
>
> mysql_connect('localhost', 'nik', '');
> //connect to localhost as the user, nik, with no password
>
> > -----Original Message-----
> > From: Nik Alleyne [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, April 10, 2002 8:56 AM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-WIN] Another Newbie Question
> >
> >
> > Good evening everyone,
> > I am new (very new) to php. I was doing some research on the
> > net and learn
> > of this packaged and after reading just a couple of pages, i
> > figure i should
> > learn this instead of ASP. It looks so easy. Anyhow here is
> > my problem.
> >
> > I am trying to connect to the database (MySQL) however, I can't I am
> > connecting to the server, but I cannot connect to my sample database.
> >
> > Here is my script?
> > <?php
> > mysql_connect("nik", "", "") or
> >   die("could not connect to the database");
> > mysql_select_db("guestbook") or
> > die ("could not connect to the specified database");
> > ?>
> > I'm getting the "could not connect to the specified database" message.
> > P.S. The database exists.
> >
> > Please Help
> > Thx
> > Nik
> >
> >
> >
> >
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >


--- End Message ---
--- Begin Message ---
I'm now trying to insert data into the database, but i seem to have a
problem with my
  If ( $submit == "Sign!" )
  {
     echo "Whatever";
  }
this is being done in a page called createentry.php which checks the submit
button on a page called index.html

once i place this statement in here the if nothin happens, but if i put it
outside, everything works fine.

Thx
Nik


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


> -----Original Message-----
> From: Nik Alleyne
> Sent: Wednesday, April 10, 2002 9:33 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP-WIN] Another Question!
> 
> 
> I'm now trying to insert data into the database, but i seem to have a
> problem with my
>   If ( $submit == "Sign!" )
>   {
>      echo "Whatever";
>   }
> this is being done in a page called createentry.php which checks the submit
> button on a page called index.html

Since you only have given use a perfectly well formed if-statement without any
conceptual connection one needs to start to ask some very basic question, like:

Does the ACTION tag in the FORM field point to the "createentry.php" page?
What are the values of the NAME and the VALUE for INPUT field of this submit buton?

Or are you trying to tell use that there is a bug in the php-interprerter for the 
if-statment?

> once i place this statement in here the if nothin happens, but if i put it
> outside, everything works fine.

It is unclear what you mean with this: where is "in here" and "outside" located?
--- End Message ---
--- Begin Message ---
I'm assuming $submit is referring to the submit button.
First of all, the submit button isn't assigned to the variable $submit, 
unless its NAME property is "submit".  You could make a text field called 
submit, a select box called submit, radio button, checkbox, etc.  All it 
depends on is which field is given the name="submit" in their tag.  So, 
unless you have specifically put name="submit" in your submit button, like 
this:
<input type="submit" name="submit" value="Sign!">
then $submit is not going to register as a variable.  Some basic debugging 
could have told you this, like echoing the value of $submit.  Why not try this:
   echo "The value of submit is: $submit<br>\n";
   if ($submit == 'Sign!') {
    echo "Whatever";
   }
That would be the logical first step in debugging.  You ask, "Why is the if 
statement not going through?"  The first answer is, "Because $submit 
doesn't equal 'Sign!'".  Then you ask, "Then what does it equal?"  And then 
you echo its value.

But, even if you did all this, and made sure that the submit button was 
named "submit" and its value was "Sign!", there is one thing you should 
know: There is behaviour in some versions of Internet Explorer where the 
value of the Submit button is not sent with the form if the button itself 
is not clicked.  But, you ask, when would a form be submitted without its 
button being clicked?  Well, you may have noticed that in IE you can submit 
forms by hitting enter while focused within the form (though not within a 
textarea, of course).  So, if the user hits enter to submit the form, and 
their browser allows it (i/e they're using MSIE), then the form will get 
submitted, and if the browser doesn't send the value of the submit button 
along since they didn't click it (i/e they're using a version of MSIE that 
behaves this way), then your if statement on the next page won't go through 
anyway, even though they submitted the form.

A better way to deal with this is to include a hidden field in ALL forms 
you make, like this:
<input type="hidden" name="submitted" value="1">
That way, you can do something like this instead:
   if ($submitted) {
    echo "Whatever";
   }
And it will work for all browsers.

-Mike

At 04:32 PM 4/10/02 -0300, Nik Alleyne wrote:
>I'm now trying to insert data into the database, but i seem to have a
>problem with my
>   If ( $submit == "Sign!" )
>   {
>      echo "Whatever";
>   }
>this is being done in a page called createentry.php which checks the submit
>button on a page called index.html
>
>once i place this statement in here the if nothin happens, but if i put it
>outside, everything works fine.
>
>Thx
>Nik

--- End Message ---
--- Begin Message ---
I am trying to use sessions on the following setup:

Win NT4, Apache 1.3.23, PHP 4.1.2

Every time I try to register a variable using any means possible, it doesn't get
registered.  If I look at the session files, they are blank.

Is there some trick I am missing?
-- 
Scott Carr
OpenOffice.org
Whiteboard-Doc Maintainer
http://whiteboard.openoffice.org/doc/





-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
--- End Message ---
--- Begin Message ---
I am trying to access data on an AS/400(IBM DB2) from a windows platform
using Apache, and PHP. The problem I am having is that the script doesn't
appear to do anything, it will run constantly and doesn't produce an error
or time out. I have tried setting the ODBC DSN as both user and server. Has
anyone else had this problem, and if so what was the fix?

Using :
Windows 2k o NT4
PHP ver.4.1.1
APACHE ver. 1.3.22
Client Access ODBC Driver (32bit) ver. 7.00.00.00

Code Snippet:
<?
    $username = "USERNAME";
    $password = "PASSWORD";
    $dsn = "DSN";
        if($conn = odbc_connect($dsn,$username,$password)){
            echo "connected";
        }else{
            echo "failed";
        }
    odbc_close($conn);
?>

Robert W. Collins II 
Webmaster 
New Orleans Regional Transit Authority 
Phone : (504) 248-3826 
Email : [EMAIL PROTECTED] 
--- End Message ---
--- Begin Message ---
What happens if you instrument your code in the following way:

<?
    echo "SEGMENT TEST CONNECT: START";

    $username = "USERNAME";
    $password = "PASSWORD";
    $dsn = "DSN";
        if($conn = odbc_connect($dsn,$username,$password)){
            echo "connected";
        }else{
            echo "failed";
        }
    odbc_close($conn);

    echo "SEGMENT TEST CONNECT: STOP";
?>


> -----Original Message-----
> From: Collins, Robert [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 11, 2002 9:15 PM
> To: PHP Windows
> Subject: [PHP-WIN] Problem Connecting to AS400 using ODBC
> 
> 
> I am trying to access data on an AS/400(IBM DB2) from a windows platform
> using Apache, and PHP. The problem I am having is that the script doesn't
> appear to do anything, it will run constantly and doesn't produce an error
> or time out. I have tried setting the ODBC DSN as both user and server. Has
> anyone else had this problem, and if so what was the fix?
> 
> Using :
> Windows 2k o NT4
> PHP ver.4.1.1
> APACHE ver. 1.3.22
> Client Access ODBC Driver (32bit) ver. 7.00.00.00
> 
> Code Snippet:
> <?
>     $username = "USERNAME";
>     $password = "PASSWORD";
>     $dsn = "DSN";
>         if($conn = odbc_connect($dsn,$username,$password)){
>             echo "connected";
>         }else{
>             echo "failed";
>         }
>     odbc_close($conn);
> ?>
> 
--- End Message ---
--- Begin Message ---
I put the code in and it worked perfectly. as it turns out there was a
networking issue that I had not been informed of that was causing the
problem. Thanks for your reply.

Robert W. Collins II 
Webmaster 
New Orleans Regional Transit Authority 
Phone : (504) 248-3826 
Email : [EMAIL PROTECTED] 



-----Original Message-----
From: Svensson, B.A.T. (HKG) [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 3:23 PM
To: Collins, Robert
Cc: PHP Windows
Subject: RE: [PHP-WIN] Problem Connecting to AS400 using ODBC


What happens if you instrument your code in the following way:

<?
    echo "SEGMENT TEST CONNECT: START";

    $username = "USERNAME";
    $password = "PASSWORD";
    $dsn = "DSN";
        if($conn = odbc_connect($dsn,$username,$password)){
            echo "connected";
        }else{
            echo "failed";
        }
    odbc_close($conn);

    echo "SEGMENT TEST CONNECT: STOP";
?>


> -----Original Message-----
> From: Collins, Robert [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, April 11, 2002 9:15 PM
> To: PHP Windows
> Subject: [PHP-WIN] Problem Connecting to AS400 using ODBC
> 
> 
> I am trying to access data on an AS/400(IBM DB2) from a windows platform
> using Apache, and PHP. The problem I am having is that the script doesn't
> appear to do anything, it will run constantly and doesn't produce an error
> or time out. I have tried setting the ODBC DSN as both user and server.
Has
> anyone else had this problem, and if so what was the fix?
> 
> Using :
> Windows 2k o NT4
> PHP ver.4.1.1
> APACHE ver. 1.3.22
> Client Access ODBC Driver (32bit) ver. 7.00.00.00
> 
> Code Snippet:
> <?
>     $username = "USERNAME";
>     $password = "PASSWORD";
>     $dsn = "DSN";
>         if($conn = odbc_connect($dsn,$username,$password)){
>             echo "connected";
>         }else{
>             echo "failed";
>         }
>     odbc_close($conn);
> ?>
> 
--- End Message ---
--- Begin Message ---
Environment:  WinNT4, Apache 1.3.23, PHP 4.0.6 THROUGH 4.2RC2

Code Snippet:

$strClientDb = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Some location";
$client = new COM("ADODB.Recordset");

$strSQL = "SELECT * FROM AnyTable";

$client->open($strSQL, $strClientDb);
----

This works fine.

Problem:

$strClientDb = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Some location";
$client = new COM("ADODB.Recordset");

$strSQL = "SELECT IDCode, FirstName, LastName, Provider, EmailAddr FROM AnyTable";

$client->open($strSQL, $strClientDb);

----

When I run this code, I get php_OLECHAR_to_char errors in 4.0.6 to 4.1.2, in RC2
I get the following error:

Warning: Invoke() failed: Exception occurred. Argument: 0 in d:\program
files\apache group\apache\htdocs\client\include\config.php on line 30

The only thing changed is the length of the SQL string.  (The SQL string works
fine if I run it in Access.)

Are there any ideas on this??

-- 
Scott Carr
OpenOffice.org
Whiteboard-Doc Maintainer
http://whiteboard.openoffice.org/doc/





-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/
--- End Message ---
--- Begin Message ---
I got a similar problem. Apahce2 says it can't find the module, even though
it is really there!

The error:
Syntax error on line 947 of D:/programmer/Apache2/conf/httpd.conf:
Cannot load D:/programmer/php/sapi/php4apache.dll into server: The specified
module could not be found.

In httpd.conf:
LoadModule php4_module D:\programmer\php\sapi\php4apache.dll
AddModule mod_php4.c
AddType application/x-httpd-php .php

*And I who was hoping to get Apache2 work! :(*


"Gaylen Fraley" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> When trying to set up PHP with Apache 2, the following error occurs:
>
> Syntax error on line 175 of  /Apache2/conf/httpd.conf:
> Cannot load /php/sapi/php4apache.dll into server: One of the library files
> nee
> ded to run this application cannot be found.
>
> How do I find what is missing?  It works under Apache 1.3.24
>
> --
> Gaylen
> PHP KISGB v4.0.4 Guest Book http://www.gaylenandmargie.com/phpwebsite/
>
>
>


--- End Message ---
--- Begin Message ---
> >>All PHP does, is create a dynamic webpage, ie create a web page
> >>"on-the-fly". This does not expose any holes any more than creating an
> >> html page does.
> 
> not true - PHP is as secure as the pages you program.
> lack of user input verification is a good example.

If you wants to be philosophical about it, then this is of course true
for any languages such as Perl, Java, C/C++, Pascal, Fortran, Eiffel,
Modula, ADA, Lisp, Prolog, Assembler, and even Born-Shell, you name it.
 
The point Fleming raised is still valid.

        //Anders

--- End Message ---

Reply via email to