KevinM1
Moderators-
Posts
5,222 -
Joined
-
Last visited
-
Days Won
26
Everything posted by KevinM1
-
Nope, that column is fine. One more thing: I'm trying to save myself a bit of work by using the mysqli extension (it literally stands for mysql improved), but I'm not sure if your hosting has it. So, write the following script: <?php php_info(); ?> Name that file info.php, then navigate to it. Once there let me know what version of PHP you're using and if you have the mysqli extension. DON'T post a screenshot, and erase that script when you're done. It'll expose some sensitive info that could potentionally be used against your server.
-
Hey, can you do me a favor? Can you change the datatype for the event_date column to be a varchar? It'll make it a lot easier on me to store it.
-
Now that it worked, you should erase the values from the database. You don't need test data floating around in there any more. I'm going to have to look at what you have for a form again, then write the rest of the script. I'm thinking of just doing it wholesale as that'll be more efficient, so hopefully you'll have a complete script ready to go tomorrow. I'll just post it in this thread when I'm done. I'll also explain the different steps involved in handling submitted data. So, be on the lookout for a rather long post or two.
-
Aha! Good, you nailed down the problem. Change the '$query = ...' line to: $query = "INSERT INTO name (name, email_address) VALUES ('Kevin', 'kevin@gmail.com')"; The reason for this is that your database is named 'jason_gold', but your table name is simply 'name'.
-
I own both. In terms of graphics, they're pretty even. I haven't seen anything from one that makes me think it's vastly superior to the other. For online play, the Xbox is superior. Unfortunately, you need to pay $50 a year for an Xbox Live Gold account in order to play online. The Xbox also requires one to use their proprietary currency in order to buy things through the online store. I believe 80 XBL Points = $1. Finally, you'll also need to purchase a separate wireless internet adapter if you plan on playing online in a room without an internet connection. The PS3 comes with built-in wireless internet capabilities, and the PlayStation Network is free. Purchasing things through the store is done with cash instead of a proprietary currency with a wacky exchange rate. Those are all big positives in my book. Everything else boils down to their respective libraries. The Playstation 3 is only now getting its legs. Resistance, Warhawk, Uncharted, MGS4, and the soon-to-be-released LittleBigPlanet are the core apps. For the Xbox, I'd say Gears of War, the upcoming Gears of War 2,Halo 3, and Mass Effect are the big titles to date. Most of the rest are on both platforms.
-
Yup, that's the one. Hmm... try changing the '$result = ...' line to: $result = mysql_query($query) OR die("Insert query error: " . mysql_error()); That will kill the script if the insert doesn't work and, hopefully, spit out a useful error message.
-
Hmm...so now it looks like the insert query itself isn't working. Can you repost the main script code? I just want to see how I handled the errors. I think I can add some more error reporting so it can point us in the right direction to fixing this new problem.
-
I'm having trouble with session's, I could use some help.
KevinM1 replied to vetman's topic in PHP Coding Help
Sessions and general header() function calls must take place before any output is sent to the browser. EDIT: See the stickied thread we have on this already: http://www.phpfreaks.com/forums/index.php/topic,37442.0.html -
Your for-loop is backwards. It should be: for($i = 0; $i < $total; $i++)
-
How Many Of You Are Self-Taught Programmers/Developers?
KevinM1 replied to Vermillion's topic in Miscellaneous
Ah, gotcha. Yeah, that doesn't sound like much fun. -
How Many Of You Are Self-Taught Programmers/Developers?
KevinM1 replied to Vermillion's topic in Miscellaneous
How different is ActionScript from JavaScript? I ask because I thought they were both based on EMCAScript. I haven't tried ActionScript myself as I have the artistic ability of a blind gnat. -
<script type="text/javascript"> window.onload = function() { var myTrigger = document.getElementById('trigger'); var myText = document.getElementById('text'); myTrigger.onclick = function() { myText.innerHTML = "I just got added to this div!"; } } </script> <!-- ... --> <a href="#" id="trigger">Click me to add text below!</a> <div id="text"> </div>
-
In your constants.php file, change 'widget_corp' to your actual database name, 'jason_gold.'
-
Oh, really? Interesting. Eh, I still like the parens...it matches the rest of my coding style.
-
Hmm...well, the files both look okay, and removing the not-null from the other columns will definitely make testing easier. I'm unsure if you need to include that WAMP config file, as I've only ever used *nix hosting for my PHP projects. Did you try testing it after you modified the column attributes? Because everything else looks right. The only things I could think would be causing nothing to happen is either a bad db host name, or that it can't 'see' the dbconnect file due to file permissions. That said, you should still be seeing some errors on the screen if that's the case. The calls to the database would generate several errors if it couldn't connect. Hmm...did you ever need to change file permissions for your normal HTML files to be visible? Because you shouldn't be seeing a blank, white screen regardless of whatever errors are there. You should be seeing something. I probably won't be around much this weekend. I'm not usually on the computer at all during the weekend, so keep at it, and feel free to ask others questions.
-
Well, there are several things at play here. First, you don't initialize your object correctly. You should write: $mess =& new Message($message); Why? Because of your constructor: function Message($body){ //Line 8 $this->message = $body; } Since you defined a constructor for your object, it's expecting you to pass to it the one parameter defined in its signature ($body). Even if you didn't define your own constructor, you'd still need to instantiate the object like so: $mess =& new Message(); Object creation always invokes an object constructor, which, in turn, is a function. Since it's a function, you need the parentheses. The next line follows the same train of thought from the previous mistake. Your body() function merely returns a value. It doesn't set the $message member of the object. So, trying to use it in that context doesn't make sense. Instead, you'll need to write what's commonly called a 'setter' function to go along with your 'getter' function. Together, they'd look something like this: function getMessage() { return $this->message; } function setMessage($message) { $this->message = $message; } Using these within the client code would look like: $myMessage = "Welcome to Rapture"; $welcome =& new Message($myMessage); echo "$welcome->getMessage()"; $welcome->setMessage("Don't let the Big Daddy's get you"); echo "$welcome->getMessage()"; Finally, if you're serious about trying OOP with PHP, you should really update to PHP 5. I cannot stress how much better its OOP capabilities are.
-
I believe there's also a size limitation to GET as well. So, if the OP is transferring a lot of data, POST is definitely their best bet. Well, you'd build your query string in the same way, so say you had a username and password: var userName = encodeURIComponent("Billy Idol"); var password = encodeURIComponent("12345fuy8ytt5"); var parameters = "user=" + userName + "&pass=" + password; xmlHttp.open("POST", "yourscript.php", true); xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); //not sure if it's needed, but it works xmlHttp.onreadystatechange = handleRequest; xmlHttp.send(parameters); For the PHP page, all you'd need to do is handle the POST data: $user = $_POST['user']; $password = $_POST['pass'];
-
Yup, it should be okay, provided it's used consistently. Regarding output, you'll probably still want to run what's retrieved from the database through both htmlentities and stripslashes. This has more to do with security than with whether or not things will display properly.
-
The use of those two functions aren't dependent on magic quotes. Stripslashes, in particular, isn't itself necessary to display data that has been escaped using mysql_real_escape_string. A more pressing concern would be whether or not your apps use the superglobals (i.e., $_GET, $_POST, etc) to access request data, or if the previous developer relied on magic quotes to do the heavy lifting there. If you want, you could make a test script to double-check how mysql_real_escape_string works. I did the following: $string = "()'?--"; $string = mysql_real_escape_string($string); $query = "INSERT INTO mytable (string) VALUE ('$string')"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); echo "Escaped string as it looks before going into the db: $string<br />"; echo "Escaped string as it looks after being retrieved from the db: {$row['string']}"; You should notice that the single-quote/apostrophe is escaped in the first line of output, but not in the second.
-
http://www.php.net/manual/en/function.array-unique.php
-
Okay, let's start at the beginning. First, your web root would be the folder that you'd put all of your website files in. It's the folder that is visible to the internet. Normally, it's named something like public_html, but not always. It's the folder where you put all your HTML files, and is where you should put all of your PHP files, except your dbconnect.php file. You can create other folders within the web root to help organize things, but all the files you want to show to the outside world have to be in this folder somewhere. Where is your dbconnect.php file located in relation to your other website files? I think you said you put it two folders above the web root. Is this correct? For that file, unless you were given a path to the database not named localhost, then all you need for the host value is localhost (I hope that made sense). Again, the dbconnect.php file should simply be: <?php DEFINE('HOST', 'localhost'); DEFINE('USER', 'username'); DEFINE('PASS', 'password'); DEFINE('MYDB', 'database name'); ?> Where 'username' and 'password' are the login info to the database, and 'database name' is the name of the database you need to access. Double-check with your hosting that 'localhost' is all you need. My own hosting requires me to enter in more than just 'localhost' when I'm using straight mysql, so you may be running into the same problem. Regarding the database columns: setting one to not-null means that it is not valid to leave that column empty. Your id column should be not-null because every database row should have an id associated with it. For the other columns, it all depends on whether or not you want to force your users to enter certain information. There's no real right or wrong answer to this, as it depends on what columns you don't mind potentially leaving empty. You should probably show me the code for both PHP files, just so I can double-check what's going on. I just ran a test on my hosting, which worked fine, so I'm thinking you either have a syntax error, bad database login info, or the dbconnect file is in the wrong spot and you're not actually including it. EDIT: I think I see the problem. I just looked at your table structure again, and all columns are set to not-null. Since that's the case, change the line with $query = "INSERT INTO..."; to: $query = "INSERT INTO name (name, email_address, day_number, night_number, best_way_to_reach, type_of_event, date_of_event, budget, how_did_you_find, comment_questions) VALUES ('Kevin', 'kevin@gmail.com', 0, 0, 'email', 'party', '2008-12-25', '1200.50', 'phpfreaks', 'great site')"; And see if it works now. EDIT2: Make sure you highlight the entire line I wrote above...the code box cut it off, but you should be able to get the whole thing if you keep dragging your mouse to the right.
-
Couldn't you merely start your for-loop with $i = 2?
-
What variable are you trying to truncate?