Jump to content


Photo

Help me with blog please.


  • Please log in to reply
11 replies to this topic

#1 Saturnfirefly

Saturnfirefly
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 14 June 2006 - 01:56 PM

Hi!
My english isn't good, so i cant say much. I need help with a blog-script i got from my friend, he cant do better so please help me with this script.
I'm not good at php so please, please help me.
Please dont remove any html-codes... it helps me to find everything.
Thanx!

Index of blog.
<div id="content">
<?php
session_start();
include "conn.php"; // Databasanslutningen
if (isset($_GET['ny_nyhet'])){
if (isset($_SESSION['sess_firefly'])){
echo "<h1>Skriv en ny nyhet:</h1>";
if (isset($_POST['submit'])){
 $date = date("Y-m-d H:i:s");
  // Tag bort eventuella blanksteg i början eller slutet
  foreach($_POST as $key => $val){
    $_POST[$key] = trim($val);
  }
 $sql = "INSERT INTO firefly_news(av, nyhet, rubrik, date, cat)
            VALUES('{$_SESSION['sess_firefly']}', '{$_POST['nyhet']}', '{$_POST['rubrik']}', '{$date}', '{$_POST['cat']}')";
    mysql_query($sql) or die("sql: $sql<br/>".mysql_error());

    echo "En ny nyhet är klar =)";
    exit;
  }


?>

Skriv en ny nyhet!
<form action="index.php?ny_nyhet=" method="post">
<table cellspacing="3">
 <?php
 $result = @mysql_query("SELECT * FROM firefly_news_cat")
  or die("Error fetching data<br>".mysql_error());
    echo '
 <select name="cat">
 
<option selected value="Välj här!">Välj här!</option>';
while ($row = @mysql_fetch_array($result)){
    echo '
<option value="'.$row['id'].'">'.$row['rubrik'].'</option>
'; 
}
echo '</select>';
?>
<tr>
<td>Rubrik:</td>
<td><input type="text" name="rubrik" value=""></td>
</tr>
<tr>
<td></td>
<td><textarea cols="35" rows="10" name="nyhet"></textarea></td>
</tr>

 
<tr>
<td colspan="2" align="center">
  <input type="submit" name="submit" value="Spara!">
</td>
</tr>
 
</table>
</form>


<?php

}
}elseif (isset($_GET['ny_nyhets_cat'])){
if (isset($_SESSION['sess_firefly'])){
echo "<h1>Skapa en ny nyhets kategorie:</h1>";
if (isset($_POST['submit'])){
  // Tag bort eventuella blanksteg i början eller slutet
  foreach($_POST as $key => $val){
    $_POST[$key] = trim($val);
  }
 $sql = "INSERT INTO firefly_news_cat(rubrik)
            VALUES('{$_POST['rubrik']}')";
    mysql_query($sql) or die("sql: $sql<br/>".mysql_error());

    echo "En ny nyhets kategorie är klar =)";
    exit;
  }


?>
Skapa en ny kategorie till nyheterna
<form action="index.php?ny_nyhets_cat=" method="post">
<table cellspacing="3">
 
 
<tr>
<td>Namn på kategorin:</td>
<td><input type="text" name="rubrik" value=""></td>
</tr>

 
<tr>
<td colspan="2" align="center">
  <input type="submit" name="submit" value="Spara!">
</td>
</tr>
 
</table>
</form>

<?php

}
}elseif (isset($_GET['comment'])){

include "conn.php"; // Databasanslutningen
$resultt= @mysql_query("SELECT * FROM firefly_news WHERE id = {$_GET['comment']}")
  or die("Error fetching data<br>".mysql_error());
while ($row = @mysql_fetch_array($resultt)){
echo ' 
<h3> '.$row['rubrik'].'</h3></font></b>
<font face="arial" color="888888" size="1"> Written by:  '.$row['av'].' | '.$row['date'].'<br><br></font>
'.nl2br($row['nyhet']).'<br><br><font size="2"> Comments on "'.$row['rubrik'].'".</font> ';
echo '<br>';
if (isset($_SESSION['sess_firefly'])){
echo '<a href="index.php?edit='.$row['id'].'">Ändra</a>';
}
}

echo '<br>';
$result = @mysql_query("SELECT * FROM firefly_com WHERE nyhet = {$_GET['comment']} ORDER by id DESC")
  or die("Error fetching data<br>".mysql_error());
 if (mysql_num_rows($result) == 0) {
echo "<i>No comments yet =(.</i><br><br>";
}else{ 
while ($row = @mysql_fetch_array($result)){
echo 'From:<b> <a href="mailto:' . $row['mail'] . '">' . $row['av'] . '</a> ' .$row['date'] . ' <br></b> ' . nl2br($row['text']) . '';
echo '<br>';
if (isset($_SESSION['sess_firefly'])){
echo '<a href="index.php?del='.$row['id'].'">Ta bort denna kommentar</a>';
}
echo '<br><br>';
}
}


$date = date("Y-m-d H:i:s");

if (isset($_POST['post'])){

    $sql = "INSERT INTO firefly_com(nyhet, av, text, date, mail)
            VALUES('{$_GET['comment']}', '{$_POST['namn']}', '{$_POST['kom']}', '{$date}', '{$_POST['email']}')";
    mysql_query($sql)
        or die("Error fetching data<br>".mysql_error());
              echo 'Din kommentar blev postad utan problem! <a href="index.php">Gå tillbaka till startsidan</a>';
    exit;     
 
}
?>

<?php
echo '
<form method="post" action="' . $_SERVER['REQUEST_URI'] . '">
';
?>
Namn:<br>
<input type="text" name="namn" value=""><br>
Din email adress:<br>
<input type="text" name="email" value=""><br>
Kommentar:<br>
<textarea cols="35" rows="10" name="kom"></textarea><br>
<input type="submit" name="post" value="Kommentera!">

</form>
<?php
}elseif (isset($_GET['edit'])){
if (isset($_SESSION['sess_firefly'])){
echo "<h1>Ändra nyheten:</h1>";
// Tag bort eventuella blanksteg i början eller slutet
  foreach($_POST as $key => $val){
    $_POST[$key] = trim($val);
  }
if(isset($_POST['su']))
{
$sql = "UPDATE firefly_news
 
        SET rubrik = '".$_POST['rubrik']."',
                nyhet = '".$_POST['nyhet']."'
        WHERE id = '{$_GET['edit']}'";
            
mysql_query($sql) or die("SQL: $sql <br>".mysql_error());
echo "Nyheten är nu ändrad!";
   exit;
}
$sql = "SELECT * FROM firefly_news WHERE id = '{$_GET['edit']}'";
$result = mysql_query("$sql") or die("$sql funkade inte...");
while($rad = mysql_fetch_array($result))
{
echo '
<form method="POST" action="' . $_SERVER['REQUEST_URI'] . '"><input type="hidden" name="id" value="'.$_GET['edit'].'">
Rubrik:<br>
<input type="text" name="rubrik" value="'.$rad['rubrik'].'" size="20">
<br>Nyheten:<br>
<textarea cols="35" rows="10" name="nyhet">'.$rad['nyhet'].'</textarea>
<input type="submit" name="su" value="Spara">
</form>
';
}
}
}elseif (isset($_GET['del'])){
if (isset($_SESSION['sess_firefly'])){
$sql = "DELETE FROM firefly_com WHERE id = ".intval($_GET['del']);
mysql_query($sql);

echo "Kommenteren är nu borttagen =(";
exit;
}
}elseif (isset($_GET['del_news'])){
if (isset($_SESSION['sess_firefly'])){
$sql = "DELETE FROM firefly_news WHERE id = ".intval($_GET['del_news']);
mysql_query($sql);

echo "Nyheten är nu borttagen =(";
exit;
}
}elseif (isset($_GET['arkiv'])){
if (isset($_GET['id'])){

$query = mysql_query("SELECT * FROM firefly_news WHERE cat = '{$_GET['id']}' ORDER BY id DESC")
or die(mysql_error());

while($row = mysql_fetch_array($query))
{

$queryy = mysql_query("SELECT * FROM firefly_com WHERE nyhet = '{$row['id']}'")
or die(mysql_error());
$antal=mysql_num_rows($queryy);

echo ' 
<h3> '.$row['rubrik'].'</h3></font></b>
<font face="arial" color="888888" size="1"> Written by: '.$row['av'].' | '.$row['date'].'<br><br></font>
'.nl2br($row['nyhet']).'<br> <img src="underline.gif">';
echo '<a href="index.php?comment='.$row['id'].'"><font face="arial" size="1"> <img border="0" src="postcomment.gif"> Comment ('.$antal.') </a></font></a>';
echo '<br>';
if (isset($_SESSION['sess_firefly'])){
echo '<a href="index.php?edit='.$row['id'].'">Ändra</a>';
echo '<br><a href="index.php?del_news='.$row['id'].'">Ta bort denna nyhet</a>';
}
echo '<br><br>';
}
}else{

$query = mysql_query("SELECT * FROM firefly_news ORDER BY id DESC")
or die(mysql_error());

while($row = mysql_fetch_array($query))
{

$queryy = mysql_query("SELECT * FROM firefly_com WHERE nyhet = '{$row['id']}'")
or die(mysql_error());
$antal=mysql_num_rows($queryy);

echo ' 
<h3> '.$row['rubrik'].'</h3></font></b> <img src="underline.gif"> <img src="underline.gif">
<font face="arial" color="888888" size="1"> Written by: '.$row['av'].' | '.$row['date'].'<br><br></font>
'.nl2br($row['nyhet']).'<br> <img src="underline.gif">';
echo '<a href="index.php?comment='.$row['id'].'"><br><font face="arial" size="1"> <img border="0" src="postcomment.gif"> Comment ('.$antal.') </a></font></a>';
echo '<br>';
if (isset($_SESSION['sess_firefly'])){
echo '<a href="index.php?edit='.$row['id'].'">Ändra</a>';
echo '<br><a href="index.php?del_news='.$row['id'].'">Ta bort denna nyhet</a>';
}
echo '<br><br>';
}
}
}else{

$query = mysql_query("SELECT * FROM firefly_news ORDER BY id DESC")
or die(mysql_error());

while($row = mysql_fetch_array($query))
{

$queryy = mysql_query("SELECT * FROM firefly_com WHERE nyhet = '{$row['id']}'")
or die(mysql_error());
$antal=mysql_num_rows($queryy);


echo ' 
<h3> '.$row['rubrik'].'</h3></font></b>
<font face="arial" color="888888" size="1"> Written by: '.$row['av'].' | '.$row['date'].'<br><br></font>
'.nl2br($row['nyhet']).'<br> <img src="underline.gif">';
echo '<a href="index.php?comment='.$row['id'].'"><font face="arial" size="1"> <img border="0" src="postcomment.gif"> Comment ('.$antal.') </a></font></a>';
echo '<br>';
if (isset($_SESSION['sess_firefly'])){
echo '<a href="index.php?edit='.$row['id'].'">Ändra</a>';
echo '<br><a href="index.php?del_news='.$row['id'].'">Ta bort denna nyhet</a>';
}
echo "<br><br>";
}

}
?> <br><br></div>


