Jump to content

What's wrong with this code?


ValkR

Recommended Posts

But the syntax is wrong and you can't include a, variable... but you can echo it.. Im guessing you want somthing more like this:

 

  <?php
    $a = '2';
    if($_POST['number']==1){echo $a;}
  ?>

 

Or if you are actualy trying to include a file, do what Kira said.

Just out of curiosity,

 

How does

<?php
$file = 'filename.php';
if (isset($_POST['number']) && $_POST['number'] == '1')
{    
include($file);
}
?>

 

And

<?php    
$a = '2';    
if($_POST['number']==1){echo $a;}  
?>

 

do what you want?  They perform completely different actions?

 

Our if statements are basically the same.  All I did was check that it's set, and that it equals the value you want.

 

The variables are just strings, except mine has ".php" on the end of it which usually means you're pointing it to a file.  What you name the variable really don't matter.

 

Inside the if statements are what actually makes the difference.  His echoes the variable, which prints it out, and mine includes the variable, which pulls the data from the file in the variable to the file it's included in.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.