Jump to content

CaraRota

Members
  • Posts

    6
  • Joined

  • Last visited

Posts posted by CaraRota

  1. You don't care? You have to write code to programatically understand how to interpret the user input. As humans we can read an address, for example, and intuitively know the street, city, country, etc. A computer would just see a string of random characters. We have to write logic to break apart a string and determine what values are what. If the values are separated by a dash, then we can explode on the dash. If not, then we have to come up with some other rule or rules on how the string will be broken apart.

     

    As for your error, you are exploding a line of text based upon the dash and then taking ONE value at a time and trying to insert a record which requires eight values.

     

    If you are going to receive multiple lines, then follow the logic from the other post linked above to process the results into a single line. THEN use explode on each line to break it into the eight different values and use ALL EIGHT of those values in the insert query.

     

    Let me see if we understand each others; what i mean is, i dont care because I AM the one who is going to "upload" the matches, and i, as human, can use a - or a / or whatever y want; that won't bother me at all!

    So basically, i can make it explode as a dash (-), like i posted in the other reply, and i will upload the matches like that :)

     

    The other code i just don't understand it.. im not that expert on php (not even close!).

     

    Im trying to get some help from a friend, see what we can do.

     

    Thanks for all your help!

  2. Hi psycho,

     

    Thanks for your answer, but honestely i know very little php and im trying to understand what you've said.

    First of all, i really don't care if the input is divided by a - or a space, or 4 spaces; i can sort that out as soon as my explode() works :)

     

    Second, i though that inserting the value $res would give me as many records as i type in the textarea (for example, 1 2 3 4 5 6 7 8 should be working on that code.. im guessing).

     

    So, to state a ground base, let's say i want to post this into the textarea:

     

    2013/04/03 21:00-Bolivar-The Strongest-2.20-3.20-2.88-1-LFP
    2013/04/03 21:00-La Paz-Oriente Petrolero-4.33-3.50-1.73 1-LFP   
    2013/04/03 21:00-Wilstermann-Universitario-1.91-3.40-3.60-1-LFP

     

    That'd be an 8 input data with a - in the expode();

     

    $a=explode('-',$text);
    
    foreach($a as $res){
     

     

    and then execute the query normally (without the $res=mysql_real_escape_string($_POST['res']);)

     

     

    $sql="INSERT INTO events (hometeam, awayteam, ratiohome, ratioaway, ratiox, sportid, starttime, liga) VALUES ('$res')";
    $sql_result=mysql_query($sql,$link) or die(mysql_error());
     

     

    Would this be right then? Because it continues giving me the same error... :(

     

    Thanks a lot for your help!

  3. I've got this so far:

     

    if($_POST['agendar'])
    {
        // Verificamos que no haya ningun dato sin rellenar.
        if(!empty($_POST['local']))
        {
            // Pasamos los datos de los POST a Variables, y le ponemos seguridad.
    
    $text="";
    
    $a=explode(' ',$text);
    
    foreach($a as $res){
    
            // Configuracion de la base de datos.
            $dbhost = ""; // Servidor
            $dbuser = ""; // Usuario
            $dbpass = ""; // Contraseña
            $dbname = ""; // Tabla
    
            // Creando conexion.
            $link = mysql_connect($dbhost,$dbuser,$dbpass);
                mysql_select_db($dbname,$link);
    
    $res=mysql_real_escape_string($_POST['res']);
    
    $sql="INSERT INTO events (hometeam, awayteam, ratiohome, ratioaway, ratiox, sportid, starttime, liga) VALUES ('$res')";
    $sql_result=mysql_query($sql) or die(mysql_error());
    }
        } else {
            // Si hay un dato sin rellenar mostramos el siguiente texto.
            $msg = "Falta rellenar algun dato.";
        }
        
    }
     

    But it doesn't seem to work; here's the error:

     

    "Column count doesn't match value count at row 1"

     

    Even though i write, for example: 1 2 3 4 5 6 7 8 in the textarea..

  4. Hi Jessica,

     

    I have looked at it, but i do not understand that guys coding and i certainly need something different..

     

    It'd be:

     

    Line1 Line2 Line3

    Line4 Line5 Line6

    ..

    LineX LineY LineZ

     

    Altough i found this code much easier to me: http://forums.phpfreaks.com/topic/84395-solved-is-there-any-way-to-separate-lines-in-a-textarea-into-seperate-variables/

     

    I have posted a question over there too.

     

    Thanks for your reply!

  5. Hello there; i'd like to make it possible to write all the inputs i write with this text fields but make it in a single row (on a textarea), and make it possible to add multiple "events" in my website instead of one!

     

    For example:

    FIRST ROW IN TEXTAREA: Date - Local Team - Away Team - RatioLocal - Draw - RatioAway - SportID - League

    SECOND ROW IN TEXTAREA: Date - Local Team - Away Team - RatioLocal - Draw - RatioAway - SportID - League

     

    This would be a textarea example:

     

    2013/04/03 21:00    Bolivar    The Strongest    2.20    3.20    2.88    1 LFP
    2013/04/03 21:00    La Paz    Oriente Petrolero    4.33    3.50    1.73 1 LFP   
    2013/04/03 21:00    Wilstermann    Universitario    1.91    3.40    3.60 1 LFP

     

    Here are the files i use; you will get my idea as soon as you see them :)

    Agregar.php: http://pastebin.com/xeTyjrX8

    Config.php: http://pastebin.com/Tyb8SXuQ

     

    Please if you need more information ask me about it!

    Thanks a lot for your help!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.