Admin.

<div id="content">
<?php
session_start();
if (isset($_GET['logout'])){
  session_unset();
  session_destroy();
    echo "Utloggad!";
  exit;
} 
if (!isset($_SESSION['sess_firefly'])){
if (isset($_POST['submit'])){
if ($_POST['name'] == "losenord" && $_POST['pass'] == "losenord"){
$_SESSION['sess_firefly'] = $_POST['name'];
header("Location: index.php");
}else{
echo "Herregud, du försöker ju bara göra intrång, sluta!";
exit;
}
}
?>
<form action="admin.php" method="post">
Användarnamn:<br>
<input type="text" name="name"><br>
Lösenord:<br>
<input type="password" name="pass"><br>
<input type="submit" name="submit" value="Logga in">
</form>
<?php
}else{
echo "Du är inloggad som Admin, här kan du inte ändra något, de gör du direkt på nyheterna;)";
}
?> <br><br></div>


And last. Sidebar
<a href="index.php">  Startsidan</a><br>
<a href="index.php?arkiv=">  Alla nyheter</a><br>
<a href="admin.php">  Admin</a><br>
<br>
<font face="arial" size="2"><b>Categories</b><br></font>
<font face="arial">
<?php
$query = mysql_query("SELECT * FROM firefly_news_cat ORDER BY id DESC")
or die(mysql_error());

