IT-Guy Posted February 17, 2008 Share Posted February 17, 2008 Hey, I have my login, and each user has their own username and password. Once they login, I want it to say, welcome "$firstname" "$lastname" (Which will be there name). All I really want is their First Name and Last Name to display on the page ie (Hello, Joe Smith)... So is this how I would do it? <?php $con = mysql_connect("****","****","****") or die('Could not connect: ' . mysql_error()); mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_assoc($result)){ echo "<b>Hello,</b> {$row['firstname']} {$row['lastname']}<br>"; Quote Link to comment https://forums.phpfreaks.com/topic/91540-login/ Share on other sites More sharing options...
Daniel0 Posted February 17, 2008 Share Posted February 17, 2008 Yes. Doesn't that work? Quote Link to comment https://forums.phpfreaks.com/topic/91540-login/#findComment-468896 Share on other sites More sharing options...
IT-Guy Posted February 17, 2008 Author Share Posted February 17, 2008 Nope the error Im getting is Parse error: parse error, unexpected $end on line 80 Thats why I was wondering if I was doing it right $con = mysql_connect("****","***","***") or die('Could not connect: ' . mysql_error()); mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_assoc($result)){ echo "<b>Hello,</b> {$row['firstname']} {$row['lastname']}<br>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/91540-login/#findComment-468921 Share on other sites More sharing options...
skiingguru1611 Posted February 17, 2008 Share Posted February 17, 2008 That should work, I think, test it and let me know. <?php $con = mysql_connect("****","****","****") or die('Could not connect: ' . mysql_error()); mysql_select_db("login", $con); $result = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_assoc($result)){ echo "<b>Hello,</b> {$row['firstname']} {$row['lastname']}<br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/91540-login/#findComment-468926 Share on other sites More sharing options...
IT-Guy Posted February 17, 2008 Author Share Posted February 17, 2008 haha well now the parse error is gone, this is the problem now. Its printing "Hello, $first, $last" (ie: Hello Joe Smith) for every record in the database. I only want it to show the name of the person that corresponds with their login ID. So wouldn't that be a session problem on my login script? Do I need to add a start_session() to the login script? Or is it something that can be fixed just by using my script above? Quote Link to comment https://forums.phpfreaks.com/topic/91540-login/#findComment-468930 Share on other sites More sharing options...
skiingguru1611 Posted February 17, 2008 Share Posted February 17, 2008 Let me see the whole script for that page...and if you have any include() files at the top show those too. The other thing was just an easy typo I was able to catch, I myself am not that advanced with PHP either, but I will try to help. Quote Link to comment https://forums.phpfreaks.com/topic/91540-login/#findComment-468934 Share on other sites More sharing options...
IT-Guy Posted February 17, 2008 Author Share Posted February 17, 2008 Im going to private message you and send you the coding for the files. For some reason this thread wont let me post them Quote Link to comment https://forums.phpfreaks.com/topic/91540-login/#findComment-468940 Share on other sites More sharing options...
IT-Guy Posted February 17, 2008 Author Share Posted February 17, 2008 Ok, nevermind I can't do that, the forum gives me some sort of error when I try and post the scripts, Ill try and private message you them. Sorry for all the trouble Quote Link to comment https://forums.phpfreaks.com/topic/91540-login/#findComment-468942 Share on other sites More sharing options...
peranha Posted February 17, 2008 Share Posted February 17, 2008 It is printing all because you are not giving it a where clause. $result = mysql_query("SELECT * FROM users WHERE tablecolumn = $first"); Quote Link to comment https://forums.phpfreaks.com/topic/91540-login/#findComment-468950 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.