Jump to content
Larry Ullman's Book Forums

Antonio Conte

Members
  • Posts

    1084
  • Joined

  • Last visited

  • Days Won

    126

Posts posted by Antonio Conte

  1. 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? :)

  2. "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.

  3. 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>';

    • Upvote 1
  4. (...) If you have an array that needs to be manipulated by a function, it's easier to pass that array by reference so that you don't have to return the array. The array_walk() function does this:

    http://us2.php.net/m....array-walk.php

     

    If you look at the first argument in the function definition, you'll see the array to be walked over is received by array_walk() by reference.

     

    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";
       	}
    }
    ?>

  5. 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.

    • Upvote 1
  6. 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)

    • Upvote 1
  7. //run the query;

    $r=@mysqli_query($dbc, $q);

     

    //if it ran OK

    if($r) {

    //print the message.

    echo'<h1>Thank you!</h1>

    <p>You are now registered. In Chapter 11 you will actually be able to log in!</p><p></br></p>';

     

    } else { // if it didn not run OK.

     

    if(mysqli_num_rows($r) != 0) {

    echo'<p>Your email is already registered in the database. Please try a different one.</p>';

    } else {

    echo'<h1>System Error</h1>

    <p class="error">You could not be registered due to a system error. We appologize for any inconvenience.</p>';

    //debugging message;

    echo'<p>'.mysqli_error($dbc).'</p>';

    }

    }

     

    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. :)

    • Upvote 1
  8. $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...

    • Upvote 1
  9. There are a bunch of errors I'm getting which seem to be related to the use of mysqli. I'm thinking its related to my use of mysql_connect instead of mysqli_connect, but the reason I'm not sure is

    1. lack experience

    2. the mysqli_connect.php looks.

    // Add the artist to the database:
    $q = 'INSERT INTO artists (first_name, middle_name, last_name) VALUES (?, ?, ?)';
    $stmt = mysqli_prepare($dbc, $q);
    mysqli_stmt_bind_param($stmt, 'sss', $fn, $mn, $ln);
    mysqli_stmt_execute($stmt);
    

     

    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. :)

    • Upvote 1
  10. 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.

    • Upvote 1
  11. 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.

  12. 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. ;)

  13. Anyway, not sure what your intentions are, but you might want to take the getAllPlayers method out of the class, and then use that function to create an array of all the players on the fly. If you do that, your getters and setters should work fine.

     

    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.

  14. 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

    • Upvote 1
×
×
  • Create New...