Recently I have been developing a new login system for my site. Now I have a problem that I just can't seem to solve. The problem is when a user logs in successfully I am trying to make it so it shows how many points they currently have. The code go's like:
$link = mysql_connect("???", "???", "???");
$activate = mysql_db_query ("???", "SELECT * FROM members WHERE username = '$username' AND password = '$password'");
$points1 = mysql_db_query ("???", "SELECT points from members WHERE username = '$username' AND password = '$password'");
if ($result = mysql_fetch_row($activate))
{
echo "<b>Welcome " . $username . " You currently have ". mysql_fetch_row($points1) . " points!</b><p>";
mysql_close($link);
}
Thats obviously just some of the code but can someone please help me. Another thing i should mention is when the user does login it says:
Welcome Joe You currently have Array points.
When it should actually say:
Welcome Joe You currently have 200 points.
Regards!
Joe
Small problem, Please help...
Moderator: General Moderators
try:
its pretty quick n dirty n nasty, but so long as you only have one row, it shouldnt matter!
Code: Select all
<?php
$link = mysql_connect("HOST", "USERNAME", "PASSWORD");
mysql_select_db("DATABASENAME",$link) or die("couldnt connect" . mysql_error());
$activate = mysql_query("SELECT * FROM members WHERE username = '$username' AND password = '$password'",$link);
while ($result = mysql_fetch_array($activate))
{
echo "<b>Welcome " . $result['username'] . " You currently have ". $result['points'] . " points!</b><p>";
}
mysql_close($link);
?>And try :
Code: Select all
$link = mysql_connect('???', '???', '???') or die(mysql_error());
mysql_select_db('thedbname') or die(mysql_error());
$sql = "SELECT * FROM members WHERE username = '$username' AND password = '$password'";
$result = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($result)){
$row = mysql_fetch_assoc($result);
echo '<b>Welcome ' . $username . ' You currently have '.$row['points1'].' points!</b><p>';
}
Last edited by markl999 on Sun Feb 29, 2004 1:47 pm, edited 1 time in total.
Thanks
if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
echo "<b>Welcome " . $username . " You currently have ". $row['points'] . " points!</b><p>";
That worked great. Thanks for your time and help people. Its just amazing to think I got that problem fixed within my first devnetwork forum post.
Regards
Joes
{
$row = mysql_fetch_assoc($result);
echo "<b>Welcome " . $username . " You currently have ". $row['points'] . " points!</b><p>";
That worked great. Thanks for your time and help people. Its just amazing to think I got that problem fixed within my first devnetwork forum post.
Regards
Joes