Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
Also fyi, [url=http://www.php.net/manual/en/mysqlinfo.api.choosing.php]mysql functions are deprecated as of PHP 5.5.0[/url].
I'm having to use PhoneGap for a Mobile App Development course that's boiled down to writing a web app and wrapping it with PhoneGap. I'm using it command line since that seems to be the only documented way of using it (at least, Windows side, Mac seems to be able to integrate with XCode), but I'm having a slew of issues trying to get it to run.
For starters, if anyone doesn't know about it, and if I'm not mistaken, it's a Node.JS package. Unfortunately it relies on ant, which I can't get to install. When I run npm install, it warns me that ant expects Node.JS version 0.8.0, and I'm running 0.10.26, and aborts the install. I've tried node-ant, too, but that requires Python, and I'm not even sure it would work if I installed Python.
Has anyone else worked with PhoneGap on Windows, and if so, how did you get it to work? I'd really rather not degrade to an older version of Node.JS.
[QUOTE=biodude94566;44692635]I'm having to use PhoneGap for a Mobile App Development course that's boiled down to writing a web app and wrapping it with PhoneGap. I'm using it command line since that seems to be the only documented way of using it (at least, Windows side, Mac seems to be able to integrate with XCode), but I'm having a slew of issues trying to get it to run.
For starters, if anyone doesn't know about it, and if I'm not mistaken, it's a Node.JS package. Unfortunately it relies on ant, which I can't get to install. When I run npm install, it warns me that ant expects Node.JS version 0.8.0, and I'm running 0.10.26, and aborts the install. I've tried node-ant, too, but that requires Python, and I'm not even sure it would work if I installed Python.
Has anyone else worked with PhoneGap on Windows, and if so, how did you get it to work? I'd really rather not degrade to an older version of Node.JS.[/QUOTE]
I have played around with it, this guide explains the setup process perfectly [url]http://www.andrewsavory.com/blog/2013/2517[/url] just skip the android stuff if you dont need android
BTW are you alowed to post the lecture slides/notes? Im just going by online tutorials but there doesnt seem to be that many
[QUOTE=Cyberuben;44690549]MyBB has a structure where on every page it loads information from a certain user into a variable named "$mybb->user". It is basically a copy of the "mybb_user" table, but I've noticed that this is cached.
...[/QUOTE]
Honestly, i'd just use [URL="http://redis.io"]Redis[/URL]. It's much simpler.
[URL="https://github.com/nicolasff/phpredis"]Here[/URL]'s a PHP module.
[QUOTE=TrinityX;44693360]Honestly, i'd just use [URL="http://redis.io"]Redis[/URL]. It's much simpler.
[URL="https://github.com/nicolasff/phpredis"]Here[/URL]'s a PHP module.[/QUOTE]
Already have it installed. Would you mind helping me to get the hang of it? I tried fooling around with it but I can't really seem to get the basics. I see a function to dump an entire database, but no function to create a database. I find their documentation is quite poor.
I'm trying to make a forum, but not completely. I don't want to use forum software like MyBB because it will always be built around the forum, and I don't want that. So I'm trying to create my own website, but it has a forum included. I'm planning on making this a project that I can reuse if any of my clients are in need of it, but then Redis would already be bad as not every host allows this to be installed. Barely any if I'm right. But if I wanted to use Redis, would I store all threads in Redis? Would I store all posts in Redis? Or just the information that I need quite often, such as user information that is loaded on every page? And how would I properly store this without losing too much structure?
I'm making a job system for a client which works kinda like this:
The system is for a glazier company, they get orders where their customer might want to have a glass railing montaged/installed. One of their workers adds the order to the system, providing a date when an installer is supposed to be there and install the glass rail. Now, the client want to have a schedule on the page so when one of their hired installer logs in, they can see their own schedule for the week (If on desktop) / day (if on phone) & onward.
What I can't seem to figure out is how I'm going to make this schedule display like. I'm using myself of Bootstrap.
Should I use a table or go with the grid system? Any other good way of doing this?
[QUOTE=supersnail11;44691270]You should be escaping this cookie value before you use it in a query.[/QUOTE]
Yeah forgot that. I always do it, but forgot it this one time :V
[editline]1st May 2014[/editline]
[QUOTE=Svenskunganka;44694434]I'm making a job system for a client which works kinda like this:
The system is for a glazier company, they get orders where their customer might want to have a glass railing montaged/installed. One of their workers adds the order to the system, providing a date when an installer is supposed to be there and install the glass rail. Now, the client want to have a schedule on the page so when one of their hired installer logs in, they can see their own schedule for the week (If on desktop) / day (if on phone) & onward.
What I can't seem to figure out is how I'm going to make this schedule display like. I'm using myself of Bootstrap.
Should I use a table or go with the grid system? Any other good way of doing this?[/QUOTE]
Interesting. I've been looking to make a planner myself, but for different purposes. I thought of making a grid using 7 different divs that are positioned next to eachother. Then add divs in there, giving them at top-margin based on the job before that. I've thought about using the same method as Bootstrap.
Create a CSS file that has classes with specific heights. If you create a schedule that starts at 8am and ends at 5pm, you need 18 classes (if you use half-hour schedules, there are 18 different heights).
Then create additional classes that determine the offset, just like in Bootstrap. Then you can give every block 2 classes, 1 height and 1 offset, to position them properly in a div that is used as timetable.
I haven't tried it out, but this is just a method I had in mind. Might aswell share it.
Anyone have any idea on how to stop new lines in html file from moving the elements?
[QUOTE=Worre;44695076]Anyone have any idea on how to stop new lines in html file from moving the elements?[/QUOTE]
Actual new lines in the code, or <br> tags?
If new lines in the code, try opening a HTML comment on the end of the line, and closing it on the beginning of the next.
[QUOTE=TrinityX;44695263]Actual new lines in the code, or <br> tags?
If new lines in the code, try opening a HTML comment on the end of the line, and closing it on the beginning of the next.[/QUOTE]
Yeah, I meant actual new lines. Thanks, I'll try that.
So, why does php do this:
[code]$month = "06";
$day = "01";
$year = "2014";
echo $day . "-" . $month . "-" . $year;
echo "<br/>";
echo $day + "-" + $month + "-" + $year;[/code]
[quote="output"]01-06-2014
2021[/quote]
Seriously. And where are the dashes even going??
[QUOTE=false prophet;44695597]So, why does php do this:
[code]$month = "06";
$day = "01";
$year = "2014";
echo $day . "-" . $month . "-" . $year;
echo "<br/>";
echo $day + "-" + $month + "-" + $year;[/code]
Seriously. And where are the dashes even going??[/QUOTE]
Where's the problem?
Since the dots are used to append the string, they don't count towards what's actually echoed.
You could do
echo "a" .
"b";
if you wanted.
As you don't have any spaces between the hypens, PHP isn't adding new ones, either.
As for the +, well, it's just doing what those symbols mean: sum.
Specifically, it's adding $day (1)+ $month (6)+$year(2014). In total, 2021.
That's not what I am asking.
My point is why does PHP add numbers in a STRING together to produce something completely unexpected. In ordinary languages the output would have been the same. But for some reason PHP thought this would be a terrific idea:
[code] $not_a_number = "this is not the number 1000";
$not_another_number = "this is a fucking string that contains 1000";
echo $not_a_number + " " + $not_another_number + ". But instead, it outputs 0";[/code]
Oh and even worse is, you get this behavior too:
[code]echo "200 and " + "300 is not 500";[/code]
What??
[edit] PHP is weird
[QUOTE=false prophet;44695908]That's not what I am asking.
My point is why does PHP add numbers in a STRING together to produce something completely unexpected. In ordinary languages the output would have been the same. But for some reason PHP thought this would be a terrific idea:
[code] $not_a_number = "this is not the number 1000";
$not_another_number = "this is a fucking string that contains 1000";
echo $not_a_number + " " + $not_another_number + ". But instead, it outputs 0";[/code]
Oh and even worse is, you get this behavior too:
[code]echo "200 and " + "300 is not 500";[/code]
What??
[edit] PHP is weird[/QUOTE]
+ is for math
you could just do "lel" . "lel2";
Yeah plus is javascript, not PHP
I believe you are misunderstanding false prophet.
In PHP, you define a string literal in either of these ways; [URL="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single"]single quoted[/URL], [URL="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double"]double quoted[/URL], [URL="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc"]heredoc[/URL] or [URL="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc"]nowdoc[/URL]. He defined the variable to be a string literal using the double quotes, which, in theory cannot be used in arthimetics. However, in PHP, if the string(s) only contains numbers (0-9) and other arthimetic characters (dot(.)) and an arthimetic operator is executed on the string(s), the PHP engine will [URL="http://www.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting"]cast[/URL] the variable to integer or float before executing the artimetics.
Many programmers dislikes this feature since it can be misleading, but in my opinion it's one of the many beauties of PHP.
Misleading maybe, but with PHP you can often be getting numbers in Strings that you need to run calculations with, it's much nicer to have it automatically converted rather than manually keep going back and forth between Strings and Integers
[QUOTE=Svenskunganka;44696855]many beauties of PHP[/QUOTE]
:v:
[QUOTE=Svenskunganka;44696855]I believe you are misunderstanding false prophet.
In PHP, you define a string literal in either of these ways; [URL="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.single"]single quoted[/URL], [URL="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.double"]double quoted[/URL], [URL="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc"]heredoc[/URL] or [URL="http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.nowdoc"]nowdoc[/URL]. He defined the variable to be a string literal using the double quotes, which, in theory cannot be used in arthimetics. However, in PHP, if the string(s) only contains numbers (0-9) and other arthimetic characters (dot(.)) and an arthimetic operator is executed on the string(s), the PHP engine will [URL="http://www.php.net/manual/en/language.types.type-juggling.php#language.types.typecasting"]cast[/URL] the variable to integer or float before executing the artimetics.
Many programmers dislikes this feature since it can be misleading, but in my opinion it's one of the many beauties of PHP.[/QUOTE]
I think that PHP should add character's bytes representations, since that makes more sense than adding an abstract representation of numbers together.
Seriously, strings are meant to represent abstract collections of characters; adding strings should not be changed by the content of the characters. From a C-language point of view, adding strings should work like adding arrays, since all a string basically is is an array of bytes.
If you want to add the numbers in a string together, you should turn the string into an integer. To me, adding two strings and getting a number is like adding [{ hello: "world" }] and [{ foo: "bar' }] together and getting { hello: "world", foo: "bar" }. It's absolutely senseless, and if you're not careful, it'll bite you.
[QUOTE=Cyberuben;44694481]Yeah forgot that. I always do it, but forgot it this one time :V[/QUOTE]
Just get in the habit of using prepared statements which are actually supported by the developers of the language, and by their very nature, will protect you (assuming you use them correctly).
You know what, wrong thread. It's been a long time since I've done that shit.
[QUOTE=Ac!dL3ak;44698435]I think that PHP should add character's bytes representations, since that makes more sense than adding an abstract representation of numbers together.
Seriously, strings are meant to represent abstract collections of characters; adding strings should not be changed by the content of the characters. From a C-language point of view, adding strings should work like adding arrays, since all a string basically is is an array of bytes.
If you want to add the numbers in a string together, you should turn the string into an integer. To me, adding two strings and getting a number is like adding [{ hello: "world" }] and [{ foo: "bar' }] together and getting { hello: "world", foo: "bar" }. It's absolutely senseless, and if you're not careful, it'll bite you.[/QUOTE]
If you disagree with this you have not been using PHP long enough for something like this to bite you in the ass yet. Everything in this post is spot on.
[QUOTE=KmartSqrl;44704195]If you disagree with this you have not been using PHP long enough for something like this to bite you in the ass yet. Everything in this post is spot on.[/QUOTE]
Adding the characters' bytes together would make PHP more of a clusterfuck than it already is. Ideally it would just throw an error if attempting arithmetic on strings.
[QUOTE=CBastard;44704243]Adding the characters' bytes together would make PHP more of a clusterfuck than it already is. Ideally it would just throw an error if attempting arithmetic on strings.[/QUOTE]
I'd definitely prefer an exception be thrown. This is a really easy source of potential weirdness so I'd rather be made explicitly aware of it.
[QUOTE=KmartSqrl;44704195]If you disagree with this you have not been using PHP long enough for something like this to bite you in the ass yet. Everything in this post is spot on.[/QUOTE]
What? If you expect a literal string with characters, why would you even use + to concate them when the character of use is the . (dot) character? If you know your language, something like this would never "bite you in the ass".
[QUOTE=Svenskunganka;44704483]What? If you expect a literal string with characters, why would you even use + to concate them when the character of use is the . (dot) character? If you know your language, something like this would never "bite you in the ass".[/QUOTE]
Tell me without looking what...
[code]
"10-100" + 5
[/code]
...will equal.
There is NO reason that should not throw an exception. PHP's habit of trying to guess what you meant to do instead of telling you "erm, this is wrong" is part of the reason there is so much shit PHP out there.
[QUOTE=KmartSqrl;44704590]Tell me without looking what...
[code]
"10-100" + 5
[/code]
...will equal.
There is NO reason that should not throw an exception. PHP's habit of trying to guess what you meant to do instead of telling you "erm, this is wrong" is part of the reason there is so much shit PHP out there.[/QUOTE]
Surely it should throw an exception, but the interpreter doesn't execute any arthimetics on the string until you invoke an arthimetic character outside the double quotes. In fact, your snipped there, everything after, including the - (dash/minus) character is ignored by PHP when you invoke the artimetic character + later on. So in this case, PHP would output 15 ("10" + 5). Which is absolutely ridiculus and should be fixed, however "10" + "10" is a feature in my opinion, while "15words" + 5 equals to 20 is a huge error and should be fixed.
[QUOTE=CBastard;44704243]Adding the characters' bytes together would make PHP more of a clusterfuck than it already is. Ideally it would just throw an error if attempting arithmetic on strings.[/QUOTE]
That was my point - the concept that PHP interprets the string differently based on the content is something that is completely fucking stupid. I wasn't serious when I said that line - the point of it was to point out how stupid it is that PHP changes behaviour depending on the content of the string.
[QUOTE=Svenskunganka;44704483]What? If you expect a literal string with characters, why would you even use + to concate them when the character of use is the . (dot) character? If you know your language, something like this would never "bite you in the ass".[/QUOTE]
Most other object-oriented language (and even a few non-object oriented languages) use the '.' as a property character - i.e., 'some_object.some_property'. The concept that it performs concatenation probably comes from lisp, which is crazy, since PHP is supposed to be C based (which uses '.' in order to access struct elements; odd, don't you think?).
[QUOTE=Svenskunganka;44705322]Surely it should throw an exception, but the interpreter doesn't execute any arthimetics on the string until you invoke an arthimetic character outside the double quotes. In fact, your snipped there, everything after, including the - (dash/minus) character is ignored by PHP when you invoke the artimetic character + later on. So in this case, PHP would output 15 ("10" + 5). Which is absolutely ridiculus and should be fixed, however "10" + "10" is a feature in my opinion, while "15words" + 5 equals to 20 is a huge error and should be fixed.[/QUOTE]
"10" + "10" is not a feature. It should equal "1010", not 20. PHP should not care about the content of the string, nor assume what is in the string and give it some semantic meaning. Let's look at [url=https://eval.in/145655]this[/url]; that is not something that you would expect on first appearances. [url=https://eval.in/145656]In[/url] [url=https://eval.in/145657]other[/url] [url=https://eval.in/145662]languages[/url], it doesn't occur. The only other language that does this is [url=https://eval.in/145663]perl[/url], and perl is an odd language to start with. I think you should have to do something like [url=https://eval.in/145664]this[/url] in order to get 20, because it's explicit and tells the programmer (and program) what exactly that piece of code intends to do.
[QUOTE=Ac!dL3ak;44705977]That was my point - the concept that PHP interprets the string differently based on the content is something that is completely fucking stupid. I wasn't serious when I said that line - the point of it was to point out how stupid it is that PHP changes behaviour depending on the content of the string.
Most other object-oriented language (and even a few non-object oriented languages) use the '.' as a property character - i.e., 'some_object.some_property'. The concept that it performs concatenation probably comes from lisp, which is crazy, since PHP is supposed to be C based (which uses '.' in order to access struct elements; odd, don't you think?).
"10" + "10" is not a feature. It should equal "1010", not 20. PHP should not care about the content of the string, nor assume what is in the string and give it some semantic meaning. Let's look at [url=https://eval.in/145655]this[/url]; that is not something that you would expect on first appearances. [url=https://eval.in/145656]In[/url] [url=https://eval.in/145657]other[/url] [url=https://eval.in/145662]languages[/url], it doesn't occur. The only other language that does this is [url=https://eval.in/145663]perl[/url], and perl is an odd language to start with. I think you should have to do something like [url=https://eval.in/145664]this[/url] in order to get 20, because it's explicit and tells the programmer (and program) what exactly that piece of code intends to do.[/QUOTE]
For point 2, that's just nitpicky, if they want to use dots for concatenation they can, other languages use other symbols.
For point 3, I explained this already, with PHP you often get numbers retrieved in strings, so if you want to make calculations on them this makes it a lot easier, and it's very unlikely you're going to want to stick 2 numbers together
If you are getting a number as a string, it probably came from user input or from somewhere other than your codebase (third party api, file, etc). What happens if a user types a large number and puts a comma every 3 digits...
[code]
"1,000" + 5 == 6
[/code]
That's [B]REALLY[/B] wrong.
If you want a string to be treated as a number, it should be explicit. There are too many edge cases, and PHP does not handle them well.
[editline]2nd May 2014[/editline]
Lol... PHP...
[code]
"0,125" == 0 -> true
0 == false -> true
"0,125" == false -> false
[/code]
Sorry, you need to Log In to post a reply to this thread.