Jump to content


Photo

Switch is not working because of register_globals off


  • Please log in to reply
3 replies to this topic

#1 ramzess

ramzess
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 September 2006 - 06:48 AM

Hi guys!

I just found out that my code for changing contents of a table cell is not working on some servers.
Later I found out why - it is because 'register_globals'  in php.ini is Off. On ones I tried this simple script
it was On.

This is my simple code. Sure now way to make it even more simple. But What can I do about it?
How can I define this variable $cng? If I define it a value script stops working. :(
I can't believe - it should be so common to use this one, please, is there really no way out?


<?php
				switch ($cng) {

	case "1";
	require ('content/page1.php');
	break;

	case "2";
	require ('content/page2.php');
	break;

	default;
	require ('content/page0.php');
}
?>

Of course, links for calling in those pages is like:

<a href="?cng=1">Page 1</a> and <a href="?cng=2">Page 2</a>


Is there a solution? Thank you.

#2 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 20 September 2006 - 07:03 AM

Get the value of the variable from the querystring
$cng = $_GET['cng'];

switch ($cng) {

When coding, always assume the register_globals setting is OFF
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#3 ramzess

ramzess
  • Members
  • PipPip
  • Member
  • 15 posts

Posted 20 September 2006 - 07:14 AM

Thank you Barand. Thank you.

Oh yes, from now on I will work with register_globals Off to escape such situations
when you suddenly find something is not working somewhere.

Thank you.

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,021 posts

Posted 20 September 2006 - 07:20 AM

This should help

http://www.php.net/m...es.external.php
If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users