Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
mod rewrite need help
Old 04-24-2008, 05:44 AM mod rewrite need help
Banned

Posts: 23
Trades: 0
hey guys

i use this link to go to a users profile
PHP Code:
<a href="<?php echo get_username($_SESSION['user_id']);?> ">

this basicly with the help of htaccess
PHP Code:
RewriteEngine on
RewriteBase 
/
RewriteRule ^([^/.]+)/?$ members/profile.php?username=$1
RewriteRule 
^([^/.]+)/?$ members/profile.php?id=$
makes is so you can go to the users profile and their data will appear

profile.php
Code:
<?php include '../index.php';?>
<?php
session_start
();
require_once
'../settings.php';

$query = "SELECT * FROM users WHERE Username = '$username' LIMIT 1";
if (
$result = mysql_query($query)){
if (
mysql_num_rows($result)) {
$array = mysql_fetch_assoc($result);
$pemail = $array['Email'];
$puser = $array['Username'];
$pid = $array['ID'];
$pfirst_name = $array['first_name'];
$plast_name = $array['last_name'];
$pabout_me = $array['about_me'];
$pevents = $array['events'];
$pgender = $array['gender'];
$pdob = $array['dob'];
$sql = "SELECT `ext` FROM `user_images` WHERE `user_id`='$pid' LIMIT 1";
?>




<title><?php echo $puser; ?>'s profile</title><body>
<table width="100%">
<tr>
<td colspan="4">
<div class="c1">
<div align="center">
<p>Welcome to <?php echo $puser; ?>'s profile </p>
<p>&nbsp;</p>
</div>
</div> </td>
</tr>

<tr>
<td width="7%"><?php $q = mysql_query($sql) or die("Error running query:".mysql_error());
if(
$q && mysql_num_rows($q) > 0) {
$row = mysql_fetch_array($q);
if(!empty(
$row)) {
echo
"<img src='http://www.runningprofiles.com/members/images/thumbs/". $pid . "." . $row['ext'] . "'";
}
else {
echo
'no image';
}
}
?>
</td>

<td width="26%">i am <?php echo $pgender;?> and my bday is <?php echo $pdob; ?> </td>
<td width="45%"></td>

<td width="22%" bordercolor="#000000" bgcolor="#99b3b4"><p>Name: <?php echo $pfirst_name; ?><?php echo $plast_name; ?></p>
<p>&nbsp;</p>
<p>About me:</p>
<?php echo $pabout_me; ?></td>
</tr>
</table>
<?php
}
else
{
echo
"<center>Sorry no users with that name can be found within our database </center><br />";
}
}
else
{
echo
"Query failed<br />$sql<br />" . mysql_error();
}
?>

</body>
</html>


this all works fine.... but recently i have added this Code:
PHP Code:
<? $page $_GET['page'];
                    if (
ereg('[A-Za-z0-9]',$page) ) {
                        if (
file_exists('include/'.$page.'.php')) {
                            include(
'include/'.$page.'.php');
                        } else {
                            include(
'include/main.php');
                        }
                   } else {
                            include(
'include/main.php');
                    }
?>
but the code for this is http://www.mywebsite.com/members/index.php?section=(what ever the page)

so
<a href="?page=<?php echo get_username($_SESSION['user_id']);?> "> user</a>


i belive i have to chnage my mod rewrite to something like RewriteRule ^([^/.]+)/?$ members/index.php?page=?username=$1
to get it all to work :S:S
runnerjp is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-24-2008, 06:24 PM Re: mod rewrite need help
solomongaby's Avatar
Webmaster Talker

Latest Blog Post:
How Do You Find Music Online ?
Posts: 522
Name: Gabe Solomon
Location: Romania
Trades: 1
first check it there is a get variable page ... the eregi ...
also those 2 lines of rewrite seem exacly the same ... i would put numeric on the second one
__________________
If you like my posts ... TK is appreciated:)

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
solomongaby is offline
Reply With Quote
View Public Profile Visit solomongaby's homepage!
 
Reply     « Reply to mod rewrite need help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14354 seconds with 12 queries