KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
how can I apply more than one function to a variable?
KevinM1 replied to co.ador's topic in PHP Coding Help
To be honest, I'm not quite sure what you're asking. Mind giving an example of what you want to do? -
how can I apply more than one function to a variable?
KevinM1 replied to co.ador's topic in PHP Coding Help
Chain them together, like you would do in any other scenario: $validatedData = lastValFunction(middleValFunction(firstValFunction($_POST['fieldname']))); So long as your functions return a value, you'll be all set. -
What I find interesting about these kinds of books is the psychology behind them. They're aimed at people who want results while doing as little work as possible ("Only 3 days? Score!") to achieve those results. It seems similar to the various "you can lose weight by eating fast food" ads that are plastered on TV. Yeah, eating a Subway sandwich or, laughably, something from Taco Bell's so-called "Drivethru Diet Menu," may be healthy eating, but none of it matters without the other component: exercise. It indirectly describes the work ethic of our culture, IMO. Someone won't be able to become a professional programmer by merely reading these books in the same way they won't get healthy by merely changing their diet. Hard work is required.
-
What about Terminator? Terminator 1 and 2 came out years before Titanic. He didn't really have anything to do with the last two Terminator movies.
-
Don't use JavaScript for link rollovers. Use CSS instead.
-
header("Location: booknow.php? error=$error"); what????
KevinM1 replied to deansaddigh's topic in PHP Coding Help
For clarity's sake, the portion of the URL that begins with a '?' is called a query string. The information in the string is sent to a server side script for processing. This information is grouped as name-value pairs. The first bit is the name of the parameter being sent to the script, while the part after the '=' is the value of that parameter. You can send multiple name-value pairs by separating them with the '&' symbol, like so: http://www.example.com/formprocessor.php?name=Bubba&age=44 -
Using an html element id in a javascript function call
KevinM1 replied to aeroswat's topic in Javascript Help
I'm not sure if I'm understanding what you want to do - are you trying to have the click event of one form element affect the behavior/look/value/whatever of another element? If so, it's not difficult. There are two ways to go about it: Inline: <form ... > <input onclick="functionToRun('otherElementId');" ... /> <input id="otherElementId" ... /> </form> <!-- JavaScript snippet below should be where ever you put the rest of your script's code --> function functionToRun(id) { var elementToModify = document.getElementById(id); // do things to elementToModify } Unobtrusive (my preference): <!DOCTYPE html> <html> <head></head> <body> <form ... > <input id="elementWithClick" ... /> <input id="otherElementId" ... /> </form> </body> <script type="text/javascript"> var toggle = document.getElementById("elementWithClick"); var target = document.getElementById("otherElementId"); toggle.onclick = function() { // do things to the target element } </script> </html> Note that '...' denotes attributes and other things not important to the basic structure of the solution, but should still be present when you do it for real. Also, since you weren't very specific in describing what you hope to do, this was a shot in the dark. It may not be relevant to your actual problem. -
Header function is not working in the host server
KevinM1 replied to co.ador's topic in PHP Coding Help
We have a stickied thread in this section describing fixes to common "headers already sent" errors: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html -
So, you're trying to pass $myusername to this page via the session? For that to work, you need to assign the value to a session variable in your login page, like so: session_start(); // ALWAYS need session_start on the pages you try to use sessions on /* login code */ $_SESSION['username'] = $whateverVariableContainsTheUsername; Then, in this page, to retrieve the value, you need: session_start(); $myusername = $_SESSION['username']; For the rest, like I said before, it's a matter of timing - you're currently fighting against how the HTTP request cycle actually works. In order for your submit() function to work, your arrays need to persist between page refreshes. I think a sensible solution would be to store them in session variables as well, then check for their existence on page reload. If they exist, invoke submit(). Also, something else I noticed - submit() doesn't actually execute any queries. Remember: all MySQL queries need to be passed into mysql_query() to actually be run. Right now, you're merely creating queries in your loop, then overwriting them. EDIT: So, yes, what you want to do can be done. It's just a matter of designing it properly.
-
I'm surprised I even got one reply, so thanks everyone. I'll need to talk with my electrician friend who'll be helping with the actual electrical engineering portion of this. I have no real skill or talent in that area, so I'll run these suggestions by him. EDIT: given his profession, he can probably get me the parts at cost, which is an added benefit. EDIT 2: any controllers with USB connections?
-
Or, you could simply remove the offending ';'....
-
First, you really shouldn't display your database password here. Making it visible on a public forum is a very large security risk for your system. And, second, you should place all code within BBCode code tags. Anyhoo, there's a lot going on here that's messed up. I have the feeling that you're not 100% sure about how the postback cycle should work, so here's a crash course. Right now, you have several magic variables floating around. What is $myusername, and where does it come from? Have the arrays come from some other script, or are you initializing and building them here? Regardless, a typical postback script looks like: <?php if (isset($_POST['submit')) // if the form has been submitted, process it { // form processing code goes here } ?> <!-- regardless, show the form --> <html> . . . <form ... > . . . </form> . . . </html> All form processing needs to happen first. Right now, you're trying to deal with your arrays in the submit() function, but they haven't been created yet, as you don't handle them until you decide to display your form. Just because you put the function definition after the form code doesn't mean that the function is actually invoked there. Finally, don't use global to pass in values to a function. It's very bad practice, can lead to a host of errors and debugging issues, and isn't necessary as functions have an argument list for a reason. Hope this nudges you in the right direction.
-
Incorporating small Javascript function into my PHP shopping cart
KevinM1 replied to slaterino's topic in PHP Coding Help
Short answer: Use AJAX. Long answer: Use AJAX, and here's why: JavaScript executes after PHP has run on the server. It also executes within the browser itself. Both of these attributes mean that JavaScript cannot interact with your server side script (including whatever objects you're using) unless you use AJAX techniques. -
My request requires a bit of explanation, so bear with me: My brothers and I put on a rather elaborate and expensive fireworks show every July 4th. It's a recent tradition, but one that sees us trying to outdo the previous year's show as we progress. Being the computer nerd in the family with a new laptop, I want to take it up a notch (or eleven). I'd like to use my laptop to automate the firework ignition process, as well as sync the launches to music. I'm just unsure where to start. My google-fu has failed me as my searches give me a gazillion Adobe Fireworks links, but nothing regarding actual exploding fireworks launching programs. The basic idea is for me to connect something to my laptop which will ignite the fireworks themselves. My electrician friend mentioned something about programmable logic controllers, but I'm unsure how they would bridge the gap between my computer and the fireworks themselves. I'm also unsure if I could have ladder logic to execute various 'launch/ignite' commands at the appropriate times in the music. So a nudge in the right direction would be a big help. Thanks.
-
1 - b 2 - neither. Public entities begin with a capital letter. The others start lower case. 3 - a 4 - a Some people hate camel case. Those people are insane. I find it much less annoying than using underscores in variable and method names. It also looks more professional to me.
-
This is why I'm not even seriously considering freelancing, I've seen what people are offering are places like Scriptlance, That kind of pay doesn't compensate anything for the other hidden costs of being a good programmer, like your social life and your health. I get people contact me on webmaster forums wanting to do something I know will take maby 8 hours and pay me $5. $0.60 an hour anybody, no? I didn't think so. Even if you get one thats maby $500 for a 7 day job , and you spend 8 hours a day, that still only $8.92/hour. You may aswell get a job in mcdonalds. lmao There are three problems with clients, from this freelancer's POV: 1. Clients are ignorant. A lot of clients are either clueless about what it takes to create a website, or think it's still 1999 and think that the majority of the work is in designing and constructing the UI. Since that's the only part they can understand, as they can see and interact with it on the screen, they don't think that it's much more than making graphics in Photoshop and putting them into HTML. 2. Clients are cheap. Their ignorance detailed in point 1 influences how much they're willing to pay. It goes beyond getting the most bang for their buck - a lot of them literally want something for nothing because they don't understand the amount of work involved in creating a well designed, secure site. They just don't get that $10 an hour is laughable. 3. Clients are indecisive. This runs parallel with point 1. A lot of clients don't really want a website. They like the idea of having one, but aren't willing to do work on their end to get it done. Someone, somewhere, told them that a website would increase their revenue, so they search for a developer. Once they find one, they believe it's up to the developer to come up with everything on their own. They don't understand that it's a collaborative process, so they don't invest any attention to building their site. They get frustrated when they learn they're actually going to have to make decisions on what their site should be. I can't tell you how many times questions like "Are their any sites you like? Any particular things on those sites you would want? Anything you want to stay away from? What about your color preferences?" have been met with increasingly exasperated "I don't know"'s. I've had a couple of clients who were awesome. Most suck.
-
Well, you're not actually passing around objects. Rather, you're passing around strings. selectitem() is given an id of a HTML element, which is stored in an array (for reasons unknown, as you don't actually use the array for array-like purposes.). You don't actually obtain the object by the id. You merely pull the id from the array and attempt to treat it like an HTML element. In moveup(), you need something like: var realObj = document.getElementById(obj); var xypos = findPos(realObj); What you have there now only passes the id to that function. A better variable naming scheme would help eliminate the confusion.
-
I started 'programming' when I was a young kid in the early 80's by copying BASIC code I had in a few books and pasting it into my Commodore VIC-20. I didn't start programming for real until I went to college in the late 90's/early 2000's. It was primarily in C and C++. Unfortunately, I failed out of the CS program, and graduated with an essentially worthless degree in communication (would you like fries with that?). I just couldn't wrap my head around the low level binary and assembly stuff. I started learning PHP sometime around 2005 or so. In the last couple of years I've been teaching myself ASP.NET and C#. Most of my work experience comes from freelancing. Unfortunately, I hate freelancing. I have very little patience to deal with clients in a one-on-one setting, as most clients are idiots. Ideally, I'd get an office job where my interaction with clients would be minimal. I'm learning the Microsoft technologies for that reason, as most professional dev offices in my area are biased towards .NET, with maybe 35% leaning towards Java. Unfortunately, my progress has been delayed a bit in the last couple of years due to health problems and other distractions. I'm getting there, though.
-
apply javascript function to all objects of a certain type
KevinM1 replied to thewooleymammoth's topic in Javascript Help
To be honest, I'm not sure. How are you loading the images, exactly? -
apply javascript function to all objects of a certain type
KevinM1 replied to thewooleymammoth's topic in Javascript Help
Why not apply a CSS class to all the items you want to have a certain appearance? Regarding the inline JavaScript function call, you'll probably be better off using an unobtrusive coding method instead. Instead of putting the function in each img tag (which could be maddening in its tediousness), do something like: <!DOCTYPE html> <html> <head> <title>Blah</title> <style> img { display: none; } </style> </head> <body> <!-- all site code, except NO JavaScript in your tags --> </body> <script type="text/javascript"> var images = document.getElementsByTagName('img'); for(var i = 0; i < images.length; ++i) { images[i].onload = function)() { //function definition } } </script> </html> -
If I'm really stuck, that means I'm most likely frustrated as well. Taking a break with a nice, violent video game tends to help a lot in those situations. For inspiration, I like to read up on nerd stuff and dabble with different technologies. Visiting Life Hacker and Ars Technica, reading up and playing with ASP.NET's MVC framework, reading up on upcoming games and talking to my fellow geeks on Penny Arcade's forums.
-
Alcohol also helps. For me, it tends to go like this: Face Hygene - cannot be stressed enough. If a girl's teeth (having a full set is mandatory) look like they're covered in shag carpet... well, yeah, that's a deal breaker. Similarly, her breath and overall odor must, at the very least, be non-offensive. Clean nails, hair, etc. are also necessary. And don't forget the deodorant. You may think I'm joking, but I live in rural NH. A good portion of the women here are frightening. Overall shape. Not necessarily fitness - larger girls can be attractive. No, this is about proportion. Big butt and small chest doesn't work for me. Neither does the reverse. There has to be something of a figure present. Individual parts - chest and butt. If a figure is present, then its time to focus on the separate components. I tend to be biased more to the chest, but it's not all I look for. Of course this is all just the physical attraction stuff. Personality and intelligence are large factors as well.
-
The array you're looking to use is $_POST.
-
You shouldn't have two functions here. Just tie your div display function to your validate function: function validate(form) { // all your previous validation code if (!valid) { var messID = document.getElementById("message_box"); messID.style.display = "block"; } return valid } You don't need an else-clause there as you should make the div have a display set to "none" by default in the CSS, and if the form is valid, the user will be sent to where ever the form's action takes them.