Pages:
Author

Topic: [Bounty] Fix this php code for me .5 btc - page 2. (Read 11999 times)

legendary
Activity: 1498
Merit: 1000
September 06, 2012, 08:35:36 PM
#19
Update on what the code looks like so far


Code:
?>



<span style="color: #000000"><span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">$title</span><span style="color: #007700">; </span><span style="color: #0000BB">?></span></span>






echo $content?>

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']."
"
;
echo 
"Username: ".$row['username'];
mysql_close ($con);
?>





Login Successful

Click here to logout!




remove the ?> at the top
sr. member
Activity: 448
Merit: 250
September 06, 2012, 08:33:13 PM
#18
Update on what the code looks like so far


Code:
?>



<span style="color: #000000"><span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">$title</span><span style="color: #007700">; </span><span style="color: #0000BB">?></span></span>






echo $content?>

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']."
"
;
echo 
"Username: ".$row['username'];
mysql_close ($con);
?>





Login Successful

Click here to logout!



sr. member
Activity: 448
Merit: 250
September 06, 2012, 08:31:46 PM
#17
sr. member
Activity: 448
Merit: 254
September 06, 2012, 08:27:07 PM
#16
no the users info shows up for a second then it goes away. Here is the whole page code

You've got nested 's and '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. Smiley
hero member
Activity: 812
Merit: 1000
September 06, 2012, 08:24:03 PM
#15
sr. member
Activity: 448
Merit: 254
September 06, 2012, 08:22:46 PM
#14
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.
sr. member
Activity: 448
Merit: 250
September 06, 2012, 08:21:19 PM
#13
no the users info shows up for a second then it goes away. Here is the whole page code
Code:
/*
**********
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 'You are being logged out...
';
} 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 'Change PasswordChange E-MailDelete Account';
}
} elseif(
$action == 'register') {
$title   'Create an account';
$content $member->register() . 'Already have an account? • Recover Password

'
;
} elseif(
$action == 'recover-password') {
$title   'Recover your password';
$content $member->recoverPassword() . 'Already have an account?

'
;
} elseif(
$action == 'verification') {
$title   'Your account has been verified';
$content $member->verification() . 'Already have an account?

'
;
} else {
$title   'Login';
$content =  $member->login() . 'Register • Recover Password

'
;
}

?>



<span style="color: #000000"><span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">$title</span><span style="color: #007700">; </span><span style="color: #0000BB">?></span></span>



<span style="color: #000000"><span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #0000BB">$title</span><span style="color: #007700">; </span><span style="color: #0000BB">?></span></span>





echo $title?>


echo $content?>


$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']."
"
;
echo 
"Username: ".$row['username'];
mysql_close ($con);
?>

Login Successful

Click here to logout!



legendary
Activity: 1246
Merit: 1077
September 06, 2012, 08:20:16 PM
#12
when you first login it  shows it for about 1 second then goes it goes away.
Try this full HTML page:

Code:



Title



$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']."
"
;
echo 
"Username: ".$row['username'];
mysql_close ($con);
?>




hero member
Activity: 812
Merit: 1000
September 06, 2012, 08:18:15 PM
#11
when you first login it  shows it for about 1 second then goes it goes away.

goes away to what? a blank page?
sr. member
Activity: 448
Merit: 250
September 06, 2012, 08:14:22 PM
#10
when you first login it  shows it for about 1 second then goes it goes away.
legendary
Activity: 1246
Merit: 1077
September 06, 2012, 08:11:31 PM
#9
Code:
$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']."
"
;
echo 
"Username: ".$row['username'];
mysql_close ($con);
?>

he forgot a ; on the line of

Code:
$username=mysql_real_escape_string($username)
That was it. Fixed now, it should work.
legendary
Activity: 1498
Merit: 1000
September 06, 2012, 07:41:32 PM
#8
Code:
$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']."
"
;
echo 
"Username: ".$row['username'];
mysql_close ($con);
?>

he forgot a ; on the line of

Code:
$username=mysql_real_escape_string($username)
sr. member
Activity: 448
Merit: 250
September 06, 2012, 07:38:56 PM
#7
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
legendary
Activity: 1246
Merit: 1077
September 06, 2012, 06:45:16 PM
#6
$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']."
"
;
echo 
"Username: ".$row['username'];
mysql_close ($con);
?>
Note that this uses $_POST['skiz22285'], which is probably not what you want.
sr. member
Activity: 448
Merit: 250
September 06, 2012, 06:32:17 PM
#5
The problem with that is it displays all the mysql data, its not user specific.
hero member
Activity: 576
Merit: 514
September 06, 2012, 05:14:32 PM
#4
Just tested the following code without any problems
Code:


$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 
"

Email
Username
"
;
$rows=mysql_num_rows($result);
for (
$i=0$i<$rows$i++)
{
$row=mysql_fetch_array($result);
echo "";
echo "".$row['email']."";
echo "".$row['username']."";
echo "";
}
echo 
"";
mysql_close ($con);
?>

Login Successful

Click here to logout!




Also tested the while-loop with no problems.
sr. member
Activity: 448
Merit: 250
September 06, 2012, 05:04:38 PM
#3
Try this:
Code:
$rows=mysql_num_rows($result);
for ($i=0; $i<$rows; $i++)
{
$row=mysql_fetch_array($result);
echo "";--------------------------------------------------------------------- Parse error
echo "" .$row['email'] ."";
echo "" .$row['username'] ."";
echo "";
}
If you don't need an incrementing counter, you could also do
Code:
while ($row=mysql_fetch_array($result))
{
echo "";
echo "" .$row['email'] ."";
echo "" .$row['username'] ."";
echo "";
}
instead of the for-loop

Get a parse error
hero member
Activity: 576
Merit: 514
September 06, 2012, 04:58:40 PM
#2
Try this:
Code:
$rows=mysql_num_rows($result);
for ($i=0; $i<$rows; $i++)
{
$row=mysql_fetch_array($result);
echo "";
echo "" .$row['email'] ."";
echo "" .$row['username'] ."";
echo "";
}
If you don't need an incrementing counter, you could also do
Code:
while ($row=mysql_fetch_array($result))
{
echo "";
echo "" .$row['email'] ."";
echo "" .$row['username'] ."";
echo "";
}
instead of the for-loop
sr. member
Activity: 448
Merit: 250
September 06, 2012, 04:53:07 PM
#1
$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 "





";

{
echo "";

echo "";
echo "";

echo "";
}
echo "
Email username
" .$row['email'] ."" .$row['username'] ."
";
mysql_close ($con);
?>


Login Successful

Click here to logout!






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.
Pages:
Jump to:
© 2020, Bitcointalksearch.org