Whats wrong with this code?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Zanzubaa
Forum Newbie
Posts: 1
Joined: Mon Mar 20, 2006 10:02 am

Whats wrong with this code?

Post by Zanzubaa »

Pimptastic | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hiay, just got back from holiday to find my site down. As I understand it there r some code changes in php5 that need to b changes. The code for my menu is pretty simple but ive had a look around and not found a solution, doesnt help my php knowlege is limited.

http://www.trescom.co.uk

The menu system used simple image tabs that when clicked change colour and change the value of a variable which changes the page.

The first bit of code changes the tab image

Code: Select all

<?php
require_once('POPUP.JS');
if (empty($t1)) { 
$t1 = 't1_1'; 
$t2 = 't2_0'; 
$t3 = 't3_0'; 
} 
?>
When u click a tab is runs the code

Code: Select all

<? printf($t1)?>
or $t2 $t3 which ever is clicked.

The last bit of code changes the page:

Code: Select all

<? 
if ($c != "") {
include("".$c.".php");
} elseif ($c != 1) {
include("main.php");
} 
?>
Any help would b much appreciated, I have a feeling the change to make it php5 compatable is a simple one.


Pimptastic | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Run the following in a new file and tell us the results please.

Code: Select all

<?php

$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
$rg = (in_array(strtolower(ini_get('register_globals')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$de = (in_array(strtolower(ini_get('display_errors')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$so = (in_array(strtolower(ini_get('short_open_tag')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$eol = (isset($_SERVER['HTTP_HOST']) ? "<br />\n"  "\n");

$ec = array(
   'E_STRICT' => 2048,
   'E_ALL' => 2047,
   'E_USER_NOTICE' => 1024,
   'E_USER_WARNING' => 512,
   'E_USER_ERROR' => 256,
   'E_COMPILE_WARNING' => 128,
   'E_COMPILE_ERROR' => 64,
   'E_CORE_WARNING' => 32,
   'E_CORE_ERROR' => 16,
   'E_NOTICE' => 8,
   'E_PARSE' => 4,
   'E_WARNING' => 2,
   'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
   if (($t & $v) == $v)
   {
      $e[] = $n;
      $t ^= $v;
   }
}
$er = $er . ' (' . implode(' | ', $e) . ')';

echo 'PHP Version ' . $ve . $eol;
echo 'PHP OS ' . $os . $eol;
echo 'Error Reporting ' . $er . $eol;
echo 'Register Globals ' . $rg . $eol;
echo 'Short Tags ' . $so . $eol;
echo 'Display Errors ' . $de . $eol;

?>
jmut
Forum Regular
Posts: 945
Joined: Tue Jul 05, 2005 3:54 am
Location: Sofia, Bulgaria
Contact:

Post by jmut »

feyd wrote:Run the following in a new file and tell us the results please.

Code: Select all

<?php

$ve = phpversion();
$os = PHP_OS;
$er = intval(error_reporting());
$rg = (in_array(strtolower(ini_get('register_globals')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$de = (in_array(strtolower(ini_get('display_errors')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$so = (in_array(strtolower(ini_get('short_open_tag')), array(0, false, '', null, 'off')) ? 'Off' : 'On');
$eol = (isset($_SERVER['HTTP_HOST']) ? "<br />\n"  "\n");

$ec = array(
   'E_STRICT' => 2048,
   'E_ALL' => 2047,
   'E_USER_NOTICE' => 1024,
   'E_USER_WARNING' => 512,
   'E_USER_ERROR' => 256,
   'E_COMPILE_WARNING' => 128,
   'E_COMPILE_ERROR' => 64,
   'E_CORE_WARNING' => 32,
   'E_CORE_ERROR' => 16,
   'E_NOTICE' => 8,
   'E_PARSE' => 4,
   'E_WARNING' => 2,
   'E_ERROR' => 1,
);

$e = array();
$t = $er;
foreach ($ec as $n => $v)
{
   if (($t & $v) == $v)
   {
      $e[] = $n;
      $t ^= $v;
   }
}
$er = $er . ' (' . implode(' | ', $e) . ')';

echo 'PHP Version ' . $ve . $eol;
echo 'PHP OS ' . $os . $eol;
echo 'Error Reporting ' . $er . $eol;
echo 'Register Globals ' . $rg . $eol;
echo 'Short Tags ' . $so . $eol;
echo 'Display Errors ' . $de . $eol;

?>

It returns

Code: Select all

Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING in /storage/www/test/test.php on line 9
;)

Little fix:

Code: Select all

$eol = (isset($_SERVER['HTTP_HOST']) ? "<br />\n"  "\n");
//should be
$eol = (isset($_SERVER['HTTP_HOST']) ? "<br />\n" : "\n");
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

weird.. it used to have the colon.. hmm
Post Reply