• Web Development Questions That Don't Need Their Own Thread v2
    3,079 replies, posted
Trying to use php to set a link from a text file. For some reason this: [code] <div class="contentText" id="boxOneText" <?php echo 'onClick="window.open(\''.$link.'\',\'_self\')"';?>> [/code] doesn't work, but this: [code] <div class="contentText" id="boxOneText" onClick="window.open('link.php','_self')"> [/code] does, even though the output is the same. ($link = 'link.php') I don't know whether it's valid php to put code inside an html tag so please don't shoot me if it isn't [b]EDIT:[/b] nevermind, solved it - I'm using fgets() to get each line, then making it a substring to remove the newline character - turns out I need to do strlen($string)-2 instead of -1, even though that makes no sense.
This is sort of strange to me, but what is happening when I see a directory past a file type. e.g. (derp.com/boss/index.php/home.php) What's happening?
[QUOTE=aero1444;30225941] nevermind, solved it - I'm using fgets() to get each line, then making it a substring to remove the newline character - turns out I need to do strlen($string)-2 instead of -1, even though that makes no sense.[/QUOTE] How come? For Windows it's \r\n, for *nix it's \n. Also: [php] rtrim($line, "\r\n"); [/php] If you leave the second argument blank, it'll strip out all whitespace characters, including the space character. [editline]3rd June 2011[/editline] [QUOTE=SomeFaggot;30226485]This is sort of strange to me, but what is happening when I see a directory past a file type. e.g. (derp.com/boss/index.php/home.php) What's happening?[/QUOTE] Depends on a few things, really. What web server? Are you using some sort of framework?
[QUOTE=StinkyJoe;30226537]How come? For Windows it's \r\n, for *nix it's \n. Also: [php] rtrim($line, "\r\n"); [/php] If you leave the second argument blank, it'll strip out all whitespace characters, including the space character. [editline]3rd June 2011[/editline] Depends on a few things, really. What web server? Are you using some sort of framework?[/QUOTE] I've been hired to do bugfixes and other stuff for some site, and this is for the administration section. I jumped onto the thing about 2 years in. From what I can tell it's like it's using the same style from the index.php, but displaying the content from the relevant section. It's kinda confusing.
[QUOTE=SomeFaggot;30226676]I've been hired to do bugfixes and other stuff for some site, and this is for the administration section. I jumped onto the thing about 2 years in. From what I can tell it's like it's using the same style from the index.php, but displaying the content from the relevant section. It's kinda confusing.[/QUOTE] Either it's some webserver quirk where it climbs up the path until it hits the base directory, or most likely whatever backend you have there is handling $_SERVER['REQUEST_URI'] internally (standard procedure for pretty much any framework), and getting /home.php as the page/controller.
I remember reading about how fonts are protected by copyright. Am I allowed to use @font-face freely?
Depends on the individual font licenses afaik.
why is this integer 76561197987799766 turning into 76561197987799760 when I run it through json_decode
[code]&#10140; ~ php -r 'echo (int)(float)"76561197987799766", "\n";' 76561197987799760[/code] (Just ignore the weird prompt.)
[QUOTE=Jimbomcb;30231303]why is this integer 76561197987799766 turning into 76561197987799760 when I run it through json_decode[/QUOTE] is your php 32 or 64 bit
[QUOTE=itsbth;30231456][code]&#10140; ~ php -r 'echo (int)(float)"76561197987799766", "\n";' 76561197987799760[/code] (Just ignore the weird prompt.)[/QUOTE] why is it doing that? [QUOTE=Tangara;30231710]is your php 32 or 64 bit[/QUOTE] 64
[QUOTE=Jimbomcb;30231738]why is it doing that?[/quote] Floating point inprecision Here's how a float is laid out in memory: [img]http://upload.wikimedia.org/wikipedia/commons/thumb/e/e8/IEEE_754_Single_Floating_Point_Format.svg/618px-IEEE_754_Single_Floating_Point_Format.svg.png[/img] Basically floats are just scientific notation. If you try and fit a number that's too large in a float, it'll start to lose precision near the least significant figures. It's weird that PHP's json_decode() is parsing the number as a float, but that's PHP for you I guess. I'd recommend just encoding the number as a JSON string and pulling it back out as a string. You can then use the bc*() functions on it to do arithmetic if you want to stay compatible with 32 bit PHPs.
luckily i can get the int another way, don't need to use it from the json data. thanks for the explanation though. i don't see the sense in json_decode converting the string to float then int but oh well.
[QUOTE=Jimbomcb;30231974]i don't see the sense[/QUOTE] welcome to php, enjoy your stay
Hey, you remember when I was having trouble with namespaces in php? I figured out the problem. It was the fucking encoding type. I had it set to UTF-8, and it would shoot the error, when there was clearly no problem with it. So I tried it in Dreamweaver (I don't use it for the design view, just the ftp and the auto-complete stuff), and it worked fine. I thought that Notepad++ had to be adding something to the beginning of the file; so I thought, why not check the encoding type? Dirp is encoded in ANSI. The file I made in Dreamweaver was ANSI. The file I made in Notepad++, however, was in UTF-8. TL;DR: Protip: use ANSI.
Does anyone got any good beginner tutorials for Sencha Touch?
I've been learning php for the past 4 weeks, and have went through the basic and intermediate tutorials. Where can I go to learn the use of classes and some advanced functions? Can't seem to find a place that goes beyond handy functions/mysql
[url]http://net.tutsplus.com/tutorials/php/oop-in-php/[/url]
Could someone clarify why I should be using PDO (other reasons than modularity)? How I see it, you need more work to execute normal queries (read: don't really know the benefits of prepared statements (are they optimized for doing the same query multiple times or something?)) and there aren't some of the most useful functions (such as mysql_num_rows()). Plus, I apparently can't have a new query if I'm looping through one's results? Or do I have to "close" the previous one somehow? Now, I'm not saying I think PDO is useless or anything even remotely like that, but I haven't yet really figured out why it's so big of an improvement other than modularity.
$query->num_rows pdo prepares the statements so that they don't need to be escaped and no, another query while you have a query already fetching rows is not good practice. [quote]Plus, I apparently can't have a new query if I'm looping through one's results? Or do I have to "close" the previous one somehow?[/quote] this also makes it sound like that you're querying every loop through an original query, which you should also not do i think you should go take a look at pdo again because you missed a lot of stuff [editline]5th June 2011[/editline] i probably missed some things, but you get the point, it's much better
What's the best way to store multiple values in a single column, but can be looked up later? I have a 'city' and 'state' column, and sometimes they need to have multiple values, eg, 'WI,IL' in 'states',and I'd like to be able to search for all rows that have work done in <state>, and it'll return them. Edit:[url=http://dev.mysql.com/doc/refman/5.0/en/constraint-enum.html] I think ENUM might be good, because it'll accept anything, whereas SET will discard anything not in the initial array.[/url] Does anyone have any tips or better ideas?
[QUOTE=Dragory;30259361]Could someone clarify why I should be using PDO (other reasons than modularity)? How I see it, you need more work to execute normal queries (read: don't really know the benefits of prepared statements (are they optimized for doing the same query multiple times or something?)) and there aren't some of the most useful functions (such as mysql_num_rows()). ...[/QUOTE] When you run a statement, the SQL server parses, compiles and optimises the query (i.e. the query turns from "SELECT blah FROM..." to actual code to pull the values out of the table), using PDO allows it to cache the compiled query, and re-run it with different variables (vs. parsing, compiling and optimising each time) At least I think that's it anyway :v:
Could someone point out why the media tags don't size right in chrome. [code] #media_header{ border-top-left-radius: 14px; border-top-right-radius: 14px; color: #000; padding: 4px 6px 4px 6px; border-left: 1px solid gray; border-right: 1px solid gray; border-top: 1px solid gray; background-color: #eeeeee; min-width: 640px; display: table; text-align: center; height: 24px; } #media_footer{ border-bottom-left-radius: 14px; border-bottom-right-radius: 14px; color: #FFF; padding: 4px 6px 4px 6px; background-color: #484848; border-left: 1px solid gray; border-right: 1px solid gray; border-bottom: 1px solid gray; min-width: 640px; display: table; text-align: center; height: 24px; } [/code] They work perfect in Firefox but chrome they look like this: [url]http://www.mcskinsearch.com/ul/images/1307309849.png[/url] If you want to see the page it's [url=http://pngskin.com/forums/]here[/url].
they've gotta be a block not a table
[QUOTE=hacksore;30267601]Could someone point out why the media tags don't size right in chrome. [code] #media_header{ border-top-left-radius: 14px; border-top-right-radius: 14px; color: #000; padding: 4px 6px 4px 6px; border-left: 1px solid gray; border-right: 1px solid gray; border-top: 1px solid gray; background-color: #eeeeee; min-width: 640px; display: table; text-align: center; height: 24px; } #media_footer{ border-bottom-left-radius: 14px; border-bottom-right-radius: 14px; color: #FFF; padding: 4px 6px 4px 6px; background-color: #484848; border-left: 1px solid gray; border-right: 1px solid gray; border-bottom: 1px solid gray; min-width: 640px; display: table; text-align: center; height: 24px; } [/code] They work perfect in Firefox but chrome they look like this: [url]http://www.mcskinsearch.com/ul/images/1307309849.png[/url] If you want to see the page it's [url=http://pngskin.com/forums/]here[/url].[/QUOTE] set a size or make header 100% width inside the footer.
[QUOTE=TehWhale;30267730]they've gotta be a block not a table[/QUOTE] That fucked them up even more.
[QUOTE=cas97;30265337]What's the best way to store multiple values in a single column, but can be looked up later? I have a 'city' and 'state' column, and sometimes they need to have multiple values, eg, 'WI,IL' in 'states',and I'd like to be able to search for all rows that have work done in <state>, and it'll return them. Edit:[url=http://dev.mysql.com/doc/refman/5.0/en/constraint-enum.html] I think ENUM might be good, because it'll accept anything, whereas SET will discard anything not in the initial array.[/url] Does anyone have any tips or better ideas?[/QUOTE] Let's say your table is called people (if it isn't, just adapt what I'm saying to your circumstances). You'd have another table called people_states with a column called person_id and a column called state (both indexed). You might also want to have a primary key in there. If you want to find all the rows pertaining to a certain state, you'd use a query like the following: [code] SELECT people.* FROM people INNER JOIN people_states ON people_states.person_id = people.id AND people_states.state = ? [/code] You [i]could[/i] hack something together with CSV values, but that's going to be a hell of a lot slower to query against than a separate, properly indexed table to store the data.
[QUOTE=Tangara;30269970]Let's say your table is called people (if it isn't, just adapt what I'm saying to your circumstances). You'd have another table called people_states with a column called person_id and a column called state (both indexed). You might also want to have a primary key in there. If you want to find all the rows pertaining to a certain state, you'd use a query like the following: [code] SELECT people.* FROM people INNER JOIN people_states ON people_states.person_id = people.id AND people_states.state = ? [/code] You [i]could[/i] hack something together with CSV values, but that's going to be a hell of a lot slower to query against than a separate, properly indexed table to store the data.[/QUOTE] I see what you're doing there, and I thought of that, but I thought that there should've been a better way to do it with just a certain type of column :saddowns:
What's the best method of generating 6-7 random letters and numbers for a page "id", while making sure the same one never appears twice? (php)
sha1(time()) or md5(time())?
Sorry, you need to Log In to post a reply to this thread.