Jump to content

unlishema.wolf

Members
  • Posts

    110
  • Joined

  • Last visited

About unlishema.wolf

  • Birthday 05/30/1992

Contact Methods

  • MSN
    unlishema.wolf@hotmail.com
  • Website URL
    http://unlishema.us.to
  • Skype
    unlishema.wolf

Profile Information

  • Gender
    Male
  • Location
    United States of America, West Virginia

unlishema.wolf's Achievements

Newbie

Newbie (1/5)

1

Reputation

  1. I believe I see what you mean with @num. I might be able to give this a try. I need to finish this project but luckily it has not been an extreme concern. I will be looking into this more. I will reply if this helped at all. I appreciate the help, however what you don't seem to realize is the database does not contain the rank of the user. I am determining the rank during the query based on the score. This would work great if the rank was stored in the database. The database needs to be flexible due to the nature of live stream updating. Therefore I need to do everything in 1 query to make less strain on the server due to high bandwidth traffic.
  2. Okay so what I have is a problem with the SELECT query. Pretty sure this is the correct spot seeing as it is with the mysql query. I need to select a specific username's row get the rank of the user and get the users for one rank higher and one rank lower. So here is the code I have. Query for grabbing user with rank: SELECT z.*, x.rank FROM `hiscore` z INNER JOIN (SELECT a.username, a.score, @num := @num + 1 AS rank from `hiscore` a, (SELECT @num := 0) d order by a.score DESC) x ON z.username = x.username WHERE z.username = 'unlishema' LIMIT 1 Query for table: SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; SET time_zone = "+00:00"; CREATE TABLE IF NOT EXISTS `hiscore` ( `id` int(11) NOT NULL AUTO_INCREMENT, `score` int(11) NOT NULL, `username` varchar(50) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; INSERT INTO `hiscore` (`id`, `score`, `username`) VALUES (1, 456, 't1'), (2, 548, 't2'), (3, 123, 't3'), (4, 234, 't4'), (5, 923, 't5'), (6, 234, 't6'); The Query I developed to try to do this: (does not work as I don't know half of what I am doing) SELECT * FROM `hiscore` AS z LEFT JOIN (select a.*, @num := @num + 1 AS rank from `hiscore` a, (SELECT @num := 0) d order by a.score DESC) w ON z.username = w.username LEFT JOIN (select b.*, @num := @num + 1 AS rank from `hiscore` WHERE b.rank=a.rank-1 b, (SELECT @num := 0) e order by a.score DESC) x ON z.username = x.username LEFT JOIN (select c.*, @num := @num + 1 AS rank from `hiscore` WHERE c.rank=a.rank+1 c, (SELECT @num := 0) f order by a.score DESC) y ON z.username = y.username WHERE z.username = 't2' LIMIT 3 so for an example lets pull the folling usernames with ranks in correct order. t2 with score of 548 (inital user we are pulling) t1 with score of 456 (below user we are pulling) t5 with score of 923 (above user we are pulling) Correct order would be: t1, t2, t5 Also I wanted to note that scores can be the same. It don't really matter the order of same scores if the initial score does not have any duplicate scores, otherwise we would not want the same scores to be pulled even though they are the same. (greater than score > initial score) and (less than score < initial score) NOT (greater than score >= initial score) and (less than score <= initial score) Sorry for the previous paragraph I can't do paragraph formation very well. I can provide additional information as needed. I can't think of anything else I would need to post at this moment. Thanks in advance.
  3. The following code allows you to call one function and run a mysql query without having to leave a mysql connection open or opening it every time. It will open the connection, select the database, run the query, and then close the connection if you wish so. Notice: If a mysql_error() occurs it will not close the connection. <?php $mysql_test_server="localhost"; $mysql_test_username="username"; $mysql_test_password="password"; $mysql_test_database="database"; function mysql_test_query($mysql_test_query, $mysql_test_close=true) { global $mysql_test_server,$mysql_test_username,$mysql_test_password,$mysql_test_database; $mysql_test_conected = mysql_connect($mysql_test_server,$mysql_test_username,$mysql_test_password); if(!$mysql_test_conected) { return false; } if(!mysql_select_db($mysql_test_database)) { return false; } $mysql_test_result = mysql_query($mysql_test_query); if(!$mysql_test_result) { return false; } if ($mysql_test_close) { if(!mysql_close()) { return false; } } return $mysql_test_result; } $result = mysql_test_query("SELECT * FROM people") or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { echo "First Name: ".$row['first_name']."</ br>"; echo "Last Name: ".$row['last_name']."</ br>"; } ?> Sorry for the third post just wanted to post the solution for my problem for anybody in the future.
  4. I forgot to mention I have attempted the following without any working results. <?php $mysql_test_server="localhost"; $mysql_test_username="username"; $mysql_test_password="password"; $mysql_test_database="database"; function usql_query($mysql_test_query, $mysql_test_close=true) { mysql_connect($mysql_test_server,$mysql_test_username,$mysql_test_password) or return false; mysql_select_db($mysql_test_database) or return false; $mysql_test_result = mysql_query($mysql_test_query) or return false; if ($mysql_test_close) { mysql_close() or return false; } return $mysql_test_result; } $result = usql_query("SELECT * FROM people") or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { echo "First Name: ".$row['first_name']."</ br>"; echo "Last Name: ".$row['last_name']."</ br>"; } ?> However, after reading up on the php functions page I am going to test the following once I get my localhost back up and running. <?php $mysql_test_server="localhost"; $mysql_test_username="username"; $mysql_test_password="password"; $mysql_test_database="database"; function usql_query($mysql_test_query, $mysql_test_close=true) { $mysql_test_conected = mysql_connect($mysql_test_server,$mysql_test_username,$mysql_test_password); if(!$mysql_test_conected) { return false; } if(!mysql_select_db($mysql_test_database)) { return false; } $mysql_test_result = mysql_query($mysql_test_query); if(!$mysql_test_result) { return false; } if ($mysql_test_close) { if(!mysql_close()) { return false; } } return $mysql_test_result; } $result = usql_query("SELECT * FROM people") or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { echo "First Name: ".$row['first_name']."</ br>"; echo "Last Name: ".$row['last_name']."</ br>"; } ?> Sorry for double post. I waited to long and can't edit the first post.
  5. You aren't passing you variables correctly. /sig2/showimage.php?day=&month=&year=&smokedperday=&costperday=&icon=/sig2/bsv.jpg You should be able to edit this into your current /sig2/showresults.php and fix the image display. <?php echp '<img src="http://example.com/sig2/showimage.php?day=".$day."&month=".$month."&year=".$year."&smokedperday=".$smokedperday."&costperday=".$costperday."&icon=/sig2/bsv.jpg" />'; ?> All the help I can give with the info I have. Also please read my signature.
  6. Well it is the time of the year I refresh myself on php again. I am wanting to make a function to connect to the mysql database, run the query, and return the result. However, I also wish to add in a way to get the mysql error if something messes up (for debugging of course). Here is what I have so far: <?php $mysql_test_server="localhost"; $mysql_test_username="username"; $mysql_test_password="password"; $mysql_test_database="database"; function mysql_test_query($mysql_test_query, $mysql_test_close=true) { mysql_connect($mysql_test_server,$mysql_test_username,$mysql_test_password); mysql_select_db($mysql_test_database); $mysql_test_result = mysql_query($mysql_test_query); if ($mysql_test_close) { mysql_close(); } return $mysql_test_result; } $result = mysql_test_query("SELECT * FROM people") or die(mysql_error()); while($row = mysql_fetch_assoc($result)) { echo "First Name: ".$row['first_name']."</ br>"; echo "Last Name: ".$row['last_name']."</ br>"; } ?>
  7. I went through all my files and changed my dynamic links to hard links and fixed it. Next on my list is to redo my dynamic links after i find error.
  8. Also I have been working on trying to get this to work off and on. I have got http://unlishema.us.to/news to redirct to http://unsliehma.us.to/?p=news and it works. However, when i try to redirect http://unlishema.us.to/projects/minecraft it redirects fine but it then tries to load my style from http://unlishema.us.to/projects/styles/default/style.css along with my images and everything. Here is my code so you can see the exact problem. You can also see my live site at http://unlishema.us.to but just FYI the nav links are for the old index.php not the new one. .htaccess <Files .htaccess> order allow,deny deny from all </Files> Options -Indexes RewriteEngine on Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)/([a-z0-9\-]+)$ index.php?p=$1&c=$2&t=$3 [L] RewriteRule ^([a-z0-9\-]+)/([a-z0-9\-]+)$ index.php?p=$1&c=$2 [L] RewriteRule ^([a-z0-9\-]+)$ index.php?p=$1 [L] RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www\.)?unlishema.us.to/.*$ [NC] RewriteRule .*\.(jpe?g|gif|bmp|png)$ http://i.imgur.com/qX4w7.gif [NC,R,L] ErrorDocument 400 http://unlishema.us.to/?error ErrorDocument 401 http://unlishema.us.to/?error ErrorDocument 403 http://unlishema.us.to/?error ErrorDocument 404 http://unlishema.us.to/?error ErrorDocument 500 http://unlishema.us.to/?error index.php <?php $Page_Name="Projects"; $style="default"; $href="./"; $u_agent = $_SERVER['HTTP_USER_AGENT']; $page="main"; if(isset($_GET['p'])) $page=$_GET['p']; if($page == "projects") { if(isset($_GET['c'])) $project = $_GET['c']; if(!isset($project)) include $href."project/default.php"; else include $href."project/other.php"; } else if($page == "gallery") { include $href."gallery.php"; } else if($page == "forum")) { include $href."forum.php"; } else { $type=$page; include $href."default.php"; } include $href."styles/$style/footer.php"; ?>
  9. What I would like to do is the following. Sorry for not including in the first post: http://unlishema.us.to http://unlishema.us.to/projects http://unlishema.us.to/projects/minecraft http://unlishema.us.to/forum http://unlishema.us.to/forum/1 http://unlishema.us.to/forum/1/2 I don't have to worry about the forum's as far as indicating 1 is c and not p2. The only code I have that gets p2 is in my main index. The fourm index has completely separate code. I just need to modify my url so it gives me the info but it looks like a directory not $GET values.
  10. You have an error with your mysql query. I would need your query to determine if it is your query or your database. The other option is you can run the following code after adding your info: <?php // Edit below this line $mysql_host="localhost"; $mysql_user="username"; $mysql_pass="password"; $mysql_database="database" $mysql_sql="SELECT id as userid, fullname, userstatus FROM sometable WHERE userstatus = 1"; // Do NOT Edit below this line $conn = mysql_connect($mysql_host, $mysql_user, $mysql_pass); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); exit; } if (!mysql_select_db($mysql_database)) { echo "Unable to select " . $mysql_database . ": " . mysql_error(); exit; } $result = mysql_query($mysql_sql); if (!$result) { echo "Could not successfully run query ($mysql_sql) from DB: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No rows found, nothing to print so I am exiting"; exit; } while ($row = mysql_fetch_assoc($result)) { echo $row . "</br>"; } mysql_free_result($result); ?>
  11. I am working on writing a htaccess file to "hide" my $_GET fields. However I am only able to do 1 field and sometimes I have multiple (Examples below). I do not know the santex of htaccess hardly at all. Current urls I can have: http://unlishema.us.to http://unlishema.us.to/?p=projects http://unlishema.us.to/?p=projects&p2=minecraft http://unlishema.us.to/?p=forum http://unlishema.us.to/?p=forum&c=1 http://unlishema.us.to/?p=forum&c=1&t=2 My current rewrite rule is as follows: <IfModule mod_rewrite.c> Options +FollowSymlinks RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^/]*)$ http://unlishema.us.to/?p=$1 [L] </IfModule> I need someone with knowledge of htaccess to help me make a rewrite rule that can work with all these urls.
  12. Ok I finally found out what I did wrong. I set it up for https and the port is 8080 so my routers IP is https://192.168.0.236:8080 Thanks for trying to help. Took about 8 hours to get everything to work. Finally I got it
  13. Ok I made the server's IP static. It is now 192.168.1.100 on my father's pc. Also if I go to 192.168.0.1 on my host computer. It loads my host computer's wamp server. (Used wamp cause I couldn't connect to my server computer. And have been using it to test this stuff out.)
  14. ~Wireless Internet Connection~ Host PC IP: 192.168.43.40 Host PC Gateway: 192.168.43.1 ~Wired Internet Connection~ Host PC IP: 192.168.0.1 (ICS address) Router Static IP: 192.168.0.236 (This is what I use to access my server computer from host computer) I port forward ports 80 and 22 to my server computer. ~On my fathers computer~ Father's PC IP: 192.168.1.101 Father's PC Gateway: 192.168.1.1 Server PC IP: 192.168.1.106 (I need to make these static was 102 before) Router IP: 192.168.1.1 Host PC IP: 192.168.0.1
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.