BitcoinINV (OP)
|
|
September 06, 2012, 09:53:07 PM |
|
<?php $con = mysql_connect("localhost","]",""); if (!$con) { die('Could not connect: ' .mysql_error()); } mysql_select_db("", $con); $username=$_POST['skiz22285']; $result = mysql_query("SELECT * FROM `users` LIMIT 0, 30 "); echo "<table border='1'> <tr>
<th> Email </th> <th> username </th>
</tr>";
{ echo "<tr>";
echo "<td>" .$row['email'] ."</td>"; echo "<td>" .$row['username'] ."</td>";
echo "</tr>"; } echo "</table>"; mysql_close ($con); ?> <html> <body> Login Successful <p><a href="index.php\">Click here to logout!</a></p> </body> </html>
What I need it to do is display the users mysql information, right now its just posting the email and username with no database outputs.
|
|
|
|
Bitsky
|
|
September 06, 2012, 09:58:40 PM |
|
Try this: $rows=mysql_num_rows($result); for ($i=0; $i<$rows; $i++) { $row=mysql_fetch_array($result); echo "<tr>"; echo "<td>" .$row['email'] ."</td>"; echo "<td>" .$row['username'] ."</td>"; echo "</tr>"; }
If you don't need an incrementing counter, you could also do while ($row=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" .$row['email'] ."</td>"; echo "<td>" .$row['username'] ."</td>"; echo "</tr>"; } instead of the for-loop
|
|
|
|
BitcoinINV (OP)
|
|
September 06, 2012, 10:04:38 PM |
|
Try this: $rows=mysql_num_rows($result); for ($i=0; $i<$rows; $i++) { $row=mysql_fetch_array($result); echo "<tr>";--------------------------------------------------------------------- Parse error echo "<td>" .$row['email'] ."</td>"; echo "<td>" .$row['username'] ."</td>"; echo "</tr>"; }
If you don't need an incrementing counter, you could also do while ($row=mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" .$row['email'] ."</td>"; echo "<td>" .$row['username'] ."</td>"; echo "</tr>"; } instead of the for-loop Get a parse error
|
|
|
|
Bitsky
|
|
September 06, 2012, 10:14:32 PM |
|
Just tested the following code without any problems <html> <body> <?php $con=mysql_connect('localhost', 'user', 'pass'); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("db", $con); $username=$_POST['skiz22285']; $result=mysql_query("SELECT * FROM users LIMIT 0, 30"); echo "<table border='1'> <tr> <th>Email</th> <th>Username</th> </tr>"; $rows=mysql_num_rows($result); for ($i=0; $i<$rows; $i++) { $row=mysql_fetch_array($result); echo "<tr>"; echo "<td>".$row['email']."</td>"; echo "<td>".$row['username']."</td>"; echo "</tr>"; } echo "</table>"; mysql_close ($con); ?> Login Successful <p><a href="index.php\">Click here to logout!</a></p> </body> </html>
Also tested the while-loop with no problems.
|
|
|
|
BitcoinINV (OP)
|
|
September 06, 2012, 11:32:17 PM |
|
The problem with that is it displays all the mysql data, its not user specific.
|
|
|
|
dree12
Legendary
Offline
Activity: 1246
Merit: 1077
|
|
September 06, 2012, 11:45:16 PM Last edit: September 07, 2012, 01:11:12 AM by dree12 |
|
<?php $con=mysql_connect('localhost', 'user', 'pass'); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("db", $con); $username=$_POST['skiz22285']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?>
Note that this uses $_POST['skiz22285'], which is probably not what you want.
|
|
|
|
BitcoinINV (OP)
|
|
September 07, 2012, 12:38:56 AM |
|
the skiz22285 thing is just something for a troubleshooting guide I was reading but when I ran your code i got Parse error: syntax error, unexpected T_VARIABLE on line 78
|
|
|
|
gweedo
Legendary
Offline
Activity: 1498
Merit: 1000
|
|
September 07, 2012, 12:41:32 AM |
|
<?php $con=mysql_connect('localhost', 'user', 'pass'); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("db", $con); $username=$_POST['skiz22285']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?>
he forgot a ; on the line of $username=mysql_real_escape_string($username)
|
|
|
|
dree12
Legendary
Offline
Activity: 1246
Merit: 1077
|
|
September 07, 2012, 01:11:31 AM |
|
<?php $con=mysql_connect('localhost', 'user', 'pass'); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("db", $con); $username=$_POST['skiz22285']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?>
he forgot a ; on the line of $username=mysql_real_escape_string($username)
That was it. Fixed now, it should work.
|
|
|
|
BitcoinINV (OP)
|
|
September 07, 2012, 01:14:22 AM |
|
when you first login it shows it for about 1 second then goes it goes away.
|
|
|
|
payb.tc
|
|
September 07, 2012, 01:18:15 AM |
|
when you first login it shows it for about 1 second then goes it goes away.
goes away to what? a blank page?
|
|
|
|
dree12
Legendary
Offline
Activity: 1246
Merit: 1077
|
|
September 07, 2012, 01:20:16 AM |
|
when you first login it shows it for about 1 second then goes it goes away.
Try this full HTML page: <!DOCTYPE html> <html> <head> <title>Title</title> </head> <body> <p> <?php $con=mysql_connect('localhost', 'user', 'pass'); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("db", $con); $username=$_POST['skiz22285']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?> </p> </body> </html>
|
|
|
|
BitcoinINV (OP)
|
|
September 07, 2012, 01:21:19 AM |
|
no the users info shows up for a second then it goes away. Here is the whole page code <?php /* ********** Member Page ********** */ /* Include Code */ include("assets/member.inc.php"); /* Is an Action set? */ if(isset($_GET['action'])) { $action = $_GET['action']; } else { $action = null; } if(isset($_GET['subaction'])) { $subaction = $_GET['subaction']; } else { $subaction = null; } if($action == 'logout') { echo $member->logout(); $title = 'Logging user out'; $content = '<div class="notice info">You are being logged out...</div>'; } elseif($action == 'settings') { $member->LoggedIn(); $user = $member->data(); if($subaction == 'password') { $title = 'Change Password'; $content = $member->changePassword($user->id); } elseif($subaction == 'email') { $title = 'Change E-Mail'; $content = $member->changeEmail($user->id); } elseif($subaction == 'delete') { $title = 'Delete Account'; $content = $member->deleteAccount($user->id); } else { $title = 'Settings'; $content = '<a href="member.php?action=settings&subaction=password" class="button full">Change Password</a><a href="member.php?action=settings&subaction=email" class="button full">Change E-Mail</a><a href="member.php?action=settings&subaction=delete" class="button full">Delete Account</a>'; } } elseif($action == 'register') { $title = 'Create an account'; $content = $member->register() . '<p class="options group"><a href="member.php?action=login">Already have an account?</a> • <a href="member.php?action=recover-password">Recover Password</a></p>'; } elseif($action == 'recover-password') { $title = 'Recover your password'; $content = $member->recoverPassword() . '<p class="options group"><a href="member.php?action=login">Already have an account?</a></p>'; } elseif($action == 'verification') { $title = 'Your account has been verified'; $content = $member->verification() . '<p class="options group"><a href="member.php?action=login">Already have an account?</a></p>'; } else { $title = 'Login'; $content = $member->login() . '<p class="options group"><a href="member.php?action=register">Register</a> • <a href="member.php?action=recover-password">Recover Password</a></p>'; }
?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" /> <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" /> </head> <body> <div id="members" class="group"> <h1><?php echo $title; ?></h1> <?php echo $content; ?> <html> <body> <?php $con=mysql_connect('localhost', 'xxx', 'xxxxx'); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("xxxxxx", $con); $username=$_POST['username']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?> Login Successful <p><a href="index.php\">Click here to logout!</a></p> </body> </html>
|
|
|
|
scintill
|
|
September 07, 2012, 01:22:46 AM |
|
when you first login it shows it for about 1 second then goes it goes away.
I think whoever fixed the code, has earned their bounty -- 99% sure this has nothing to do with the code you originally posted.
|
1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
|
|
|
payb.tc
|
|
September 07, 2012, 01:24:03 AM |
|
no the users info shows up for a second then it goes away. Here is the whole page code <?php /* ********** Member Page ********** */ /* Include Code */ include("assets/member.inc.php"); /* Is an Action set? */ if(isset($_GET['action'])) { $action = $_GET['action']; } else { $action = null; } if(isset($_GET['subaction'])) { $subaction = $_GET['subaction']; } else { $subaction = null; } if($action == 'logout') { echo $member->logout(); $title = 'Logging user out'; $content = '<div class="notice info">You are being logged out...</div>'; } elseif($action == 'settings') { $member->LoggedIn(); $user = $member->data(); if($subaction == 'password') { $title = 'Change Password'; $content = $member->changePassword($user->id); } elseif($subaction == 'email') { $title = 'Change E-Mail'; $content = $member->changeEmail($user->id); } elseif($subaction == 'delete') { $title = 'Delete Account'; $content = $member->deleteAccount($user->id); } else { $title = 'Settings'; $content = '<a href="member.php?action=settings&subaction=password" class="button full">Change Password</a><a href="member.php?action=settings&subaction=email" class="button full">Change E-Mail</a><a href="member.php?action=settings&subaction=delete" class="button full">Delete Account</a>'; } } elseif($action == 'register') { $title = 'Create an account'; $content = $member->register() . '<p class="options group"><a href="member.php?action=login">Already have an account?</a> • <a href="member.php?action=recover-password">Recover Password</a></p>'; } elseif($action == 'recover-password') { $title = 'Recover your password'; $content = $member->recoverPassword() . '<p class="options group"><a href="member.php?action=login">Already have an account?</a></p>'; } elseif($action == 'verification') { $title = 'Your account has been verified'; $content = $member->verification() . '<p class="options group"><a href="member.php?action=login">Already have an account?</a></p>'; } else { $title = 'Login'; $content = $member->login() . '<p class="options group"><a href="member.php?action=register">Register</a> • <a href="member.php?action=recover-password">Recover Password</a></p>'; }
?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" /> <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" /> </head> <body> <div id="members" class="group"> <h1><?php echo $title; ?></h1> <?php echo $content; ?> <html> <body> <?php $con=mysql_connect('localhost', 'xxx', 'xxxxx'); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("xxxxxx", $con); $username=$_POST['username']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?> Login Successful <p><a href="index.php\">Click here to logout!</a></p> </body> </html> well first of all, this code has two heads remove one of them: <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" /> then change <?php echo $content; ?> <html> <body> <?php to <?php echo $content; ?> <?php
|
|
|
|
scintill
|
|
September 07, 2012, 01:27:07 AM |
|
no the users info shows up for a second then it goes away. Here is the whole page code
You've got nested <head>'s and <body>'s, this could cause the "going away". no the users info shows up for a second then it goes away. Here is the whole page code
EDIT: bah, you can't put formatting into the middle of code blocks. What payb.tc said.
|
1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
|
|
|
BitcoinINV (OP)
|
|
September 07, 2012, 01:31:46 AM |
|
when you first login it shows it for about 1 second then goes it goes away.
I think whoever fixed the code, has earned their bounty -- 99% sure this has nothing to do with the code you originally posted. I was getting the same results as, I am with there code so... no the users info shows up for a second then it goes away. Here is the whole page code <?php /* ********** Member Page ********** */ /* Include Code */ include("assets/member.inc.php"); /* Is an Action set? */ if(isset($_GET['action'])) { $action = $_GET['action']; } else { $action = null; } if(isset($_GET['subaction'])) { $subaction = $_GET['subaction']; } else { $subaction = null; } if($action == 'logout') { echo $member->logout(); $title = 'Logging user out'; $content = '<div class="notice info">You are being logged out...</div>'; } elseif($action == 'settings') { $member->LoggedIn(); $user = $member->data(); if($subaction == 'password') { $title = 'Change Password'; $content = $member->changePassword($user->id); } elseif($subaction == 'email') { $title = 'Change E-Mail'; $content = $member->changeEmail($user->id); } elseif($subaction == 'delete') { $title = 'Delete Account'; $content = $member->deleteAccount($user->id); } else { $title = 'Settings'; $content = '<a href="member.php?action=settings&subaction=password" class="button full">Change Password</a><a href="member.php?action=settings&subaction=email" class="button full">Change E-Mail</a><a href="member.php?action=settings&subaction=delete" class="button full">Delete Account</a>'; } } elseif($action == 'register') { $title = 'Create an account'; $content = $member->register() . '<p class="options group"><a href="member.php?action=login">Already have an account?</a> • <a href="member.php?action=recover-password">Recover Password</a></p>'; } elseif($action == 'recover-password') { $title = 'Recover your password'; $content = $member->recoverPassword() . '<p class="options group"><a href="member.php?action=login">Already have an account?</a></p>'; } elseif($action == 'verification') { $title = 'Your account has been verified'; $content = $member->verification() . '<p class="options group"><a href="member.php?action=login">Already have an account?</a></p>'; } else { $title = 'Login'; $content = $member->login() . '<p class="options group"><a href="member.php?action=register">Register</a> • <a href="member.php?action=recover-password">Recover Password</a></p>'; }
?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" /> <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" /> </head> <body> <div id="members" class="group"> <h1><?php echo $title; ?></h1> <?php echo $content; ?> <html> <body> <?php $con=mysql_connect('localhost', 'xxx', 'xxxxx'); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("xxxxxx", $con); $username=$_POST['username']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?> Login Successful <p><a href="index.php\">Click here to logout!</a></p> </body> </html> well first of all, this code has two heads remove one of them: <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" /> then change <?php echo $content; ?> <html> <body> <?php to <?php echo $content; ?> <?php Still nothing lol been working on this for close to 3 hours now...... brain fried fixed all that payb.tc said with no avail lol, came from all the cuting and pasting trying to fix this dang thing
|
|
|
|
BitcoinINV (OP)
|
|
September 07, 2012, 01:33:13 AM |
|
Update on what the code looks like so far ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" />
<body> <div id="members" class="group"> <?php echo $content; ?>
<?php <?php $con=mysql_connect('localhost', '', ''); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("", $con); $username=$_POST['username']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?> </p> </body> </html>
Login Successful <p><a href="index.php\">Click here to logout!</a></p> </body> </html>
|
|
|
|
gweedo
Legendary
Offline
Activity: 1498
Merit: 1000
|
|
September 07, 2012, 01:35:36 AM |
|
Update on what the code looks like so far ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" />
<body> <div id="members" class="group"> <?php echo $content; ?>
<?php <?php $con=mysql_connect('localhost', '', ''); if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("", $con); $username=$_POST['username']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?> </p> </body> </html>
Login Successful <p><a href="index.php\">Click here to logout!</a></p> </body> </html> remove the ?> at the top
|
|
|
|
dree12
Legendary
Offline
Activity: 1246
Merit: 1077
|
|
September 07, 2012, 01:36:58 AM |
|
Update on what the code looks like so far ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" />
<body> <div id="members" class="group"> <?php echo $content; ?>
<?php $username=$_POST['username']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?> </p> </body> </html>
Login Successful <p><a href="index.php\">Click here to logout!</a></p> </body> </html> Do the following: - Remove ?> at the beginning of the code.
- Add "</head>" after <link rel="stylesheet" type="text/css" href="assets/css/style.css" />
- Add "</div>" after <?php echo $content; ?>
- Add "<p>" after the </div> you just added.
- Remove the first "</body></html>", located right after the </p>.
- Put back the "$con=mysql_connect('localhost', '', '');
if (!$con) { die('Could not connect: '.mysql_error()); } mysql_select_db("", $con);".
The code should look like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title><?php echo $title; ?></title> <!--CSS Files--> <link rel="stylesheet" type="text/css" href="assets/css/style.css" /> </head>
<body> <div id="members" class="group"> <?php echo $content; ?> </div>
<p> <?php $con=mysql_connect('localhost', '', '') or die('Could not connect: '.mysql_error()); mysql_select_db("", $con); $username=$_POST['username']; $username=mysql_real_escape_string($username); $result=mysql_query("SELECT * FROM users WHERE username='$username'"); $row=mysql_fetch_array($result); echo "Email: ".$row['email']."<br/>"; echo "Username: ".$row['username']; mysql_close ($con); ?> </p>
Login Successful <p><a href="index.php\">Click here to logout!</a></p> </body> </html>
|
|
|
|
|