I can break this down more if people like
I am having problems with this peice of code
I get the following error message
[error]
Notice: Use of undefined constant d_no - assumed 'd_no' in /home/qncqnc/public_html/testbed/firstphp/science/edit_indiviual_marker.php on line 23
Notice: Undefined variable: company in /home/qncqnc/public_html/testbed/firstphp/science/edit_indiviual_marker.php on line 86
[/error]
This continues till line 96!!
Then I get, on the same page
[error]
Error updating author details: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '= dye= '', size_start= '', size_end='', pos= '', pos1='', het=
[error]
been at it hours now and can't figure out where I am going wrong
I THINK THAT THIS IS THE SECTION THAT IS CAUSING PROBLEMS
<?php
// THIS SECTION IS CAUSING PROBLEMS
if (isset($_POST[d_no])) {
$d_no = $_POST['d_no'];
$chr = $_POST['chr'];
$cm = $_POST['cm'];
$mbp = $_POST['mbp'];
$panel_no = $_POST['panel_no'];
$dye = $_POST['dye'];
$size_start= $_POST['size_start'];
$size_end = $_POST['size_end'];
$pos = $_POST['pos'];
$pos1 = $_POST['pos1'];
}
// put edited data in database.
$sql = "UPDATE $dbtabl SET
company='$company',
cm= '$cm',
mbp= '$mbp',
panel_no='$panel_no',
$dye = dye= '$dye',
size_start= '$size_start',
size_end='$size_end',
pos= '$pos',
pos1='$pos1',
het= '$het',
chr= '$chr'
WHERE d_no='$d-no' ";
if (@mysql_query($sql)) {
echo '<p>Author details updated.</p>';
} else {
echo '<p>Error updating author details: ' .
mysql_error() . '</p>';
}
// END OF PROBLEM SECTION
?>
It is adaptation of chapter 6 code from databse driven website using php and mysql
good book by the way but this code is not working for me here is the whole code
When you try to edit something you get:
[error]
Notice: Undefined index: size_end in /home/qncqnc/public_html/testbed/firstphp/science/edit_indiviual_marker.php on line 78
Notice: Undefined variable: company in /home/qncqnc/public_html/testbed/firstphp/science/edit_indiviual_marker.php on line 86
Notice: Undefined variable: d in /home/qncqnc/public_html/testbed/firstphp/science/edit_indiviual_marker.php on line 96
Error updating author details: Unknown column 'FAM' in 'field list'
[/error]
THIS IS THE WHOLE CODE FOR CONTEXT ANY OBVIOUS OTHERE ERRORS
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<!--
PAGE PURPOSE:
show all amrker info in data base in editable tables
-->
<!-- connect to database and generate page title -->
<?php
// report all errors
error_reporting(E_ALL);
// set database parameters
$dbhost = '****';
$dbuser = '***';
$dbpass = '***';
$dbname = '***';
$dbtabl = 'marker_info';
$d_no = $_GET[d_no];
// Connect to the database server
$dbcon = mysql_connect($dbhost, $dbuser, $dbpass) OR die('could not connect to MySQL: ' . mysql_error());
// Select the database
mysql_select_db ($dbname) OR die('could not connect to database: ' . mysql_error());
// PAGE TITELS
// information about family and markers or just display "upload page"
if(!isset($_POST['submit']))
{
$page_title = "editing marker $d_no";
}
else
{
$page_title = "DISPALYING PAGE for $d_no marker";
}
echo "<title> $page_title </title>";
//for pretty html code
echo "\n"; //end
?>
<!-- link JavaScript and css elements close head -->
<script src="../page_elements/form_go_on_select.js"></script>
<link rel="stylesheet" type="text/css" href="../page_elements/qnctv_css_style_sheet.css" />
</head>
<!-- link body tag -->
<?php
include('../page_elements/body.htm'); //end
//for pretty html code
echo "\n"; //end
?>
<!-- after any editing display new info -->
<?php
// THIS SECTION IS CAUSING PROBLEMS
if (isset($_POST['d_no'])) {
$d_no = $_POST['d_no'];
$chr = $_POST['chr'];
$cm = $_POST['cm'];
$mbp = $_POST['mbp'];
$panel_no = $_POST['panel_no'];
$dye = $_POST['dye'];
$size_start= $_POST['size_start'];
$size_end = $_POST['size_end'];
$pos = $_POST['pos'];
$pos1 = $_POST['pos1'];
}
// put edited data in database.
$sql = "UPDATE $dbtabl SET
company='$company',
cm= '$cm',
mbp= '$mbp',
panel_no='$panel_no',
$dye = dye= '$dye',
size_start= '$size_start',
size_end='$size_end',
pos= '$pos',
pos1='$pos1',
het= '$het',
chr= '$chr'
WHERE d_no='$d-no' ";
if (@mysql_query($sql)) {
echo '<p>Author details updated.</p>';
} else {
echo '<p>Error updating author details: ' .
mysql_error() . '</p>';
}
// END OF PROBLEM SECTION
?>
<a href="marker_list.php">Return to full marker list</a>
<?php
// else: // Allow the user to edit the author
$d_no_result = @mysql_query(
"SELECT * FROM $dbtabl WHERE d_no='$d_no'");
if (!$d_no_result) {
exit('<p>Error fetching author details: ' .
mysql_error() . '</p>');
}
$d_no_result = mysql_fetch_array($d_no_result);
$company = $d_no_result['company'];
$het = $d_no_result['het'];
// CALULATED
// $het_act = $d_no_result['het_act'];
$chr = $d_no_result['chr'];
$cm = $d_no_result['cm'];
$mbp = $d_no_result['mbp'];
$panel_no = $d_no_result['panel_no'];
$dye = $d_no_result['dye'];
$size_start= $d_no_result['size_start'];
$size_end = $d_no_result['size_end'];
$pos = $d_no_result['pos'];
$pos1 = $d_no_result['pos1'];
// Convert special characters for safe use
// as HTML attributes.
$company = htmlspecialchars($company);
$het = htmlspecialchars($het);
// calulated
// $het_act = htmlspecialchars($het_act);
$chr = htmlspecialchars($chr);
$cm = htmlspecialchars($cm);
$mbp = htmlspecialchars($mbp);
$panel_no = htmlspecialchars($panel_no);
$dye = htmlspecialchars($dye);
$size_start= htmlspecialchars($size_start);
$size_end = htmlspecialchars($size_end);
$pos = htmlspecialchars($pos);
$pos1 = htmlspecialchars($pos1);
?>
<h2>edit marker: <?php echo $d_no; ?></h2>
<br /><br />
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<label>marker id: <input type="text" name="d_no" value="<?php echo $d_no; ?>" /></label>
<!-- comapny need search of new table then use
<label>company: <input type="text" name="company" value="<?php echo $company; ?>" /></label>
-->
<br /><br />
<label>stated hetroz: <input type="text" name="het" value="<?php echo $het; ?>" /></label>
<!--
N.B. calculate hetrozygosity by accesing alleles in database then use...
<label>actual hetroz: <input type="text" name="het_act" value="<?php echo $het_act; ?>" /></label>
-->
<br /><br />
<label>chromosome: <input type="text" name="chr" value="<?php echo $chr; ?>" /></label>
<label>cm position: <input type="text" name="cm" value="<?php echo $cm; ?>" /></label>
<label>mbp position: <input type="text" name="mbp" value="<?php echo $mbp; ?>" /></label>
<br /><br />
<label>panel no: <input type="text" name="panel_no" value="<?php echo $panel_no; ?>" /></label>
<label>dye: <input type="text" name="dye" value="<?php echo $dye; ?>" /></label>
<label>size_start: <input type="text" name="size_start" value="<?php echo $size_start; ?>" /></label>
<label>size_end: <input type="size_end" name="cm" value="<?php echo $size_end; ?>" /></label>
<br /><br />
<label>Pos control: 1347 allele 1 size: <input type="text" name="pos" value="<?php echo $pos; ?>" /></label>
<label>allele 2 size: <input type="text" name="pos1" value="<?php echo $pos1; ?>" /></label>
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<br />
<!-- provide submission and end form -->
<input type="submit" value="SUBMIT" /></p>
</form>
<a href="marker_list.php">Return to full marker list</a>
</body>
</html>