Curt
02-25-2001, 02:13 AM
I have a phone directory script that I can get everything to work on except for the modify record command. When I run it I get back "Couldn't execute query" error.
Can any of you see a problem with the code below?
Thanks,
Curt
<?
if ((!$lname) || (!$fname)) {
header("Location: http://localhost/pick_modcontact.php");
exit;
} else {
session_start();
}
if ($valid != "yes") {
header("Location: http://localhost/phone/contact_menu.php");
exit;
} else {
session_register('valid');
}
$db_name = "wood_crafting_com";
$table_name = "overlook_phone";
$connection = @mysql_connect("localhost", "*****", "********") or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "UPDATE $table_name
SET
lot = \"$lot\",
lname = \"$lname\",
fname = \"$fname\",
addr = \"$addr\",
phone = \"$phone\",
cell = \"$cell\",
page = \"$page\",
email = \"$email\",
im = \"$im\",
nchild = \"$nchild\",
misc = \"$misc\",
WHERE id = \"$id\"
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");
?>
<HTML>
<HEAD>
<TITLE>Overlook Contact Management System: Contact Updated</TITLE>
</HEAD>
<BODY>
<h1>Overlook Contact Management System</h1>
<h2><em>Modify a Contact - Contact Updated</em></h2>
<P>The following information was successfully updated in <? echo "$table_name"; ?></p>
<table cellspacing=3 cellpadding=5>
<tr>
<th>NAME & ADDRESS INFORMATION</th>
</tr>
<tr>
<td valign=top>
<P><STRONG>Lot Number:</STRONG><BR>
<? echo "$lot"; ?></P>
<P><STRONG>Last Name:</STRONG><BR>
<? echo "$lname"; ?></P>
<P><STRONG>First Name:</STRONG><BR>
<? echo "$fname"; ?></P>
<P><STRONG>Address:</STRONG><BR>
<? echo "$addr"; ?></P>
<P><STRONG>Phone:</STRONG><BR>
<? echo "$phone"; ?></P>
<P><STRONG>Cell:</STRONG><BR>
<? echo "$cell"; ?></P>
<P><STRONG>Page:</STRONG><BR>
<? echo "$page"; ?></P>
<P><STRONG>Email Id:</STRONG><BR>
<? echo "$email"; ?></P>
<P><STRONG>AOL IM ID:</STRONG><BR>
<? echo "$im"; ?></P>
<P><STRONG>Children Names:</STRONG><BR>
<? echo "$nchild"; ?></P>
<P><STRONG>Misc:</STRONG><BR>
<? echo "$misc"; ?></P>
</td>
</tr>
<tr>
<td align=center colspan=2><br>
<p><a href="contact_menu.php">Return to Main Menu</a></p>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
Can any of you see a problem with the code below?
Thanks,
Curt
<?
if ((!$lname) || (!$fname)) {
header("Location: http://localhost/pick_modcontact.php");
exit;
} else {
session_start();
}
if ($valid != "yes") {
header("Location: http://localhost/phone/contact_menu.php");
exit;
} else {
session_register('valid');
}
$db_name = "wood_crafting_com";
$table_name = "overlook_phone";
$connection = @mysql_connect("localhost", "*****", "********") or die("Couldn't connect.");
$db = @mysql_select_db($db_name, $connection) or die("Couldn't select database.");
$sql = "UPDATE $table_name
SET
lot = \"$lot\",
lname = \"$lname\",
fname = \"$fname\",
addr = \"$addr\",
phone = \"$phone\",
cell = \"$cell\",
page = \"$page\",
email = \"$email\",
im = \"$im\",
nchild = \"$nchild\",
misc = \"$misc\",
WHERE id = \"$id\"
";
$result = @mysql_query($sql,$connection) or die("Couldn't execute query.");
?>
<HTML>
<HEAD>
<TITLE>Overlook Contact Management System: Contact Updated</TITLE>
</HEAD>
<BODY>
<h1>Overlook Contact Management System</h1>
<h2><em>Modify a Contact - Contact Updated</em></h2>
<P>The following information was successfully updated in <? echo "$table_name"; ?></p>
<table cellspacing=3 cellpadding=5>
<tr>
<th>NAME & ADDRESS INFORMATION</th>
</tr>
<tr>
<td valign=top>
<P><STRONG>Lot Number:</STRONG><BR>
<? echo "$lot"; ?></P>
<P><STRONG>Last Name:</STRONG><BR>
<? echo "$lname"; ?></P>
<P><STRONG>First Name:</STRONG><BR>
<? echo "$fname"; ?></P>
<P><STRONG>Address:</STRONG><BR>
<? echo "$addr"; ?></P>
<P><STRONG>Phone:</STRONG><BR>
<? echo "$phone"; ?></P>
<P><STRONG>Cell:</STRONG><BR>
<? echo "$cell"; ?></P>
<P><STRONG>Page:</STRONG><BR>
<? echo "$page"; ?></P>
<P><STRONG>Email Id:</STRONG><BR>
<? echo "$email"; ?></P>
<P><STRONG>AOL IM ID:</STRONG><BR>
<? echo "$im"; ?></P>
<P><STRONG>Children Names:</STRONG><BR>
<? echo "$nchild"; ?></P>
<P><STRONG>Misc:</STRONG><BR>
<? echo "$misc"; ?></P>
</td>
</tr>
<tr>
<td align=center colspan=2><br>
<p><a href="contact_menu.php">Return to Main Menu</a></p>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>