Page 1 of 1
i can't send my userid to the next page..can some1 check for
Posted: Thu May 13, 2004 3:17 am
by fnleong
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>
?>
Posted: Thu May 13, 2004 3:18 am
by fnleong
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");
?>
Posted: Thu May 13, 2004 3:21 am
by JayBird
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
Posted: Thu May 13, 2004 3:22 am
by malcolmboston
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());
?>
Posted: Thu May 13, 2004 3:23 am
by fnleong
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
Posted: Thu May 13, 2004 3:24 am
by malcolmboston
Code: Select all
while (($row = mysql_fetch_object($result)))
to
Code: Select all
while (($row = mysql_fetch_array($result))){
stil cant
Posted: Thu May 13, 2004 4:00 am
by fnleong
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>';
}
?>
?>
?>
Posted: Thu May 13, 2004 4:01 am
by fnleong
it still can't get the user id from the previous page i think..
undefined variable row in line 16
Posted: Thu May 13, 2004 5:20 am
by teckyan888
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']}' ";
?>
Posted: Thu May 13, 2004 5:39 am
by fnleong
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