Ok, I know I seem to be posting a lot of questions. But it's how I learn so deal with it! :p Just playin'. Anywho, I'm working on this quite large script. It's a news script that allows people post news, add comments, and the like. This is a tutorial in a PHP book I'm working threw. I've finally got it all typed out, it took forever, and I'm debugging all my mistakes. I'm getting this error:
Parse error: parse error, expecting T_STRING' orT_VARIABLE' or `T_NUM_STRING' in c:\program files\apache group\apache\htdocs\php\switchdot.php on line 67
I'm going to bold line 67 to point it out. The script is large, so I only put a small bit.
<?
#Start Function Decs#
function connect() {
if(!$db = mysql_connect("localhost", "root")):
print("<h1>Can't Connect to the DB!</h1>\n");
else:
mysql_select_db("mattdb", $db);
endif;
}
function head($title) {
?>
<html>
<head>
<title><? echo $title ?></title>
<meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<style type="text/css">
<!--
BODY {font-family : Verdana, Arial, Helvetica;}
h1, h2, h3, h4, h5, h6 {font-family : Arial, Helvetica, Verdana, sans-serif;}
TD {font-family : Verdana, Arial, Helvetica;}
PRE {font-family : Courier Fixed;}
.date {
font-size : small;
font-family : Verdana;
font-style : italic;
}
-->
</stle>
</head>
<body>
<table width="420" border="0" align="center">
<tr><td>
<hr align="left" size="1" width="420" noshade>
<h1>Switch News</h1>
<hr align="left" size="1" width="420" noshade>
</td></tr>
</table>
<?
}
function write_post(){
?>
<h2>Write a New Article</h2>
<form action="switchdot.php" method="post">
<p>Author: <br> <input type="text" name="author">
<P>Password: <br><input type="password" name="password">
<p>Category: <br><? catList(); ?>
<p>Title: <br><input type="text" name="title" size="36" maxlength="36">
<p>Intro: <br><textarea cols=75 rows=5 name="intro"></textarea>
<p>More: <br><textarea cols=75 rows=15 name="more"></textarea>
<p><input type="submit" name="submit">
</form>
<?
}
function enter_post($author, $password, $title, $intro, $more, $caregory) {
connect();
$sql = "select from authors where author_name = '$author'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if($row["author_password"] != $password):
print("<h1>Wrong Password Loser!</h1>;
else:
$author = $row["author_id"];
$time = date("H:i:s");
$date = date("y-m-d");
$sql = "insert into news2 VALUES(NULL, '$title','$intro','$more','$author','$caregory','$date','$time')";
mysql_query($sql);
endif;
}
function display($show_what) {
switch ($show_what) {
case "":
$sql = "select from news2 where(TO_DAYS(NOW())-TO_DAYS(date)) <= '1' ORDER BY date DESC, time DESC";
break;
default:
$sql = "select * from news2 where (TO_DAYS(NOW())-TO_DAYS(date)) <= '1' ORDER BY date DESC, time DESC";
break;
}
display_posts($sql);
}
Can anyone see my mistake? Or the book's mistake (😃)? I'm sorry for all the questions. Any help will be GREATLY appreciated.