KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
Yeah, you have your assignment statements backwards. Remember: you're putting the value of the right operand in the left operand. Also, using the '@' symbol with $_GET to squelch errors only to use it in a conditional to catch an error is ass backwards logic. Simply use isset.
-
How can I use this menu function to link to external URL's?
KevinM1 replied to healthbasics's topic in PHP Coding Help
Making this suggested change breaks it. The whole link menu just disappears. Any ideas on fixing my 404? When you invoke your menu function, you still need to pass in the argument. E.g.: menu($_menu); -
How can I use this menu function to link to external URL's?
KevinM1 replied to healthbasics's topic in PHP Coding Help
Also, never, ever, ever use the 'global' keyword. It's a lazy way to code, which often leads to nasty, unexpected surprises down the road. Do it right and pass $_menu in through your function's argument list. In other words, instead of: function menu() { global $_menu; // ... } Do: function menu($_menu) { // ... } It doesn't seem like much, but trust me, it matters in the long run. -
No, they're not the same. You can use objects to mimic a database's structure and behavior. But there's far more they can do than just that. Read up on composition, inheritance, and polymorphism.
-
Wow, that was horrid.
-
Nope, still wrong. Try: class Base { protected $baseVar = "Start"; public function show() { echo $this->baseVar; } } class Child extends Base { public function edit($value) { $this->baseVar = $value; // Child has access to Base::baseVar because it inherits from Base } } $test = new Child(); $test->show(); // should display 'Start' $test->edit("I'm changing my innards! WEEEEE!"); $test->show();
-
There's no way around it - you need to have your function definitions in the same file as the code that's trying to invoke your user-defined functions. This can be done by include and/or require, or by explicitly writing the definitions in the file that will be invoking the functions itself. Most languages require one to manually import namespaces, or header files, or other similar library code.
-
@OP, you'd probably get more help at the ASP.NET forums. There's probably some other service provider you can use, or a way to directly connect to the DB, without having to introduce another language into the mix.
-
That quiz, like just about everything else on w3schools, is laughable. It's essentially trivia from the first chapter of a beginner's book. I agree with this, however. The only way you'll improve is by writing code. There's no way around it. Working on problems presented by others on this forum is a very good way to practice as you'll be solving common problems that virtually everyone starting out with PHP encounters. You may also find that asking questions in the 'Application Design' sub-forum we have to be a good way to wrap your head around some of the big picture hurdles you'll no doubt stumble on. I also highly stress getting a good introductory book. There are a ton of free tutorials out there, but I find the majority of them to be poor. They either rely on bad coding habits, or are written in a deprecated version of the language. You might as well get a good book if you're serious about it. PHP's own site is a good resource as well. I wouldn't use it as your #1 resource, but it's a good place to see how to use some modules you may not be familiar with (like mysqli), and its function reference is unbeatable.
-
The following will center a div horizontally, but not vertically. That's harder to do, because you need to calculate the height of the containing element. <!DOCUMENT html> <html lang="en"> <head> <title>Blah</title> </head> <body> </body> <script type="text/javascript"> var oDiv = document.createElement('div'); oDiv.style.margin = "auto"; oDiv.style.border = "1px solid black"; oDiv.style.width = "400px"; oDiv.innerHTML = "Hi"; var oBody = document.getElementsByTagName('body')[0]; oBody.appendChild(oDiv); </script> </html>
-
I don't understand? can you elaborate. Thanks. Say someone enters the value 'cat' into your input. How would you handle it?
-
Everything I've read has said the opposite.
-
You'd be better off with Microsoft Security Essentials, anyway.
-
Why does this code kill my "for" loop???
KevinM1 replied to ShootingBlanks's topic in Javascript Help
Looks like a scope issue. Can you alert i there, or somehow see whether or not it's being passed into the object there? -
Why does this code kill my "for" loop???
KevinM1 replied to ShootingBlanks's topic in Javascript Help
I actually do have firebug installed, but I never use it so I'm not really sure what I'd be looking for when I pull up the main panel (by clicking in the bottom-right of the browser window). I do notice one of those JS errors on the bottom-left of IE, and when I double-click to open it, it says: Line: 37 Char: 19 Error: Expected '}' Code: 0 URL: http://localhost/jQuery/configurator/configurator.php However, that confuses me more because line 37 of the PHP page is nothing more than "}". That's because IE's error console sucks, and never gives the correct error. That's why it's important to use Firebug as its error messages are much better. What do you get when you click on Firebug? If there's a JavaScript error, it should be there. EDIT: Also, can you show more code? I just want to see exactly where your JS is situated in relation to the rest. -
Why does this code kill my "for" loop???
KevinM1 replied to ShootingBlanks's topic in Javascript Help
Do you have firebug installed? If so, is it telling you anything? -
Why does this code kill my "for" loop???
KevinM1 replied to ShootingBlanks's topic in Javascript Help
Take your $(document).ready() out of your loop. The loop should be inside $(document).ready(), not the other way around. -
Kohana's own error reporting generates a runtime error screen with a stack trace upon application runtime error while in testing mode. However, when a caught error condition occurs, I also use a header redirect to my own, user friendly error screen, followed by an empty exit() statement. Since when I test the form with the same strings as SQL Inject Me uses I get my own error screen, I'm guessing it's my own exit() call that's doing it.
-
Hmm... I'm using the Kohana framework, so there could be a trigger_error call somewhere in the bowels of the system that's causing it. I looked over my code in the controller a few times, just to double-check what I've done. For this particular login form I - Only allow alphanumeric characters via RegEx Use Kohana's MySQLi driver, which automatically uses prepared statements I'm not sure what else I can/should do.
-
I tested the admin login form of a site I'm currently building with the SQLInjectMe extension for FireFox. It claims I have 51 failures, all of which are a 500 internal server error. Testing the form itself with some of the test strings it used fails to bring up the 500 error, and instead shows my error message, which is the behavior it should be exhibiting. Should I be concerned about these errors? I can't reproduce them myself through the form.
-
The error means what it states - you don't have a function named get_pages_for_subject() defined in a place where public_navigation() can 'see' it. This either means it exists somewhere, and needs to be included, or it doesn't exist, and it's up to you to create it.
-
Updating database row is updating the whole table
KevinM1 replied to Murciano's topic in PHP Coding Help
Syntax error. The following: WHERE $id='id' needs to be WHERE id='$id' -
Awesome. Thanks, guys.
-
I was wondering how I'd go about selecting and counting database entries based on how their titles are arranged alphabetically, and how to obtain the count for all the entries associated with a particular letter. The results I'm trying to get should look something like: A (15) B (2) C (9) etc. None of the built-in string functions jump out at me, at least not in a way that I could use them in a select query.
-
Wouldn't something like the following work: foreach($manf as $val) { echo $val->someColumnName; }