|
functional posted:I'm worried about your code, though. Lines like these: I have security, I just cut it out because it wasn't really part of the logic. You cannot go upwards using .., and the file has to exist before anything is done with it, and the strings are escaped. I don't think you can inject anything. Leaching was not the major concern, just more of a sidenote. Okay, since that is good, what is the easiest way to go about displaying the statistics? Everything I see is either too simple to use, or too complex. Something like http://wettone.com/code/slimstat, except prettier. I doubt I'll find the right package though, I'll probably end up writing my own.
|
# ? Jan 12, 2009 05:58 |
|
|
# ? May 15, 2024 14:36 |
|
What's the scope of a session_start( ) call? I have a multi-layered AJAX application that filters requests, then forwards each request onto a controller object which then in turn completes the request. At any given time you could propagate over a number of objects, a lot of which rely on session variables and I'm wondering if it's necessary for me to call session_start( ) any time that there is a reference to $_SESSION or will it work if I just call it at the beginning of a request routine?
|
# ? Jan 12, 2009 16:16 |
|
$_SESSION is a global variable which is initialized by session_start(), so you only need to call the function once per request.
|
# ? Jan 12, 2009 16:39 |
|
Battle Bott posted:Something like http://wettone.com/code/slimstat, except prettier. This is good and all...and I admire your productive attitude...but if this is all you're doing, and you don't care about leeching (and apparently, file substitution), why don't use just use some kind of webserver stats plugin? What are you trying to accomplish? You've piqued my curiosity. functional fucked around with this message at 19:16 on Jan 12, 2009 |
# ? Jan 12, 2009 19:11 |
|
awdio posted:Yes. And I can get a php variable into Flash. Its the GET variable in a mysql query is what causes things to get hung up. If I define the variable without the GET, it does not happen. I can echo back the correct results of the php query, the Flash just does not get anything from the result of the query. How is the Flash supposed to get the stuff you generate to the hidden field? Magic? Why not tack on your vars to the end of the URL to the movie? code:
|
# ? Jan 12, 2009 19:32 |
|
Does the DateTime object actually work in the latest PHP release? I tried instantiating a new DateTime object and doing DateTime.sub to subtract some time, but I get a function not defined error. Am I missing an include or something, or does 'experimental' just mean 'doesn't work at all'? The code is essentially this: <?php $date = new DateTime(formatstring); $date.sub(T1D); ?>
|
# ? Jan 12, 2009 20:30 |
|
SHODAN posted:Does the DateTime object actually work in the latest PHP release? I tried instantiating a new DateTime object and doing DateTime.sub to subtract some time, but I get a function not defined error. $date->sub is what you want
|
# ? Jan 12, 2009 21:00 |
|
Zorilla posted:$date->sub is what you want Sweet, I figured there was a good chance of me being dumb. Thanks! Edit: Looks like I may have celebrated a bit too quickly, here's what I'm running into now: with the code changed to: code:
code:
SHODAN fucked around with this message at 00:40 on Jan 13, 2009 |
# ? Jan 13, 2009 00:24 |
|
SHODAN posted:I get this error message: The documentation seems to confirm that DateTime::sub() probably hasn't made it into PHP 5.2.x or whatever most servers use. Can you do what you're trying to do with time() and date() ? For instance: php:<?php date_default_timezone_set("America/Los_Angeles"); // something like this probably belongs in a site-wide config file // yesterday, 24 hours ago echo date("Y-m-d", time() - 86400); ?> Zorilla fucked around with this message at 01:07 on Jan 13, 2009 |
# ? Jan 13, 2009 01:02 |
|
Zorilla posted:The documentation seems to confirm that DateTime::sub() probably hasn't made it into PHP 5.2.x or whatever most servers use. Yeah, this is one of my first forays into PHP so I was hoping for a good date object implementation, I'll probably just end up using date/time. Thanks for your help though, I'm sure the member function calls issue (-> vs .) would have come up sooner or later.
|
# ? Jan 13, 2009 03:40 |
|
Lumpy posted:How is the Flash supposed to get the stuff you generate to the hidden field? Magic? Why not tack on your vars to the end of the URL to the movie? Flash can get the stuff on the hidden field perfectly fine except when the initial variable from GET that SQL uses for a query is used. If I just simply defined the variable instead of using the value of GET everything would be fine. I'd explain how this works all over again but I've explained this in at least 3 other replies so far. Read those so you can understand what the problem is more. But thanks for your suggestion I'll try that. LP0 ON FIRE fucked around with this message at 05:12 on Jan 13, 2009 |
# ? Jan 13, 2009 04:33 |
|
functional posted:This is good and all...and I admire your productive attitude...but if this is all you're doing, and you don't care about leeching (and apparently, file substitution), why don't use just use some kind of webserver stats plugin? What are you trying to accomplish? You've piqued my curiosity. The truth? Because I can. No real need. I already run google analytics, and my host runs Webalizer and Awstats. I just want to design a data logging system, and then figure out how to display it pretty with all sorts of fun ajax stuff. I think xml/flash graphs are the way to go. I'm just learning php, sql, flash, javascript, html, css and whatever else this takes.
|
# ? Jan 13, 2009 04:42 |
|
Does anybody know how to get the value of an array from an array? That sounds pretty confusing after reading it, so here's an example:php:<? $header = array("Home","Info"=>array("E-Mail","Other")); echo $header[0]; echo $header[1]; //Line 3 ?> scanlonman fucked around with this message at 12:45 on Jan 13, 2009 |
# ? Jan 13, 2009 12:39 |
|
scanlonman posted:Does anybody know how to get the value of an array from an array? That sounds pretty confusing after reading it, so here's an example: You're trying to get the element's key, not its value. The confusing part is that you're mixing an indexed array with an associative array, since you didn't give the first element a key. php:<? $header = array("Home","Info"=>array("E-Mail","Other")); $keys = array_keys($header); echo $keys[0]; // Prints "0" because this element doesn't have a key echo $keys[1]; // Prints "Info" ?>
|
# ? Jan 13, 2009 12:57 |
|
Aha! Thanks, I got it to work now. Sorry for my PHP dumbness. [edit] Hmmm, another question. Instead of having to do: http://webpage.com/?section=blah&other=blahblah Would it be possible to change that to http://webpage.com/?blah&blahblah and still be able to get $_GET[] the values? scanlonman fucked around with this message at 13:38 on Jan 13, 2009 |
# ? Jan 13, 2009 13:15 |
|
scanlonman posted:0 With this .htaccess file, http://webpage.com/blah/blahblah would be rewritten to http://webpage.com/index.php/blah/blahblah . Your script could then grab the path from $_SERVER['PATH_INFO'] which contains "blah/blahblah", split by / and then do whatever. code:
Internet Headache fucked around with this message at 14:49 on Jan 13, 2009 |
# ? Jan 13, 2009 14:43 |
|
awdio posted:Flash can get the stuff on the hidden field perfectly fine except when the initial variable from GET that SQL uses for a query is used. If I just simply defined the variable instead of using the value of GET everything would be fine. I'd explain how this works all over again but I've explained this in at least 3 other replies so far. Read those so you can understand what the problem is more. But thanks for your suggestion I'll try that. I have to say, I've read all your explanations and I just got more confused with every iteration. scanlonman posted:Would it be possible to change that to http://webpage.com/?blah&blahblah and still be able to get $_GET[] the values? You can iterate over $_GET just like any other array or use isset() to see if anything you're looking for was set. For example, &ascsv might act as a flag to output some report as CSV as long as it's set by checking for isset($_GET['ascsv']). Of course, this could confuse the poo poo out of someone who edits the query string with &ascsv=0 and expects it to work, so take that into consideration Internet Headache posted:According to SEO guys, search engines hate query strings. SEO people are full of poo poo. Any modern search engine that wants to remain relevent must be able to understand them.
|
# ? Jan 13, 2009 16:09 |
|
awdio posted:Flash can get the stuff on the hidden field perfectly fine except when the initial variable from GET that SQL uses for a query is used. If I just simply defined the variable instead of using the value of GET everything would be fine. I'd explain how this works all over again but I've explained this in at least 3 other replies so far. Read those so you can understand what the problem is more. But thanks for your suggestion I'll try that. Your replies are confusing at best. "Flash can get stuff out of hidden fields" doesn't make any sense whatsoever. Good luck finding a solution, but you've baffled me beyond the ability to try to help you any more
|
# ? Jan 13, 2009 16:15 |
|
Lumpy posted:Your replies are confusing at best. "Flash can get stuff out of hidden fields" doesn't make any sense whatsoever. Flash actionscript can use loadVariables("currentpageURL.php", this, "POST"); to get POST variables from the current page that it is on. You can make the value of hidden fields like so to make a POST variable like so: php:<? $variableSentToFlash="hello there"; echo "<INPUT type = 'hidden' name = 'Page' value='&variableSentToFlash=$variableSentToFlash'>"; ?>
|
# ? Jan 13, 2009 19:59 |
|
awdio posted:Flash actionscript can use loadVariables("currentpageURL.php", this, "POST"); to get POST variables from the current page that it is on. You can make the value of hidden fields like so to make a POST variable like so: You realize it doesn't "look at the current page" right? It actually sends a request to the server for the script, and loads it in again. That's your problem. Do what I suggested, since what you are doing makes no sense whatsoever. Lumpy fucked around with this message at 20:24 on Jan 13, 2009 |
# ? Jan 13, 2009 20:19 |
Munkeymon posted:as long as it's set by checking for isset($_GET['ascsv']). Don't you need to check array_key_exists('ascsv', $_GET) first?
|
|
# ? Jan 13, 2009 20:20 |
|
Little Brittle posted:Are there any good tutorials or samples online for eAccelerator? I want to use it, but it's hard to find real world sample code, and the API documentation is pretty bare. I want to dig in to granular caching and learn more about its user data caching. What exactly do you want to know? The api is pretty self explanatory. eaccelerator_put($key, $data, $duration) puts $data into the cache with an access key of $key, for $duration seconds. eaccelerator_get($key) tries to retrieve data stored at $key eaccelerator_rm($key) removes entry stored at $key If you just need to know about caching 'theory' in general, just do a search for that. Pretty much all caching backends(apc, eccelerator, xcache, memcached, disk, etc) work exactly the same way in every language.
|
# ? Jan 13, 2009 21:11 |
|
fletcher posted:Don't you need to check array_key_exists('ascsv', $_GET) first? Empty $_GET vars are zero-length strings in 5 and 4 in my testing. Surprise!
|
# ? Jan 13, 2009 22:08 |
|
When using the php DomDocument, what does the error "ID loginForm already defined in entity" mean? I've tried googling for this and I can't find anything that defines the error. I've checked through the HTML and I don't see any duplicate loginForm elements. The only thing I notice is that there is a form id and a form name that is both loginForm. Could that cause this error?
|
# ? Jan 14, 2009 04:45 |
|
sonic bed head posted:When using the php DomDocument, what does the error "ID loginForm already defined in entity" mean? I've tried googling for this and I can't find anything that defines the error. I've checked through the HTML and I don't see any duplicate loginForm elements. The only thing I notice is that there is a form id and a form name that is both loginForm. Could that cause this error? In the time you've written up this post you could have checked it ten times over.
|
# ? Jan 14, 2009 11:12 |
|
Hi guys, I'm pretty new with queries in PHP and I have a question. I'm setting up a little game for some friends that calculates a budget (each player playing as a nation of their choice). My units table has different types of units such as "army", "navy", etc. You can see the page here: http://www.rickpierce.info/dotw/nations.php I got army subtracting fine with the help of a friend using a LEFT JOIN command. But now I come to adding a second (navy) and I'm lost. My friend suggested subqueries but he's unfamiliar with the process, and I'm feeling in over my head on this one as a beginner. Here's the query and some other information to help you get an idea of what I've done/am trying to do: php:<? $result = mysql_query("SELECT `nations`.*,SUM(Size) AS `armycount` FROM `nations` LEFT JOIN `units` ON `units`.`Owner` = `nations`.`NatID` WHERE TYPE='army' GROUP BY `nations`.`NatID`"); ... while($row = mysql_fetch_assoc($result)) { $percent = $row["Growth"] * 100; $armycost = $row['armycount'] * 3; $navycost = $row['navycount'] * 20; $net = ($row["GDP"] * $row["Growth"]) + $row["GDP"] + $row["Reserve"] - $armycost - $navycost; ?> Edit: broke query in half to stop tables from breaking.
|
# ? Jan 15, 2009 07:35 |
|
ExtraNoise posted:The hang up is the WHERE TYPE, as I can't just insert another WHERE TYPE='navy' in the query without it falling apart. Running a second query is both stupid and doesn't work. I've tried rearranging the query to incorporate another SUM and WHERE, but because the WHERE needs to be in that exact location in the query, it doesn't work. Unless I'm misunderstanding, you want to use WHERE `type` = 'army' OR `type` = 'navy' Or you could use WHERE `type` IN ('army','navy')
|
# ? Jan 15, 2009 22:41 |
|
jasonbar posted:Unless I'm misunderstanding, you want to use WHERE `type` = 'army' OR `type` = 'navy' Would it be able to differentiate between the two, or would it SUM up both types? Either way, I'll give it a try! Edit: I should note that I would like it to also create the variable navycount (see armycount) that is the SUM for type="navy", sort of how the query creates a SUM for armycount that is the SUM for type="army". Would I be a lot better off just using separate tables for each type of unit?
|
# ? Jan 15, 2009 23:04 |
|
I hate to sound rude, but you might need to do a little reading about database normalization before you go much further. The issue of putting 'army' and 'navy' in different tables will become clear, you'll prevent lots of headaches, and the project will turn out better.
|
# ? Jan 15, 2009 23:11 |
|
royallthefourth posted:I hate to sound rude, but you might need to do a little reading about database normalization before you go much further. The issue of putting 'army' and 'navy' in different tables will become clear, you'll prevent lots of headaches, and the project will turn out better. Not rude at all. I'll go read up on better practices and push forward with different tables on this project. Thank you for the input.
|
# ? Jan 15, 2009 23:14 |
|
edit: nevermind
jasonbar fucked around with this message at 05:42 on Jan 16, 2009 |
# ? Jan 16, 2009 05:40 |
|
I could use some help. Our website guy (goon JH Pufnstuf) departed us ages ago and now my boss wants a few changes done to the website. Between my coworker and myself, we've managed to tackle all but one of the requested fixes, but this one is throwing us both for a loop. Goal: I want to add an onClick variable to a radio button selection. Summary: To access a group of text listings on our site, it's necessary to click on a radio button to indicate the region, and then a drop down menu for a section, before hitting submit and having the values returned. The boss wants it so that after clicking the radio button, but before selecting from the drop down and hitting submit, a temporary page with banner ads (that correspond to region selected by the radio button) pops up in the opposing frame. What we have now: php:<? <form id="form1" name="city" method="get" action="adsbycity_results.php"> <?php $result = mysql_query("SELECT * FROM cities"); while($cities = mysql_fetch_object($result)) { ?> <ul style="list-style: none; margin: 0 0 -7px 0;"><li style="padding: 0 0 0 16px; background: none;"><input type="radio" name="city_id" value="<?php echo $cities->city_id?>" /> <?php echo stripslashes($cities->name)?></li></ul> <?php } ?>?> php:<? <!-- Banner Ads start here --> <?php $city_id = $_GET['city_id']; ?> <?php $category = $_GET['category']; ?> <?php $ban_result = mysql_query("SELECT * FROM banners WHERE city_id='$city_id' AND category='$category'"); while($banners = mysql_fetch_object($ban_result)) { ?> <ul> <li><a href="<?php echo $banners->link?>" target="_blank"><img src="<?php echo $banners->file?>" alt="<?php echo $banners->company?>"></a></li> </ul> <?php } ?>?> php:<? <input type="radio" name="city_id" value="<?php echo $cities->city_id?>" onClick="XXX" />?>
|
# ? Jan 16, 2009 17:23 |
|
Manos del Sino posted:Banner Popup stuff. You want a Javascript function that shows the banner. code:
php:<? onClick="showBanner(<?php #code for retrieving your banner url here ?>"?>
|
# ? Jan 16, 2009 20:59 |
|
surrealcatalyst posted:You want a Javascript function that shows the banner. He mentioned a frame, so I think he's actually just changing the relevant frame's .location.href property: http://www.aspfree.com/c/a/ASP-Code/Change-the-URL-of-a-Frame-Using-Javascript/ . Also, if the input is in a form, remember to return false from the anonymous method to prevent the change from bubbling up and submitting the form (as long as you don't actually want the change to submit the form). This is how I have Javascript addressing frames in some code I have laying around. It looks horrible, but I generally have to worry a lot about browser compatibility, so I'm reasonably confident it's tested and works: code:
|
# ? Jan 17, 2009 00:07 |
|
I get an error (Parse error: syntax error, unexpected T_VARIABLE) in line 1 of the 1st code snippet below. I want to be able to have default values for when a new instance of the class is called and also want to be able to assign my own values for flexibility's sake. I've looked at other people's code where they declare default values and it looks the same as what I have, which is why I come to you guys. What could be causing the issue? php:<? public function __construct($un=$_POST['username'], $pw=$_POST['password']){ $this->ip = $_SERVER['REMOTE_ADDR']; $this->username = $un; $this->password = $pw; $this->md5pass = md5($un.$pw.$ip); } ?> php:<? public function __construct(){ $this->ip = $_SERVER['REMOTE_ADDR']; $this->username = $_POST['username']; $this->password = $_POST['password']; $this->md5pass = md5($un.$pw.$ip); } ?>
|
# ? Jan 17, 2009 03:08 |
|
It might be a PHP limitation in which you can only assign static default values to function inputs. For instance, This is probably illegal: php:<?php public function __construct($un = $_POST["username"], $pw = $_POST["password"]) { // ... } ?> php:<?php public function __construct($un = "defaultuser", $pw = "defaultpassword") { // ... } ?>
|
# ? Jan 17, 2009 03:21 |
|
quote:What could be causing the issue? You can use the default value of false and then do a conditional test to set it to something else. php:<? public function __construct($un=false, $pw=false){ if ($un === false) { $un = $_POST['username']; } if ($pw === false) { $pw = $_POST['password']; } ... ?>
|
# ? Jan 17, 2009 03:24 |
|
Internet Headache posted:Default function arguments can only be literal values, array, or NULL.
|
# ? Jan 17, 2009 03:39 |
|
I'm trying to fix some code that needs to be able to send mail from a website. Right now the line of code for mailing is just: mail($_POST['chrEmail'].", ".$_POST['chrPerson'],$subject,$body,$headers); It needs to include SMPT authentication because I'm moving the code to another server (and their mail server requires login credentials), but since I'm not really that fluent in PHP, I'm having some trouble getting it to work. I know the server name, user name, password, and all that, but I'm not sure how to put it together and the scripts that I've found online look a lot different than just the normal "mail" function. Any ideas?
|
# ? Jan 17, 2009 08:37 |
|
|
# ? May 15, 2024 14:36 |
|
I'm not too sure how to do this automatically but I'm sure there is a way and I think php is the way to go. I want to update a mysql database according to payments made through paypal. So if someone pays for an upgrade using paypal it automatically upgrades their account by updating the mysql database. The only ways I've thought of was to manually download the paypal transaction list, and get the people to submit a form with their username and paypal transaction number then run a program to compare the lists and update the database. There still seem to be manual steps which I want to remove or reduce somehow. I don't know php , but I figured it wouldn't be that hard to learn. Edit: It was quite easy once I found the sandbox page for paypal and looked at the documentation and stuff there. FSMC fucked around with this message at 00:11 on Jan 18, 2009 |
# ? Jan 17, 2009 11:50 |