Jump to content

[SOLVED] $_GET problem (3)


DEVILofDARKNESS

Recommended Posts

I think the problem is in the $_GET (again)...

 

the code doesn't work fine, it always give me the page where $type = "poem".

 

for the $_GET, the page link is: 4ade.uuuq.com/gedichten/test/testgedicht.php?poem_id=1&type=poem

 

<?php
/* DATABASE SETTINGS */

$test = (int)$_GET["poem_id"];
$type = $_GET["type"];

if(isset($test)) {
	$query= "SELECT p.*, u.*, c.*
  FROM poems p
  INNER JOIN users u ON u.user_id = p.user_id
  INNER JOIN categories c ON c.category_id = p.category_id
  WHERE p.poem_id = '$test'";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result)) :

if($type="poem") {
$title = $row['poem_name'];
$text = $row['poem_text'];
}elseif($type="info") {
$title = "INFO";
$text = "This is where the info should come";
} else {
echo "<script type='text/Javascript'>
	alert('This page doesn't exist, or is under construction, you will now be redirected to the main page.');
</script>";
header('location:../../index.html');
};
?>
<html dir="ltr">
    <head>
        <title><?php echo $title; ?></title>
        <link href="../../standard.css" type="text/css" rel="stylesheet" />
<link href='liefde.css' type='text/css' rel="stylesheet" />
    </head>
    <body>
        <table class="look" height="100%" width="100%" border="1">
            <tbody>
                <tr>
                    <td width="10%" height="100%"><iframe class="frames" src="../../functieknoppen/functieknoppengedicht.php?poem_id=<?php echo $_GET['poem_id']; ?>" frameborder="0" width="100%" height="100%" scrolling="no"></iframe>
                    </td>
                    <td><center>
<?php
echo $text;
?>
</center></td>
                </tr>
            </tbody>
        </table>
    </body>
</html>
<?php
endwhile;
}
?>

Link to comment
Share on other sites

when comparing items, you need to use a double equal sign: ==

 

if($type == "poem") { //Needed a double equal
   $title = $row['poem_name'];
   $text = $row['poem_text'];
}elseif($type == "info") { //Needed a double equal
   $title = "INFO";
   $text = "This is where the info should come";
} else {
   echo "<script type='text/Javascript'>
      alert('This page doesn't exist, or is under construction, you will now be redirected to the main page.');
   </script>";
   header('location:../../index.html');
};

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.