PHP help and tutroials Created 19 years ago2005-07-20 14:40:41 UTC by Luke Luke

Created 19 years ago2005-07-20 14:40:41 UTC by Luke Luke

Posted 19 years ago2005-07-23 13:22:20 UTC Post #122975
Why the hell doesnt dreamweaver do that? I might not have it on :o

ok, i see, seventh.
Luke LukeLuke
Posted 19 years ago2005-07-23 13:26:54 UTC Post #122977
Dreamweaver colors and highlights text too... but I perfer using Notepad++, but does anyone know how to turn off the feature that makes a .bak of the file whenever you save it?

BTW, on my site emeraldchapter.dyndns.org its all run by PHP and coded by me, if you want to know how to do any of it ill be glad to send you the code.

Oh, and I almost forgot www.phpfreaks.com has been an excellent source of information for me, because not only do they have some tutorials (most are preety advanced) but they have a huge community on the forums to answer any newbie question you may have. Just goto the Newbie Help forum :P
Posted 19 years ago2005-07-23 13:52:18 UTC Post #122984
Sweet, thanks.

Acctualy, PHP freaks has been helping me a lot in making this script.
Luke LukeLuke
Posted 19 years ago2005-07-23 15:09:30 UTC Post #123003
Parse error: parse error, unexpected $ in /home/iemc/public_html/nukesilo/news_add.php on line 34

Ok, look at the same text file i posted earlier. As you can see, on line 34, its the </html> tag... Now.. wtf..
Luke LukeLuke
Posted 19 years ago2005-07-23 15:56:10 UTC Post #123011
Well, I can only see one closing curly brace for if constructs there.

Indent your code properly.
Seventh-Monkey Seventh-MonkeyPretty nifty
Posted 19 years ago2005-07-23 16:00:15 UTC Post #123012
I'll be honest your code is a bit different to mine so I dunno whats up with that. Here's some edited snippets of my code from emeraldchapter.dyndns.org . Just forget the function line. The $authorized is makes sure your logged in as an admin.

/ Add News /
function addNews() {
// Check if user is authorized (login.php) //
$authorized=$_SESSION['auth'];
// Get Data From Form //
$title=$_POST['title'];
$time=date("F j, Y, g:i a");
$poster=$_POST['poster'];
$article=$_POST['article'];
if($authorized==1) { // If your logged in //
	$query="INSERT INTO news VALUES ('','$title','$time','$poster','$article')";
	mysql_query($query);
	header('Location: index.php');
} else {
	header('Location: login.php');
}
}

/ Show News /
function showNews() {
$query="SELECT * FROM news ORDER BY id DESC";
$result=mysql_query($query);
$rows=mysql_num_rows($result);
$i=0;
while($i<$rows) {
	$title=mysql_result($result,$i,'title');
	$time=mysql_result($result,$i,'time');
	$poster=mysql_result($result,$i,'poster');
	$article=mysql_result($result,$i,'article');
	echo "<br><b>$title</b><br><i>Written on $time by $poster</i><br>    $article<hr>";
	$i=$i+1;
}
}

FYI the way I have it is where all the sites content is in one main file and all the pages the site uses just use functions, which makes it easy to edit. If you want you can do this by storing those two things in a file called functions.php and then having the following code on a different page --
<?
/ Include the functions.php file /
include('functions.php');
/ Call the function /
showNews();
?>

The result of that page is whatever is between the brackets of the function...
function showNews() {
/ All code here is run /
}

Yeah I kind went a little far there... Hopefully its a little understandable :glad:
Posted 19 years ago2005-07-23 16:48:33 UTC Post #123018
I dont have any $_POST, would that mean anything?

I gotta find a support forum for someone to look over it.
Luke LukeLuke
Posted 19 years ago2005-07-23 20:23:48 UTC Post #123035
AHA! i know whats missing!

Thanks for that davideo, this is helping a lot.
Luke LukeLuke
You must be logged in to post a response.