Question: I have this code and i only want to display a record from the table :

```
<?php
session_start();
echo $_SESSION['idu'];
$connect=mysql_connect("localhost","root","");
mysql_select_db("bilet");
$queryreg=mysql_query("SELECT * FROM oferte WHERE idu='$_SESSION['idu']' ");
while($row = mysql_fetch_array($queryreg)):
  {
    echo   $row['adresa'];
  echo  $row['descriere'] ;
  echo $row['stele'] ;
    echo $row['pret'] ;
  }
  endwhile;

?>

```

I get this error : 

> 
> Parse error: syntax error, unexpected '' (T\_ENCAPSED\_AND\_WHITESPACE),
>  expecting identifier (T\_STRING) or variable (T\_VARIABLE) or number
>  (T\_NUM\_STRING) in D:\xampp\htdocs\bilet\viz.php on line 6.
> 
> 
> 

```
 The table has more then 4 rows , but i just wanna see if it works.

```

Answer: 
Try with...

```
$queryreg=mysql_query("SELECT * FROM oferte WHERE idu='" . $_SESSION['idu'] . "'");

```

And you won't confuse to PHP interpreter.
The specific issue has to do with your line 6 (as the error suggests). You're not properly including your session variable into the string. Try this instead:

```
$queryreg = mysql_query("SELECT * FROM oferte WHERE idu='" . $_SESSION['idu'] . "'");

```

That being said, there are a few other things to keep in mind. If the user ever sets `$_SESSION['idu']`, then your code is highly vulnerable to an SQL injection attack (read up [here](https://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php?rq=1) on how to prevent it)

---

As an aside, as @meda pointed out, you're actually using two different ways of doing while-loops. While you have it technically correct, it's certainly not a recommended way of doing such. I suggest choosing one or the other:

```
// Choice 1: Recommended
while ($row = mysql_fetch_array($queryreg)) {
    echo $row['adresa'];
    echo $row['descriere'];
    echo $row['stele'];
    echo $row['pret'];
}

// Choice 2
while ($row = mysql_fetch_array($queryreg)):
    echo $row['adresa'];
    echo $row['descriere'];
    echo $row['stele'];
    echo $row['pret'];
endwhile;

```