Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 11th, 2004, 08:32 PM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default IIS and PHP

Hello. I used IIS instead of APACHE.
Some of the code in Ch. 6 is not working, namely the example involving $Server and REQUEST_URI. Does this have anything to do with me not using Apache, and how do I fix this?

 
Old June 12th, 2004, 04:52 AM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's hard to say if you don't post an example. How is it not working? Are you getting any error messages? Can you post the code you are using so we can take a look at it?

BuzzLY
aka Michael K. Glass
Author, Beginning PHP, Apache, MySQL Web Development
 
Old June 12th, 2004, 03:12 PM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default


There's no error, except that when I click "Yes" (as in Yes I want to delete the page), there is a page saying that page cannot be found (http://localhost/%3Cbr%20/%3E%3Cb%3E...br%20/%3E&do=1)



THIS CODES IS DIRECTLY FROM THE DOWNLOADED ZIP FILE:
<?php
   $link = mysql_connect("localhost", "root", "")
      or die("Could not connect: " . mysql_error());
   mysql_select_db('chapter6', $link) or die ( mysql_error());
// DELETE SCRIPT
   if ( !isset( $_GET['do'] ) || $_GET['do'] != 1 ){
?>
      <p align="center" style="color:#FF0000">
         Are you sure you want to delete this <?php echo $_GET['type']?>?<br/>
         <a href="<?php echo $_SERVER['REQUEST_URI']?>&do=1">yes</a> or <a
href="index.php">Index</a>
      </p>
<?php
   } else {
      if ( $_GET['type'] == "people" ){
         // delete references to people from the movie table
         // delete reference to lead actor
         $actor = "UPDATE
                  `movie`
               SET
                  `movie_leadactor` = '0'
               WHERE
                  `movie_leadactor` = '".$_GET['id']."'
               ";
         $result = mysql_query( $actor )
            or die("Invalid query: " . mysql_error());
         // delete reference to director
         $director = "UPDATE
                  `movie`
               SET
                  `movie_director` = '0'
               WHERE
                  `movie_director` = '".$_GET['id']."'
               ";
         $result = mysql_query( $director )
            or die("Invalid query: " . mysql_error());
      }
      // generate SQL
      $sql = "DELETE FROM
               `".$_GET['type']."`
            WHERE
               `".$_GET['type']."_id` = '".$_GET['id']."'
            LIMIT 1";
      // echo SQL for debug purpose
      echo "";
      $result = mysql_query( $sql )
         or die("Invalid query: " . mysql_error());
?>
      <p align="center" style="color:#FF0000">
         Your <?php echo $_GET['type']?> has been deleted. <a href="index.php">Index</a>
      </p>
<?php
   }
?>

 
Old June 12th, 2004, 04:24 PM
Authorized User
 
Join Date: May 2004
Location: , , .
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ah, ok... the problem is that IIS does not support REQUEST_URI. Yay Microsoft :(

REQUEST_URI returns the entire path, filename, and query_string from the URL. If it's not available, we'll have to "build" the URL ourselves. Fortunately, that's easily done! Put this code at the beginning of your php code (just after the <?php tag):
Code:
if (!isset($_SERVER['REQUEST_URI'])) {
    $_SERVER['REQUEST_URI'] = $_SERVER["SCRIPT_NAME"] .
    $_SERVER['QUERY_STRING'];
}
Unfortunately, even the authors of this book can sometimes fall into the trap of coding "what they know." If a person is used to using REQUEST_URI (and most people are -- PHP is most often installed with Apache (Unix/Linux/etc.)), they wouldn't know that such a common variable is not available in IIS. Sorry about the confusion.

REQUEST_URI might be used in other areas as well. If you put the above code in any script that uses REQUEST_URI, you should be ok.

BuzzLY
aka Michael K. Glass
Author, Beginning PHP, Apache, MySQL Web Development
 
Old July 13th, 2004, 08:43 PM
Registered User
 
Join Date: Jun 2003
Location: Cincinnati, OH, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Not sure if it makes a difference for anyone, but I used a very slight variation BuzzLY's code (note the addition of the '?' in the 2nd line):

if (!isset($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'].'?'.$_SERVER['QUERY_STRING'];
}

Bruce
 
Old December 1st, 2005, 06:00 PM
mtk mtk is offline
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

NO COMENT
:) Sorry for my english !!! but I think will be help this:

Code:
<?php
if (!isset($_SERVER['REQUEST_URI']))
{
    if (!isset($_SERVER['QUERY_STRING']))
    {
        $_SERVER['REQUEST_URI'] = $_SERVER["SCRIPT_NAME"];
    }
    else
    {
        $_SERVER['REQUEST_URI'] = $_SERVER["SCRIPT_NAME"] .'?'.
        $_SERVER['QUERY_STRING'];
    }
}

echo $_SERVER["REQUEST_URI"];
?>

MTK MADRID SPAIN





Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP on IIS and on WAMp vinu123 BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 February 20th, 2007 02:08 PM
How to conigure IIS for php aneesh_sunu@yahoo.co.in PHP How-To 1 November 1st, 2006 04:04 AM
which is best :php with iis or php with apache? fromheavenz Beginning PHP 4 September 7th, 2005 01:47 AM
PHP and IIS 5.0 isheikh PHP Databases 2 June 18th, 2004 07:07 AM
Can someone help me about iis and Php installment lancet2003 Wrox Book Feedback 2 August 10th, 2003 12:18 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.