Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
tim
- DevNet Resident
- Posts: 1165
- Joined: Thu Feb 12, 2004 7:19 pm
- Location: ohio
Post
by tim »
How do you select data fom a mysql table where username=$_SESSION['username']?
I know
$user = $_SESSION['username'];
select $ from table where username='$user'"; works
but I tried multiple formats and I get a parse error everytime
where username={$_SESSION['username']}
many more, is this possible?
-
lostboy
- Forum Contributor
- Posts: 329
- Joined: Mon Dec 30, 2002 8:12 pm
- Location: toronto,canada
Post
by lostboy »
Code: Select all
$sql ="select * from tableName where username = '".$_SESSION['usesrname']."'":
Outside the quoted string with the single quotes inside
-
tim
- DevNet Resident
- Posts: 1165
- Joined: Thu Feb 12, 2004 7:19 pm
- Location: ohio
Post
by tim »
yeah I got it
I had an syntax error before the sql statement that was messing me up. Turns out there are a few methods to do that
thank you