php - Echo two different user's column -


i want echo information account's line, shown on page.

exemple: if user aaron logins, , goes page "yasmine" want echo yasmine's picture.

this code now

php:

mysql_select_db("vestiged_sala");     $user = $_session['username']; $ppoza = '';  // add these lines in place of $result query $result = mysql_query("select * users username='$user' limit 1"); while($row = mysql_fetch_array($result)){             $ppoza = $row['ppoza'];     }  if (!$result) {     echo "could not run query ($sql) db: " . mysql_error();     exit; } 

and html

<div class="ppoza"><?php echo $ppoza; ?></div> 

the problem echo aaron's profile picture instead of yasmine's

you need run select current user's data.

select * users username= ? 

or

select * users userid= ? 

you should update driver pdo or mysqli can use parameterized queries i've shown here. prevent sql injections , quote data correctly.

you can read more here:

  1. http://php.net/manual/en/mysqlinfo.api.choosing.php
  2. http://php.net/manual/en/mysqli.quickstart.prepared-statements.php (or...)
  3. http://php.net/manual/en/pdo.prepared-statements.php (...dont use pdo , mysqli, (nor mysql_ separate)

Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -