468,315 Members | 1,488 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,315 developers. It's quick & easy.

Building queries with session variables

I'm quite new to PHP so apologies if this is a really simple problem.
I'm using a session variable to store a userID after login and trying
to build a query using this variable. I have session_start() at the top
of each page and have registered the variable like so ($username is an
e-mail address taken from some user input)...

$user=$username;
session_register("user");

By echoing it on each page I can see that the $user session variable is
correctly passed through several pages (where it doesn't get used), but
when I come to actually use it to build a query using the following
line of code...

$getmovlist="SELECT movTitle, movYear FROM movie WHERE movID=(SELECT
movID FROM fMovie WHERE uID='" .$user ."')";

.... the query which is constructed is...

SELECT movTitle, movYear FROM movie WHERE movID=(SELECT movID FROM
fMovie WHERE uID='cxi03u')

which returns nothing as the end of the email address (@cs.nott.ac.uk)
has been cut off. If I echo the variable before inserting it into the
query it outputs the variable correctly (cx****@cs.nott.ac.uk)
alongside the incorrect query, but then if I refresh the page the value
of the variable has changed to cxi03u.

Feb 13 '06 #1
0 924

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Bernd Kohler | last post: by
10 posts views Thread by tshad | last post: by
1 post views Thread by Řyvind Isaksen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.