Developing a newscript, problem.
Posted: Thu Oct 08, 2009 6:36 pm
Hey, well i've been workin' on a newsscript that I'm going to use on my homepage.
Now, my problem is not to fetch the news from my database. But to write to the DB.
I've checked if my var.php file is wrong, but since i can get information out of my db from my News.php file. It should be correct?
Here is my add.php file: --Newb, on php =)
var.php
Hope some of you guys can help me
I'm sorry my bad english. I'm a norwegian =)
Now, my problem is not to fetch the news from my database. But to write to the DB.
I've checked if my var.php file is wrong, but since i can get information out of my db from my News.php file. It should be correct?
Here is my add.php file: --Newb, on php =)
Code: Select all
<?php
include "var.php";
if ($action==add) {
mysql_query("INSERT INTO news (title, content) VALUES ('".$_POST['title']."', '".$_POST['content']."')");
echo "<a href='news.php'>Home?</a>";
} else {
print "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
<tr>
<td><form name=\"form1\" method=\"post\" action=\"add.php?action=add\">
<div align=\"center\">
<p>Title:
<input type=\"text\" name=\"textfield\">
</p>
<p>Skriv :
<textarea name=\"title\" cols=\"50\" rows=\"10\" id=\"title\"></textarea>
</p>
<p>
<input type=\"submit\" name=\"submit\" value=\"Add\">
</p>
</div>
</form></td>
</tr>
</table>\n";
}
?>Code: Select all
<?php
////////////////////////////////////////////////////////////////////////////////////////
$news_limit="11";
$host="localhost";
$username="xxxxxx";
$password="xxxxxx";
$db_name="xxxxxx";
$tbl_name="xxxxxx";
$bullet="www.mysite.url/my_image.png";
$title_cell_color="#999999";
$news_cell_color="#999999";
////////////////////////////////////////////////////////////////////////////////////////
$db = mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name", $db)or die("cannot select DB");
?>Hope some of you guys can help me
I'm sorry my bad english. I'm a norwegian =)