[PHP] News System

You might want to make a backend script so the staff can post messages easier, as no one really wants to open SQL Management Studio every time they want to post a new message.

Other than that, fairly nice release.
 
Easy, i am brother of xGlast.
Here PHP Code to make new:
PHP:
<?php
mssql_connect("XXX\SQLEXPRESS", "sa", "pass");
mssql_select_db("ACCOUNT_DBF");
$ip = $_SERVER['REMOTE_ADDR'];
$time = date("F j, Y, g:i a");
echo '
<form action="add.php?accion=add" method="post">
<input name="title" value="Title Here" type="text"/><br>
<input name="external" value="#" type="text"/><br>
<select name="category">
<option value="1">News</option>
<option value="2">Events</option>
<option value="3">Patch Notes</option>
</select><br>
<input name="time" value="'.$time.'" type="text" readonly="readonly"/><br>
<input name="who" value="" type="text"><br>
<textarea name="content" value="Text here" type="text" width="111" rows="12"/></textarea><br>
<input size="20" type="submit" value="Submit"/>
</form>';
if(@$_GET['accion'] == "add"){
if(isset($_POST["title"])){
mssql_select_db("ACCOUNT_DBF");
mssql_query("INSERT into NEWS_TBL (title,title_url,category,when,who,content,ip,blocked) VALUES ('$_POST[title]','$_POST[external]','$_POST[category]','$_POST[time]','$_POST[who]','$_POST[content]','$ip','no')");
}
}
?>
Script Creted by XiDaX

PD: Sry for me bad English ...
 
Last edited by a moderator:
OBJECT NOT FOUND ._. in big letters its looking for add.php but cant find it i changed it to create.php but it wouldnt work. since where on this subject the script to find the database for the news wont show up QQ i hate mssql thats why i made one for mysql xD

edit: i made the add.php and got this error

Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near the keyword 'when'. (severity 15) in C:\xampp\htdocs\FFSilence\add.php on line 24

Warning: mssql_query() [function.mssql-query]: Query failed in C:\xampp\htdocs\FFSilence\add.php on line 24
 
Last edited:
OBJECT NOT FOUND ._. in big letters its looking for add.php but cant find it i changed it to create.php but it wouldnt work. since where on this subject the script to find the database for the news wont show up QQ i hate mssql thats why i made one for mysql xD

edit: i made the add.php and got this error

Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near the keyword 'when'. (severity 15) in C:\xampp\htdocs\FFSilence\add.php on line 24

Warning: mssql_query() [function.mssql-query]: Query failed in C:\xampp\htdocs\FFSilence\add.php on line 24

Try the new i putted.
I dont say it works because i use wamp and u xampp
 
Well. Here goes all the best scripts being released.
News system - A cool thing for a server to have. Sad it got released to the public.
Nice release <.<
 
Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near the keyword 'when'. (severity 15) in C:\xampp\htdocs\FFSilence\add.php on line 23

Warning: mssql_query() [function.mssql-query]: Query failed in C:\xampp\htdocs\FFSilence\add.php on line 23 tried D: i dunno i think my computer is failing xD
 
