reza777 Posted June 21, 2006 Share Posted June 21, 2006 basically i am learning php and i have copied the following code from a book and saved it on my server but everytime i run it it wont execute properly and all i get is this:[a href=\"http://www.persian-princes.com/learnphp/phpinfo.php\" target=\"_blank\"]http://www.persian-princes.com/learnphp/phpinfo.php[/a]i know there is nothing wrong with the code as it works on my cousins server:[a href=\"http://lucylayton.com/phpinfo.php\" target=\"_blank\"]http://lucylayton.com/phpinfo.php[/a]i contacted my host (im running a dedicated server so i have root access) and they said:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Thank you for contacting customer support. There may be a custom configuration that you have to set on the server such as with the php.ini file. Unfortunately, we do not provide assistance with third party coding issues.[/quote]does anyone know why i am having this proble? ok it wouldnt let me copy the code here, but what it does is basically display the users browser, ip address and name of the file thats all Quote Link to comment https://forums.phpfreaks.com/topic/12548-im-learning-php-but-wont-execute/ Share on other sites More sharing options...
wildteen88 Posted June 21, 2006 Share Posted June 21, 2006 Are you using echo or print to output the information? Also what variables are you using to get the filename, user agent (web browser) and ip address.Also could you paste you code here, you should be able to. If you code has functions add a space before the parenthesis like so:[code]function_name ()[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12548-im-learning-php-but-wont-execute/#findComment-48067 Share on other sites More sharing options...
reza777 Posted June 21, 2006 Author Share Posted June 21, 2006 [code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>Information</title></head><body><?php# This page lists some cool information for the userecho "You are running the file <b>$PHP_SELF</b>.<br />\n";echo 'You are viewing this page using: <b>', $HTTP_USER_AGENT, '</b>.<br />from IP address ', $REMOTE_ADDR;?></body></html>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/12548-im-learning-php-but-wont-execute/#findComment-48079 Share on other sites More sharing options...
wildteen88 Posted June 21, 2006 Share Posted June 21, 2006 Umm,. just as I thought! The book is teaching you old code, well not old, but deperciated code. Try this instead:[code]<?php# This page lists some cool information for the userecho "You are running the file <b>$_SERVER['PHP_SELF']</b>.<br />\n";echo 'You are viewing this page using: <b>', $_SERVER['HTTP_USER_AGENT'], '</b>.<br />from IP address ', $_SERVER['REMOTE_ADDR'];?>[/code]The problem is to do with a PHP setting called [a href=\"http://uk.php.net/register_globals\" target=\"_blank\"]register_globals[/a] Quote Link to comment https://forums.phpfreaks.com/topic/12548-im-learning-php-but-wont-execute/#findComment-48082 Share on other sites More sharing options...
reza777 Posted June 21, 2006 Author Share Posted June 21, 2006 ok i see you have added $_SERVER before the variablesso do i now have to add this to every variable when writing php regardless og wot the book says?i dont quite understand why u have done this?i read the register_globals link u sent me but couldnt make much sense of itshould i just change the register global setting on my server? im running a mambo site on my server also, would doing this harm my site?!!really confused thank u for ur help i appreciate it :) Quote Link to comment https://forums.phpfreaks.com/topic/12548-im-learning-php-but-wont-execute/#findComment-48090 Share on other sites More sharing options...
kenrbnsn Posted June 21, 2006 Share Posted June 21, 2006 Please read the section on [a href=\"http://www.php.net/register_globals\" target=\"_blank\"]register_globals[/a] in the manual on php.net. Also read the section on [a href=\"http://www.php.net/manual/en/language.variables.external.php\" target=\"_blank\"]Variables from outside PHP[/a].Ken Quote Link to comment https://forums.phpfreaks.com/topic/12548-im-learning-php-but-wont-execute/#findComment-48099 Share on other sites More sharing options...
wildteen88 Posted June 21, 2006 Share Posted June 21, 2006 Dont change the register_globals setting at all as can create a security issue.The variable I used is part of a group of variables called [a href=\"http://uk2.php.net/manual/en/language.variables.predefined.php#language.variables.superglobals\" target=\"_blank\"]super globals[/a]You only use these variables when you need to access server information, cookie, session, post'd and get data etc.I would suggest you get a book that is uptodate and doesnt use register_globals for its examples. Quote Link to comment https://forums.phpfreaks.com/topic/12548-im-learning-php-but-wont-execute/#findComment-48101 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.