Jump to content

Doesn't show anything


Livijn

Recommended Posts

I coded this for like 1 month ago and i still can't get it to work.

The page just turns white. No errors and so on.

 

<? include "online_header.php"; ?>
<h1>Admin</h1>
<div class="pagemenu">
<a href="admin.php?news=true&add=true">Nyheter</a> <img src="images/line.png">
<a href="admin.php?members=true">Medlemmar</a>
</div>

<p>
<?php

// Kolla om det är en admin
$yuu = mysql_query("SELECT * FROM members WHERE user='$_SESSION[sess_user]'")or die(mysql_error());
$ytr = mysql_fetch_array($yuu)or die(mysql_error());
if ($ytr['level'] != 3) {
header("Location: welcome.php");
break;
}

// Nyheter, skapa, radera, ändra
if (isset($_GET['news']) {

//Lägg till (skickat)
if (isset($_POST['add'])) {
if (empty($_POST['subject']) || empty($_POST['text'])) {
echo "Du måste fylla i alla fält. Dumma admin!";
} else {

$ddd = date("Y-m-d H:i:s");
mysql_query("INSERT INTO news (`date`, `by`, `subject`, `text`)VALUES('$ddd', '$_SESSION[sess_user]', '$_POST[subject]', '$_POST[text]')")or die(mysql_error());
echo "Nyheten har lagts till!";
}
}

// Lägg till
if (isset($_GET['add'])) {
?>
<form action="admin.php?news=true" method="POST">
Ämne: <input type="text" name="subject" maxlength="20"><br>
Text: <textarea name="text" rows="10" cols="20"></textarea><br>
<input type="submit" name="add" value="Lägg till">
</form>
<?php
}

// Ändra (skickat)
if (isset($_POST['change'])) {
mysql_query("UPDATE news SET `subject`='$_POST[subject]', `text`='$_POST[text]'")or die(mysql_error());
echo "Din ändring är klar!";
}

// Ändra
if (isset($_GET['change'])) {
if (isset($_GET['show'])) {
$myw = mysql_query("SELECT * FROM news WHERE id='$_GET[show]'")or die(mysql_error());
$trw = mysql_fetch_array($myw);
?>
<form action="admin.php?news=true&id=<?= $trw['id']; ?>" method="POST">
Ämne: <input type="text" name="subject" maxlength="20" value="<?= $trw['subject']; ?>"><br>
Text: <textarea name="text" rows="10" cols="20"><?= $trw['text']; ?></textarea><br>
<input type="submit" name="change" value="Lägg till">
</form>
<?php
} else {
?>

<table cellpadding='0' cellspacing='0'>
   <tr>
      <td width='190'><b>Ämne</b></td>
      <td width='100'><b>Datum</b></td>
      <td></td>
  </tr>

<?php

$i = 1;
$qnyeter = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 10")or die(mysql_error());
while($rad = mysql_fetch_array($qnyeter)) {
	$i++;
if(($i%2))
{
$bg = "#828282";
}
else
{
$bg = "";
}
?>
   <tr bgcolor=<?php echo "'".$bg."'"; ?>>
      <td><a href="news.php?news=true&change=true&show=<?php echo $rad['id']; ?>"><?php echo $rad['subject']; ?></a></td>
      <td><?php echo $rad['date']; ?></td>
</tr>
<?php
}
echo '</table>';
}
}

//Delete (vald)
if (isset($_GET['deleta'])) {
mysql_query("DELETE FROM news WHERE `id`='$_GET[deleta]'")or die(mysql_error());
echo "Du har deletat en nyhet!";
}

//Deleta
if (isset($_GET['delete'])) {
?>

<table cellpadding='0' cellspacing='0'>
   <tr>
      <td width='190'><b>Ämne</b></td>
      <td width='100'><b>Datum</b></td>
      <td></td>
  </tr>

<?php

$i = 1;
$qnyeter = mysql_query("SELECT * FROM news ORDER BY id DESC LIMIT 10")or die(mysql_error());
while($rad = mysql_fetch_array($qnyeter)) {
	$i++;
if(($i%2))
{
$bg = "#828282";
}
else
{
$bg = "";
}
?>
   <tr bgcolor=<?php echo "'".$bg."'"; ?>>
      <td><a href="news.php?news=true&deleta=<?php echo $rad['id']; ?>"><?php echo $rad['subject']; ?></a></td>
      <td><?php echo $rad['date']; ?></td>
</tr>
<?php
}
echo '</table>';
}
}


?>
<div class="pagemenu">
<a href="admin.php?news=true&add=true">Lägg till</a> <img src="images/line.png">
<a href="admin.php?news=true&change=true">Ändra</a> <img src="images/line.png">
<a href="admin.php?news=true&delete=true">Radera</a>
</div>
<?
}
?>
</p>
<? include "footer.php"; ?>

It's a long code, but please, help me.

http://livijndesign.se/test.php

You can see thats nothing haswrong color.

 

Whats wrong?

Link to comment
https://forums.phpfreaks.com/topic/41806-doesnt-show-anything/
Share on other sites

I can't remember exactly if doing it the way you're doing it works or not, but try this...

 

instead of

if (isset($_GET['add'])) {
?>
<form action="admin.php?news=true" method="POST">
Ämne: <input type="text" name="subject" maxlength="20"><br>
Text: <textarea name="text" rows="10" cols="20"></textarea><br>
<input type="submit" name="add" value="Lägg till">
</form>
<?php
}

 

do this

if (isset($_GET['add'])) {

    echo('
    <form action="admin.php?news=true" method="POST">
    Ämne: <input type="text" name="subject" maxlength="20"><br>
    Text: <textarea name="text" rows="10" cols="20"></textarea><br>
    <input type="submit" name="add" value="Lägg till">
    </form>
    ');
}

Link to comment
https://forums.phpfreaks.com/topic/41806-doesnt-show-anything/#findComment-202782
Share on other sites

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.