Go Back   Singapore Web Hosting Talk > TECHNICAL > Programming Forum

Programming Forum Web applications, languages and other related issues in configuration, optimization, practical usage and database connectivity.

Thread Tools
Old 22-07-2009, 03:07   #1
SGWHT Newbie
Join Date: 09-07-2009
Posts: 12
MumbleVoice-Jen is on a distinguished road
PHP Help

Hey everyone,

Well I'm having some trouble, I can't seem to get this edit script to work.

I found a great tutorial and changed it around a lot, and I simply can't figure out the first.

The error I am getting: Query failed: Unknown column 'name' in 'where clause'

My goal is to have it load the information that is in the database and then post it so I can edit the information, once I have changed what I wanted, have it re-submit to the database making the changes.

<form name="update_record" action="update.php" method="post">
<table style="margin-bottom: 1px; padding-left:10px;" border="0" cellpadding="0"
cellspacing="1" width="75%">
   <td align="right" bgcolor="#e9ece9" >Enter Doctor ID to edit: </td>
   <td bgcolor="#e9ece9" style="padding-left:4px;" >
  <input name="phone"  size="20" maxlength="20"   value="<? echo $BNAME; ?>">

<table style="margin-bottom: 1px; padding-left:455px;" border="0" cellpadding="0" cellspacing="1" width="50%">
       <td colspan="2" align="right" bgcolor="#dadce1" height="4">
   <input name="submit" value="submit" type="submit">

#Form Variables.

#Database connection strings.
$usr = "#";
$pwd = "#";
$db = "#";
$host = "localhost";

# connect to database
$cid = mysql_connect($host,$usr,$pwd);
if (mysql_error()) { print "Database ERROR: " . mysql_error(); }


#A query is written which will extract all information
#from basic_info table based on phone number entered.

$query = "SELECT * FROM INFORMATION where name='".$BNAME."'";
#Execute query and store result into variable $result.
#echo $query;
$result = mysql_query($query) or die('Query failed: ' . mysql_error());

 while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {


echo "<form method=\"post\">";
echo "<table style=\"margin-bottom: 1px;\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"60%\">\n";
echo "\t<tr>\n";
echo "\t\t<td bgcolor=\"#dadce1\" colspan=\"2\">Business Name:\t $BNAME</td>";
echo "\t\t<td bgcolor=\"#dadce1\"> <input type=\"hidden\" value='$BNAME' name=\"name\" size=\"50\" ></td>";

echo "\t</tr>\n";

echo "\t<tr>\n";
echo "\t\t<td bgcolor=\"#dadce1\">First Appointment: </td>";
echo "\t\t<td bgcolor=\"#dadce1\"> <input type=\"text\" value='$FAPPOINTMENT' name=\"fappoint\" size=\"50\" ></td>";
echo "\t</tr>\n";

echo "\t<tr>\n";
echo "\t\t<td bgcolor=\"#dadce1\">Second Appointment: </td>";
echo "\t\t<td bgcolor=\"#dadce1\"> <input type=\"text\" value='$SAPPOINTMENT' name=\"sappoint\" size=\"50\"></td>";
echo "\t</tr>\n";

echo "\t<tr>\n";
echo "\t\t<td bgcolor=\"#dadce1\">Nomination Received: </td>";
echo "\t\t<td bgcolor=\"#dadce1\"> <input type=\"checkbox\" value='$NOMINATIONC' name=\"nomination\"></td>";
echo "\t</tr>\n";

echo "\t<tr>\n";
echo "\t\t<td bgcolor=\"#dadce1\">Nomination Congratulations (Letter/Visit): </td>";
echo "\t\t<td bgcolor=\"#dadce1\"> <input type=\"checkbox\" value='$NOMINATIONC' name=\"nominationc\"></td>";
echo "\t</tr>\n";

echo "\t<tr>\n";
echo "\t\t<td bgcolor=\"#dadce1\">Finalist: </td>";
echo "\t\t<td bgcolor=\"#dadce1\"> <input type=\"checkbox\" value='$FINALIST' name=\"finalist\"></td>";
echo "\t</tr>\n";

echo "\t<tr>\n";
echo "\t\t<td bgcolor=\"#dadce1\">Finalist Congratulations Visit: </td>";
echo "\t\t<td bgcolor=\"#dadce1\"> <input type=\"checkbox\" value='$FINALISTV' name=\"finalistv\"></td>";
echo "\t</tr>\n";

echo "\t<tr>\n";
echo "\t\t<td bgcolor=\"#dadce1\">Products Sold: </td>";
echo "\t\t<td bgcolor=\"#dadce1\"> <textarea value='$NOTESPS' name=\"noteps\" rows=4 cols=30></textarea></td>";
echo "\t</tr>\n";

echo "\t<tr>\n";
echo "\t\t<td bgcolor=\"#dadce1\">New Dollars: </td>";
echo "\t\t<td bgcolor=\"#dadce1\"> <textarea value='$NOTESND' name=\"notend\" rows=4 cols=30></textarea></td>";
echo "\t</tr>\n";

echo "\t<tr>\n";
echo "\t\t<td bgcolor=\"#dadce1\">Date of Last Contact: </td>";
echo "\t\t<td bgcolor=\"#dadce1\"> <input type=\"checkbox\" value='$DATE' name=\"date\"></td>";
echo "\t</tr>\n";

echo "</table>\n";

echo "<table style=\"margin-bottom: 1px;\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" width=\"40%\">";
echo "<tr>";
echo "<td colspan=\"2\" align=\"right\" bgcolor=\"#dadce1\" height=\"4\">";
echo "<input name=\"submit02\" value=\"submit\" type=\"submit\">";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</form>";
#Free up Memory for $result.

#Close database connection.
The Database structure is:

$BNAME - varchar(60)
$FAPPOINTMENT - varchar(60)
$SAPPOINTMENT - varchar(60)
$NOMINATION - varchar(60)
$NOMINATIONC - varchar(60)
$FINALIST - varchar(60)
$FINALISTV - varchar(60)
$NOTESPS - text
$NOTESND - text
$DATE - varchar(60)
MumbleVoice.com - Providing Affordable & Reliable Mumble Voice Hosting Servers since 2001!
MumbleVoice-Jen is offline   Reply With Quote


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT +8. The time now is 12:35.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright (C) 2002-2015 Brought to you by Singapore Web Hosting Talk (SGWHT). All Rights Reserved.