Jump to content

corbin

Staff Alumni
  • Posts

    8,102
  • Joined

  • Last visited

Everything posted by corbin

  1. If its just an exact copy of the table theres some function for it... But if you plan to change some stuff just do SELECT * FROM table; then a while loop and insert it into your other table...
  2. DIdnt take me long to figure out that doesnt return what im wanting... Its very unlikely, but incase someone else ever has a similar situation ill post what I ended up with... [code=php:0] SELECT    TOP 10 user_data.char_id, SUM(user_item.amount) AS total, user_data.char_name, user_data.gender, user_data.Lev, user_data.Exp, user_data.class, user_data.PK,  user_data.Duel FROM user_data INNER JOIN user_item ON user_data.char_id = user_item.char_id WHERE (user_item.item_type = '57') AND (user_data.builder = '0') GROUP BY user_data.char_id, user_data.char_name, user_data.gender, user_data.class, user_data.PK, user_data.Duel, user_data.Lev, user_data.Exp ORDER BY total DESC [/code]
  3. Hmmm that might have worked too... But what i finally came up with was: [code=php:0] @mssql_query("CREATE VIEW adena_total AS SELECT user_data.builder,user_data.char_id,user_item.amount AS invamount, user_warehouse.amount AS whamount, user_data.char_name AS name FROM user_item,user_warehouse,user_data WHERE user_item.item_type = '57' AND user_data.builder = '0'"); $q = mssql_query("SELECT top 10 invamount + whamount AS total_adena, name FROM adena_total ORDER BY total_adena DESC"); [/code] Hehe forgot about my post on here...
  4. That doesnt help at all O.o... Maybe I'm still not explaining correctly, or what Im tryin to do is impossible... I want to add a column in table A to a column in table B then sort that desc
  5. you realize that wont echo anything right?  And I think I made my first post ambigously... I need to add field.table1 to field.table2 then sort the results by field.table1 + field.table2... I cant pull the results then add them them sort them since its over 1000 users...
  6. I don't tab html; I just use lots of new lines :P.
  7. [code=php:0] <a href='logout.php'>Log Out</a> [/code] then on logout.php [code=php:0] foreach($_SESSION as $k = $v) { $_SESSION[$k] = NULL; } [/code]
  8. Ive been tryin for the past 20 minutes or so to figure out how to somehow get mssql to run a query that a. selects amount from user_item where item_type is 57 b. selects amount from user_warehouse where item_type is 57 c. adds them together and treats them as colum x d.  ORDER BY x DESC My problem is i cannot figure out how to structure a sql query that does what i desire. Any help will be appreciated :P
  9. Your server may automatically addslashes everything... but just to be safe you probably want to do it in your script.  Someone could put [code=php:0] ');  DELETE FROM `messages`; [/code] or other things and it would execute it in the sql query... [code=php:0] foreach($_POST as $k => $v) { $_POST[$k] = addslashes($v); } is what i normally use....
  10. you could use javascript to grab the contents of the textbox if it doesnt need to be used server side... or you could store it in a file, or preserve the $_POST var set by it...
  11. Ummmm wayyyy too many backslashes... try removing them all unless theyre used in echo's or something of the such...
  12. You could do 3 different queries... or a join query... but im half asleep so i cant think of how to do that :P
  13. My favorite code for checking server status's that i came across a while back is: [code=php:0] $IP = array(   "server1" => "<serv1_ip>:<serv1_port>",   "server2" => "<serv2_ip>:<serv2_port>", ); while(list($ServerName,$Host)=each($IP)) {   list($IPAddress,$Port)=explode(":",$Host);   if($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5))   {   $server[$ServerName]=1;   fclose($fp);   }   elseif($fp=fsockopen($IPAddress,$Port,$ERROR_NO,$ERROR_STR,(float)0.5))   {   $server[$ServerName]=1;   fclose($fp);   }   else{   $server[$ServerName]=0;   } } [/code] Then if $server['server1'] is 0 the server is down and 1 its up.
  14. if you wanted to see if it was the databases fault you could do something like ($query being the most complicated query that performed): $time = time(); $time2 = time() + 60; $i = 0; while(time() < $time2) { mysql_query($query); $i++; } Echo "{$i} queries in 60 seconds.  About {$i/60} queries a second.";
  15. [code=php:0] How would the "profile.php" page come to be renamed "profiles.php?member=thorpe". How did it get that way? [/code] Either you worded this oddly or you're fairly new.  Its the same page with a different GET value... Simply by changing memebe= in your address bar, or by using the more sought after <a href..., you can gain the same effect.
  16. From personal experience, I have determined that SID can only be used the first time the session is opened... So I tend to not rely on it.
  17. I figure you should make sure your upload script will not allow .php extensions or .cgi... and so on...
  18. content.php <? $path = "folder1"; ?> rest of your html content ------------------------------------ css.php #topnav  { background:url(<?=$path;?>/includes/teal.gif) repeat-x; padding-top:5px; color:#fff; } Edit:  Sorry didn't see the second page of this thread... This post is semi irrelivent now...
  19. The code posted by printf will always work and it will have nice corrosponding numbers, but sometimes random can be good :P. [code=php:0] <? $str = "a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|w|z|0|1|2|3|4|5|6|7|8|9"; $str_a = explode("|", $str); $fn = explode(".", $_FILES["file"]["name"]); $c = count($fn); if($fn[$c - 1] != "mpg") { die("File must be .mpg file extension!"); }     while(file_exists("music/" . $rand . ".mp3"))     { $rand = NULL; while($i < 8) { $rand .= $str_a[rand(0,34)]; }     } if(!file_exists("music/" . $rand . ".mpg") { if(move_uploaded_file($_FILES["file"]["tmp_name"], $rand . ".mp3")) { ?> Your file <i><?=$_FILES["file"]["name"];?></i> has been successfully uploaded to <a href="music/<?=$rand;?>.mp3"></a>. <? } else { echo "Sorry, your file could not be uploaded."; } }     else       {       echo "Unable to upload.  Please try again.";       } ?> [/code] Will randomly name it something like music/c8e03l78.mpg, and it wont rely on a file.  If the file exists it will simply generate another name.
  20. [code=php:0] $_SESSION["login"]; [/code] Does absolutly nothing... change that to $_SESSION['login'] = "logged"; and change [code=php:0] <?php session_start(); if($login=="") { Header("Location: login.php"); } else { ?> Page Contents go below this. <?php } ?> [/code] to [code=php:0] <?php session_start(); $login = $_SESSION['login']; if($login == "logged") { Header("Location: login.php"); } else { ?> Page Contents go below this. <?php } ?> [/code]
  21. [code=php:0] <?php session_start(); if($login=="") { Header("Location: login.php"); } else { ?> Page Contents go below this. <?php } ?> [/code] nothing is setting $login... Try making it a session variable like $_SESSION['login'] and do the same for the login script...
  22. Ummm not sure about your first question but for the comma thing i would use something like <? $str = explode(',', $num); $i = 0; while(count($str) > $i) { if($str[$i] != ",") { $num2 .= $str[$i]; } } ?> Then $num2 would contain the number with just numerals... Probably a more effecient way to do it though...
  23. Change $success = setcookie('User ID', $row['User ID'], time()+43200, '/', '.light-within.org', 0); to setcookie('User ID', $row['User ID'], time()+43200, '/', '.light-within.org', 0); and see if it works
  24. If someone has everything you said disabled they have a very bland web experience.
  25. Ummmm you could make a function but that would be some wierd logic...
×
×
  • 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.