Jump to content
Larry Ullman's Book Forums

Antonio Conte

Members
  • Posts

    1084
  • Joined

  • Last visited

  • Days Won

    126

Everything posted by Antonio Conte

  1. As Larry point out, why code for such an old version of PHP? It just don't make any sense. I would check for mysqli-extension. If it does exsist, use prepared statement, otherwise, use mysql_real_escape_string and other checks.
  2. How do you bind the value to $camt? Something like $_POST['camt'] = $camt; ?
  3. If you want to return the information from print_r rather than print it, use TRUE (1 boolean as in this example). echo '<h3>Array As Is</h3><pre>' . print_r($students, TRUE) . '</pre>'; Is working exactly the same way.
  4. I've actually read a good chunk of Matt Zandstra's book myself. But as I'm no quick learner, and don't like technical language, I find it a bit hard to read. Larry's style of explaining things are easier for me to grasp.
  5. Are you asking questions about PHP security, or just recommending this app? As I work mostly with data from MySQL, the extended MySQLI is very good. Besides that, mysqli_real_escape_string, checking globals like get and post and checking for empty, unset fields will take you a long way.
  6. Hey. You need to send header info with the mail if this is to work. $too = 'exmample@yahoo.com'; $header = "Content-Type: text/plain; charset=\"UTF-8\""; mail($too, $subject, $body, "from: {$email}", $header); Hope this works for you.
  7. Very cool! You absolutly got my respect. Nice to see fans contribute in such a way.
  8. Btw. Check out jQuery validate UI. It provides most of the checks you will every need. Sooo easy to implement.
  9. Btw. I see you do a lot of football stuff. I'm a Juventus fans myself, and I am the proud admin of Juvenorge.com We are set up with Textpattern (something like Wordpress) and got developed a great plugin called cnk_soccer. It allows you to - Add leagues (seasons) - Add clubs (Name, Nation, Logo) - add rounds to the leagues (10 games in a Serie A round) - Calculate the table based on the rounds - Show Next oponent for your team - Show five next games/latest games for your team (self developed) - Add stadiums and TV-channel management (self developed) I'm currently working on a large system for handling this myself. What team is your favorite, and what's your site?
  10. "clicking preview tab or preview in button on the tool bar the handle_form.php does execute the php code but no variables are passed from form.html." But you never say that the script should DISPLAY any of your variables. You just check if they are not empty, then display the name of the comment poster. I don't know why the file is opened in clipboard. An easy thing to do is to uninstall PHP5 from your machine and install XAMPP. It's very easy to set up and requires a PURE minimum of configuration. Setting it up will take less than 15 minutes the first time. I think that would solve your problem faster.
  11. Aha, I understand. for ($i=0; $i<3; $i++) { row[$i] = // do something clubName[$i] = // do something played[$i] = // do something won[$i] = // do something draw[$i] = // do something lost[$i] = // do something } This is a possible way to loop through the data. Hope that makes sense
  12. First off, why do you use 100 echoes when you could've just used one? echo '<form action="#" method="post"> <table> <tr> <td>Position</td> <td>Club Name</td> <td>Ply</td> <td>Won</td> <td>Drw</td> <td>Lst</td> ..... Second, do you have a query, a mysql(i)_query() function and a for/while loop to get the rows from the table? You need that. Third: I don't think everything is valid regarding the array variables. (Are they just text?) echo '<td><input type="hidden" name="row[1]" value="1"> <input type="text" name="position[1]" maxlength="50" /></td>'; Should possible be: echo '<td><input type="hidden" name="'.row[1].'" value="1"> <input type="text" name="'.position[1].'" maxlength="50" /></td>';
  13. What would be preferable: - Using array_walk to pass the array as reference to a function? - Passing the array straight to the function as reference? array_walk() does not seem to difficult to use, but it does add a layer of complexity. Are both these methods listed possible solutions, or do you NEED to use the array_walk()? Example: <?php $fruits = array("d" => "lemon", "a" => "orange", "b" => "banana", "c" => "apple"); function test_print($item2, $key) { echo "$key. $item2<br />\n"; } array_walk($fruits, 'test_print'); /*----------- Straight to function -----------*/ self::my_function($fruits) private function my_function(%$array) { foreach ($array as $key => $item) { echo "$key. $item<br />\n"; } } ?>
  14. Hey, John. I can't answer all your questions, but some of them. - Yes. If you edit the configuration, you need to restart Apache. - Xampp is very easy to get up and running. (both on Mac and PC - I use both) How about taking a backup of your content, then reinstall xampp? - Are you using an URL like http://localhost to watch your content? (Standard for Xampp) - Are your web content inside the folder "htdocs" found in xampp? Sorry if these questions are moronic/a personal insult/etc. Trivial stuff's easy to overlook.
  15. I got this explained really really good by watching a Java online course from Stanford University. Passed by value: When you work with a variables, you get the value from the memory location of the variable inside the computer. The original variable is not known or important, just it's value. Passed by reference: Because objects and arrays are much larger amounts of data, you get a pointer to the memory locations (plural) of the actuall array/object. Think of it like this: Little Jimmy goes to Louvre to watch Mona Lisa. He wants to use his Chainsaw to cut Mona Lisa in half. When you pass by value, Little Jimmy goes to the gift shop instead, and gets A COPY to play with. It looks the same, but the original is safely stored in Louvre (And your computer) When you pass by reference, Little Jimmy plays with the REAL MONA LISA. Any changes he does to it, will affect the original! (And also the original on your computer)
  16. The problem is the testing of the variable $r if ($r) { // returns TRUE on queries POSSIBLE to run. } else { // returns FALSE on query FAILURE (Mysql error) } As your query (hopefully) is written correctly, the TRUE clause will always apply. mysql_num_rows() is a function that checks how many rows was AFFECTED by your MySQL query. - Lets say you add one user to the table users successfully by $r=mysqli_query($dbc, $q); - The number of rows inserted to the table is now 1 (one) - This means, mysql_num_rows($r) will be equal to 1 (one) What's the point of mysql_num_rows?: While the code if ($r) { } will only check if the query is true... (It gets TRUE/FALSE from mysqli_query($dbc, $q); The code if (mysql_num_rows($r = 1)) { } will test for interacting with the table data Hope this clears something up.
  17. $var = 0; function name( &$var ) { $var = 15; } echo $var; // this is now 15 if you use the function [i]name[/i] This means the variable is passed by reference. - You play with the ACUTALL variable - Normally you get A COPY / NEW variable with the same name The difference is that any thing you do with the variable passed by refference, is kept with the original variable. Edit: Too late...
  18. You need to use mysqli_connect instead of mysql_connect. The reason you get these error, are that mysqli_prepare is not finding a (mysqli)connection. This also gives you several more errors down the line.
  19. MegL: When you SHA1' passwords, you can't compare them to a normal password anymore. You need to compare the SHA1'd password the user types in with the SHA1'd password in the database. If the hashes (the SHA1'd passwords) are the same, then it's the right password. I don't know if this is your problem, but I think it might be common thing to forget. Hope you work this out, and please ask more questions if you need to.
  20. Thank you, HartleySan. I don't absolutely need to go OOP on this. It's more about learning, gaining coding experience, and develop in a higher speed. What I mean by speed is, once I've established a certain way of getting, editing, adding and deleting data, from there, it's more about changing table rows in the prepared statements. This is my first rewrite of a functioning administrative environment for the the things listed in the above post. It's secured by .htaccess in an unknown subdomain on a small site, so the security measures is probably don't even needed. In the end, it's about learning.
  21. It's more for the learning part. I do a little Java too, and this just seemed natural from what I've learned. I just want an easy workflow. This project is going to manage: - Football seasons (EU kind) - leagues - teams - matches - players - player statistics Because of that, I wanted to see if I could possible use getters and setters for editing/adding/deleting data without writing all the queries. Guess I just gotta keep on writing code.
  22. Me neighter, to be honest... The point here being, these getter and setter methods was used a lot in my Java programming class. I wondered wheter they could actually work with info from a database. Even if I move the method 'getAllPlayers' from the script and add players to an array, the database values good not be changed directly, right? So I really don't see the point of them, that is, in this context. I would have to write add, edit and delete methods for players using mysqli anyway, right? THIS is perhaps a better way to descibe what I tried to ask for. Thanks for the answeer btw.
  23. Thought I posted here earlier? Maybe I forgot to push the Add Reply-button... You can't check number of rows. What you can do is check for a certain LENGTH of the comment (and this should be about 5 rows) Lets say that 255 characters. §comment = §_POST['comment']; if (strlen(§comment) < 255) { echo "You can only type 255 characters, Twitr style!"; } // some other checks aswell
×
×
  • Create New...