while($row = mysql_fetch_array($query))
{
$queryy = mysql_query("SELECT * FROM firefly_news WHERE cat = '{$row['id']}'")
or die(mysql_error());
$antal=mysql_num_rows($queryy);
echo '
<a href="index.php?arkiv=&id='.$row['id'].'">  '.$row['rubrik'].'</a> <font face="arial" color="888888">('.$antal.')<br>
';
}
?><br></font>


<?php
if (isset($_SESSION['sess_firefly'])){
?>
<font face="arial" size="2"><b>Administrate</b></font><br>
<font face="arial">
<a href="index.php?ny_nyhet=">  Ny nyhet</a><br>
<a href="index.php?ny_nyhets_cat=">  Ny nyhets kategorie</a><br>
<a href="admin.php?logout=">  Logga ut</a>
<?php
}
?> </div>


#2 Chips

Chips
  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 14 June 2006 - 01:58 PM

Help in what way? That's a lot of code to look at without knowing what you are supposed to be looking for to be honest. Any more?

#3 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 14 June 2006 - 01:59 PM

You didn't write the script, you didn't say what was wrong with it, and you obviously didn't even try to work with it. I'm about 3 seconds away from closing the thread. If you're asking for modifications, go to the freelance board. We're not here to add features to your stuff. We're here to help you work through errors and problems and understanding things.

