Andrius
12-01-2006, 01:13 AM
The code below works on another website I use but when pasted and modded to fit this site it stopped working for no apparent reason (I've looked over and tripled checked my code) The database connection is correct but the script dies trying to insert the entries.
The database looks like this:
Table: News
news_id : int(5) (auto increment)
subject : varchar(200)
body : longtext
image : varchar(200)
date : date
<?
session_start(); # 7
if (@$_SESSION['auth'] != "yes") # 9
{
header("Location: Login.php");
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
background-image: url(Images/bg_main.gif);
background-repeat: repeat-x;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a:link {
color: #FFFF00;
text-decoration: none;
}
a:visited {
color: #FFCC00;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
}
.style2 {font-size: 10px}
-->
</style></head>
<body>
<div align="center">
<table width="1000" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
<td width="102" height="163"><img src="Images/1.gif" width="102" height="163" /></td>
<td width="482" height="163"><img src="Images/2.gif" width="482" height="163" /></td>
<td width="233" height="163"><img src="Images/3.gif" width="233" height="163" /></td>
<td width="117" height="163"><img src="Images/4.gif" width="117" height="163" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td width="102" height="77"><img src="Images/5.gif" width="102" height="77" /></td>
<td background="Images/6_bg.gif"><div align="center"><img src="Images/banner_top.jpg" width="468" height="60" /></div></td>
<td width="233" height="77"><img src="Images/7.gif" width="233" height="77" /></td>
<td width="117" height="77"><img src="Images/8.gif" width="117" height="77" /></td>
<td> </td>
</tr>
<tr>
<td width="32" height="40"><img src="Images/9.gif" width="32" height="40" /></td>
<td width="102" height="40"><img src="Images/10.gif" width="102" height="40" /></td>
<td width="482" height="40"><img src="Images/11.gif" width="482" height="40" /></td>
<td width="233" height="40"><img src="Images/12.gif" width="233" height="40" /></td>
<td width="117" height="40"><img src="Images/13.gif" width="117" height="40" /></td>
<td width="34" height="40"><img src="Images/14.gif" width="34" height="40" /></td>
</tr>
<tr>
<td width="32" height="80"><img src="Images/15.gif" width="32" height="80" /></td>
<td width="102" height="80"><img src="Images/16.gif" width="102" height="80" /></td>
<td height="80" colspan="2"><img src="Images/17.gif" width="715" height="80" /></td>
<td width="117" height="80"><img src="Images/18.gif" width="117" height="80" /></td>
<td width="34" height="80"><img src="Images/19.gif" width="34" height="80" /></td>
</tr>
<tr>
<td height="100%" background="Images/20_runner_BG.gif"> </td>
<td height="100%" valign="top"><div align="right"><img src="Images/banner_left.jpg" width="100" height="487" /></div></td>
<td height="100%" colspan="2" valign="top" background="Images/bg_inner.gif"><div align="center"><br />
<?php
if(isset($_POST['add']))
{
//************************************************
// Customize this area to match your database information
//************************************************
include_once("Includes/news_conn.php");
//************************************************
// End of Database Connection & Selection
//************************************************
$insert_subject = $_POST['subject'];
$insert_body = $_POST['body'];
$insert_image = $_POST['image'];
$date = date("Y-m-d");
$query = "INSERT INTO News (subject, body, image, date) VALUES ('$insert_subject', '$insert_body', '$insert_image', '$date')";
mysql_query($query) or die('Error, insert query failed');
mysql_close();
echo "New News Item has been added!<br> <a href='http://www.getliveevents.com'>Click Here to see your addition.</a>";
}
else
{
?>
<form method="post">
<table width="502" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#999999">
<tr>
<td><div align="center">
<table width="500" border="0" align="center" cellpadding="2" cellspacing="1">
<tr>
<td colspan="2" bgcolor="#363636"><div align="center"><img src="Images/add_news.jpg" width="495" height="82"></div></td>
</tr>
<tr>
<td width="88" bgcolor="#363636" class="style12"><div align="right"><span class="style1">Subject</span></div></td>
<td width="401" bgcolor="#363636"><div align="left">
<input name="subject" type="text" id="subject" size="62">
</div></td>
</tr>
<tr>
<td width="88" valign="top" bgcolor="#363636" class="style12"><div align="right"><span class="style1">Body</span></div></td>
<td bgcolor="#363636">
<div align="left">
<textarea name="body" cols="45" rows="7" id="body"></textarea>
</div>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#363636" class="style12"><div align="right"><span class="style1">Image Name </span></div></td>
<td bgcolor="#363636"><div align="left">
<input name="image" type="text" id="image" size="62">
</div></td>
</tr>
<tr>
<td colspan="2" bgcolor="#363636"><span class="style1">(Please input the image name including extension you have uploaded to the Images Directory. If you have no image leave this field <strong>EMPTY</strong> and no image will be used.) </span></td>
</tr>
<tr>
<td width="88" bgcolor="#363636"> </td>
<td bgcolor="#363636">
<div align="center">
<input name="add" type="submit" id="add" value="Add News">
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</form>
<?php
}
?> <br />
<br />
</div></td>
<td height="100%" valign="top"><div align="right"><img src="Images/banner_right.jpg" width="100" height="487" /></div></td>
<td height="100%" background="Images/21_runner_BG.gif"> </td>
</tr>
</table>
</div>
</body>
</html>
The database looks like this:
Table: News
news_id : int(5) (auto increment)
subject : varchar(200)
body : longtext
image : varchar(200)
date : date
<?
session_start(); # 7
if (@$_SESSION['auth'] != "yes") # 9
{
header("Location: Login.php");
exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
body,td,th {
color: #FFFFFF;
}
body {
background-color: #000000;
background-image: url(Images/bg_main.gif);
background-repeat: repeat-x;
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a:link {
color: #FFFF00;
text-decoration: none;
}
a:visited {
color: #FFCC00;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
a:active {
text-decoration: none;
}
.style1 {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
}
.style2 {font-size: 10px}
-->
</style></head>
<body>
<div align="center">
<table width="1000" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
<td width="102" height="163"><img src="Images/1.gif" width="102" height="163" /></td>
<td width="482" height="163"><img src="Images/2.gif" width="482" height="163" /></td>
<td width="233" height="163"><img src="Images/3.gif" width="233" height="163" /></td>
<td width="117" height="163"><img src="Images/4.gif" width="117" height="163" /></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td width="102" height="77"><img src="Images/5.gif" width="102" height="77" /></td>
<td background="Images/6_bg.gif"><div align="center"><img src="Images/banner_top.jpg" width="468" height="60" /></div></td>
<td width="233" height="77"><img src="Images/7.gif" width="233" height="77" /></td>
<td width="117" height="77"><img src="Images/8.gif" width="117" height="77" /></td>
<td> </td>
</tr>
<tr>
<td width="32" height="40"><img src="Images/9.gif" width="32" height="40" /></td>
<td width="102" height="40"><img src="Images/10.gif" width="102" height="40" /></td>
<td width="482" height="40"><img src="Images/11.gif" width="482" height="40" /></td>
<td width="233" height="40"><img src="Images/12.gif" width="233" height="40" /></td>
<td width="117" height="40"><img src="Images/13.gif" width="117" height="40" /></td>
<td width="34" height="40"><img src="Images/14.gif" width="34" height="40" /></td>
</tr>
<tr>
<td width="32" height="80"><img src="Images/15.gif" width="32" height="80" /></td>
<td width="102" height="80"><img src="Images/16.gif" width="102" height="80" /></td>
<td height="80" colspan="2"><img src="Images/17.gif" width="715" height="80" /></td>
<td width="117" height="80"><img src="Images/18.gif" width="117" height="80" /></td>
<td width="34" height="80"><img src="Images/19.gif" width="34" height="80" /></td>
</tr>
<tr>
<td height="100%" background="Images/20_runner_BG.gif"> </td>
<td height="100%" valign="top"><div align="right"><img src="Images/banner_left.jpg" width="100" height="487" /></div></td>
<td height="100%" colspan="2" valign="top" background="Images/bg_inner.gif"><div align="center"><br />
<?php
if(isset($_POST['add']))
{
//************************************************
// Customize this area to match your database information
//************************************************
include_once("Includes/news_conn.php");
//************************************************
// End of Database Connection & Selection
//************************************************
$insert_subject = $_POST['subject'];
$insert_body = $_POST['body'];
$insert_image = $_POST['image'];
$date = date("Y-m-d");
$query = "INSERT INTO News (subject, body, image, date) VALUES ('$insert_subject', '$insert_body', '$insert_image', '$date')";
mysql_query($query) or die('Error, insert query failed');
mysql_close();
echo "New News Item has been added!<br> <a href='http://www.getliveevents.com'>Click Here to see your addition.</a>";
}
else
{
?>
<form method="post">
<table width="502" border="0" align="center" cellpadding="1" cellspacing="0" bgcolor="#999999">
<tr>
<td><div align="center">
<table width="500" border="0" align="center" cellpadding="2" cellspacing="1">
<tr>
<td colspan="2" bgcolor="#363636"><div align="center"><img src="Images/add_news.jpg" width="495" height="82"></div></td>
</tr>
<tr>
<td width="88" bgcolor="#363636" class="style12"><div align="right"><span class="style1">Subject</span></div></td>
<td width="401" bgcolor="#363636"><div align="left">
<input name="subject" type="text" id="subject" size="62">
</div></td>
</tr>
<tr>
<td width="88" valign="top" bgcolor="#363636" class="style12"><div align="right"><span class="style1">Body</span></div></td>
<td bgcolor="#363636">
<div align="left">
<textarea name="body" cols="45" rows="7" id="body"></textarea>
</div>
</td>
</tr>
<tr>
<td valign="top" bgcolor="#363636" class="style12"><div align="right"><span class="style1">Image Name </span></div></td>
<td bgcolor="#363636"><div align="left">
<input name="image" type="text" id="image" size="62">
</div></td>
</tr>
<tr>
<td colspan="2" bgcolor="#363636"><span class="style1">(Please input the image name including extension you have uploaded to the Images Directory. If you have no image leave this field <strong>EMPTY</strong> and no image will be used.) </span></td>
</tr>
<tr>
<td width="88" bgcolor="#363636"> </td>
<td bgcolor="#363636">
<div align="center">
<input name="add" type="submit" id="add" value="Add News">
</div></td>
</tr>
</table>
</div></td>
</tr>
</table>
</form>
<?php
}
?> <br />
<br />
</div></td>
<td height="100%" valign="top"><div align="right"><img src="Images/banner_right.jpg" width="100" height="487" /></div></td>
<td height="100%" background="Images/21_runner_BG.gif"> </td>
</tr>
</table>
</div>
</body>
</html>