Paul - Maybe this is a typo as well, but "$access_code = access_code;" ?
What are you trying to do here? My recommendation is that you add an 'echo "Access Code: $access_code";' before and after this line to confirm that you're getting what you think you should be getting. Best Regards - Rick ============ -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of PaulCheung Sent: Saturday, September 22, 2007 12:21 PM To: NYPHP Talk Subject: Re: [nyphp-talk] MySQL Monitor V PHP & MySQL Hi everybody I have implemented all the suggested changes and still cannot get it to work maybe it is time to just hand over the code to see if anybody can see what I am doing wrong. What I am trying to do is get the value of ACCESS_CODE Paul ----- Original Message ----- From: "Rick Retzko" <[EMAIL PROTECTED]> To: "'NYPHP Talk'" <talk@lists.nyphp.org> Sent: Saturday, September 22, 2007 3:57 PM Subject: RE: [nyphp-talk] MySQL Monitor V PHP & MySQL > Two errors that I can find: > > 1. You're missing the 'WHERE' key word in your SQL: $sql = "SELECT > access_code > FROM authorised_users > user_id = '$userid' AND > user_password = '$password' AND > account = '$account'"; > should be: > $sql = "SELECT access_code > FROM authorised_users > WHERE user_id = '$userid' AND > user_password = '$password' AND > account = '$account'"; > > 2. Your mysql_num_rows is misspelled (Yours is mysql_numrows) making the > subsequent 'if' statement FALSE. > > Hope this helps > > > Rick > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > On > Behalf Of PaulCheung > Sent: Friday, September 21, 2007 3:47 PM > To: talk@lists.nyphp.org > Subject: [nyphp-talk] MySQL Monitor V PHP & MySQL > > I have researched, checked and tried everything I can think of and still > cannot get it to work. > > when using MySQL monitor the following works > ================================= > > SELECT access_code FROM authorised_users WHEN user_id = 'Nancy' AND > user_password = 'qwerty' AND account = '48572998'; > > Access_code is displayed = 11966552 > > When using PHP & MySQL ($userid='Nancy', $user_password='qwerty', > $account='48572998') > ==================== > <?PHP session_start(); ob_start(); PHP?> > <HTML><HEAD><TITLE>auth</TITLE></HEAD> > <FORM action="X.php" id="primary" method="post"> <BODY> <?PHP > $userid = $_POST['user']; > $password = $_POST['passcode']; > $account = $_POST['account']; > $self = $_SERVER['PHP_SELF']; > $referer = $_SERVER['HTTP_REFERER']; > $access_code = $access_code - $access_code; > > /* FOR TEST ONLY */ > echo ("user id = " . $userid . "<br>"); > echo ("password = " . $password . "<br>"); echo ("account = " . $account > . > "<br>"); echo ("self = " . $self . "<br>"); > > /* VALIDATE FOR BLANK INPUT FIELD */ > if( ( !$userid ) or ( !$password ) or (!$account) ) { header( > "Location:$referer" ); exit(); } /*CONNECT TO MYSQL */ > [EMAIL PROTECTED]( "localhost", "paul", "enter" ) > or die( "Could not connect" ); > /* CONNECT TO DATABASE */ > $rs = @mysql_select_db( "test_db", $conn ) > or die( "Could not select database" ); > > $rs = @mysql_select_db( "test_db", $conn ) or die( "Could not select > database" ); > > $sql = "SELECT access_code > FROM authorised_users > user_id = '$userid' AND > user_password = '$password' AND > account = '$account'"; > > $rs = mysql_query( $sql, $conn ) or die( "Could not execute query" ); > > $num = mysql_numrows( $rs ); > > if( $num != 0 ) > { $access_code = access_code; > echo ("testcheckpoint - Welcome - your log-in succeeded!" . "<br>"); > echo ("testcheckpoint - accesscode = " . access_code . "<BR>"); > echo ('testcheckpoint - $accesscode = ' . $access_code . "<BR>"); } else > { echo (" test checkpoint statement 55 " . "<br>"); > header( "Location:$referer" ); > exit(); } > > =========================================== > this is what is returned from the test > > user id = Nancy > password = qwerty > account = 48572998 > self = /tp_orth.php > conn = Resource id #2 > sql = SELECT access_code FROM authorised_users WHERE user_id = 'Nancy' AND > user_password = 'qwerty' AND account = '48572998' > access = 0 > Welcome - your log-in succeeded! > testcheckpoint - accesscode = access_code testcheckpoint - $accesscode = > access_code > > I am trying to get the Access_code and cannot see what I am doing wrong > > P > > > > > > > _______________________________________________ > 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 > > _______________________________________________ > 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 _______________________________________________ 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