|
Lumpy posted:
Since we're on the topic, I really wish there was a method built into HTML/CSS that sets the widths and things automatically based on a "scale" value. For instance: code:
nbv4 fucked around with this message at 09:14 on Mar 22, 2008 |
# ¿ Mar 22, 2008 09:08 |
|
|
# ¿ Apr 29, 2024 11:42 |
|
is there a more elegant way to do this?:code:
|
# ¿ Apr 4, 2008 12:07 |
|
Say, since we're on the subject of escaping, I noticed a little while ago that whenever data comes in through a <textarea>, the string is already escaped. If I run it through mysql_real_escape_string, double escaping will occur. I don't know if it's the browser thats doing this, or if it some kind of magic quotes thing... After I finally realized this, I just stopped escaping all my textarea data. Is this a bad decision?
|
# ¿ Apr 7, 2008 08:11 |
|
I have this one class which is getting so huge, it's almost 2000 lines. I want to split it up into smaller text files to make editing easier, but I'm having trouble doing so. Apparently you can't just do:php:<? class foo extends lol { include "text_file_with_methods.php"; function blah() { ... ?>
|
# ¿ Apr 7, 2008 18:09 |
|
Inquisitus posted:Either try and split the class up logically into smaller classes, or leave it as it is if you can't. I could do that fairly easily because this huge class is essentially two classes in one anyways, but the only problem is that this classes constructor runs like 20 SQL queries which provide information for pretty much every function in that class. If I split it into two or three classes, I'll have to run those constructors another time or maybe even twice more. I'd really hate to do that for just the convenience of having seperate text files...
|
# ¿ Apr 7, 2008 18:27 |
|
duz posted:You can have constructors run the parent's constructors or you can have your queries just use the last used connection.
|
# ¿ Apr 7, 2008 18:34 |
|
Does anyone here have have experience using jpGraph? I'm having trouble with a graph of mine. It seems whenever you try to display the values of an accumulated bar graph rotated at 90 degrees, the labels get printed a few pixels higher than they are supposed to be. here is an example: http://xs226.xs.to/xs226/08156/list_graph473.png Here is the code for that particular graph: code:
|
# ¿ Apr 13, 2008 19:32 |
|
Kaluza-Klein posted:
I don't know if this is related, but you can't call functions from within a class variable declaration. For instance: php:<? class poop extends woop { var variable1 = "4389348"; var variable2 = "fdjf545478"; var variable3 = trim("fdsuiofd ui fui fds "); function poop() { print "poo lol"; } ?> quote:edit: I realize now why having an object declared like that is a bad idea. You could declare a variable $what and then also have a function called $what and that would not be good. You can declare arrays, but only if you use the syntax $bla = array ('huh'), doing $bla[] = 'huh' doesn't work. When you do $blah[] = "something", the "=" operator kind of works like the ".=" operator. Your basically saying "add this value to the array", When the array has not been set, an error occurs.
|
# ¿ May 1, 2008 06:33 |
|
drcru posted:Didn't know where to put this question but since I'm writing in PHP... What I do is use YYYY-MM-DD when putting dates into the database, and when i get dates from the database, I immediately convert to unix timestamp for php manipulation. I've found that entering a unix timestamp into the database directly, via the UNIX_TIMESTAMP() mysql function (or whatever it's called) would sometimes add or a few hours because of timezones, so it would end up incrementing the day. Theres probably a good solution to that problem, but gently caress it, I just use YYYY-MM-DD so I know it's the right date.
|
# ¿ May 8, 2008 02:31 |
|
Bonus posted:What's a good PHP library for sending out emails? Just one at a time from a form, so no need for mass mailing. mail()? doesnt get much simpler than that
|
# ¿ May 8, 2008 10:57 |
|
I have a PHP array with each item being an airport identifier. "KBOS", "KTEB", "KMIA", "MMIO", etc. These are wordwide airports, not just US airports. I want to get the longitude/latitude coordinates of each item. It's a long shot, but is there a tool that already does such a thing? I can probably swing together a function that crawls some other page for the info, but I don't want to waste my time if something already exists. Once I get the longitude/latitude coordinates, I want to map them all on a map with lines connecting some of them. Whats a good tool for doing this? Would the Google Maps API be the only way to achieve this? I'd rather have it be a static image that can be saved.
|
# ¿ May 21, 2008 22:25 |
|
bt_escm posted:I found this http://www.webservicex.com/airport.asmx and I was able to get a couple of coordinates for a few airports. Thats not quite as comprehensive as I'd like. Anyways, I found airnav.com, which is 100% comprehensive for american airports, which is about as good and I'm going to find I'm afraid. Now, I'm wondering, whats the best way to go about mining the data from the page? I'm looking around the web, but I'm not finding much on how to actually build a web crawler... Anyone know of any good resources/tools for doing something like this?
|
# ¿ May 26, 2008 00:58 |
|
Evil Angry Cat posted:To be honest you're best off using Google Maps. If you notice that searching "KBOS" or "LAX" or "LGW" in Google Maps brings up the airport in question it's jut matter of using the API to get the latitude and longitude (or whatever information you're looking for). Much simpler than parsing a page of tables (which the airnav.com page is) to extract data. The reason I wanted to use airnav is because the information is 100% reliable. Relying on Google hits just doesn't seem very robust to me. But anyways, for the hell of it I looked into using the google API, and so far the results I've gotten have been pretty good, so gently caress it, I'll just use google. I have one problem though: Here is the PHP function that I wrote that gets the coordinates and then puts them into the database: code:
nbv4 fucked around with this message at 03:35 on May 26, 2008 |
# ¿ May 26, 2008 03:20 |
|
I want to add a feature on my site that outputs that data into a PDF file, so when the user print, it looks consistent and paged correctly. Anyone know of a good library or something that will do this?
|
# ¿ Jun 14, 2008 02:48 |
|
I'm trying to crawl a webpage using file_get_contents(), but it is giving me a 403 error. If I copy the exact same URL that the function is betting to a webbrowser, the page loads fine, but in PHP I get this error: Warning: file_get_contents(http://gc.kls2.com/airport/HECA) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /var/www/logbook/classes/map_class.php on line 252 I assume the site owner has some anti-spam thing in place which is why I'm blocked. Is there any way around this? This particular function is only going to be ran once or twice a month, so its not like I'm going to be overloading the site's bandwidth... nbv4 fucked around with this message at 06:38 on Jul 16, 2008 |
# ¿ Jul 16, 2008 06:32 |
|
jasonbar posted:This worked for me - please only use it for good. sweeeet, that worked. I won't be bad I promise. Bandwidth usage from this script will probably amount to a few hundred KB's per month.
|
# ¿ Jul 16, 2008 08:28 |
|
How do you add a indexed value to an array via indirection? I have this: code:
Whats odd is that I can change that line to: code:
|
# ¿ Aug 13, 2008 07:39 |
|
Oh I see, order of operations. I'm surprised it didnt bring up an error or something... Anyways, I guess a double array is my only option: $times[$category]['xc_dual'] = $temp[0];
|
# ¿ Aug 13, 2008 08:39 |
|
I have a huge array that is filled with strings in the form of "ABC-DEF", "ABC-XYZ", "XYZ-ABC", etc. I want to not only remove duplicates (which is very easy), but also remove any "reverse" duplicates. For instance, only one of "XYZ-ABC" and "ABC-XYZ" should exist. Each three letter "word" represents a start point and an end point in a line. I only need each line once, not its "backcourse". This seems like a very simple problem, but I can't think of a simple solution that doesn't involve tons of lines of code and large memory useage.
|
# ¿ Aug 25, 2008 15:38 |
|
KuruMonkey posted:Wherever and however you are checking for a dupe, construct the inverse and check for "dupe OR inverse" I'm not really "checking" for dupes, I'm just doing: php:<? $line_array = array_values(array_unique($line_array)); ?> php:<? implode("-", array_reverse(explode("-", $line_string))))?>
|
# ¿ Aug 25, 2008 16:07 |
|
I have a class that handles printing the DOCTYPE and headers, as well as the footer on each page. At the top of the class declaration, I have all these things defined like so:php:<? class page { var $page; var $title; var $year; var $copyright; var $auth; var $style; var $auth_level; var $get_sec; var $get_sec_q; var $page_title; var $doctype = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"; $meta_header = <<<EOF <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://www.w3.org/2005/10/profile"> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <meta name="DESCRIPTION" content="stupid description goes here." /> <meta name="KEYWORDS" content="keywordz" /> EOF; var $advert = ""; ?> the php website suggests "nowdoc", but I'm using PHP 5.2.X, and those are only allowed in 5.3 and greater.
|
# ¿ Oct 9, 2008 17:30 |
|
|
# ¿ Apr 29, 2024 11:42 |
|
I am having a hard time figuring out character encodings. I have a function that crawls a webpage that happens to be encoded in ISO-8859-1. Some text is lifted off that site and then ran through utf_encode() and then stored in a database. When I view the contents of that field in phpMyAdmin, it looks like this: "México", with a "A" with a squiggly line above it and a copyright logo instead of an "e" with an accent mark as how it looks on the original ISO-8859-1 page. The phpMyAdmin page is encoded in UTF-8, so I don't know what is happening. Is this caused by utf_encode() not working? What could be causing this? The "collation" of the databse is "latin1_swedish_ci", could that be the problem? I think I remember messing with encoding a few months ago, and changing the collation didn't change anything. When I drawl the info from the database it works fine, with the accent mark displaying correctly, which gets me because the page I use to display the data is set to UTF-8 as well...
|
# ¿ May 9, 2009 01:04 |