|
Problem with a script i wrote... not sure though!
I wrote this script which simply lists articles in a database by their title and allows the user the option to add an article to the database... i've been working on it for the last two days now and it doesnt compile in apache. It's beginning to really get up my back...
Could people in the know have a look and tell me if they're is anything noticeably out of place...
Thanks
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?php
if (isset($_GET['addarticle'])):
<echo> '<form action = $_SERVER['PHP_SELF']; method ="post">';
<echo> '<tr><td height="19" valign="top">Title: </td><td valign="top"><input type="text" name="title"></td></tr>';
<echo> '<tr><td height="19" valign="top">Sub Title: </td><td valign="top"><input type="text" name="subtitle"></td></tr>';
<echo> '<tr><td height="19" valign="top">Author: </td><td valign="top"><input type="text" name="author"></td></tr>';
//fills the drop down menu with article categories taken from the database
$query = "SELECT category_name FROM core_article_category";
$result = mysql_query($query);
if(mysql_num_rows($result))
{
while($row = mysql_fetch_row($result))
{
<echo> '<select name="categories">';
print("<option value=\"$row[0]\">$row[0]</option>\n");}
}
else
{
print("<option value=\"\">No categories created yet</option>");
}
<echo> '<tr><td height="17" valign="top">Body: </td><td rowspan="2" valign="top"><textarea name="body" cols="65" rows="35"></textarea></td></tr>';
<echo> '</select>';
<echo> '<input type="submit" value="SUBMIT">';
<echo> '</form>';
else:
include("db.php");
$today = date("dmY");
if (isset($_POST['title'], isset($_POST['subtitle'], isset($_POST['author'], isset($_POST['categories'], isset($_POST['body']))
{
$title=$_POST['title'];
$subtitle=$_POST['subtitle'];
$author=$_POST['author'];
$categories=$_POST['categories'];
$body=$_POST['body'];
$addarticle = "'$title','$subtitle','$author','$categories','$body',1,'$today'";
mysql_query ("INSERT INTO core_article (title,subtitle,author_id,cat_id,body,enabled,timestamp) VALUES ($addarticle)");
}
echo '<p>List of articles in the database:</p>';
$results = @mysql_query('SELECT title FROM core_article');
if (!$results){
exit ('<p>Error performing query on the database:' .mysql_error(). '</p>');
}
while ($row = mysql_fetch_array($results)) {
echo '<li>' .$row['title']. '</li>';
}
echo '<p><a href="'.$_SERVER['PHP_SELF'].'?addarticle=1">Add an Article</a></p>';
endif;
?>
|