KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
You should make a new thread here: http://www.phpfreaks.com/forums/index.php/board,8.0.html (I'm not moving the entire thread as only the last post was truly freelance oriented)
-
Asking for homework to be completed is against the rules here (see rule 11 in the DO NOTs section: http://www.phpfreaks.com/page/rules-and-terms-of-service#toc_forum_do_nots). We're not going to just drop everything and provide the solution. The OP needs to to their own work. Some of us will guide and help them with questions regarding their work, but no one will do it for them wholesale. Also, in regards to premiso's reply, we are all volunteers here. We are under no obligation to help anyone. We do so because we enjoy working with PHP and being a part of the greater coding community. It is not our job to help you. We don't get paid for this. If the OP simply wants someone to spoon feed them code, we have a Freelance section available to them. I'm sure they can get a ready made solution for a reasonable price.
-
Hmm... Invoking it on the window.onload event shouldn't be causing any problems. Do you have any other JavaScript with the line 'document.preferences' explicitly written anywhere? I'm guessing that the line that's causing the thing to die is: var radiolength = document.forms[0].elements.length; But that shouldn't be causing a problem. Is there a link to the page you can send me?
-
Where/when is your JavaScript being written? 'Not defined' errors tend to be runtime problems, when the JavaScript is attempting to grab a reference of an element that hasn't been loaded into the browser yet. You need to ensure that your HTML is loaded before you attempt to do anything with your script.
-
Well, there are no doubt some OOP tutorials here at PHP Freaks you could look at. I also recommend the books PHP 5 Objects, Patterns, and Practice by Matt Zandstra and Design Patterns: Elements of Reusable Object Oriented Software by the Gang of Four.
-
IMO, it'd be dumb not to use OOP for this. Think about MMOs, and what can be mapped to objects with little work. Loot, equipment, characters, virtually everything related to combat (the attacks themselves, status effects, weapons, armor...), etc. You're going to be generating, using, and passing around this info on the fly. Moreover, various objects naturally contain other objects (characters have equipment, attacks and/or equipment can apply status effects on other characters, etc). Keeping things in this LEGO-esque building block fashion (which is essentially what OOP boils down to - the construction of parts that can be combined into larger things) is a good way to look at the design. For me, an MMO practically begs for OOP.
-
It works useing my cases like that and thanks for step 2 and how to I do the hidden value? Like: <input type="hidden" name="option" value="<?php echo $option ?>" /> right? Yes, but again, since you're generating the form via PHP, you don't need to use PHP tags there. In fact, it's a bad idea. Use simply: $message .= "<input type=\"hidden\" name=\"option\" value=\"$option\" />";
-
First, your switch statement is messed up. A semicolon is used to end a statement. You do not want to use that in your cases. So, instead of: case "2"; You need to use a colon case "2": Second, since you're using PHP to generate your output, you don't need to toss in the PHP tags in order to output the value of a variable. In fact, that can cause issues with PHP thinking you're actually ending the code block when you try closing that nested tag. You should simply have: $message = "You chose to donate <strong>$option</strong>..."; Third, for step three, you need to retain the value the user specified in step 1. PHP doesn't automatically remember form values. You have two options: 1. Store the value in a hidden field in the form you create in step 2. 2. Use sessions. Option 1 is the simplest.
-
That's what regular expressions are for. Test the input for whatever you're afraid of first with the proper expression. If the input contains a bad thing, deny/ban as necessary. Otherwise display it, being sure to pass the text through htmlentities just in case.
-
Problem with variable declaration in switch statement
KevinM1 replied to resident1155's topic in PHP Coding Help
Can you show more code? Is $error being declared somewhere else? How are you using $error once its been set? -
Best way to learn advanced Object Oriented PHP ?
KevinM1 replied to scanreg's topic in PHP Coding Help
Well, I suggest getting a good book or two. The PHP-specific OOP tome is PHP 5 Objects, Patterns, and Practice by Matt Zandstra (http://www.amazon.com/PHP-Objects-Patterns-Practice-Second/dp/1590599098/ref=sr_1_2?ie=UTF8&s=books&qid=1259430455&sr=1-2). You can't go wrong with the Gang of Four's groundbreaking book on the subject, either (in fact, Zandstra's book borrows heavily from this one - http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612/ref=sr_1_1?ie=UTF8&s=books&qid=1259430526&sr=1-1). Best used as a supplement to Zandstra's book once you get comfortable with the basics. Aside from that, practice is your best friend. Write code, lots of it. -
You don't define $myFile. EDIT: d'oh, didn't see the preg_match for $m
-
The key you use in $_GET needs to be the same as what you pass to the script via URL. In other words: in your URL, you have imgurl, but in your code, you're trying to obtain $_GET['img_url']. Note the difference.
-
?? The code you originally gave was: if(Get_QString('Post') == true) { GetGuide(); } You check $_GET within GetGuide(). Here's a suggestion: organize your code. Right now you're mixing function definitions with actual executing code, which makes it a mess to read, and is probably part of your problem. Also, again, you need to show what Get_QString() is, as it's not in either of the code blocks you've given. I'm getting the feeling that you're over-thinking your problem, and thus over-engineering your solution. Start with channel 1. Once that works, move on to getting channel 2 to work. Don't try for it all at once.
-
I'd say the first thing you got wrong was neglecting to specify what your problem is, and assuming we'd somehow know (via telepathy? ESP? tarot cards?) without any context. The second is not giving more code. What is Get_QString()? Where are you defining your $Table array? Again, context. What are you trying to do, and how is it not working? Be specific.
-
You have to select the db you want to use before accessing its tables. See: mysql_select_db
-
Hmm...could be, although one of your die() functions should've caught it if it couldn't connect.
-
You haven't given any of your columns a NOT NULL directive, or anything along those lines? You should try changing your table name, so it and the db name aren't the same. I'm not sure if that could be causing the problems, but it's a good idea just for maintenance's sake. Also, you need to check and filter the input coming into your script. Just because MySQL does some type conversion/supplies default values for the wrong kinds of data in certain instances doesn't mean that's the right thing to do. At the very best, it will create nonsense values (like setting the year to 0). And that's to say nothing of the security risks. Do me a favor, and try to run the following insert query: INSERT INTO publications (pub_id, Title, Author, Year, Journal, Pages) VALUES ('100', 'Test', 'Bubba Gump', '2009', 'Shrimping Made Easy', '658')
-
In order to save some frustration, can you show me your table's structure? That is, its column names and attributes. Also, can you tell me the values you're using in your script when you test this?
-
but it is still not correct. None of the values I submit on the form make their way to the database. Do you think it is a connection issue? That's not what I was suggesting. For your query, either write this: $query = "INSERT INTO publications (pub_id, Title, Author, Year, Journal, Pages)" . " VALUES ('$pub_id', '$title', '$author', '$year', '$journal', '$pages')"; Note the space before VALUES. The part within the quotes is what matters...that's what you're sending to the db. Or, you can have it all on one line: $query = "INSERT INTO publications (pub_id, Title, Author, Year, Journal, Pages) VALUES ('$pub_id', '$title', '$author', '$year', '$journal', '$pages')"; If that doesn't help matters stick the following lines at the top of your script (just after the <?php at the beginning) and try again: error_reporting(E_ALL); ini_set('display_errors', 1); This will force PHP to display all PHP-related errors and warnings, if there are any. Also, have you tried your insert query through php_myadmin? It may report an error through there.
-
I'm surprised your not getting an error on your query, as the way its written would actually come out as: INSERT INTO publications (pub_id, Title, Author, Year, Journal, Pages)VALUES('$pub_id', '$title', '$author', '$year', '$journal', '$pages') Note how 'VALUES' is smooshed between the parentheses. This stems from not putting a space at the beginning of the second line of your query. Be sure that your db columns' data types match the values you're trying to put in, and that the order is the same as how the db is structured. Other than that, nothing jumps out at me immediately. That said, two things: 1. You should never display your db password on a public forum. 2. The 'die()' function shouldn't be used in error handling, unless it's for debugging purposes only (more on this at: http://www.phpfreaks.com/blog/or-die-must-die).
-
An id is a unique value. So, give the other tables unique ids. A simple solution would be something like 'tbl1', 'tbl2', etc.
-
From what I can tell, Silverlight needs either Visual Studio, or Visual Web Developer 2008 Express.
-
Run the value through toFixed. I.e., var result = /*something */; alert(result.toFixed(2)); Just keep in mind that toFixed rounds up the decimal portion.
-
What's the context? Are you merely trying to echo that string, or are you trying to set the checked attribute of a checkbox or radio button?