You cant print the contents of $check1 because all it contains is a database resource pointer.
You need to run a query and pass the query result to mysql_fetch_array() before you can print anything.
PHP Code:
<?php
$db = mysql_connect("localhost", "nobody", "" ) or die ("could not connect to database" );
mysql_select_db("book" ) or die ("could not select database" );
$check1 = mysql_query("SELECT title FROM BOOK WHERE title='$title'", $db);
while ($row = mysql_fetch_array($check1) )
{
if ($row['title'] == $title)
{
print $title;
print "<p>There is already an article by with that title in the database. " .
"Please enter the article again using a different title</p>";
print '<a href="administration.html">Click here</a>';
}
else
{
$query = "INSERT INTO book (day, month, year, zip, category, title, document) " .
"VALUES ('$day', '$month', '$year', '$zip', '$category', '$title', '$document')";
$result = mysql_query($query, $db);
if (!$result)
{
die('Error: Query failed');
}
else
{
include("./infopanel.php" );
}
}
}
?>
Bookmarks