PHP MySql

The following code used to work  for me but i went away for a week and now it doesn't work at all .....will somebody please tell me why i can't insert data into the database? I can connect to the database and the error codes  work fine it just won't insert for some odd reason. YES the database is set up correctly and i can access it from the php command line interface.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>


<title>eol</title>


<head>

<link href="../common_css/eol.css" rel="stylesheet" type="text/css" media ="screen">


</head>



<body>




<?php require("../common_code/navncon.inc"); ?>

<div class="datcon">
<?PHP
$assettag = $_POST['assettag'];
$serial = $_POST['serial'];
$location = $_POST['location'];
$department = $_POST['department'];
$office = $_POST['office'];
$issues = $_POST['issues'];
$collected = $_POST['collected'];
$submit = $_POST['submit'];

$error = "<div class= \"error\">please fill in all form fields</div>";

$success = "<div class= \"error\">data inserted correctly</div>";


include("../authentication/connect.inc");
$db;
$tab;
if ($submit){
 if (!$assettag || !$serial || !$location || !$department || !$office || !$issues || !$collected){

echo $error;

} else {

echo $success;
 
 mysql_query("INSERT INTO EOL (assettag, serial, location, department, office, issues, collected) VALUES('$assettag','$serial','$location','$department','$office','$issues','$collected')");
}
}

mysql_close();
?>

<form id= "" name= "form1" method= "post" action= "">


<div class= "formbox1">asset tag #&nbsp<input type= "text"  name="assettag"  id= "" value= "" label="" size= "" maxlength= ""></div>


<div class= "formbox1">serial # &nbsp<input  type= "text" name= "serial"  id= ""  value= "" label= "" size= "" maxlength= ""></div>



<div class= "formbox1">location &nbsp<input  type= "text" name= "location" id= "" value= "" label= "" size= "" maxlength= ""></div>



<div class= "formbox1">department &nbsp<input  type= "text" name= "department"  id= "" value= "" label= "" size= "" maxlength= ""></div>

 

<div class= "formbox1">office &nbsp<input  type= "text" name= "office"  id= ""    value= "" label= "" size= "" maxlength= "" ></div>




<div class= "textformbox">issues &nbsp<textarea rows= "1" cols= "17" name= "issues"    id="" value="" label="" size="" maxlength="" ></textarea></div>



<div class ="formbox1">collected? &nbsp yes <input type= "checkbox" name= "collected" action= " " id= "" value= "1" label= "" size= "" maxlength= ""></div>


<div class="buttbox">
<div class="bubox0">

<input src="../common_images/insert.jpg" alt= "insert" type= "image"  name = "submit" action= "" id= "" value= "insert" label= "" size= "10" maxlength= "">
</div>

</form>

<form class="bubox1" method="link" action= "home.php" id= "">

<input src="../common_images/bak.jpg" alt= "back" type= "image"  name = "back" action= "home.php" id= "" value= "insert" label= "" size= "10" maxlength= "" tabindex="">
</form>

<form class="bubox2" method="link" action=home.php id= "">
<input src="../common_images/can.jpg" alt= "cancel" type= "image"  name = "submit" action= "home.php" id= "" value= "insert" label= "" size= "10" maxlength= "">
</form>
</div>
</div>

</body>

</html>
calmchessAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michael701Commented:
well, let's ask the computer what error is being generated.

$sql_command="INSERT INTO EOL (assettag, serial, location, department, office, issues, collected) VALUES('$assettag','$serial','$location','$department','$office','$issues','$collected')";
$ok=mysql_query($sql_command);
if (mysql_errno() or $debug)
  echo $sql_command."<br />\n".mysql_errno() . ": " . mysql_error(). "<br />\n";

Michael

calmchessAuthor Commented:

1045: Access denied for user 'apache'@'localhost' (using password: NO)
calmchessAuthor Commented:
weird that the php debugger didn't give me that errror code.
calmchessAuthor Commented:
ok i  granted all privleges to user apache and now i get the error .....................1065: Query was empty
Michael701Commented:
odd little issue, let's try adding a ; at the end of the sql_command

$sql_command="INSERT INTO EOL (assettag, serial, location, department, office, issues, collected) VALUES('$assettag','$serial','$location','$department','$office','$issues','$collected');";

there are some threads and comments about this issue in older versions of mysql.

Michael

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.