Im not understanding why its saying Query was empty I could use some help.
Ive been working on this for awhile. Its my first real script or atleast its supose to be 😃 so if anyone could just give me a few pointers and not post the whole script fixed that would be sweet.
<?
require ("config.php");
?>
<?
if (!class_exists(auth))
{
include ("auth.php");
}
include ("authconfig.php");
include ("check.php");
if ($check["level"] != 1)
{
print "<font face=\"Arial, Helvetica, sans-serif\" size=\"5\" color=\"#FF0000\">";
print "<b>Illegal Access</b>";
print "</font><br>";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\" color=\"#000000\">";
print "<b>You do not have permission to view this page.</b></font>";
exit;
}
?>
<?
$table = "COMMENT";
$ip = getenv("REMOTE_ADDR");
$time = date("D M j");
$dirL = "http://shanksta.com/images/user/";
$absolute_path = "/home/shanksta/public_html/images/user/";
mysql_connect("$dbhost", "$dbusername", "$dbpassword") or die("could not connect");
mysql_select_db("$dbname");
$uname = $_POST['uname'];
$ucomment = $_POST['ucomment'];
$imagecat = $_POST['imagecat'];
$title = $_POST['title'];
echo "<form method=\"post\" action=\"$PHP_SELF\">";
if ($Submit == "Add")
{
if ($ahead == "+")
{
$Add = "INSERT INTO $table VALUES('$uname','$ucomment','$ip','$time','','$imagecat','$title')";
mysql_query($add_all) or die(mysql_error());
}
else
{
$Add = "INSERT INTO $table VALUES('$uname','$ucomment','$ip','$time','','$imagecat','$title')";
mysql_query($Add) or die(mysql_error());
}
$action = "";
}
elseif ($Submit == "Modify")
{
$Update ="UPDATE $table SET title='$title', ucomment='$ucomment', imagecat='$imagecat' WHERE id='$id'";
mysql_query($Update) or die(mysql_error());
$action = "";
}
// Delete News
if ($action=="delete")
{
$Delete = mysql_db_query($dbname, "DELETE FROM $table WHERE id='$id'");
mysql_query($Delete) or die(mysql_error());
}
if ($id != "")
{
// Show selected news
$Show = mysql_db_query($dbname, "SELECT * FROM $table WHERE id='$id'");
$ShowRow = mysql_fetch_array($Show);
$ShowNews = strip_tags($ShowRow["ucomment"]);
$Showimage = strip_tags($ShowRow["imagecat"]);
$Showtitle = strip_tags($ShowRow["title"]);
mysql_free_result($Show);
}
// Show all news
$result = mysql_db_query($dbname, "SELECT * FROM $table ORDER BY id DESC");
$row = mysql_fetch_array($result);
if ($action=="edit")
{
echo "<input type=\"text\" name=\"title\" value=$Showtitle size=\"20\">";
}
else
{
echo "<input type=\"text\" name=\"title\" size=\"20\">";
}
echo "<br>";
echo "<textarea name=\"ucomment\" cols=\"45\" rows=\"12\" wrap=\"VIRTUAL\">";
if ($action=="edit")
{
print trim($ShowNews);
}
print "</textarea>";
echo "<BR>";
echo"<input type=\"Hidden\" name=\"uname\" size=\"1\" value=\"$uname\">";
if ($action=="edit")
{
echo "<select size=1 name=imagecat value=$Showimage>";
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file != "..") and ($file != ".")) {
$list .= "<option value=$file>$file</option>";
}
}
echo $list;
}
else
{
echo "<select size=1 name=\"imagecat\">";
}
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file != "..") and ($file != ".")) {
$list .= "<option value=$file>$file</option>";
}
}
echo $list;
echo "</select>";
echo "<br>";
if ($action!="edit")
{
print "<input type=\"submit\" name=\"Submit\" value=\"Add\">";
}
else
{
print "<input type=\"submit\" name=\"Submit\" value=\"Modify\">";
}
echo "<input type=\"reset\" name=\"Reset\" value=\"Reset\">";
echo "</form>";
while ($id=$row["id"])
{
$id = $row["id"];
$uname = $check["uname"];
$ucomment = $row["ucomment"];
$ip = $row['ip'];
$time = date("D M j", strtotime($row["time"]));
$title = $row['title'];
print "<font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
print " $id</font><BR>";
print "<font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
print " $ip</font><BR>";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">";
print " $title</font><BR>";
print "<font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
print " $uname</font><BR>";
print "<font size=\"1\" face=\"Verdana, Arial, Helvetica, sans-serif\">";
print " $ucomment</font><BR>";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"1\">";
print " $time</font><BR>";
print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"2\">";
print " <a href=\"123.php?id=$id&action=edit\"><img border=\"0\" src=\"/admin/images/edit.gif\" width=\"15\" height=\"15\" alt=\"Modify news\"></a> ";
print " <a href=\"123.php?id=$id&action=delete\"><img border=\"0\" src=\"/admin/images/delete.gif\" width=\"15\" height=\"15\" alt=\"Delete news\"></a></font><BR><BR>";
$row = mysql_fetch_array($result);
}
mysql_free_result ($result);
?>