Page 1 of 1

Can no longer write to database

Posted: Thu Oct 30, 2003 9:08 am
by VincentWolf
Location: Michigan
Posts: 5
Can no longer write to database
I have written a simple Employee Directory for my company's Intranet to display employee information and a picture. The information is stored in a MYSQL database running on a server running SuSe 8.2 Pro. I wrote a few simple scripts for the HR department here to maintain the employees on the database (add, update and delete). Up until now, it has been working fine. Today, the individual in the Human Resources department in charge of maintaining the database called me and said that she was unable to add an employee. I tried myself and was also unable to. I was able to use my "maintenence" page to update employees and delete employees with no problem. However, I cannot add any employees to the database. The id field is set to auto increment. Could this be the field causing the problems?
None of the code has been altered in a couple months, so I am absolutely lost as to what the hell happened in the last day or two to not allow the addition of records to the database. Here is a list of things I have tried:

manually setting the ID and then trying to submit-no go

stopping and restarting the database- no go

deleting a record and then try to add (i figured if it was an issue with the NUMBER of records, this would free up enough room to add one)- no go

None of the permissions on the database have changed.

Is there a set size of a database? If so, how do you change to allow more records?

Here is the page to enter the employee info:

<html>
<head>
<title>Add Employee to Database</title>
</head>
<FONT FACE="Verdana">
<FORM ACTION="dbwrite.php" METHOD=POST>
<TABLE BORDER=0 ALIGN=CENTER>
<TR BGCOLOR="#008B00">
<TH COLSPAN=2 ALIGN=CENTER><FONT COLOR="#FFFFFF">Add Employee</TH>
</TR>
<TR BGCOLOR="#00CC00">
<TD>Last Name</TD><TD BGCOLOR="#FFFFFF"><INPUT TYPE=TEXT
NAME="Array[lname]" SIZE=25></TD>
<TR BGCOLOR="#00CC00">
<TD>First Name</TD><TD BGCOLOR="#FFFFFF"><INPUT TYPE=TEXT
NAME="Array[fname]" SIZE=25></TD>
</TR>
<TR BGCOLOR="#00CC00">
<TD>Title</TD><TD BGCOLOR="#FFFFFF"><INPUT TYPE=TEXT
NAME="Array[title]" Size=25></TD>
</TR>
<TR BGCOLOR="#00CC00">
<TD>Department</TD><TD BGCOLOR="#FFFFFF"><INPUT TYPE=TEXT
NAME="Array[department]" SIZE=25></TD>
</TR>
<TR BGCOLOR="#00CC00">
<TD>Supervisor</TD><TD BGCOLOR="#FFFFFF"><INPUT TYPE=TEXT
NAME="Array[supervisor]" SIZE=25></TD>
</TR>
<TR BGCOLOR="#00CC00">
<TD>Location</TD><TD BGCOLOR="#FFFFFF"><INPUT TYPE=TEXT
NAME="Array[location]" SIZE=25></TD>
<TR BGCOLOR="#00CC00">
<TD>Phone</TD><TD BGCOLOR="#FFFFFF"><INPUT TYPE=TEXT
NAME="Array[phone]" SIZE=25></TD>
</TR>
<TR BGCOLOR="#00CC00">
<TD>Email</TD><TD BGCOLOR="#FFFFFF"><INPUT
TYPE=TEXT NAME="Array[email]" SIZE=25></TD>
</TR>
<TR BGCOLOR="#00CC00">
<TD>URL to Photo</TD><TD BGCOLOR="#FFFFFF"><INPUT TYPE=TEXT
NAME="Array[photo]" SIZE=25</TD>
</TR>
<TR BGCOLOR="#00CC00">
<TD>Comments</TD><TD BGCOLOR="#FFFFFF"><TEXTAREA
NAME=Array[comments] ROWS=5 COLUMNS=25></TEXTAREA></TD>
</TR>
</TABLE>
<BR><BR>
<CENTER>
<INPUT TYPE=SUBMIT NAME="SUBMIT" VALUE="Add Record to Directory">
</CENTER>
</FORM>
</BODY>
</HTML>

And here is the page to write the info to the database:
<html>
<head>
<title>Inserting Data into DataBase</title>
</head>
<BODY>
<?php
//Trim the incoming data
$Array["lname"]=trim
($Array["lname"]);
$Array["fname"]=trim
($Array["fname"]);
$Array["title"]=trim
($Array["title"]);
$Array["department"]=trim
($Array["department"]);
$Array["supervisor"]=trim
($Array["supervisor"]);
$Array["location"]=trim
($Array["location"]);
$Array["phone"]=trim
($Array["phone"]);
$Array["email"]=trim
($Array["email"]);
$Array["photo"]=trim
($Array["photo"]);
$Array["comments"]=trim
($Array["comments"]);


//Set the variables for database access
$Host="localhost";
$User="root";
$Password="";
$DBName="EmployeeDirectory";
$TableName="Master";

$Link=mysql_connect($Host, $User, $Password);

$Query="INSERT into $TableName VALUES ('$Array[id]',
'$Array[lname]','$Array[fname]','$Array[title]','$
Array[department]','$Array[supervisor]','$Array[lo
cation]','$Array[phone]','$Array[email]','$Array[p
hoto]','$Array[comments]')";

print ("The query is:<BR>$Query<P>\n");
if (mysql_db_query ($DBName, $Query, $Link)) {
print ("The query was successfully executed!<BR>\n");
} else {
print ("The query could not be executed!<BR>\n");
}
mysql_close ($Link);
?>
<BR><BR><BR>
<A HREF="Add_Main.html" style="text-decoration:none">Add another
employee</A><BR>
<A HREF="DBMaint.html" style="text-decoration:none" TARGET="_top">Return to Database Maintenence Main
Page</A>

</BODY>
</HTML>

The 'id' field is type INT. There are approximately 430 rows currently in the database.


Thanks in advance for any help,

Vincent Wolfenbarger

:cry:

Posted: Thu Oct 30, 2003 5:59 pm
by BDKR
Are you capturing errors in any kind of meaningful way. If MySQL is complaining, it would at leat tell you what it's not happy about as long as you listen.

Same with the rest of the code.

Are you recieving anyting in the way of an error message?

Cheers,
BDKR

No Error Message

Posted: Fri Oct 31, 2003 7:06 am
by VincentWolf
I am not receiving any kind of an error message.

I posted this on another PHP forum and a member suggested that I remove the address field from the table since I am not using it and not writing to it (I originally created this field with the intenetion of using it, however, when I decided not to, I just left the field in the table). I removed it and I and now able to write to the database again just fine. ??? GO FIGURE ???

Anyhew, thanks for the feedback.


Vincent Wolfenbarger

Posted: Fri Oct 31, 2003 7:05 pm
by BDKR
Well, I looked at your code. It's not doing anything to report back problems or errors. You may want to check into mysql_error() and some of the error reporting functionality. This will most likely make life a lot easier over time.

Cheers,
BDKR