Jump to content

thepip3r

Members
  • Posts

    289
  • Joined

  • Last visited

    Never

Everything posted by thepip3r

  1. i'm not that familiar with URL rewriting but reading up on it as I have, it sure seems like you should be able to accomplish what you're looking to do with it. i understand that all paths/variables passed still redirects to the same page even though there are more variables passed than intended. it sounds like you either need a catch-all RewriteCond that redirects to a custom error page or more specific ReWriteConds from your current .htaccess to more granularly control the paths passed. http://corz.org/serv/tricks/htaccess2.php
  2. I'm not entirely positive about what your'e asking in your "Then" area of your post but it sounds like you're trying to use include(); to include different pages based off of a user's click. If I'm understanding your problem correctly and all you want to do is to know what was the last included page, that's easy. As you posted: <li><a href="index.php?id=page1" title="Page 1" On your index.php page, just echo the $_GET['id'] element of the GET superglobal and you'll see exactly what variable was passed based off of the hyperlink clicked. -- HTH
  3. that's the entire point of the exit(); function -- to completely halt code execution. that's why i said you should use ELSE conditional logic or some other method to only execute your "gang code" upon the appropriate conditions.
  4. i don't see an exit in that code... i'm talking about something like: Well here is the Code! Code: [select] <?php case "1": if ($ir['gang'] == 0) { echo "<div class='fitembgs'>Sorry your not in a gang!</div> <div class='fitembgs'></div> <div class='fitembgs'></div> <div class='fitembgs'></div> <div class='fitembgs'></div>"; EXIT(); } global $db,$ir,$c,$userid,$gangdata; $atks=$db->query("SELECT a.*,u1.username as attackern,u1.gang as attacker_gang, u2.username as attackedn,u2.gang as attacked_gang FROM attacklogs a LEFT JOIN users u1 ON a.attacker=u1.userid LEFT JOIN users u2 ON a.attacked=u2.userid WHERE (u1.gang={$ir['gang']} OR u2.gang={$ir['gang']}) AND result='won' ORDER BY time DESC LIMIT 5"); while($r=$db->fetch_row($atks)) { if($r['attacker_gang'] == $ir['gang']) { $color="green"; } else { $color="red"; } $d=date('F j,',$r['time']); echo "<div class='fitembgs'><a href='viewuser.php?u={$r['attacker']}'>{$r['attackern']}</a> <font color='$color'>attacked</font> <a href='viewuser.php?u={$r['attacked']}'>{$r['attackedn']}</a> on $d</div>"; ...MORE CODE } OR Well here is the Code! Code: [select] <?php case "1": if ($ir['gang'] == 0) { echo "<div class='fitembgs'>Sorry your not in a gang!</div> <div class='fitembgs'></div> <div class='fitembgs'></div> <div class='fitembgs'></div> <div class='fitembgs'></div>"; } ELSE { global $db,$ir,$c,$userid,$gangdata; $atks=$db->query("SELECT a.*,u1.username as attackern,u1.gang as attacker_gang, u2.username as attackedn,u2.gang as attacked_gang FROM attacklogs a LEFT JOIN users u1 ON a.attacker=u1.userid LEFT JOIN users u2 ON a.attacked=u2.userid WHERE (u1.gang={$ir['gang']} OR u2.gang={$ir['gang']}) AND result='won' ORDER BY time DESC LIMIT 5"); while($r=$db->fetch_row($atks)) { if($r['attacker_gang'] == $ir['gang']) { $color="green"; } else { $color="red"; } $d=date('F j,',$r['time']); echo "<div class='fitembgs'><a href='viewuser.php?u={$r['attacker']}'>{$r['attackern']}</a> <font color='$color'>attacked</font> <a href='viewuser.php?u={$r['attacked']}'>{$r['attackedn']}</a> on $d</div>"; ...MORE CODE } //END ELSE }
  5. If I get what you're asking, I think you simply want something like URL rewriting: http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html
  6. I'm sorry if I'm misunderstanding your problem as it's pretty cryptic but if you're not in a gang and your code is still running as if you are it seems to me that this is your problem: if ($ir['gang'] == 0) { echo "<div class='fitembgs'>Sorry your not in a gang!</div> <div class='fitembgs'></div> <div class='fitembgs'></div> <div class='fitembgs'></div> <div class='fitembgs'></div>"; } What's the problem? ...your if statement may correctly be recognizing $ir['gang'] == 0 designating you're not in a gang (i'm assuming) but after those five divs are written via the echo, your code continues to execute all lines of code below it because it looks like the "attack" code is not in the else conditional of being in a gang or not OR you're not using exit() if you're in a gang. the exit(); method is a little terminal, final, or ungraceful (however u want to think of it) but it's one way to stop code from executing.
  7. damnit corbin... sorry for asking help on the same query two times in the same day. thanks for helping me both times -- at least you were familiar with the topic. =P thanx again.
  8. SELECT q.quote, q.qid, qp.paraphrase, s.*, u.username FROM quotes q LEFT JOIN quotes_paraphrases qp ON ( q.qid=qp.quote_id ) LEFT JOIN sources s ON ( q.source_id=s.sid ) LEFT JOIN users u ON ( q.user_id=u.uid ) WHERE q.enabled=1 AND q.qid=$rand my problem is that i have a numeric field in both the quotes table and the quotes_paraphrases table that are called user_id. The problem is that the person who submitted the quote and the person who submitted the paraphrase of that quote are not always the same. Is there a way to modify this SQL statement so that I can pull both the quotes.user_id=users.uid AND quotes_paraphrases.user_id=users.uid? I've tried inter-mixing an INNER join in the statement above but that gave me syntax errors (had to try), I've tried just amending the last LEFT JOIN to look like: (LEFT JOIN users u ON ( q.user_id=u.uid AND qp.user_id=u.uid) but that just adds a bunch of NULL values to the column of the result set that used to hold the user who submitted the quote where there wasn't an associated paraphrase to that particular quote. All help is greatly appreciated.
  9. ur missing ur comma: hrt_blk bbb, should be: hrt_blk, bbb, [/code edit: in the INSERT part of your query statement...
  10. so... there's an implicit exit(); in die(); then? i think that's what you guys are getting at and I do see the added value of letting the rest of your page load and just throwing a custom error. thank you for the clarification. @flyhoney - errorHandler() is my custom function that formats error messages certain ways, exits, and displays certain errors or not depending on whether i'm debugging or not. currently, i'm using the if (!$val) structure so I didn't realize the implicit exit(); within die(); thanx again gents.
  11. My question is, what are the differences (if any) of: $q = mysql_query("SELECT COUNT(*) FROM quotes"); if (!$q) { errorHandler("mysql", 1); } vs. $q = mysql_query("SELECT COUNT(*) FROM quotes") or die(errorHandler("mysql", 1)); Any clarification on best practices, etc would be greatly appreciated.
  12. eh screw it. thanx for the assistance guys, i'll go through and rename my db keys.
  13. Thanx for the reply corbin. Aside from having to add the AS keyword in my queries for clarity, is there any other functional reason why I should not leave them ambiguous? I'm asking because I'll change if I have to but am lazy and don't want to go through my entire db to change the fields around. =P
  14. Thank you Si-Fu. One more question in the same query: SELECT q.quote, q.id, qp.paraphrase, s.*, u.username FROM quotes q LEFT JOIN quotes_paraphrases qp ON ( q.id=qp.quote_id ) LEFT JOIN sources s ON ( q.source_id=s.id ) LEFT JOIN users u ON ( q.user_id=u.id ) WHERE q.enabled=1 I guess this is a three part question. I have all of my table primary keys titled just "id" so it's easy to reference table.id. In this query, the quote.id and sources.id fields are represented in the result set but both entitled "id". 1) Should I rename my primary keys unique across my entire DB? 2) If not, is there a way to uniquely identify the different id fields returned in the result set? 3) Or if not, is there a way to use and asterisk(*) on a table but exclude one or more fields? Pseudocode example of 3: SELECT q.quote, q.id, qp.paraphrase, s.*(-s.id), u.username
  15. SELECT q.quote, qp.paraphrase, s.*, u.username FROM quotes q, quotes_paraphrases qp, sources s, users u WHERE q.id=qp.quote_id AND q.source_id=s.id AND q.user_id=u.id AND q.id=qp.quote_id AND q.enabled=1 so the problem is that I'm trying to pull all of the quotes out of the quotes table and include the pararphrases if a paraphrase has been entered for each particular quote. Unfortunately, right now, this query only pulls quotes that HAVE paraphrases and leaves out the majority. Is there a way I can restructure this query so that it will just leave my paraphrase fields blank for the quotes that do not have corresponding paraphrases? All help is greatly appreciated!
  16. For anyone who's looking into this and has a hosting service where they can only modify the .htaccess file, here is a very good reference taht explains every aspect of what I was looking for -- thanks for the direction Brian. http://roshanbh.com.np/2008/03/url-rewriting-examples-htaccess.html
  17. that might be enough.. i'll do some research on URL rewriting and post my findings once I get something definitive. thanx for the direction.
  18. no i understand how to pass varirable arguments with PHP. My question is... like wikipedia with doesn't use the somepage.php?url=blah&something=something_else -- their arguments look specifically a folder structure. my question is, if they are not actually created a folder structure for every one of their arguments, how do i intercept the incoming request to the webserver that would look like it was trying to read the default or index file off of the folder structure? just like wikipedia...
  19. how is that done? is it some server variable they're interpreting?? if so, what "page" is it that you can use to write custom code to evaluate that variable?? do you have to change your default web server error pages to look for that? please help me out with a general direction on how something like: http://en.wikipedia.org/wiki/Operation_Northwoods ...i'm guessing it's not that they individuall create some crazy folder structure on the web server... any help would be greatly appreciated.
  20. Ok, it appears that other people are also having massive problems with this but I hope that someone might be able to offer a little more insight into what might be the problem. My problem is that, I can establish an LDAP connection to my domain controller and bind, but when I run a search, I get some generic "Operations Error". It's the most unhelpful generic error possible!! Here is my simplified code that I've narrowed the problem down to in order to just troubleshoot this issue: <? // Connect to the directory server. $ad = ldap_connect("myserver.my.local.domain") or die("Couldn't connect to AD!"); ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ad, LDAP_OPT_REFERRALS, 0); // Bind to the directory server. $bd = ldap_bind($ad) or die("Couldn't bind to AD!"); echo "SUCCESS!"; // Carry out directory server-specific tasks. $dn = "ou=root ou,DC=my,DC=local,DC=domain"; $filter = "(cn=*)"; $result = ldap_search($ad, $dn, $filter); var_dump($result); $entries = ldap_get_entries($ad, $result); for ($i=0; $i<$entries["count"]; $i++) { echo $entries[$i]["displayname"] [0]."(".$entries[$i]["l"][0].")<br />"; } // Close the connection ldap_unbind($ad); ?> and the error that gets thrown is: SUCCESS! Warning: ldap_search() [function.ldap-search]: Search: Operations error in C:\adw\ldap\test2.php on line 21 bool(false) Warning: ldap_get_entries(): supplied argument is not a valid ldap result resource in C:\adw\ldap\test2.php on line 23
  21. no i mean.. bring up the page, right-click > view source, and copy and paste the HTML here.
  22. paste in the source of the HTML output of the page NOT showing the appropriate description field.
  23. inside your mysql_fetch_array brackets, do the following: echo "<pre>"; print_r($row); echo "</pre>"; ...and let us know if the values are being successfully pulled out of the database. Your code looks syntactically correct as far as i can see. Unfortunately I can only pull up the item list page. The hyperlink'd pages are blocked from the network I'm currently on.
  24. I've thought about this for some time and there are ways to get the information by combining a SQL join and and some PHP loops with multi-dimensional arrays but I'm pretty sure that you CAN get what you're looking for in a single SQL join using the MATCH statement. Without testing out different variants on a live database, I'm afraid me supplying that SQL statement would be horribly incorrect. Although, here is an article talking about SQL Matches: http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html HTH
  25. I've done some searches on Google for a way to obtain the root DSE through PHP and the only thing I could find was a few bug articles related to this topic. Does anyone know how I can query LDAP to get the rootDSE instead of hard coding a specific server to bind to? TIA.
×
×
  • 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.