We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now



calmchess asked
Medium Priority
Last Modified: 2006-11-18
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">




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



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

<div class="datcon">
$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>";

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')");


<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= "">


<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 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= "">


Watch Question

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')";
if (mysql_errno() or $debug)
  echo $sql_command."<br />\n".mysql_errno() . ": " . mysql_error(). "<br />\n";




1045: Access denied for user 'apache'@'localhost' (using password: NO)


weird that the php debugger didn't give me that errror code.


ok i  granted all privleges to user apache and now i get the error .....................1065: Query was empty
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.


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.