Jump to content

KevinM1

Moderators
  • Posts

    5,222
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by KevinM1

  1. It looks like you may be dealing with another stack handle thingie. Are you trying to convert from string to int, or string^ to int?
  2. Still a good thing to think about, IMO. A lot of times people think they're writing OOP code when in actuality they're either putting a wrapper around an existing class, without doing so to extend or otherwise merge that class into the greater system, or they're writing a basic function library with object/class syntax. Learning and playing with the syntax is only part of the battle. I'm not saying that you won't, or don't have the desire, to learn the theory. I'm just saying that as you get comfortable with the nuts and bolts of writing syntactically correct code, you should be asking questions like "Does this class attempt to do too much? Is it too narrowly defined? What do I gain by doing things this particular way? Is it sufficiently encapsulated? Or will I have problems trying to add it to another system?" It'll save you headaches down the road, believe me.
  3. Show us your current code.
  4. A couple of issues regarding theory: 1. Your class is unnecessary because MySQLi is already a class. You're merely adding a wrapper to it. 2. That wrapper is defined too narrowly to be universally useful. You're assuming that the only data you'll ever need to obtain are from columns named 'title' and 'content.' What if the database doesn't have such columns? You shouldn't need to change the internals of a class to make it useful.
  5. To be honest, I'm not sure. My C++ is very rusty. Are you certain you've included the header file?
  6. With more digging, I believe I've found the solution: Button^ ctrl = safe_cast<Button^>(sender);
  7. Hey, I found this article which may help: http://msdn.microsoft.com/en-us/library/yk97tc08.aspx
  8. Also I have always used "element.property", now I'm having to use "element->property". Do you know the difference? Well, for the first problem, I'd try keeping the method signature the same as what it was, but cast the sender as a Button^ (whatever that's supposed to mean). The worst that can happen is another compiler error. For the second, the -> operator is used to dereference a pointer. The element variable is a pointer of some type, and you're dereferencing it to get a hold of its property. I wonder if the '^' is a Microsoft/.NET/Visual Studio thing to represent a pointer. Usually it's denoted by a '*', like say int* num, but the other operator looks to be used in a similar fashion here.
  9. Hmm...what does the '^' denote? I'm not familiar with that marker/operator.
  10. Also, you should double-check the position of your brackets. Brackets denote the beginning and end of a block structure. These structures include function definitions, loops, and conditional statements. Writing something like: { if(/* some conditional statement */) /* action */ else /* another action */ } Is wrong. Instead, it's: if(/* some conditional statement */) { /* action */ } else { /* another action */ } The same thing goes for loops and function definitions: while(/* some condition is true */) { /* stuff to do */ } function myFunction($arg) { /* do something with $arg */ }
  11. When you write: $taken = $row['the_url']; You're not adding that value to the array. Instead, you're overwriting the entire thing. The simplest way to add a value to an array is to simply put brackets at the end of the array variable's name: $taken[] = $row['the_url']; You can also explicitly push the value onto the array: array_push($taken, $row['the_url']);
  12. Have you tried casting it as a button? Like: Button ctrl = (Button)sender; I do that in C#, and it works fine.
  13. KevinM1

    I hate ASPX

    I agree that doing something in a language you're familiar with is much faster. But this was just ridiculous. And when I say everything was trapped in a DLL... well... there weren't ANY SQL queries in any of the pages I viewed and I couldn't find any classes that did the updates, so they must have compiled all DB updates/interaction into DLLs. I'm not talking about picking apart functions, I'm talking about normal interactions. No offense to people from India on these boards, but a group from India wrote the application and it sucks total balls. Holy...yeah, that's just ridiculous.
  14. KevinM1

    I hate ASPX

    Remember: C# is strongly typed. Using reader.GetFloat() when the data is stored in the db as a double (even though the column datatype is specified as a float) causes a lot of compiler errors. It doesn't want to do the implicit conversion from double to float because of the potential loss of data.
  15. KevinM1

    I hate ASPX

    Ah, I see. Yeah, the ASP.NET page lifecycle is a bitch. I'm experiencing issues with it myself. DB stuff with it is weird. From what I've seen, the connection info is stored in the web.config file, but using that with SQL queries is still done within the code itself. Like: string query = "Select level, name, tpCost, dmgModifier, hitPenalty from DBHackerAttacks"; using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["GitSConnectionString1"].ConnectionString)) { SqlCommand cmd; SqlDataReader reader; cmd = new SqlCommand(query, conn); conn.Open(); reader = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (reader.Read()) { HackerAttack hackerAttack = new HackerAttack(reader.GetInt32(0), reader.GetString(1), reader.GetInt32(2), reader.GetDouble(3), reader.GetDouble(4)); this.attacks.Add(hackerAttack.Level, hackerAttack); } } I'm not a big fan of its helper objects, like SqlReader. They're just awkward to use. Also, with SQLExpress, floats are actually stored as doubles within the db. That caused me a day or two worth of headaches.
  16. KevinM1

    I hate ASPX

    Was this .NET, classic ASP, or something else altogether different?
  17. Yes, you want to use mysql_real_escape_string(). The difference between that and addslashes() is that addslashes() doesn't add slashes (say that three times fast!) to everything that could compromise your db down the line. It's just a matter of using the right tool for the job. Since there are db-specific functions in the language itself, that should be taken as a hint that you should use those rather than creating a custom solution. After all, they're in the language for a reason.
  18. Yup. Flash. I believe there are free editors around, but I'm not too knowledgeable in that area. And, given their free, not-from-Adobe nature, their quality may be suspect as well. How would any of us know? What you're asking depends on your abilities, commitment, and interest. Your best bet is to go to the local bookstore and peruse a book on the subject. That way you can get a decent idea of the cost of learning it (both time AND money), as well as whether or not Flash is for you, before jumping in.
  19. Also: 1. Put your form inputs' names within quotes in the HTML (i.e.: <input name="Name"> ). 2. Don't put a space between an array name and the key you're trying to access. In other words, do this: $name = $_REQUEST["Name:"]; 3. Use the right superglobal array instead of $_REQUEST. Since you're passing the data in via POST, use $_POST. 4. Are you certain that you can mail things out successfully? Have you tried writing a small test script to see if the mail() function is working at all?
  20. 1. Are you sure you want to create a new table in this code? Is this page going to be viewed more than once by the same user(s)? If so, you should create the table manually, through whatever database management system you have access to (phpMyAdmin?), and only let the PHP script insert/update data. 2. Where do $websites and $destination come from?
  21. Well, first, to get a technicality (and pet peeve of mine) out of the way, $_GET is not a function. It's a superglobal array filled with values passed into a script via query string. Big difference. Anyhoo, to get to your problem, you should know what incoming $_GET values are legit. In other words, you should know that, like you say, news only has 13 items. Knowing that, you simply need to test if the incoming value is good (in this case, less than or equal to 13). If so, they proceed normally. If not, write the error message and/or redirect back to the homepage. In pseudo-code, something like: if($_GET['news'] <= 13) { /* proceed to the news item */ } else { /* echo error, and give link to redirect back to home */ echo "The page you're looking for doesn't exist. Please go back to <a href=\"index.php\">home</a> and try again. If the problem persists, contact our webmaster."; }
  22. Something like the following should work: $count = 0; $table = "<table><tr>"; while($row = mysqli_fetch_assoc($result)) { if(($count % 4) == 0) { $table .= "</tr><tr>"; } if($row['image'] == 'blank') { $row['image'] = "image/achievement_locked.png"; } $table .= "<td><img src=\"{$row['image']}\" alt=\"{$row['alt_text']}\" /></td>"; ++$count; } $table .= "</tr></table>"; echo $table;
  23. It's a syntax issue. Since the inputs use array notation, you can't reference them quite the way you're attempting to. Instead, try: document.forms['form'].elements['data[name]'].value; See also: http://www.javascripttoolbox.com/bestpractices/#squarebracket
  24. Most likely the gothapotamus scared it out of him.
  25. I saw a gothapotamus once, last year, in Yellowstone National Park of all places. It was pretty much like "oh, there's an elk...there's a geyser...WHAT THE HELL IS THAT THING??"
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.