Jump to content

bncplix

Members
  • Posts

    26
  • Joined

  • Last visited

    Never

Contact Methods

  • Website URL
    http://www.BncApps.com

Profile Information

  • Gender
    Not Telling

bncplix's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Okay it turns out I did not solve it. First, I will show you my query: SELECT system.id ,system.username ,system.password ,system.followed ,follows.userid ,follows.systemid FROM system INNER JOIN follows WHERE system.followed=0 AND system.id != follows.systemid ORDER BY RAND() LIMIT 10 Basically, i need it to select a group of members from the system table, that have the "followed" field set to 0. Also, it has to check the follows table and makesure that the new id's it is selecting from the system table are not already listed in the follows table with the same userid So here is my structure: Table: System id username password followed Table: Follows id userid systemid So basically, my query must select the amount from system. But the ones selected in system must have followed=0. It also must check the follows table to makesure that there is no insersion already that has the same userid and systemid as the new ones it is grabbing. Any help?
  2. ( i cant edit) Nevermind, I think i got it.
  3. Ohh and I will paypal the first person that helps me and it ends up working $2
  4. Okay so first I will give you a rundown of the structure, then ask my question Table 1: Friend status. Contains the friend id of one person then the friend id of who they have added as a friend. Table 2: All the different friends What I need to do is make a query that will select the people from table 2, that do not have an entry in table 1 So the table 1 structure may be ID userid friendid Where: ID is just the general entry Userid is the main user id Friend id is the person they ahve added Table 2 may have: ID Username Password hasfriended It should only select those from table2 that have hasfriended as 0. I am not too great at combining queries like this. Can anybody point me in the right direction?
  5. Ok, so I have a catch-all subdomain setup. This points to /sub to be handled by the index php file there. In that file atm, all I currently do is print out "The subdomain you are currently using is:" then the subdomain, as a way to test. I also have a .htaccess in my root, that contains this: RewriteEngine on RewriteBase / Options -MultiViews RewriteRule ^([0-9a-zA-Z-]+)/?$ shortlink.php?short=$1 [L] This rewrites anything on the domain to the shortlink file to be handled. Such as www.mydomain.com/MyLink That works perfectly, but with that htaccess file, if i try to access a subdomain, it no longer prints out which subdomain i am on, instead it says: Not Found The requested URL /shortlink.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. I have been looking around everywhere on how to make a rewrite cond that will only run the rewrite rule if IT IS NOT on a subdomain, but i just cant find it anywhere! Can anybody give me a little help?
  6. Here is the full script <? session_start(); if ($_GET['log'] == "true"){ session_destroy(); } $loggedas = $_SESSION['myusername']; if(!session_is_registered(myusername)){ //echo 'You are not logged in'; ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="yes" name="apple-mobile-web-app-capable" /> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" /> <meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" /> <link href="../css/style.css" rel="stylesheet" type="text/css" /> <script src="../javascipt/functions.js" type="text/javascript"></script> <title> Friend List</title> <meta content="" name="Keywords" /> <meta content="Description of your site" name="description" /> </head> <body class="list"> <div id="topbar"> <div id="title">Friend List</div> <div id="leftnav"> <a href="index.php"><img alt="home" src="../images/home.png"/></a> </div> </div> <div id="content"> <ul> <li class="title">Please log in</span></li> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF"> <tr> <td colspan="3"><strong></strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername" type="text" id="myusername"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="text" id="mypassword"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"></td> </tr> </table> </td> </form> </tr> </table> <?php //header("location:main_login.php"); }else{ ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="yes" name="apple-mobile-web-app-capable" /> <meta content="text/html; charset=iso-8859-1" http-equiv="Content-Type" /> <meta content="minimum-scale=1.0, width=device-width, maximum-scale=0.6667, user-scalable=no" name="viewport" /> <link href="../css/style.css" rel="stylesheet" type="text/css" /> <script src="../javascipt/functions.js" type="text/javascript"></script> <title> Friend List</title> <meta content="" name="Keywords" /> <meta content="Description of your site" name="description" /> </head> <body class="list"> <div id="topbar"> <div id="title">Friend List</div> <div id="leftnav"> <a href="index.php"><img alt="home" src="../images/home.png"/></a> </div> <div id="rightbutton"> <a href="index.php">Refresh</a> </div> </div> <div id="content"> <ul> <!--<li class="title">Enter a character name</span></li>--> <?php //echo 'You are logged in<p>'; $host = 'localhost'; // Database host usually localhost $dbuser = ''; // Database Username $dbpass = ''; // Database Password $dbname = ''; // Database name // Database Connection - do NOT edit mysql_connect("$host", "$dbuser", "$dbpass") or die(); mysql_select_db("$dbname") or die(); //$newfriend = $_GET['add']; $newfriend= str_replace("\'","'",$_GET['add']); //$newfriend= str_replace("'","\'",$_GET['add']); $newfriend = htmlentities($newfriend); //prevent xss if ($newfriend != ""){ //add new friend //check to see if new character exists $charSite = file_get_contents('http://www.tibia.com/community/?subtopic=character&name='.str_replace(array(' ','~'),array('+',''),$newfriend)); $splitA = explode('<TR><TD BGCOLOR="#505050" CLASS=white><B>', $charSite); $splitB = explode('</B></TD></TR>',$splitA[1]); if($splitB[0] == "Could not find character"){ echo 'The character '.$newfriend.' does not exist.'; }else{ //lets first find what world hes in $splitA = explode('World:</TD><TD>', $charSite); $splitB = explode('</TD></TR>',$splitA[1]); $world = $splitB[0]; //echo '-'.$world.'-'; //fix name up for databasr //$newfriend = str_replace(" ","+",$newfriend); $newfriend = strtolower($newfriend); //check to see if hes already in the database $newfriend = str_replace("'","\'",$newfriend); $request = mysql_query("SELECT friendname FROM friendnames WHERE friendname = '".$newfriend."'"); //find world id related to world $query = "SELECT worldid FROM worlds WHERE worldname = '".$world."'"; $result = mysql_query($query); //while($data = mysql_fetch_array($result)){ $data = mysql_fetch_array($result); $worldid = $data['worldid']; //} //echo '-'.$worldid.'-'; if (mysql_num_rows($request) > 0){ //already exists //echo 'This player is already in the database.'; $query = "SELECT id FROM members WHERE username='".$loggedas."'"; $result = mysql_query($query); $data = mysql_fetch_array($result, MYSQL_ASSOC); $loggedid = $data['id']; //echo $loggedid; //user's id number //lets add the id that is already in the database to the users list $request = "SELECT friendid FROM friendnames WHERE friendname = '".$newfriend."'"; $result = mysql_query($request); $data = mysql_fetch_array($result, MYSQL_ASSOC); $friendid = $data['friendid']; //we now know the friend id and the user id //echo 'friendid: '.$friendid; $request = mysql_query("SELECT userid FROM friends WHERE friendid = '".$friendid."' AND userid = '".$loggedid."'"); if (mysql_num_rows($request) > 0){ echo 'You already have '.$newfriend.' on your friend list.'; }else{ //add new to friends, user id, friend id and world id $query = "INSERT INTO friends(userid, friendid, worldid) VALUES ('".$loggedid."', '".$friendid."', '".$worldid."')"; mysql_query($query); mysql_free_result($result); //mysql_query(" "); echo 'You added '.$newfriend.' to your VIP list.'; }//}else{ for already has }else{ //echo 'name id not already added'; $query = "SELECT id FROM members WHERE username='".$loggedas."'"; $result = mysql_query($query); $data = mysql_fetch_array($result, MYSQL_ASSOC); $loggedid = $data['id']; //find world id related to world //$request = mysql_query("SELECT worldid FROM worlds WHERE worldname = '".$world."'"); //$result = mysql_query($request); //$data = mysql_fetch_array($result, MYSQL_ASSOC); //$worldid = $data['worldid']; //$newfriend = str_replace("'","\'",$newfriend); $query = "INSERT INTO friendnames(friendname, worldid) VALUES ('".$newfriend."', '".$worldid."')"; mysql_query($query); $request = "SELECT friendid FROM friendnames WHERE friendname = '".$newfriend."'"; $result = mysql_query($request); $data = mysql_fetch_array($result, MYSQL_ASSOC); $friendid = $data['friendid']; //check to ensure he dosnt already have the friend added $request = mysql_query("SELECT userid FROM friends WHERE friendid = '".$friendid."' AND userid = '".$loggedid."'"); if (mysql_num_rows($request) > 0){ echo 'You already have '.$newfriend.' on your friend list.'; }else{ //add new to friends, user id, friend id and world id $query = "INSERT INTO friends(userid, friendid, worldid) VALUES ('".$loggedid."', '".$friendid."', '".$worldid."')"; mysql_query($query); echo 'You added '.$newfriend.' to your VIP list.'; mysql_free_result($result); } } //end if for if it exists, else } }//if ($newfriend != ""){ //CHECK ONLINES!! $query = "SELECT id FROM members WHERE username='".$loggedas."'"; $result = mysql_query($query); $data = mysql_fetch_array($result, MYSQL_ASSOC); $userid = $data['id']; $result = mysql_query("SELECT worldid as id, worldname as name FROM worlds"); // Loop through each world while($world = mysql_fetch_assoc($result)) { // Query the players in this world $request = mysql_query("SELECT fn.friendname AS name, fn.friendid AS id FROM friends AS f LEFT JOIN friendnames AS fn ON (f.friendid = fn.friendid AND fn.worldid = $world[id]) WHERE f.worldid = $world[id] AND f.userid = $userid"); // If there are no friends then continue if(!mysql_num_rows($request)) continue; //Lets get the world list and do some checks $worldSite = file_get_contents('http://www.tibia.com/community/?subtopic=whoisonline&world='.$world['name']); $splitA = explode('<TD>Currently ', $worldSite); $splitB = explode(' players are online.',$splitA[1]); $onlinecount = $splitB[0]; echo '<li class="title">'.$world['name'].'</span></li>'; // Loop through each friend while($friend = mysql_fetch_assoc($request)) { for ($i = 1; $i <= $onlinecount; $i++) { $splitA = explode('<A HREF="http://www.tibia.com/community/?subtopic=characters&name=', $worldSite); $splitB = explode('">',$splitA[$i]); $online[$i] = str_replace("+"," ",$splitB[0]); $online[$i] = str_replace("%27","'",$online[$i]); if ( strtolower($online[$i]) == $friend['name']){ echo '<li><span class="name"><a href="http://tibia.mobi/search.php?char='.$friend['name'].'">'.$friend['name'].'</a></span></li>'; } } } mysql_free_result($request); } mysql_free_result($result); mysql_close(); echo '<center>Add a friend:</center>'; echo '<center><form name="add" action="index.php" method="get"> <br><br> <input type="text" size="15" name="add" style="font-size:20pt;" value=""> <br><input type="submit" value="Submit" style="height:5em; width:18em; font-size:10pt;"><br> </form></center>'; } //else (if logged in) ?>
  7. Thats weird, yesterday this script worked fine, no problems. Today i went on the site with it, no changes to the script For some reason, the "world" while loop goes through twice, so all the data is printed, then the excact same data is printed out again
  8. Robbo has been such a help in the IRC channel. I want to say thanks
  9. I can do that? That is why I posted cuz i said i know theres a more efficient way but i just cant figure it out
  10. To be honest i dont see a diference, but ill stick with mysql_assoc read my post above yours and i hope you can help, been at this for a whle and i hit a brick wall ;/
  11. Ok im calling on you guys for some help I have been trying to get this work for a while but i just cant So my database has these tables: friendnames friends members worlds In friendnames, i have friendid, friendname and worldid This is where the names are added and the friend id is looked up to find the name In friends this is where it stores the data for what friends each user has it has : userid (members id) friendid worldid (needed again for selecting in database) members has just the id, username and password worlds has the world id and name (never changed) Im making it so when a name is passed to the script it will check the database. If the name is nowhere in friendnames, then it will add that and link the id as one the player is friends with. If it is already in the database, it simply links the id Now I am trying to make it display but I have run into some bumps, herei s the script: <? session_start(); $loggedas = $_SESSION['myusername']; if(!session_is_registered(myusername)){ //echo 'You are not logged in'; ?> <?php //header("location:main_login.php"); }else{ echo 'You are logged in<p>'; $host = 'localhost'; // Database host usually localhost $dbuser = ''; // Database Username $dbpass = 'i'; // Database Password $dbname = ''; // Database name // Database Connection - do NOT edit mysql_connect("$host", "$dbuser", "$dbpass") or die(); mysql_select_db("$dbname") or die(); $query = "SELECT id FROM members WHERE username='".$loggedas."'"; $result = mysql_query($query); $data = mysql_fetch_array($result, MYSQL_ASSOC); $loggedid = $data['id']; for ($i = 0; $i <= 74; $i += 1) { $request = "SELECT friendid FROM friends WHERE userid = '".$loggedid."' AND worldid='".$i."'"; $result = mysql_query($request); $data = mysql_fetch_array($result, MYSQL_ASSOC); $friendid = $data['friendid']; echo '<p>friend id: '.$friendid; $request = "SELECT friendname FROM friendnames WHERE friendid = '".$friendid."'"; $result = mysql_query($request); $data = mysql_fetch_array($result); $friendname = $data['friendname']; echo '<p> name: '.$friendname; $request = "SELECT worldname FROM worlds WHERE worldid = '".$i."'"; $result = mysql_query($request); $data = mysql_fetch_array($result, MYSQL_ASSOC); $worldname = $data['worldname']; echo '<p> world: '.$worldname; } } //else (if logged in) ?> I cant figure out how to get it to display properly each name Also, as you can see I am using a loop to check every single world to see if there is players from each. Is there a way to select the first world id found when looking, do all the players from that one, then do the next found world id, until all are done, instead of the unneccessary checking? Help is greatly appreciated and I can reward it somehow too
  12. Didnt think that really mattered, its not noticably faster anywho I am having a few problems still so i think im going to rework the way my database handles the data and ill let you guys know if i run into any problems And i did hav that MYSQL_ASSOC thing on some, but it didnt seem to do anything so i removed it, what excactly does it do that makes everything faster?
  13. I will start by showing some of my code: for ($i = 0; $i <= $74; $i += 1) { $request = "SELECT friendid FROM friends WHERE userid = '".$loggedid."' AND worldid='".$i."'"; $result = mysql_query($request); $data = mysql_fetch_array($result, MYSQL_ASSOC); $friendid = $data['friendid']; $request = "SELECT friendname FROM friendnames WHERE friendid = '".$friendid."'"; $result = mysql_query($request); $data = mysql_fetch_array($result, MYSQL_ASSOC); $friendname = $data['friendname']; $request = "SELECT worldname FROM worlds WHERE worldid = '".$i."'"; $result = mysql_query($request); $data = mysql_fetch_array($result, MYSQL_ASSOC); $worldname = $data['worldname']; } when io make i output friendname it will be the latest result, how can i make it go through each result found to print? As you can see I am selecting sets of data bassed on certain things Now I know how to get individual data out of it, but how do i get the multiple sets of data each query is selecting?
  14. Ok, what I am making is a login system where people can login, and add their friends from this online mmorpg game. When they are on their main page after logging in, it selects their friends from a database, connects to the mmorpg site to that specific game world and checks if the player is in the list If they are, they are online so it gets dislayed. So far it is perfectly working for one world. I can easily make it look up each player, determine the world, then load that world list and check, but this has to be done for every player. What would the best way be to store the players of the same world (that is found when they add them) all together so i can load the list of one world and check them all at once, instead of repeated loading of the site? I prefer not to make 72 new tables in the database Any suggestions are appreciated Thanks Additional info: I am currently storing the players friends in the database part for the user they are logged in as. They are comma seperated and then split later on to ensure the same one isnt being added twice
×
×
  • 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.