PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
fnleong
Forum Newbie
Posts: 18 Joined: Wed May 12, 2004 5:49 am
Post
by fnleong » Thu May 13, 2004 3:17 am
thanks~~
//this is the 1st page allow user to click and then link to another profile page..
Code: Select all
<?php
<html>
<HEAD><TITLE>Member Section</TITLE>
</HEAD>
<body>
<a href="userview.php?userID=<?php echo $row["userID"];?>">View Profile </a></div></td>
</body>
</html>
?>
Last edited by
fnleong on Thu May 13, 2004 3:43 am, edited 2 times in total.
fnleong
Forum Newbie
Posts: 18 Joined: Wed May 12, 2004 5:49 am
Post
by fnleong » Thu May 13, 2004 3:18 am
this is the page link to
Code: Select all
<?php
<html>
<head>
<title>List MY Records</title>
</head>
<h1>My Profile</h1></center>
<?php
@ $db = mysql_pconnect('localhost','root');
if (!$db)
{
echo 'Error: no record to database. Please try again later.';
exit;
}
mysql_select_db('mobile');
$userID = $_GET['userID'];
$query = "select * from users where userID =$userID";
$result = mysql_query($query);
printf("<TABLE BORDER WIDTH="100%%">\n");
printf("<TR>
<TD><B>User Name</B></TD>
<TD><B>Password</B></TD>
<TD><B>first Name</B></TD>
<TD><B>Last Name</B></TD>
<TD><B>Email</B></TD>
<TD><B>Address</B></TD>
<TD><B>PhoneNumber</B></TD>
<TD><B>Gender</B></TD>
<TD><B>userID</B></TD>
</TR>\n");
while (($row = mysql_fetch_object($result))){
printf("<TR>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD><A HREF="modifyuser.php?userID=%s"><I>Modify</I></A></TD>
</TR>\n",
$row->username, $row->password, $row->first_name, $row->last_name,$row->email,$row->address,$row->PhoneNumber,$row->gender, $row->userID,$row->userID,$row->userID);}
printf("</TABLE>\n");
?>
Last edited by
fnleong on Thu May 13, 2004 3:38 am, edited 1 time in total.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Thu May 13, 2004 3:21 am
PLEASE PLEASE PLEASE READ THIS BEFORE I ANSWER ANY OF YOURS POSTS!
viewtopic.php?t=21171
Once you have edited your posts into the correct format, i will try to help.
Mark
malcolmboston
DevNet Resident
Posts: 1826 Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK
Post
by malcolmboston » Thu May 13, 2004 3:22 am
replace your query with this, see what happens
Code: Select all
$query = "SELECT * from USERS where userID ='$userID'";
// added this print statement to view query
print $query;
$result = mysql_query($query) or die (mysql_error());
?>
fnleong
Forum Newbie
Posts: 18 Joined: Wed May 12, 2004 5:49 am
Post
by fnleong » Thu May 13, 2004 3:23 am
this is the error msg
Code: Select all
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Group\Apache2\htdocs\viewprofile.php on line 47
it display a table but is without contents
Last edited by
fnleong on Thu May 13, 2004 3:39 am, edited 1 time in total.
malcolmboston
DevNet Resident
Posts: 1826 Joined: Tue Nov 18, 2003 1:09 pm
Location: Middlesbrough, UK
Post
by malcolmboston » Thu May 13, 2004 3:24 am
Code: Select all
while (($row = mysql_fetch_object($result)))
to
Code: Select all
while (($row = mysql_fetch_array($result))){
fnleong
Forum Newbie
Posts: 18 Joined: Wed May 12, 2004 5:49 am
Post
by fnleong » Thu May 13, 2004 4:00 am
i hav change as what u said, but still cant
Code: Select all
<?php
<?php
session_start();
if (isset($HTTP_SESSION_VARS['valid_user']))
{ echo '<p>You are logged in as '.$HTTP_SESSION_VARS['valid_user'].'</p>';
?>
<html>
<head>
<title>List MY Records</title>
</head>
<h1>My Profile</h1></center>
<?php
@ $db = mysql_pconnect('localhost','root');
if (!$db)
{
echo 'Error: no record to database. Please try again later.';
exit;
}
mysql_select_db('mobile');
$userID = $_GET['userID'];
$query = "SELECT * from users where userID ='$userID'";
print $query;
$result = mysql_query($query) or die (mysql_error());
printf("<TABLE BORDER WIDTH="100%%">\n");
printf("<TR>
<TD><B>User Name</B></TD>
<TD><B>Password</B></TD>
<TD><B>first Name</B></TD>
<TD><B>Last Name</B></TD>
<TD><B>Email</B></TD>
<TD><B>Address</B></TD>
<TD><B>PhoneNumber</B></TD>
<TD><B>Gender</B></TD>
<TD><B>userID</B></TD>
</TR>\n");
while (($row = mysql_fetch_array($result))){
printf("<TR>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD>%s</TD>
<TD><A HREF="modifyuser.php?userID=%s"><I>Modify</I></A></TD>
</TR>\n",
$row->username, $row->password, $row->first_name, $row->last_name,$row->email,$row->address,$row->PhoneNumber,$row->gender, $row->userID,$row->userID,$row->userID);}
printf("</TABLE>\n");
?>
<br><br>
<a href="adminusermenu.php">BACK</br></a>
</body>
</html><?
exit;
}else
{
echo '<p>You are not logged in..</p>';
echo '<p>Only logged in admins may see this page.</p>';
}
?>
?>
?>
fnleong
Forum Newbie
Posts: 18 Joined: Wed May 12, 2004 5:49 am
Post
by fnleong » Thu May 13, 2004 4:01 am
it still can't get the user id from the previous page i think..
undefined variable row in line 16
teckyan888
Forum Commoner
Posts: 40 Joined: Tue May 11, 2004 10:46 am
Post
by teckyan888 » Thu May 13, 2004 5:20 am
Code: Select all
<?php
mysql_select_db('mobile');
$userID = $_GET['userID'];
$query = "select * from users where userID =$userID";
?>
u try like this:
Code: Select all
<?php
mysql_select_db('mobile');
$query = 'select * from Users '
."where userID = '{$_REQUEST['userID']}' ";
?>
fnleong
Forum Newbie
Posts: 18 Joined: Wed May 12, 2004 5:49 am
Post
by fnleong » Thu May 13, 2004 5:39 am
still cant teck yan.is not this proiblm, is it cant get the userid from the previous page, how to pass the id to this page?
hav u do the view profile part?for user to view their profile