NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL table updating

Ben Sgro ben at projectskyline.com
Wed Dec 5 16:50:10 EST 2007


Hello,

Looks good to me. Maybe the where clause is never getting met.

- Ben

PaulCheung wrote:
> 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
>
>
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>




More information about the talk mailing list