RESOLVED
thanks for the help
hi all ive had a look through the existing threads re php updates but
im still having problem with a UPDATE records in table if anyone wants to help...
i thought it was working and was very happy but obviously i didnt test it properly did i...
grr.
i have a page called view_me.php
it just takes a record from the owner table and lists off the entry in a html table (<tr><td>...
..not a problem...
next stage
edit_me.php
performs a similar task to above but instead of putting entry's in table tr/td it puts it back in a form. ive done this by doing
PHP Code:
echo "<td><input type=\"text\" name=\"dbFname\" maxlength=\"20\" value=\"{$row['dbFname']}\"/></td>";
it takes the info from a $query2 a few lines up...
this is also working alright...
the problem is when i change the values and press the button to update.
if i change a value to a number is fine, no problem, but if a change a value to a actual name with letters and stuff it spits out a error..
Unknown column 'test' in 'field list'
'test' is just what i put in the first name field.
form to take fields from db and put them in the form for update
take a look at the <div id main >
PHP Code:
<?php
include('../db_connection.php');
if (!isset($_SESSION["sess_loggedon"])) {
session_start();
}
else{ header ('location: index.html');
}
$query = ("SELECT * FROM xowner WHERE dbOwnerId='".$_SESSION['sess_loggedon']."'");
$result = mysql_query($query);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- lots of menu and normal html formatting to layoout the page... -->
<div id="lownav">
<?php
echo ("<p>Current user is " . $_SESSION["sess_loggedon"]." </p>");
?>
<ul><li><a href="../logout.php">logout</a></li></ul>
<!-- show username and date -->
</div>
<!-- close id lownav -->
</div>
<!-- close id col 1-->
<div id="main"><p>UPDATE MY DETAILS </p>
<?php
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<form name=\"update\" method=\"post\" action=\"update.php\">";
echo "<table align=\"center\">";
echo "<tr>";
echo "<td width=\"50%\">User Name </td>";
echo "<td width=\"50%\">{$row['dbOwnerId']} </td>";
echo "</tr>";
echo " <tr>";
echo " <th>DbFname:</th>";
echo " <td><input type=\"text\" name=\"dbFname\" maxlength=\"20\" value=\"{$row['dbFname']}\"/></td>";
echo " </tr>";
echo " <tr>";
echo " <th>DbLname:</th>";
echo " <td><input type=\"text\" name=\"dbLname\" maxlength=\"20\" value=\"{$row['dbLname']}\"/></td>";
echo " </tr>";
echo " <tr>";
echo " <th>Dbemail:</th>";
echo " <td><input type=\"text\" name=\"dbemail\" maxlength=\"30\" value=\"{$row['dbemail']}\"/></td>";
echo " </tr>";
echo " <tr>";
echo " <th>Dbmainphone:</th>";
echo " <td><input type=\"text\" name=\"dbmainphone\" maxlength=\"11\" value=\"{$row['dbmainphone']}\"/></td>";
echo " </tr>";
echo " <tr>";
echo " <th>Dbotherphone:</th>";
echo " <td><input type=\"text\" name=\"dbotherphone\" maxlength=\"11\" value=\"{$row['dbotherphone']}\"/></td>";
echo " </tr>";
echo " <tr>";
echo " <th>Dbaddress:</th>";
echo " <td><input type=\"text\" name=\"dbaddress\" maxlength=\"40\" value=\"{$row['dbaddress']}\"/></td>";
echo " </tr>";
echo " <tr>";
echo " <th>Dbaddress1:</th>";
echo " <td><input type=\"text\" name=\"dbaddress1\" maxlength=\"40\" value=\"{$row['dbaddress1']}\"/></td>";
echo " </tr>";
echo " <tr>";
echo " <th>Dbcity:</th>";
echo " <td><input type=\"text\" name=\"dbcity\" maxlength=\"20\" value=\"{$row['dbcity']}\"/></td>";
echo " </tr>";
echo " <tr>";
echo " <th>Dbpostcode:</th>";
echo " <td><input type=\"text\" name=\"dbpostcode\" maxlength=\"9\" value=\"{$row['dbpostcode']}\"/></td>";
echo " </tr>";
echo " <tr>";
echo " <th>notes:</th>";
echo " <td><input type=\"notes\" name=\"dbnotes\" size=\"70\" value=\"{$row['dbnotes']}\"></td>";
echo " </tr>";
echo " <tr>";
echo " <th>Dbpassword:</th>";
echo " <td><input type=\"password\" name=\"dbpassword\" value=\"{$row['dbpassword']}\"></td>";
echo " </tr>";
echo " <tr>";
echo " <td width=\"116\"></td>";
echo " <td width=\"156\"><input type=\"submit\" name=\"submit\" value=\"Update\">";
echo " </td>";
echo " </tr>";
echo " </table>";
echo " </form> ";
} ?>
</div><!-- end id main -->
</div>
<!-- end content -->
</div>
<!-- end id page -->
<div id="foot">footer</div>
<!-- end id foot -->
<br /><div style="z-index:3" class="smallfont" align="center">Content Relevant URLs by vBSEO 3.0.0 ©2007, Crawlability, Inc.</div>
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-139461-1";
urchinTracker();
</script>
</body>
</html>
the actual update.php file. its not working tho
PHP Code:
<?php
include('../db_connection.php');
if (!isset($_SESSION["sess_loggedon"])) {
session_start();
}
else{ header ('location: index.html');
}
//$dbOwnerId = $_POST['dbOwnerId'];
$dbFname = $_POST['dbFname'];
$dbLname = $_POST['dbLname'];
$dbemail = $_POST['dbemail'];
$dbmainphone = $_POST['dbmainphone'];
$dbotherphone = $_POST['dbotherphone'];
$dbaddress = $_POST['dbaddress'];
$dbaddress1 = $_POST['dbaddress1'];
$dbcity = $_POST['dbcity'];
$dbpostcode = $_POST['dbpostcode'];
$dbnotes = $_POST['dbnotes'];
$dbpassword = $_POST['dbpassword'];
$query2 = ("UPDATE xowner SET dbFname=$dbFname, dbLname=$dbLname, dbemail=$dbemail, dbmainphone=$dbmainphone, dbotherphone=$dbotherphone, dbaddress=$dbaddress, dbaddress1=$dbaddress1, dbcity=$dbcity, dbpostcode=$dbpostcode, dbnotes=$dbnotes WHERE dbOwnerId='".$_SESSION['sess_loggedon']."'");
//, , dbpassword=$dbpassword
mysql_query($query2) or die(mysql_error());
mysql_close();
echo "You have updated your record <a href=\"view_me.php\">Continue</a>";
?>
as i said it will update a record if the new values are numbers but only numbers but not if i use letters.