Fixed SQL:
Code:
USE [ACCOUNT_DBF]
GO
/****** Object:  Table [dbo].[NEWS_TBL]    Script Date: 08/10/2010 11:06:46 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[NEWS_TBL](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[title] [varchar](200) NULL,
	[title_url] [text] NULL,
	[category] [varchar](50) NOT NULL CONSTRAINT [DF_NEWS_TBL_category]  DEFAULT ('1'),
	[date] [text] NULL,
	[who] [text] NULL,
	[detalle] [text] NULL,
	[ip] [text] NOT NULL,
	[blocked] [varchar](1) NOT NULL CONSTRAINT [DF_NEWS_TBL_isblock]  DEFAULT ('no')
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
SET ANSI_PADDING OFF
Fixed "news.php"
create news.php
PHP:
<?php
function cat($cat)
{
	if($cat == '1')
	{
		return "News";
	}
	else if($cat == '2')
	{
		return "Events";
	}
	else if($cat == '3')
	{
		return "Patch Notes";
	}
}

$nbsp = "     ";
$conexion = mssql_connect("XXX\SQLEXPRESS", "user", "pass");
$db = mssql_select_db("ACCOUNT_DBF");
$consulta = mssql_query("SELECT * FROM NEWS_TBL WHERE blocked='no'");
$asoc = mssql_fetch_assoc($consulta);
?>
<h2>Title: <strong><a href="<?php echo $asoc['title_url']; ?>" alt="<?php echo $asoc['title']; ?>"><?php echo $asoc['title'];?></a></strong><?php echo $nbsp; ?>Posted by <strong><?php echo $asoc['who']; ?></strong></h2> in <strong><?php echo cat($asoc['category']); ?> category.</strong><br>
Content: <br>
<?php echo $asoc['detalle']; ?><br><br>
Date: <?php echo $asoc['date']; ?>
Fixed "add.php"
PHP:
   <?php
mssql_connect("XXX\SQLEXPRESS", "sa", "pass");
mssql_select_db("ACCOUNT_DBF");
$ip = $_SERVER['REMOTE_ADDR'];
$time = date("F j, Y, g:i a");
echo '
<form action="add.php?accion=add" method="post">
<input name="title" value="Title Here" type="text"/><br>
<input name="external" value="#" type="text"/><br>
<select name="category">
<option value="1">News</option>
<option value="2">Events</option>
<option value="3">Patch Notes</option>
</select><br>
<input name="time" value="'.$time.'" type="text" readonly="readonly"/><br>
<input name="who" value="" type="text"><br>
<textarea name="content" value="Text here" type="text" width="111" rows="12"/></textarea><br>
<input size="20" type="submit" value="Submit"/>
</form>';
if(@$_GET['accion'] == "add"){
if(isset($_POST["title"])){
mssql_select_db("ACCOUNT_DBF");
mssql_query("INSERT into NEWS_TBL (title,title_url,category,date,who,detalle,ip,blocked) VALUES ('$_POST[title]','$_POST[external]','$_POST[category]','$_POST[time]','$_POST[who]','$_POST[content]','$ip','no')");
}
}
?>
Sry for take a time to fix it.
Just press in thanks :)
Credits to XiDaX.

---------- Post added at 01:26 PM ---------- Previous post was at 01:22 PM ----------

Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near the keyword 'when'. (severity 15) in C:\xampp\htdocs\FFSilence\add.php on line 23

Warning: mssql_query() [function.mssql-query]: Query failed in C:\xampp\htdocs\FFSilence\add.php on line 23 tried D: i dunno i think my computer is failing xD

The problem is the script of query, SQL Server make a line called [when] and it is wrong, in query cant out [] extra, so just rename it or make me new script, [content] have the same problem.
Scroll up and try me new code.
 
Last edited by a moderator:
when i press Submit nothing happen

See, This guy probably didn't notice this(The guy who "fixed" the php script).

Here's the GOOD version:
PHP:
   <?php
mssql_connect("XXX\SQLEXPRESS", "sa", "pass");
mssql_select_db("ACCOUNT_DBF");
$ip = $_SERVER['REMOTE_ADDR'];
$time = date("F j, Y, g:i a");
echo '
<form action="add.php?accion=add" method="post">
<input name="title" value="Title Here" type="text"/><br>
<input name="external" value="#" type="text"/><br>
<select name="category">
<option value="1">News</option>
<option value="2">Events</option>
<option value="3">Patch Notes</option>
</select><br>
<input name="time" value="'.$time.'" type="text" readonly="readonly"/><br>
<input name="who" value="" type="text"><br>
<textarea name="content" value="Text here" type="text" width="111" rows="12"/></textarea><br>
<input size="20" type="submit" name="submit" value="Submit"/>
</form>';
if(@$_GET['accion'] == "add"){
if(isset($_POST["submit"])){
mssql_select_db("ACCOUNT_DBF");
mssql_query("INSERT into NEWS_TBL (title,title_url,category,date,who,detalle,ip,blocked) VALUES ('$_POST[title]','$_POST[external]','$_POST[category]','$_POST[time]','$_POST[who]','$_POST[content]','$ip','no')");
}
}
?>

Replace that.

-Apixen.

It should process your request.
 
How about you guys stop QQ'eing all the time? This **** is unique and helps alot of people. It's going to get leeched but it's not something that got leaked. If your any decent and your server's as decent as you say it is, you'll be able to come up with something unique and top the others. A simple news system doesn't top other servers. And who knows how many of you aren't using this.
I say, nice release.
 
How about you guys stop QQ'eing all the time? This **** is unique and helps alot of people. It's going to get leeched but it's not something that got leaked. If your any decent and your server's as decent as you say it is, you'll be able to come up with something unique and top the others. A simple news system doesn't top other servers. And who knows how many of you aren't using this.
I say, nice release.

You left tears in my eyes with that post.

Ahhh, but this comes all the way back to when people started hating the official files because they couldn't setup it (or even with Caali's files). If people can't setup it => they hate it and claim it's non functional. I wouldn't expect less from a community which is build and based on over 9000 13 years old who expect everything to be done in a second.

As for the release itself, it's different. Atleast it's not a god damn register script again. Seriously, they keep releasing the same old script over 9000 times but they can't even remember how to add neat stuff like AJAX to automatically check if the username/email already exists on the database. See, that's inovation.
 
Amen.

Why can't people EVER take the time to actually LEARN a web-language, or even a programming language. It's not that fuckin' hard. I did it. Well, I did it in 1 year - 2 years, but thats cause I really didn't take my time reading over stupid w3school ****. I went and used common sense. I looked at the source code, figured out what the **** it meant, and so on. It can't be that hard. I'm 12 years old, for crying out loud. I've set up my own server(Personal), I've coded my share of ****, and these fuckin' 20 year olds can't set their own **** up, and they have to leech to make a decent website.

/End Rage Mode

//Edit
I reached 600 posts!!!! W00T, GO ME!

Theres peoples who waste their childhood with friends and outside, and theres also peoples who stay behind computer all days.
 
Back