runnerjp Posted November 26, 2007 Share Posted November 26, 2007 hey im using this <?php $query="SELECT * FROM users WHERE Username = '$_GET[username]' LIMIT 1"; $result=mysql_query($query); while($array=mysql_fetch_assoc($result)){ $pID=$array['ID']; $puser=$array['username']; } ?> <?php echo $puser . " " . $ID; ?> to get a users data by following a link like mywebsite.com/members/name where in the members folder i have .htaccess <?php RewriteEngine on RewriteBase / RewriteRule ^i([^/\.]+)/?$ /images.php?username=$1 RewriteRule ^([^/\.]+)/?$ members/profile.php?username=$1 [L] ?> shouldent $_GET[username] get it either form fact im logged in or from the url itself and display there information? Link to comment https://forums.phpfreaks.com/topic/78907-solved-sql-query-getting-no-data/ Share on other sites More sharing options...
trq Posted November 26, 2007 Share Posted November 26, 2007 Your rule should look more like.... RewriteRule ^members/([A-Za-z0-9]+)$ members/profile.php?username=$1 Then your code... <?php if (isset($_GET['username'])) { $username = mysql_real_escape_string($_GET['username']); $query = "SELECT * FROM users WHERE Username = '$username' LIMIT 1"; if ($result = mysql_query($query)) { if (mysql_num-rows($result)) { $array = mysql_fetch_assoc($result); $pID = $array['ID']; $puser = $array['Username']; } } } echo $puser . " " . $pID; ?> Link to comment https://forums.phpfreaks.com/topic/78907-solved-sql-query-getting-no-data/#findComment-399348 Share on other sites More sharing options...
runnerjp Posted November 26, 2007 Author Share Posted November 26, 2007 the re-write rule u gave does not work... http 404 error Link to comment https://forums.phpfreaks.com/topic/78907-solved-sql-query-getting-no-data/#findComment-399381 Share on other sites More sharing options...
runnerjp Posted November 26, 2007 Author Share Posted November 26, 2007 any ideas any1? Link to comment https://forums.phpfreaks.com/topic/78907-solved-sql-query-getting-no-data/#findComment-399416 Share on other sites More sharing options...
runnerjp Posted November 26, 2007 Author Share Posted November 26, 2007 ? Link to comment https://forums.phpfreaks.com/topic/78907-solved-sql-query-getting-no-data/#findComment-399518 Share on other sites More sharing options...
adam291086 Posted November 26, 2007 Share Posted November 26, 2007 have you tired echoing all your variables to make sure information is being passed across and that the query is working? Link to comment https://forums.phpfreaks.com/topic/78907-solved-sql-query-getting-no-data/#findComment-399523 Share on other sites More sharing options...
runnerjp Posted November 26, 2007 Author Share Posted November 26, 2007 tried <?php if (isset($_GET['username'])) { $username = mysql_real_escape_string($_GET['username']); $query = "SELECT * FROM users WHERE Username = '$username' LIMIT 1"; if ($result = mysql_query($query)) { if (mysql_num-rows($result)) { $array = mysql_fetch_assoc($result); $pID = $array['ID']; $puser = $array['Username']; echo $puser . " " . $pID; } else { echo "No users found with id $id<br />"; } } else { echo "Query failed<br />$sql<br />" . mysql_error(); } } else { echo "No ID passed"; } ?> does this mean its not passing anyhting and if so why? Link to comment https://forums.phpfreaks.com/topic/78907-solved-sql-query-getting-no-data/#findComment-399532 Share on other sites More sharing options...
kjtocool Posted November 26, 2007 Share Posted November 26, 2007 Try simplifying: <?php if (isset($_GET['username'])) { $username = $_GET['username']; $query = "SELECT * FROM users WHERE Username = '$username' LIMIT 1"; $result = mysql_query($query) if ($result) { if (mysql_num_rows($result)) { $array = mysql_fetch_assoc($result); $pID = $array['ID']; $puser = $array['Username']; echo $puser . " " . $pID; } else { echo "No users found with id $id<br />"; } } else { echo "Query failed<br />$sql<br />" . mysql_error(); } } else { echo "No ID passed"; } ?> You had at least 1 syntax error in the last block of code you posted. Link to comment https://forums.phpfreaks.com/topic/78907-solved-sql-query-getting-no-data/#findComment-399624 Share on other sites More sharing options...
xyn Posted November 26, 2007 Share Posted November 26, 2007 Mod-Rewrite: #Rewrite RewriteEngine On RewriteBase / RewriteRule ^/members/(.*)$ /members/index.php?username=$1[L] Link to comment https://forums.phpfreaks.com/topic/78907-solved-sql-query-getting-no-data/#findComment-399651 Share on other sites More sharing options...
runnerjp Posted November 26, 2007 Author Share Posted November 26, 2007 i have messed around wiht code and finally got it...thanks guys Link to comment https://forums.phpfreaks.com/topic/78907-solved-sql-query-getting-no-data/#findComment-399755 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.