NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL table updating

PaulCheung paulcheung at tiscali.co.uk
Wed Dec 5 16:39:31 EST 2007


I am using the MySQL Update for the first time and do not think I am doing 
it correctly. I have checked coding examples and my coding (to me) looks 
correct. but am not updating my table and I cannot see what it is I am doing 
wrong.

<?PHP SESSION_START(); ob_start(); ?>
<HTML><BODY><?PHP
$self = $_SERVER['PHP_SELF'];
$referer = $_SERVER['HTTP_REFERER'];
$access = $_SESSION['access'];
$nr0 = $_SESSION['nr0'];
$testno = $_SESSION['testno'];
$actualdata = $_POST['actualdata'];
$actualresult = $_POST['actualresult'];
$testnote = $_POST['testnote'];

$_SESSION['actualdata'] = $actualdata;
$_SESSION['actualresult'] = $actualresult;
$_SESSION['testnote'] = $testnote;

echo('NEW_UPDATE_TR.PHP' . "<BR>");
echo('================' . "<BR>");
echo('$self = ' . $self . "<BR>");
echo('$referer = ' . $referer . "<BR>");
echo('$access = ' . $access . "<BR>");
echo('$nr0 = ' . $nr0 . "<BR>");
echo('$testno = ' . $testno . "<BR>");
echo('$actualdata = ' . $actualdata  . "<BR>");
echo('$actualresult = ' . $actualresult . "<BR>");
echo('$testnote = ' . $testnote . "<BR>");

#connect to MySQL
$conn = mysql_connect("localhost", "paul", "enter") or die( "Err:Conn" );

#select the specified database
$rs = mysql_select_db( "test_db", $conn ) or die( "Err:Db" );

#create
$rs = mysql_query( $sql, $conn );

$query = ("UPDATE tr_test_record
                  SET    tr_actualdata = '$actualdata', tr_actualresult = 
'$actualresult', tr_testnote = '$testnote'
                 WHERE  tr_access     = '$access'
                 AND    tr_testno     = '$testno'
                 LIMIT  1");

echo("<br>" . '$query = ' . "<BR>" . $query . "<BR>");

mysql_close($conn);
exit();
?>
</body>
</html>


*****************************
         OUTPUT RESULTS
*****************************


NEW_UPDATE_TR.PHP
================
$self = /tp_update_tr.php
$referer = http://localhost/new_tp_update.php
$access = 73226318
$nr0 = 9
$testno = 001
$actualdata = AO
$actualresult = AR
$testnote = TN

$query =
UPDATE tr_test_record SET tr_actualdata = 'AO', tr_actualresult = 'AR', 
tr_testnote = 'TN' WHERE tr_access = '73226318' AND tr_testno = '001' LIMIT 
1






More information about the talk mailing list