5kyy8lu3
Members-
Posts
257 -
Joined
-
Last visited
Everything posted by 5kyy8lu3
-
Hi. I've narrowed my session problems down to the garbage collection clearing my sessions. This happens at random times and it's the only thing I can think of. What can I do to avoid this problem? I'm guessing something in the php.ini? I've tried google searching but it's like those bing.com commerials the kind of results I'm getting lol. Thanks ahead of time.
-
just have a style column in the database. if the user has style set to 1, then include style_1.php. if that column contains 2, then include style_2.php. unless i'm reading your question wrong... lol
-
Hi. I'll try to word this as best I can. I'm just playing around with some layouts I've come up with especially php structure. I decided to try to make a site that runs completely from index.php and links just goto a page that sets a session variable, then uses header to go back to index.php where php file(s) are include()'ed depending on what's in the session variable in a big switch statement. why? i just wanted to try it. the biggest thing i wanted was for the name of the document to not be visiable (index.php, etc). when i have header set to this: <?php header("Location: index.php"); ?> it works fine. but this makes index.php show up after the domain in the address bar like this: http://www.domain.com/index.php so i try this: <?php header("Location: http://domain.com"); ?> but when I have header direct to the domain instead of the specific index.php file, the session variable won't load. i have the page echo the session ID and it doesn't change but the contents of the variable won't carry over for some reason. i change header back to index.php and it works fine. any ideas? (keep in mind I know there isn't much risk to allowing index.php be visible, I just wanted to see if it's possible so until it's possible or not possible it's going to bug me. must....find...out...how...) thanks =)
-
As the title states, I've noticed that occasionally my site shows the server's ip address from $_SERVER['REMOTE_ADDR'] instead of the visitor's and it's weird because it only happens about half the time. Any idea what's going on? I'm guessing it's my server's IP, i don't know what else it would be because it's a private ip range (192.168.151.33) Thanks.
-
first thing I would do is ban that user's account and IP address lol
-
[SOLVED] Need query to pull rows for current year but...
5kyy8lu3 replied to 5kyy8lu3's topic in MySQL Help
yea i tried it and it didn't work until i put the where clause first and it works now, thanks for the help =) -
[SOLVED] Need query to pull rows for current year but...
5kyy8lu3 replied to 5kyy8lu3's topic in MySQL Help
well I know how to pull rows from this year, what I'm having trouble doing is bringing back 1 result per day, so I need 365 results back. And if there are multiple rows for one day, I need it to average those into one result for that date. I'm not sure if this makes sense lol. "SELECT AVG(Speed) FROM MyTable GROUP BY DATE(DateAdded) WHERE YEAR(DateAdded) = YEAR(CURDATE()) ORDER BY DateAdded ASC" Ok pretend table: DateAdded - Speed 2009-02-01 0 2009-02-01 10 2009-02-02 6 2009-02-03 2 2009-02-03 4 And I want this as my result: 2009-02-01 5 2009-02-02 6 2009-02-03 3 -
[SOLVED] Need query to pull rows for current year but...
5kyy8lu3 replied to 5kyy8lu3's topic in MySQL Help
would this work? i might have to make a dummy table and add a full 365+ results with multiple rows for some days to try this out "SELECT AVG(Speed) FROM MyTable GROUP BY DATE(DateAdded) ORDER BY DateAdded ASC" -
Hi. I have PHP 5.0.45. I know I can somehow do this with PHP but I'm slowing realizing how powerful MySQL can be on its own and would like to see if there's a way I can do this using just a complex query. I would like to pull ALL rows from my table from the current year BUT I want any rows from the same day (according to the timestamp) to be averaged into one value so i end up with 365 entries for the year (assuming they have at least one entry per day). Is this possible? I tried to play around with using GROUP BY and AVG but I can't seem to get it right, any advice/suggestions would be great. If all else fails I'll just pull everything and do the work with php. Thanks.
-
that's exactly what you do. here's a quick example, i'll make up my own variables and stuff but it will be really easy for you to change the stuff to work with your application: <?php //make these link to itself, so if this file is ThisPage.php, make these links link to ThisPage.php and the $_GET variables will handle the sorting method echo '<a href="ThisPage.php?sort=price_asc">Click here to sort by price ascending</a><br>'; echo '<a href="ThisPage.php?sort=price_desc">Click here to sort by price descending</a><br>'; echo '<a href="ThisPage.php?sort=bedrooms_asc">Click here to sort by bedrooms ascending</a><br>'; echo '<a href="ThisPage.php?sort=bedrooms_desc">Click here to sort by bedrooms descending</a><br>'; switch ($_GET['sort'] ) { case "price_asc": $query = 'SELECT * FROM properties ORDER BY maxprice ASC'; break; case "price_desc": $query = 'SELECT * FROM properties ORDER BY maxprice DESC'; break; case "bedrooms_asc": $query = 'SELECT * FROM properties ORDER BY bedrooms ASC'; break; case "bedrooms_desc": $query = 'SELECT * FROM properties ORDER BY bedrooms DESC'; }
-
<?php // the code you posted for this should work ok but I like to use extra parentheses to make things absolutely sure like this: $percentage = round( ( 100 / ( ( $result->ban_length * 60 ) / ($date_and_ban - $now ) ) ), 2); //and for this part: $player = $result->player_nick; $MaxLength = 10; //this is the number you change to set the max length of your string echo substr($player, 0, $MaxLength); // this will echo this: "The name o" $MaxLength = 19; echo substr($player, 0, $MaxLength); // this will echo this: "The name of the pla" hope that helps
-
if you're asking what I think you're asking, you can use ORDER BY with your mysql queries examples: <?php $query = 'SELECT * FROM properties ORDER BY maxprice ASC'; //sort by maxprice ascending $query2 = 'SELECT * FROM properties ORDER BY maxprice DESC'; //sort by maxprice descending $query3 = 'SELECT * FROM properties ORDER BY bedrooms ASC'; //sort by bedrooms ascending $query4 = 'SELECT * FROM properties ORDER BY bedrooms DESC'; sort by bedrooms descending ?> and you can obviously add the other conditions back into those queries as needed, but that should give you an idea of how you can sort the stuff. you can also use a switch statement to pull sort method from $_GET to choose the proper sort method (so have sort links on the page just change the $_GET variable you set for the sorting to a different sort method)
-
ok well i think i found a solution, and it's embarrassingly simple. i just shift the entire data set down by the value of the minimum in the set to set the 'base' to zero. then i graph it. now to come up with how to set the 'max length' to where it's always just enough to fit the max numbers in teh data set.
-
if you're using numbers you can round that number using round() so round(67.328578235, 2); would give you 67.33
-
couldn't you use UNIQUE or DISTINCT?
-
Hi. I'm working on some new home-made php graphs for my site but I'd like the table to adjust the 'viewing range' depending on the minimum and maximum values in the data set. I've tried lots of things and even after 4 hours of brainstorming I can't come up with a solution. I'm pretty sure it's going to end up being something I should know but at the moment I don't know how to tackle this hurdle. I basically want my graph to show only the 'meat' of the data. If my lowest percent is 30% and the top percent is 70%, i don't want the white space from 0-30% and 70-100% showing so only the middle stuff is visible. i want to be able to set a 'maximum length' for the graph's bars. lets say my lowest number is 3 and the max is 8, i want 3 to show up at the bottom of the graph and 8 at the top. I basically want the 3 to be 0% of the max length and i want the 8 to be 100% of the max length. if this doesn't make sense i uploaded a mock up graph to show you what i mean http://www.kloudz.com/graph.jpg sorry for the crude paintbrush picture lol I'm guessing i'll either need to use some statistics formula or possibly calculus. Any help is greatly appreciated, thanks ahead of time.
-
one method: You use a tiny bit of math (percents) and php to parse the img width to your liking and you end up with graph bars. First you find your max value in your table (or in the data set you're going to display on this page). If the data is from a table, you can just make a quick query to find the max using MAX(YourDataThatYouArePullingOut) in the query to get the max value. Then you make a 1x10 image of a solid color (the second dimension being the height/thickness of the graph bar, so this one would be 10 pixels high). if you wanted some pre-made pretty graphs, there are tons of php graphs that use the gd toolkit to do some really impressive graphs, should you choose the premade route =) <?php $Max = '300'; //our pretend max value $CurrentValue = '150'; //our pretend current value $Width = ( ( $CurrentValue / $Max ) * 800 ); //with a current value of 150, the current bar's width would be 400 (50% of 800) echo '<img src="bar.gif" border="0" height="10" width="' . $Width . '">'; //this echos the image out, stretched to the right width //use this kind of code inside a loop to get an entire graph //you can even have a horizonal graph where the bars grow //from bottom of a table cell upwards. //to do this just make sure you throw this //into your stylesheet: td img { vertical-align: bottom; }
-
Hi. I have an array with numbers in it but they were read in as strings. Because of this I can't seem to get min() and max() to work properly since they aren't decimals. Is there a way to convert the array to a decimal array or something so I can get the min() and max() values in the array? I've tried walking through the array manually but I can't compare values when they're being evaluated as strings :'(
-
yea that was kind of my last resort, i figured there was some 'proper' method of getting around this but I might as well go this route until i figure something out lol thanks
-
I still can't figure this out. The only thing I can think of doing is setting the data type to string so it doesn't default to 0.00 when I want the column to be empty for a row. Incase I'm not being clear enough, let me reword this. I'm going to insert two new rows to my table. For the first row, I want to enter a value of zero in the windchill column. $wc = 0; In the second row, I don't have windchill information so I want it to be null. $wc = ''; or $wc = 'NULL'; or however I'm supposed to do it. Using the decimal(5,2) data type both entires are showing up as 0.00 and I can't tell them apart when I pull them back out and it's really important to know since having no data (null) vs having 0 as a value in the column are two completely different things. So... if I pull both rows out of the database and print them to the browser, the first row should print 0 degrees. The second row is supposed to have a null value for the windchill column so it prints 'N/A' to the browser. How can I do this with a decimal data type? Is this possible? I would imagine it's possible, I just have no idea how and all the searching and reading online via google searching, looking up NULL and DECIMAL in my book, and even forum searches haven't given me sufficient information to figure this out on my own
-
I'm not sure I follow. If I try to enter a value of NULL it still shows up in the table as 0.00 in my table. If I want to enter a temperature of 0 degrees, it also shows up as 0.00 in the table. I have a page that loads * from that table, and prints those values out in a while loop. If the column is NULL for a row, I want to be able to know so I can print "N/A" for that row. If the column has the actual temperature of zero, I want it to properly print 0 degrees to the browser. What can I do to tell the difference? I've read mysql.com and my o'reilly book but I guess I'm just not comfortable with NULL values and how they work with decimal data types. (or at all) Thanks.
-
Hi. I have PHP 5.0.45. I have a column called windchill in my table and the data type is set to decimal(5,2) null yes. It seems when i insert an empty variable into that column, it saves at 0.00. Since a temperature of 0 degrees can occur, that won't work. Is that 0.00 distinguishable from null? How can I enter a null value and tell if it's the number 0 or if it's null when I select data from that column? Thanks!
-
not sure if it's reasonable to do so but you could easily make a new column in the username/pwd table named 'last_page' and just save the name of the last page they were on, and have each page update that column to that page, so you don't have to mess with cookies. so... if they click on the page 'news.php' somewhere in the header of that page it saves 'news.php' to the 'last_page' column, so when they log back in, it sends them to $loc = '/the/document/path/' . $last_visit; just one method of doing it.
-
is this what you're looking for? <?php $price = $_POST['metres'] * $_POST['type']; echo 'The price for ' . $_POST['metres'] . ' metres at $' . $_POST['type'] . ' per metre comes to a total of $' . $price . '.'; ?> this should calculate your price, just make sure you validate your form data for security reasons