• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 09:27
CEST 15:27
KST 22:27
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro16 Preview Pt1: Fresh Flow5[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy21ByuL: The Forgotten Master of ZvT30
Community News
MaNa leaves Team Liquid13$5,000 WardiTV TLMC tournament - Presented by Monster Energy5GSL CK: More events planned pending crowdfunding7Weekly Cups (May 30-Apr 5): herO, Clem, SHIN win0[BSL22] RO32 Group Stage5
StarCraft 2
General
MaNa leaves Team Liquid Team Liquid Map Contest #22 - Presented by Monster Energy Quebec Clan still alive ? BGE Stara Zagora 2026 cancelled Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament $5,000 WardiTV TLMC tournament - Presented by Monster Energy RSL Revival: Season 5 - Qualifiers and Main Event GSL CK: More events planned pending crowdfunding Sea Duckling Open (Global, Bronze-Diamond)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 521 Memorable Boss The PondCast: SC2 News & Results Mutation # 520 Moving Fees Mutation # 519 Inner Power
Brood War
General
ASL21 General Discussion [ASL21] Ro16 Preview Pt1: Fresh Flow BGH Auto Balance -> http://bghmmr.eu/ JD's Ro24 review The Korean Terminology Thread
Tourneys
[ASL21] Ro16 Group A Escore Tournament StarCraft Season 2 [Megathread] Daily Proleagues [ASL21] Ro24 Group F
Strategy
Any training maps people recommend? Fighting Spirit mining rates Muta micro map competition What's the deal with APM & what's its true value
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Battle Aces/David Kim RTS Megathread General RTS Discussion Thread Starcraft Tabletop Miniature Game
Dota 2
The Story of Wings Gaming Official 'what is Dota anymore' discussion
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
Canadian Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread US Politics Mega-thread The China Politics Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread Formula 1 Discussion Cricket [SPORT] Tokyo Olympics 2021 Thread
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
lurker extra damage testi…
StaticNine
How Streamers Inspire Gamers…
TrAiDoS
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 2168 users

The Big Programming Thread - Page 329

Forum Index > General Forum
Post a Reply
Prev 1 327 328 329 330 331 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Yoshi-
Profile Joined October 2008
Germany10227 Posts
Last Edited: 2013-07-24 21:11:59
July 24 2013 20:54 GMT
#6561
On July 25 2013 05:44 tofucake wrote:
There are a bunch of php websocket libraries. socketo.me is probably the most well known. And even without that PHP still supports sockets (I made a bnet bot in php+ajax almost a decade ago).


Yea I know I already realized that and removed that part.

On July 25 2013 05:43 fdsdfg wrote:

Isn't google chat (chat from the gmail web interface) done using ajax?


Just did a quick check doesn't look like ajax, or at least the firebug console doesn't show any ajax request that could be related to it.
Yea, they use long polling or httpstreaming for it: http://stackoverflow.com/questions/2440135/is-long-polling-the-most-efficient-way-to-create-a-web-real-time-app/2440150#2440150
They arguably uses "Ajax", but not the same way how OP does
nunez
Profile Blog Joined February 2011
Norway4003 Posts
July 24 2013 20:55 GMT
#6562
On July 25 2013 05:28 fdsdfg wrote:
Show nested quote +
On July 25 2013 05:12 czaku wrote:
On July 25 2013 04:54 tofucake wrote:
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?

Why?


It's a project to pass the next semester from programming and she is not interested in learning it. So she asked for my help. Basically you show the teacher code, explain how it works and you passed.


On July 25 2013 05:00 fdsdfg wrote:
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?


Just write a 1-line batch file that calls format and throws the output away. You're reinventing the wheel if you try to write a new format utility for no reason.



The problem is it has to be in C/C++ and i prefer C at the moment.


You're asking for help on writing your friend's school project for her? She should fail if she can't learn the stuff. Programmers work on teams, and I wouldn't wish a useless teammate on any fellow programmer, which is what you're trying to inflict.


i too enjoy moralizing instead of shutting up when i am unable to answer.
conspired against by a confederacy of dunces.
KainiT
Profile Joined July 2011
Austria392 Posts
July 24 2013 20:58 GMT
#6563
On July 25 2013 05:02 LukeNukeEm wrote:
Hi, I have a question for the c++-gurus:
given
template<class T = void>
class foo
{
};

int main(void)
{
foo<> foo1;
foo<int> foo2;
}
and that I am lazy, is there a way to make
foo foo1;
foo<int> foo2;
legal?
I know i can do this
namespace detail
{
template<class T = void>
class foo
{
};
}
using foo = detail::foo<>;

int main(void)
{
foo foo1;
detail::foo<int> foo2;
}
, but now i have to write detail:: for every class with a non-default template parameter.
Is there any magic available to make this work, perhaps with template aliases?


I am afraid there isn't, but I do not really get your "problem". Writing "<>" is too much work? I find it helpful that the compiler makes one aware of which classes are actually templated.
With great power comes great responsibility.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-07-24 21:18:31
July 24 2013 21:16 GMT
#6564
I've got a question from a relative today what a programmer is supposed to do when it comes to "domain requirements", e.g. it's required from you to create software that will be used in (say) architecture development or any other non-computer field really. The problem is you're a software engineer not an architect, physician or whatever.

What I answered was that the contractor of the project (or the manager) should be responsible to teach/give enough material to programmers to fullfill application requirements. However, is this what's done in practice? Am I close to truth?

Edit: The purpose of the question was that he thinks everyone should understand everything even if it's just a little bit.
1handsomE
Profile Blog Joined July 2011
United States199 Posts
Last Edited: 2013-07-24 21:22:32
July 24 2013 21:22 GMT
#6565
Hi. I am a relatively junior level programmer (2 years professional experience) who just got an actual programming job (UI Programmer) in the game industry. I was wondering if there was anyone else on the forums who works in the industry?

Edit: DM me, let's be friends!
MarineKing / Jaedong / DeMusliM / SeleCT / Maru hwaiting!
fdsdfg
Profile Blog Joined February 2010
United States1251 Posts
July 24 2013 22:08 GMT
#6566
On July 25 2013 05:55 nunez wrote:
Show nested quote +
On July 25 2013 05:28 fdsdfg wrote:
On July 25 2013 05:12 czaku wrote:
On July 25 2013 04:54 tofucake wrote:
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?

Why?


It's a project to pass the next semester from programming and she is not interested in learning it. So she asked for my help. Basically you show the teacher code, explain how it works and you passed.


On July 25 2013 05:00 fdsdfg wrote:
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?


Just write a 1-line batch file that calls format and throws the output away. You're reinventing the wheel if you try to write a new format utility for no reason.



The problem is it has to be in C/C++ and i prefer C at the moment.


You're asking for help on writing your friend's school project for her? She should fail if she can't learn the stuff. Programmers work on teams, and I wouldn't wish a useless teammate on any fellow programmer, which is what you're trying to inflict.


i too enjoy moralizing instead of shutting up when i am unable to answer.


If he asked for $20 and you didn't send him $20, would it be right to assume that you don't have $20 to your name?
aka Siyko
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
Last Edited: 2013-07-24 22:22:52
July 24 2013 22:20 GMT
#6567
On July 25 2013 06:16 darkness wrote:
I've got a question from a relative today what a programmer is supposed to do when it comes to "domain requirements", e.g. it's required from you to create software that will be used in (say) architecture development or any other non-computer field really. The problem is you're a software engineer not an architect, physician or whatever.

What I answered was that the contractor of the project (or the manager) should be responsible to teach/give enough material to programmers to fullfill application requirements. However, is this what's done in practice? Am I close to truth?

Edit: The purpose of the question was that he thinks everyone should understand everything even if it's just a little bit.


Probably not a bad idea to understand the industry in which your code will be running. In particular, there are script compliance rules for certain industries which require obnoxious certifications in order to have use your code.
Check out MISRA for automotive, for example.
http://en.wikipedia.org/wiki/MISRA_C
In this sense, an 'industry panel of experts' has strict rules regarding what features of the language you can use, and how you should use them. It even has rules about benign features, like whitespace. Some certifications require some really strange stuff, like a clean desk, and showing up on time to work as part of the software requirements. I guess it makes sense that if you control the programmer's level of reliability, then his code ought to be more reliable as well. I figure that in pratice, there have been very few software bugs in certified environments, like automotive, space, trains, medical, architecture, etc...

+ Show Spoiler +
Probably worth noting that code that is to specifications is usually 10x harder to debug than hacked together garbage from a jr. dev .
Any sufficiently advanced technology is indistinguishable from magic
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-07-24 23:07:45
July 24 2013 23:05 GMT
#6568
On July 25 2013 07:20 RoyGBiv_13 wrote:
Show nested quote +
On July 25 2013 06:16 darkness wrote:
I've got a question from a relative today what a programmer is supposed to do when it comes to "domain requirements", e.g. it's required from you to create software that will be used in (say) architecture development or any other non-computer field really. The problem is you're a software engineer not an architect, physician or whatever.

What I answered was that the contractor of the project (or the manager) should be responsible to teach/give enough material to programmers to fullfill application requirements. However, is this what's done in practice? Am I close to truth?

Edit: The purpose of the question was that he thinks everyone should understand everything even if it's just a little bit.


Probably not a bad idea to understand the industry in which your code will be running. In particular, there are script compliance rules for certain industries which require obnoxious certifications in order to have use your code.
Check out MISRA for automotive, for example.
http://en.wikipedia.org/wiki/MISRA_C
In this sense, an 'industry panel of experts' has strict rules regarding what features of the language you can use, and how you should use them. It even has rules about benign features, like whitespace. Some certifications require some really strange stuff, like a clean desk, and showing up on time to work as part of the software requirements. I guess it makes sense that if you control the programmer's level of reliability, then his code ought to be more reliable as well. I figure that in pratice, there have been very few software bugs in certified environments, like automotive, space, trains, medical, architecture, etc...

+ Show Spoiler +
Probably worth noting that code that is to specifications is usually 10x harder to debug than hacked together garbage from a jr. dev .


That MISRA stuff is interesting. Especially this:

Avoiding using functions and constructs that are prone to failure, for example, malloc may fail.


What do they use instead of malloc? Is there even an alternative to it for dynamic memory assuming they need one?

Plus, this seems like underestimating malloc imho. You can always:


if (variable != NULL) {
...
}
else {
printf("Screw you\n");
}
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2013-07-24 23:24:33
July 24 2013 23:14 GMT
#6569
double post
There is no one like you in the universe.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2013-07-24 23:32:01
July 24 2013 23:24 GMT
#6570
On July 25 2013 05:12 czaku wrote:
Show nested quote +
On July 25 2013 05:00 fdsdfg wrote:
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?


Just write a 1-line batch file that calls format and throws the output away. You're reinventing the wheel if you try to write a new format utility for no reason.



The problem is it has to be in C/C++ and i prefer C at the moment.



You can run command line inside C++ using system() I think.



On July 25 2013 08:05 darkness wrote:
That MISRA stuff is interesting. Especially this:

Show nested quote +
Avoiding using functions and constructs that are prone to failure, for example, malloc may fail.


What do they use instead of malloc? Is there even an alternative to it for dynamic memory assuming they need one?

Plus, this seems like underestimating malloc imho. You can always:


Maybe they prefer if you used realloc and calloc? No clue :d


On July 25 2013 02:11 tec27 wrote:
Show nested quote +
On July 24 2013 18:33 WolfintheSheep wrote:
On July 24 2013 17:52 tec27 wrote:
On July 24 2013 17:29 Blisse wrote:
Programmers aren't Product Managers. Product Managers talk with higher-ups and Architects who may or may not communicate with Senior Developers before reaching decisions in what designs/implementation details are used in the product - way before you actually have a project to work on. Assuming you're not in very new start-ups, because for most programmers you'll be joining several years in and hopping right into their chosen language. Programmers rarely make real important implementation decisions unless there's a huge issue and/or oversight found.

Whatever company you work at sounds incredibly dysfunctional and you should seek new employment ASAPly

It sounds to me like you don't have much working experience in the field.

Most companies anywhere work like this. Architecture and frameworks are chosen by cost evaluation, programming languages are chosen based on software compatibility or legacy code, and projects are always set before programmers and low-level designers have heard anything except rumours.

And believe me, if you think that's dysfunctional, a company where programmers use whatever they want is several magnitudes worse.

So you think a company where PM's are deciding what technology you'll use and "Solution Architects" (who are clearly, in his example, *not* anyone actually touching the code) are making decisions from on high which you have no actual say in makes for a good place to work? I'm not trying to insult the company, I'm just trying to give advice. If you work at a place that does that, they're treating you like shit and you can do better. If you want to be treated like shit, then have at it


Well, Solution Architects need to touch the code in order to know what it can and cannot do. Not sure where you got the idea that they knew nothing about coding, most of them were previous programmers and moved up? You have a say in what you do. It's just your say is not relevant unless the architect completely missed something in the design requirements.


On July 25 2013 02:55 tec27 wrote:
Decent programmers are not going to say "I like python" and think that's a good reason for choosing it for a project. If your company doesn't trust you to be able to pick the right tool for the job, they think you're a moron and unless you actually believe you are a moron, you should find a new job. Its really not that difficult.

There are plenty of companies that will treat you like shit, I'm not arguing that they don't exist. I'm just saying that if you have any self-respect and desire to actually work effectively, you shouldn't work for them.


Do your companies actually allow you to pick your tools for the job? I'm not sure what kid of jobs we're describing here because I really don't think it's the same set. I'm not aware of jobs where you're given "arbitrary project" as a programmer and then management is like, "do it", and then you do it in whatever way you want. For the most part I would've thought sometime somewhere in management they've received design requirements from the customer and then they consulted with a consultant/architect on what can and cannot be done (who may consult with you if he/she requires), then they delegate the task to you and your programming team. Not sure what hierarchical system you're describing though.


Anyways, the way you describe this is like you're looking down on code monkeys, and while they're pretty bad, that's a huge reality of the profession and you shouldn't be an asshole about people who have to program in those environments and have yet to figure out they don't belong.
There is no one like you in the universe.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
July 24 2013 23:42 GMT
#6571
On July 25 2013 07:08 fdsdfg wrote:
Show nested quote +
On July 25 2013 05:55 nunez wrote:
On July 25 2013 05:28 fdsdfg wrote:
On July 25 2013 05:12 czaku wrote:
On July 25 2013 04:54 tofucake wrote:
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?

Why?


It's a project to pass the next semester from programming and she is not interested in learning it. So she asked for my help. Basically you show the teacher code, explain how it works and you passed.


On July 25 2013 05:00 fdsdfg wrote:
On July 25 2013 04:32 czaku wrote:
Hi guys, i'd need some help from you, a couple of questions to be answered.
A friend of mine has a project to do during holidays. She needs to low level format whole HDD (this means filling each byte with 0x0). And now it begins. It cannot show any dialog, so calling system("format c:/") is not an option.
I've seen some codes in C++ but i'd prefer it to be C as i have it in school (basically whole theory covered so i only need experience and research) so i can understand your tips better. Is it even possible in C? In C++ i can try using CreateFile() and then ReadFile(), WriteFile() with HDD. But then i thought of bad sectors and it snared me.
Any tips where i can start?


Just write a 1-line batch file that calls format and throws the output away. You're reinventing the wheel if you try to write a new format utility for no reason.



The problem is it has to be in C/C++ and i prefer C at the moment.


You're asking for help on writing your friend's school project for her? She should fail if she can't learn the stuff. Programmers work on teams, and I wouldn't wish a useless teammate on any fellow programmer, which is what you're trying to inflict.


i too enjoy moralizing instead of shutting up when i am unable to answer.


If he asked for $20 and you didn't send him $20, would it be right to assume that you don't have $20 to your name?

depends on context.
conspired against by a confederacy of dunces.
DeltaX
Profile Joined August 2011
United States287 Posts
July 25 2013 00:00 GMT
#6572
On July 25 2013 08:24 Blisse wrote:

Do your companies actually allow you to pick your tools for the job? I'm not sure what kid of jobs we're describing here because I really don't think it's the same set. I'm not aware of jobs where you're given "arbitrary project" as a programmer and then management is like, "do it", and then you do it in whatever way you want. For the most part I would've thought sometime somewhere in management they've received design requirements from the customer and then they consulted with a consultant/architect on what can and cannot be done (who may consult with you if he/she requires), then they delegate the task to you and your programming team. Not sure what hierarchical system you're describing though.


Anyways, the way you describe this is like you're looking down on code monkeys, and while they're pretty bad, that's a huge reality of the profession and you shouldn't be an asshole about people who have to program in those environments and have yet to figure out they don't belong.


I think it depends on various factors including:

1. Size of team
2. Who came up with the project
3. Culture of organization (related to first 2)

If the team is going to be large and a "higher up" came up with the project, it is unlikely you will have much choice on something as core as the programming language or major tools that affect others. If on the other hand it is a smaller project, or you/your manager came up with the project idea yourselves and got it approved, then you could make almost any decision and as long as you can justify it, then go for it.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
July 25 2013 00:09 GMT
#6573
On July 25 2013 06:22 1handsomE wrote:
Hi. I am a relatively junior level programmer (2 years professional experience) who just got an actual programming job (UI Programmer) in the game industry. I was wondering if there was anyone else on the forums who works in the industry?

Edit: DM me, let's be friends!


oh damn nice job. I want to get into UI programming maybe UX design, though design doesn't really fit into programming. congrats.
There is no one like you in the universe.
ThatGuy
Profile Blog Joined April 2008
Canada695 Posts
July 25 2013 01:11 GMT
#6574
On July 25 2013 06:22 1handsomE wrote:
Hi. I am a relatively junior level programmer (2 years professional experience) who just got an actual programming job (UI Programmer) in the game industry. I was wondering if there was anyone else on the forums who works in the industry?

Edit: DM me, let's be friends!


Hia, yeah, I also do UI programming for Ubisoft . Good luck in the field!
phar
Profile Joined August 2011
United States1080 Posts
July 25 2013 03:34 GMT
#6575
On July 25 2013 08:05 darkness wrote:
What do they use instead of malloc? Is there even an alternative to it for dynamic memory assuming they need one?

Read up on the code they use on Mars. You don't use dynamic memory.
Who after all is today speaking about the destruction of the Armenians?
Fawkes
Profile Blog Joined May 2010
Canada1935 Posts
Last Edited: 2013-07-25 03:49:07
July 25 2013 03:44 GMT
#6576
A php related question.

I'm working on some old code written by someone who I can't really get a hold of anymore. Is there a reason why these two blocks of code work differently in php? I just started dabbling with php within the last month.


$sql = "select achievement from achievement_list";
$sql = $sql." where achievement_id = ";
echo "$sql<br>";

This echos
"select achievement from achievement_list where achievement_id = "


$sql = "select achievement from achievement_list where achievement_id = ";
echo "$sql<br>";

This echos nothing.

Another possibly somewhat related thing was trying this (this code is the same block as the first, except there's a value 1 at the end)

$sql = "select achievement from achievement_list";
$sql = $sql." where achievement_id = 1";
echo "$sql<br>";

This echos
"select achievement from achievement_list where achievement_id = " missing the 1.

I realize the first two queries don't actually do anything. With a quick glance from anyone experienced with php, is this something obvious I am missing or there may be more than meets the eye and I would need to investigate deeper?

My actual end goal was to end up doing something like

$sql = "select achievement from achievement_list";
$sql = $sql." where achievement_id = $achievementsel";
echo "$sql<br>";

which I was trying to pass it some selection menu's value when the form was submitted. But it wasn't working, so I simplified the query and then ended up with the weird situations above.
Taeyeon ~ Jennie ~ Seulgi ~ Irene @Fawkes711
tofucake
Profile Blog Joined October 2009
Hyrule19202 Posts
Last Edited: 2013-07-25 03:52:52
July 25 2013 03:50 GMT
#6577
They work as expected for me. There is likely something else you've left out is futzing with $sql
https://tofucake.net/fawkes.php
https://tofucake.net/fawkes.phps
Liquipediaasante sana squash banana
Fawkes
Profile Blog Joined May 2010
Canada1935 Posts
July 25 2013 03:54 GMT
#6578
Alright thanks. At least I know it is supposed to work.
Taeyeon ~ Jennie ~ Seulgi ~ Irene @Fawkes711
Fawkes
Profile Blog Joined May 2010
Canada1935 Posts
Last Edited: 2013-07-25 06:03:57
July 25 2013 04:45 GMT
#6579
Let me rewrite this to the simplest way possible.


$sql = "select achievement from achievement_list";

$sql = $sql." where achievement_id = 1";

//$sql = $sql." where achievement_id = ".$achievementsel;


$sql = "select achievement from achievement_list";

//$sql = $sql." where achievement_id = ".$achievementsel;

$sql = $sql." where achievement_id = 1";


These two chunks of code, are not doing the same thing for me and I have no idea why.

+ Show Spoiler [frustration x1000000000000] +


//$sql = "select achievement from achievement_list";

//$sql = $sql." where achievement_id = ".$achievementsel;

//$sql = $sql." where achievement_id = 1";

$sql = "select achievement from achievement_list where achievement_id = 1";
echo "$sql<br>";



$sql = "select achievement from achievement_list where achievement_id = 1";

//$sql = "select achievement from achievement_list";

//$sql = $sql." where achievement_id = ".$achievementsel;

//$sql = $sql." where achievement_id = 1";

echo "$sql<br>";


The first chunk of code prints "select achievement from achievement_list where achievement_id = 1". Second does nothing.
For the record, the code after these lines just perform the query using $sql.


Wow this is so inconsistent, I don't even know what is going on anymore.
Taeyeon ~ Jennie ~ Seulgi ~ Irene @Fawkes711
HardlyNever
Profile Blog Joined July 2011
United States1258 Posts
July 25 2013 05:08 GMT
#6580
The comments and line breaks shouldn't affect anything. It looks like it is supposed to pull "achievementse1" from some form or something where the user inputs that value. I can't really tell what else is supposed to be going on with what you have shown.
Out there, the Kid learned to fend for himself. Learned to build. Learned to break.
Prev 1 327 328 329 330 331 1032 Next
Please log in or register to reply.
Live Events Refresh
Wardi Open
11:00
#82
WardiTV679
OGKoka 365
Rex107
Liquipedia
Afreeca Starleague
10:00
Ro16 Group A
Soma vs YSC
Sharp vs sSak
Afreeca ASL 12767
StarCastTV_EN344
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
OGKoka 365
Lowko301
ProTech138
Rex 107
Codebar 20
StarCraft: Brood War
Sea 24274
Calm 15079
Bisu 7769
Jaedong 3062
Horang2 1897
BeSt 1044
EffOrt 848
Mini 650
Stork 559
firebathero 530
[ Show more ]
Light 438
Zeus 363
Pusan 358
actioN 339
ZerO 228
Soulkey 220
Hyun 164
Larva 148
Mind 88
Rush 72
Killer 70
Barracks 51
ToSsGirL 50
yabsab 36
zelot 25
Nal_rA 19
soO 18
Terrorterran 18
Movie 17
Hm[arnc] 16
Shinee 16
[sc1f]eonzerg 15
GoRush 14
Bale 12
Sacsri 12
Noble 12
IntoTheRainbow 12
scan(afreeca) 11
SilentControl 9
Icarus 8
Dota 2
qojqva1064
syndereN42
febbydoto11
Counter-Strike
olofmeister3194
fl0m2176
x6flipin414
byalli385
markeloff86
Other Games
singsing1733
B2W.Neo1047
hiko676
crisheroes298
Pyrionflax151
Liquid`LucifroN98
Liquid`VortiX88
QueenE78
Mew2King49
KnowMe47
RotterdaM29
Organizations
Other Games
BasetradeTV778
Counter-Strike
PGL302
StarCraft: Brood War
UltimateBattle 302
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 14 non-featured ]
StarCraft 2
• StrangeGG 56
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis2899
• TFBlade1533
• Stunt580
Upcoming Events
Monday Night Weeklies
2h 33m
OSC
10h 33m
Afreeca Starleague
20h 33m
Snow vs PianO
hero vs Rain
WardiTV Map Contest Tou…
20h 33m
GSL
22h 33m
PiGosaur Cup
1d 10h
CranKy Ducklings
1d 19h
Kung Fu Cup
1d 22h
Replay Cast
2 days
The PondCast
2 days
[ Show More ]
WardiTV Map Contest Tou…
2 days
Replay Cast
3 days
Escore
3 days
WardiTV Map Contest Tou…
3 days
Korean StarCraft League
4 days
CranKy Ducklings
4 days
WardiTV Map Contest Tou…
4 days
IPSL
5 days
WolFix vs nOmaD
dxtr13 vs Razz
BSL
5 days
Sparkling Tuna Cup
5 days
WardiTV Map Contest Tou…
5 days
Ladder Legends
6 days
BSL
6 days
IPSL
6 days
JDConan vs TBD
Aegong vs rasowy
Replay Cast
6 days
Replay Cast
6 days
Wardi Open
6 days
Afreeca Starleague
6 days
Bisu vs Ample
Jaedong vs Flash
Liquipedia Results

Completed

Escore Tournament S2: W2
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
StarCraft2 Community Team League 2026 Spring
Nations Cup 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W3
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
RSL Revival: Season 5
WardiTV TLMC #16
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.