LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-10-2008, 03:50 AM   #1
@ngelot
Member
 
Registered: Oct 2004
Posts: 84

Rep: Reputation: 15
php5 if-else


I've been using apache/php4 for some time, and now I've set up a new server with a fresh apache2/php5.

With apache/php4 I used ex. index.php?id=2 and in the script:
Code:
<?

if ($id) {

echo 'Hi - its a nice day';

} else {

echo 'Bye - have a nice day';

}

?>
I can't get this working in apache2/php5. Is there an error in the syntax?
On apache2/php5 I'm using /etc/php5/apache2/php.ini and on apache/php4 I was using /etc/php4/cli/php.ini. Do I have to enable something in php.ini to get this working? Any modules I may need? This is my settings from /etc/apache2/sites-available/default:
Code:
DocumentRoot /var/www/
   <Directory />
      Options FollowSymLinks
      AllowOverride None
   </Directory>
   <Directory /var/www/>
      Options Indexes Includes FollowSymLinks MultiViews ExecCGI
      AllowOverride All
      Order allow,deny
      Allow from all
   </Directory>
Thanks!
 
Old 02-10-2008, 06:12 AM   #2
rubadub
Member
 
Registered: Jun 2004
Posts: 236

Rep: Reputation: 33
Code:
$id = $_GET['id'];
That should do the trick, it also means you won't have to rely on php.ini settings!, also see $_POST and $_REQUEST if your not familiar.
 
Old 02-11-2008, 04:00 AM   #3
@ngelot
Member
 
Registered: Oct 2004
Posts: 84

Original Poster
Rep: Reputation: 15
Thanks!

It was an ' vs " error.

It seems that I can't mix the two.

php4: include("'.$id.'.php");

php5: include "$id.php";
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
installing src php5 or tar php5 step by step jatender Linux - Software 2 06-28-2007 10:29 AM
FC 6 - php5 idgeitman Fedora 1 01-08-2007 10:43 PM
Need Some Help With PHP5 mtndew Linux - Software 3 01-30-2006 10:07 PM
Php5 Thanotos Linux - Newbie 2 12-07-2005 10:39 AM
php5 Hampster Linux - Software 4 01-09-2005 04:50 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration