Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP 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 April 2nd, 2006, 10:22 PM
Registered User
 
Join Date: Apr 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can anyone help with this php script plz

trying to display browser specific
this is what i have dont so for but gettting error message.
what i want to script to do is to direct the user to a new page based on whether the browser is IE or something else

just started learning php 2days ago so i dont not if i need an if else statement to do this


when ever i run the code i keep getting error message

Warning: preg_match() [function.preg-match]: Unknown modifier '1' in C:\broot\do_redirect.php on line 4

Warning: Cannot modify header information - headers already sent by (output started at C:\Webroot\do_redirect.php:4) in C:\broot\do_redirect.php on line



<?php

  $agent = getenv("http_user_agent");
 if (preg_match ("/msie/1", "$agent")) {
   $result = "you are using microsoft internet explorer.";
 }
 else if (preg_match ("/mozilla/i", "$agent")) {
   $result = " you are using netscape.";
 }
 else {
   $result = "you are using $agent";
 }


// set location if provided from form, else set it to default page:
$location = (!empty($_POST['location'])) ? $_POST['location'] :
            "http://www.msn.com/";
            "http://www.microsoft.com/";
             "http://www.expedia.com/";
              "http://www.aol.com/";
              "http://www.yahoo.com/";
               "http://www.netscape.com/";
// go to that page:
header("Location: $location");
?>









 
Old April 4th, 2006, 05:52 AM
Authorized User
 
Join Date: Mar 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why you use if or else loop.There is no Need To use this
You simply write this code it will provide you the whole
information about your browser and OS
<?php
 $agent = getenv("http_user_agent");
$result = "you are using $agent";
echo $result;

Regards
Shekhar Srivastava
?>

 
Old April 4th, 2006, 07:31 AM
Authorized User
 
Join Date: Mar 2006
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello Dear
You Should Have Declear Header before
any echo/print statment or before any HTML tag
and before Header you can not live any blank line
I hope so it's solve your problem

With Best Regards
Shekhar Srivastava


 
Old May 11th, 2006, 05:54 AM
Authorized User
 
Join Date: May 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to kaos_frack
Default

Warning: preg_match() [function.preg-match]: Unknown modifier '1' in C:\broot\do_redirect.php on line 4

Code:
if (preg_match ("/msie/1", "$agent")) {...
did you wanted to write 'i' instead of '1'?






Similar Threads
Thread Thread Starter Forum Replies Last Post
php script m_29 Beginning PHP 2 October 5th, 2008 06:53 PM
send variables from a PHP script..... ethantinder Beginning PHP 2 June 23rd, 2008 02:45 PM
Putting PHP in a C++ script Waffles Beginning PHP 2 August 8th, 2007 06:49 AM
Convert English Char To Hindi Language in PHP Plz maheshoo7 PHP How-To 1 June 26th, 2007 10:21 AM
Call and run CGI script from a PHP script ... how? dbruins BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 June 10th, 2003 03:09 PM





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