Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP How-To
|
PHP How-To Post your "How do I do this with PHP?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP How-To 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 September 11th, 2005, 04:03 AM
Registered User
 
Join Date: Sep 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default help: register_global=off, I can not get URL

I set register_global=off in php.ini file, and I found my codes as
below does not work:
================================================== =================
<html>

<body>
<?php
$myid=$_GET['myid'];
$db = mysql_connect("localhost", "root", "949701");
mysql_select_db("school",$db);

if ($myid) {
   $result = mysql_query("SELECT * FROM teacher WHERE id=$myid",$db);
   $myrow = mysql_fetch_array($result);
   printf("name: %s\n<br>", $myrow["name"]);
   printf("address: %s\n<br>", $myrow["address"]);
   printf("year: %s\n<br>", $myrow["year"]);
}
else
{
    $result = mysql_query("SELECT * FROM teacher",$db);
    if ($myrow = mysql_fetch_array($result))
    {
        do {
                printf("<a href=\"%s?$myid=%s\">%s %s</a><br>\n",$_SERVER['PHP_SELF'],
                $myrow["id"], $myrow["name"], $myrow["address"]);
            } while ($myrow = mysql_fetch_array($result));
    }
    else
    {
        echo "sorry no records!";
    }
}
?>
</body>
</html>
================================================== ==================
The error is as below:
Notice: Undefined index: myid in D:\Apache Group\Apache2\htdocs\tt.php on line 6

I don't know how to define the variable "myid" when register_global=off. and my intention in my above code is to
get the related record through "myid".

Thanks in advance!







Similar Threads
Thread Thread Starter Forum Replies Last Post
URL Redirect based on given URL somnath.kartic VS.NET 2002/2003 1 August 2nd, 2012 08:21 AM
URL rewriting with URL forwarding mtabyana BOOK: Professional Search Engine Optimization with PHP: A Dev's Guide to SEO ISBN: 978-0-470-10092-9 0 October 22nd, 2007 08:22 AM
URL MunishBhatia ASP.NET 2.0 Professional 4 May 11th, 2007 10:31 AM
extract URL from Favorites (.URL Files) PhilHawks VB.NET 2002/2003 Basics 2 November 2nd, 2004 04:35 AM
register_global "OFF" and extract command growch BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 6 November 7th, 2003 02:29 AM





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