Info: PHP Manual


#4 Saturnfirefly

Saturnfirefly
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 14 June 2006 - 02:00 PM

Well, im just wondering if somone find something wrong or something that isn't supposed to be there. Im sorry if i didnt explain so good

Because i think something is wrong with the code, it wont connect thru the conn.php and the conn.php is full correct so it has to be something with the code.

#5 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 14 June 2006 - 02:01 PM

??????? You haven't said if there is anything wrong with it or not! Are you getting any error messages?

If you're asking us to double-check someone else's work, take it somewhere else.

Info: PHP Manual


#6 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 14 June 2006 - 02:02 PM

man there's something severely wrong with the script, errors everywhere, it just needs some work of whoever made it
z..z..z..z..z..z..z..z..

#7 Saturnfirefly

Saturnfirefly
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 14 June 2006 - 02:06 PM

Well... im sorry if everyone missunderstood me..:(

My friend coded it, and he aint so good on php either, and now he cant help me anymore because he dont know howtodo.... so im asking you guys.

#8 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 14 June 2006 - 02:08 PM

look there's no point getting someone to go through that entire parade of code, if you have anything in the future you'll have to ask for small things. You have to learn php to use it. In any case if there's something specifically wrong apart from the all around consitency of the code then what would it be?
z..z..z..z..z..z..z..z..

#9 Saturnfirefly

Saturnfirefly
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 14 June 2006 - 02:18 PM

Well, im getting wrong with the connection:
<?php
$db = mysql_connect('localhost', 'juicy_clan_com', 'passw') or die("Kan inte sluta till databasen eftersom: ".mysql_error());
mysql_select_db("juicy_clan_com");
?>

So i asked the B-one support about help and they said that the connection is fully correct but that it is something wrong with the blog-script, and not anything else.


Im getting this error:
Access denied for user: 'juicy_clan_com@localhost' (Using password: YES)



#10 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 14 June 2006 - 02:22 PM

Then you have incorrect login info for the database.

Then you have incorrect login info for the database.

Info: PHP Manual


#11 Saturnfirefly

Saturnfirefly
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 14 June 2006 - 02:31 PM

No, i actually don't have.
They said that the conn.php is correct to the login info. :(

#12 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 14 June 2006 - 02:34 PM

this error will only appear if the username / password is wrong or if you do not have access from your address
z..z..z..z..z..z..z..z..




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users