Unable to update database

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 48
Joined: Mon Jun 11, 2012 9:13 am

Tue Aug 21, 2012 3:44 am

Hi ,

My earlier problem has been solved, Thanks all for the support, now i made a new page(update.php) which is used to update information, update criteria is based on the date, so for that i first fetch the information based on the date and then i am trying to update it, but my update query does'nt seem to work.

let my explain you what my script is doing below first i am fetching the data which is based on the date
using textbox, and then i take column name "TIME" and "INITIALS" into the text box which i would like to update it ,but my update query does'nt seem to work.

Please find the code below.

<form action="update.php" method="post">

<input type=text value=search name=search >
<input type=submit name=submit value=Search>


#echo $dates;

if(isset($_POST['submit'])) {

echo "Current Date Is = ";
echo "$date";

$con = mysql_connect("localhost","root","access");
if(!$con) {
die("Unable Connect To Database Server " .mysql_error());


die ("Database Connection Error" .mysql_error());


if(isset($_POST['update'])) //if update button is pressed execute the query

$updatequery = "UPDATE $table SET INITIALS='$_POST[initials]', TIME='$_POST[time]' WHERE DATE='{$_POST["search"]}'"; //search is the textbox name

} //End of isset function

$sql= "select DATE,JOBNAME,INITIALS,TIME from $table where DATE='{$_POST["search"]}'"; //date is enter by username into the text box its working.


echo "<table width=100% height=10% border=1>

<th>INITIALS </th>

while($records = mysql_fetch_array($mydata)){
echo "<form action=update.php method=post>";
echo "<tr>";
echo "<td>" . $records['DATE'] . "</td>";
echo "<td>" . $records['JOBNAME'] . "</td>";
echo "<td>" . "<input type=text name=initials value=" . $records['INITIALS'] . " </td>";
echo "<td>" . "<input type=text name=time value=" . $records['TIME'] . " </td>";
echo "<td>" . "<input type=submit name=update value=update" . " </td>";
echo "</form>";

echo "</table>";


Thanks In Advance

php-forum Super User
php-forum Super User
Posts: 1803
Joined: Thu Mar 10, 2011 5:07 pm

Tue Aug 21, 2012 9:08 pm

print your mysql update query and run it using a sql client like phpmyadmin.

New php-forum User
New php-forum User
Posts: 37
Joined: Wed Jun 20, 2012 3:20 am

Tue Aug 21, 2012 10:20 pm

Hi, You are using <form action=update.php method=post> ie, the same page,
Process form action in new page

php-forum Fan User
php-forum Fan User
Posts: 622
Joined: Fri Aug 05, 2011 9:53 am

Wed Aug 22, 2012 1:39 am

Any time you call mysql_query - you should check this has worked. Checking the return value for FALSE indicates that some error has occurred. If you don't you may never see that the update is failing with an error.

Post Reply