NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL Monitor V PHP & MySQL

PaulCheung paulcheung at tiscali.co.uk
Fri Sep 21 15:47:28 EDT 2007


 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  */
$conn=@mysql_connect( "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









More information about the talk mailing list