php - Session variable is not working in MySQL statement -
php - Session variable is not working in MySQL statement -
i trying utilize session variable($_session['asc_id']
, holds value "as0027001") in sql statement, not working. when hardcode value, is providing results.
can please right me.
mysql query not working
$asc_id = $_session['asc_id']; $rs = mysql_query('select asc_lastname, asc_firstname, asc_middlename, lname_fname_dob issio_asc_workers asc_user_type = 31 , asc_id = "$asc_id" , lname_fname_dob "' . mysql_real_escape_string($_request['term']) . '%" order lname_fname_dob asc limit 0,10', $dblink);
mysql query working
$rs = mysql_query('select asc_lastname, asc_firstname, asc_middlename, lname_fname_dob issio_asc_workers asc_user_type = 31 , asc_id = "as0027001" , lname_fname_dob "' . mysql_real_escape_string($_request['term']) . '%" order lname_fname_dob asc limit 0,10', $dblink);
when print strings, clear. when question reformatted leave sql readable, problem clear. (the first rule debugging sql statements "print string". sec rule, makes easier comply first, set sql statements string pass sql function.)
you utilize .
notation embed request term
in string; don't utilize embed $asc_id
string. should utilize mysql_real_escape_string()
on session id value prevent sql injection.
php mysql
Comments
Post a Comment