Results 1 to 32 of 32

Thread: Inserting concatenated data into DB, difficult 1

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94

    Unhappy Inserting concatenated data into DB, difficult 1

    Sorry, had to change the title of the thread

    PHP Code:
    $i 
    while (
    $i <= 3) { 

    print 
    $i//just to check 

    $result mysql_query("INSERT INTO nbalive_daybyday (GP, Nickname, PTS, FGM, FGA) VALUES ('$GP$i' , '$Nickname$i' , '$PTS$i', '$FGM$i' , '$FGA$i')"); 

    $i++; 

    The $i gets printed correctly but somehow it just fills my database with "1"'s, that's something like 29366 rows !! That's really weird anyone know what this could be ?
    Last edited by Choller; Aug 8th, 2002 at 08:14 AM.
    "Against All Odds"

  2. #2
    Fanatic Member ubunreal69's Avatar
    Join Date
    Apr 2001
    Location
    Morayfield, Australia
    Posts
    609

    Re: DB gets populated with 1's

    Originally posted by Choller
    anyone know what this could be ?
    no extremely strange though

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94

    IS this code even right ?

    What i'm trying to do is to use two variables to enter the data into the database...

    I need to get the values PTS1, GP1, PPG1, and then PTS2, GP2, PPG2 etc... i hope the above code is right.

    Strangely it now puts the correct amount of records in the field . But the data is wrong, coz it just fills the recordid in all the fields instead of filling the actual data it needs to transmit.

    I know the datas are being transmitted because i can echo them and they are correct.

    For example i'm insterting a value "15" in an int table but it just inserts the table id...weird.

    man...this is the last hurdle.
    "Against All Odds"

  4. #4
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    PHP Code:
    $i 
    while (
    $i <= 3) { 
      
    $result mysql_query("INSERT INTO nbalive_daybyday (GP, Nickname, PTS, FGM, FGA) VALUES ('GP$i' , 'Nickname$i' , 'PTS$i', 'FGM$i' , 'FGA$i')"); 
      
    $i++; 

    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    Originally posted by cpradio
    PHP Code:
    $i 
    while (
    $i <= 3) { 
      
    $result mysql_query("INSERT INTO nbalive_daybyday (GP, Nickname, PTS, FGM, FGA) VALUES ('GP$i' , 'Nickname$i' , 'PTS$i', 'FGM$i' , 'FGA$i')"); 
      
    $i++; 

    Makes sense but now my all the fields are "0" (zero).



    hmm.... /me thinks.
    "Against All Odds"

  6. #6
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    PHP Code:
    $i 
    while (
    $i <= 3) { 
      
    $result mysql_query("INSERT INTO nbalive_daybyday (GP, Nickname, PTS, FGM, FGA) VALUES ('GP".$i."' , 'Nickname".$i."' , 'PTS".$i."', 'FGM".$i."' , 'FGA".$i."')"); 
      
    $i++; 

    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  7. #7
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    where do you get 29366 rows when it loops only 3 times

  8. #8
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman
    where do you get 29366 rows when it loops only 3 times
    I you don't know, then you are not a true PHP Master.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  9. #9
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    lol, that is right, I totally forgot I am not the master

  10. #10
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    and I totally forgot the "f" on "if" in my sentence there.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  11. #11

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    cpradio thanx for the help so far but it's still not working.

    I have seen several sort of this concenation problem in the mysql query, but none have worked so far.

    So the problem still exists..... i'm out of idea's, i have asked on several forums but no one seems to know this.
    "Against All Odds"

  12. #12
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    I don't have much information on how PHP handles strings but maybe you can try using those old joins:
    PHP Code:
    $i 
    while (
    $i <= 3) { 
      
    $result mysql_query("INSERT INTO nbalive_daybyday (GP, Nickname, PTS, FGM, FGA) VALUES ('GP" $i "' , 'Nickname" $i "' , 'PTS" $i "', 'FGM" $i "' , 'FGA" $i "')"); 
      
    $i++; 

    Baaaaaaaaah

  13. #13
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    Originally posted by Choller
    cpradio thanx for the help so far but it's still not working.

    I have seen several sort of this concenation problem in the mysql query, but none have worked so far.

    So the problem still exists..... i'm out of idea's, i have asked on several forums but no one seems to know this.
    what Matt suggested should have worked. what is your code you have right now?

  14. #14

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    Originally posted by phpman

    what Matt suggested should have worked. what is your code you have right now?
    Well i don't know who Matt is....what's Matt's nickname ? Lemme know and i'll try his code again.

    I've tried all of the codes above but it didn't work. They don't fill in the actual data in the fields (the loop is ok coz it enters 3 fields).




    "Against All Odds"

  15. #15
    Fanatic Member cpradio's Avatar
    Join Date
    Apr 2002
    Posts
    616
    I am Matt
    http://cpradio.net/
    Administrator @ WDForums and a Moderator @ WebXpertz City Forums

  16. #16
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    Originally posted by Choller


    Well i don't know who Matt is....what's Matt's nickname ? Lemme know and i'll try his code again.

    I've tried all of the codes above but it didn't work. They don't fill in the actual data in the fields (the loop is ok coz it enters 3 fields).




    and I asked what is the code you have. because if we all can get it to work there must be somehting you are doing wrong. so in order to tell we need to see the code.

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    Originally posted by phpman

    and I asked what is the code you have. because if we all can get it to work there must be somehting you are doing wrong. so in order to tell we need to see the code.
    Sorry, here's the complete code. I use math's (cpradio) line.

    PHP Code:
    <?php
        mysql_connect 
    (youdontwannaknow);
        
    mysql_select_db ( :) );
        
    $i 1;
    $Attendance 3;
    while (
    $i <= $Attendance)
    {
    $result mysql_query("INSERT INTO nbalive_daybyday (GP, Nickname, PTS, FGM, FGA) VALUES ('GP".$i."' , 'Nickname".$i."' , 'PTS".$i."', 'FGM".$i."' , 'FGA".$i."')");
    $i++ ;
    }
    echo 
    "Previous data has been entered <br>";

    echo 
    "<br>GP$i is one <br>"//just testing
    echo "$GP$i is two<br>"//just testing
    ?>
    The db has the correct values (like gp fgm and fga are all integers and nickname is also int).
    The string that is being passed is ... http://www.fbistillsecret.net/basket...S1=15& etc etc
    The DB
    Field Type Null Default
    Nickname tinyint(4) No 0
    PTS int(11) Yes NULL
    PPG float Yes NULL
    FGM int(11) Yes NULL
    FGA int(11) Yes NULL
    GP int(11) No 0

    I am currrently working on this (right now) and will keep y'all posted.

    I have worked on mysql before and all my other db's have worked perfectly so i'm really dumbfounded here...

    THanx for the help so far....


    update:

    I must come to the conclusion that the concentation is not working. I can echo the data allright, and the loop is working allright but the data is not being passed correctly to the db so it must be the concentation (sp).

    How do u call that thing concentation ? I mean the art of joining strings and variables....
    Last edited by Choller; Aug 8th, 2002 at 06:39 AM.
    "Against All Odds"

  18. #18
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    you code is not the problem. it is your DB. you can't enter constants in a interger field. you will have to change all the INT to varchar.

    Nickname varchar(20) No 0
    PTS varchar(10) Yes NULL
    PPG varchar(10) Yes NULL
    FGM varchar(10) Yes NULL
    FGA varchar(10) Yes NULL
    GP varchar(10) No 0

    and the value in the () has to be big enough to make room for the word. so "nickname" has to be at least 8 so with number it should be like 10

  19. #19

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    Thank you very much phpman.

    I'm one step further.

    Thing is the actual data is not being entered, only the fieldnames are being entered.

    Example:

    PTS1, PPG1, FGM1, FGA1
    PTS2, PPG2, FGM2, FGA2
    PTS3, PPG3, FGM3, FGA3

    I now only need the actual data i can echo the data and it comes correctly so i don't know what's wrong now hehe..

    if i use this code

    PHP Code:
    $result mysql_query("INSERT INTO nbalive_daybyday (GP, Nickname, PTS, FGM, FGA) VALUES ('$GP".$i."' , '$Nickname".$i."' , '$PTS".$i."', '$FGM".$i."' , '$FGA".$i."')") or die(mysql_error()); 
    I get this:

    1, 1, 1, 1
    2, 2, 2, 2
    3, 3, 3, 3

    ....


    edit: I think that should be a dollar sign ($) before the values am i not right ? That's usual code when passing the values...

    /me thinks
    Last edited by Choller; Aug 8th, 2002 at 08:02 AM.
    "Against All Odds"

  20. #20
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337
    they only need to be $ if you are getting htem from somewhere else. in your case they are not and this should work now.

    $result = mysql_query("INSERT INTO nbalive_daybyday (GP, Nickname, PTS, FGM, FGA) VALUES ('GP".$i."' , 'Nickname".$i."' , 'PTS".$i."', 'FGM".$i."' , 'FGA".$i."')");


    you should get

    GP1 Nickname1 ...
    GP2 Nickname2 ...
    ...


    and so on. you don't get that?

  21. #21

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    Yes i get that....but i need the values they are passing....

    So i need the value of PTS1, Nickname1 etc...

    And to get that they sould be $PTS1, $Nickname2 etc in the mysql query...

    Edit: A summary

    I'm trying to concatenate (spelling) this string in a mysql query.
    First this code:
    PHP Code:
    $result mysql_query("INSERT INTO nbalive_daybyday 
    (GP, Nickname, PTS, FGM, FGA) 
    VALUES ('GP"
    .$i."' , 'Nickname".$i."' , 'PTS".$i."', 'FGM".$i."' , 'FGA".$i."')"); 
    With this code i get
    GP1, Nickname1, PTS1 etc
    GP2, Nickname2, PTS2 etc

    What i need is to get the VALUES of these data so i need.

    $GP1, $Nickname1, $PTS1 etc
    $GP2, $Nickname2, $PTS2 etc

    I tried this code but it didn't work...

    PHP Code:
    $result mysql_query("INSERT INTO nbalive_daybyday 
    (GP, Nickname, PTS, FGM, FGA) 
    VALUES ('"
    .$."GP".$i."' , '".$."Nickname".$i."' , '".$."PTS".$i."', '".$."FGM".$i."' , '".$."FGA".$i."')"); 
    When i try this code:
    PHP Code:
    $result mysql_query
    ("INSERT INTO nbalive_daybyday 
    (GP, Nickname, PTS, FGM, FGA) 
    VALUES ('
    $GP".$i."' , '$Nickname".$i."' , '$PTS".$i."', '$FGM".$i."' , '$FGA".$i."')"); 
    i get this in the database:
    1, 1, 1, etc
    2, 2, 2, etc

    These are NOT the values....
    Last edited by Choller; Aug 9th, 2002 at 02:00 AM.
    "Against All Odds"

  22. #22

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    K,

    somebody gave me this option :

    I think you'll need to define the variables before you make the query.

    $gp = $gp.$i;
    $nick = $nickname.$i; etc etc

    Then:

    ... VALUES ('". $gp ."', '". $nick ."', '....

    You'll need to do a "for" loop so that it loops through the INSERT the rigt amount of times for however many variables there are..

    for ($i=0;$i < $numberOfRows;$i++) {

    Hope this helps.

    And it looks very possible. I'm going to try it out !!

    "Against All Odds"

  23. #23
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    PHP Code:
    $result mysql_query
    ("INSERT INTO nbalive_daybyday 
    (GP, Nickname, PTS, FGM, FGA) 
    VALUES ('"
    .$_REQUEST['GP'].$i."' , '".$_REQUEST['Nickname'].$i."' , '".$_REQUEST['PTS'].$i."', '".$_REQUEST['FGM'].$i."' , '".$_REQUEST['FGA'].$i."')"); 
    you never said you were getting the GP from the user from a form.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  24. #24
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    Originally posted by Choller
    K,

    somebody gave me this option :




    And it looks very possible. I'm going to try it out !!

    what do you think you ae doing here.
    PHP Code:
    $i 
    while (
    $i <= 3) { 
      
    $result mysql_query("INSERT INTO nbalive_daybyday (GP, Nickname, PTS, FGM, FGA) VALUES ('GP$i' , 'Nickname$i' , 'PTS$i', 'FGM$i' , 'FGA$i')"); 
      
    $i++; 

    samething, just replace the values with what I have just given you.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  25. #25

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    Originally posted by scoutt
    PHP Code:
    $result mysql_query
    ("INSERT INTO nbalive_daybyday 
    (GP, Nickname, PTS, FGM, FGA) 
    VALUES ('"
    .$_REQUEST['GP'].$i."' , '".$_REQUEST['Nickname'].$i."' , '".$_REQUEST['PTS'].$i."', '".$_REQUEST['FGM'].$i."' , '".$_REQUEST['FGA'].$i."')"); 
    you never said you were getting the GP from the user from a form.
    No but i think i said that i need the data and not the actual name (hence the dollar sign).
    I'm getting the data from a previous from so that's why i'm using the $variable to enter the data in the db (this is the normal procedure from the get/post code in the previous form).

    I've tried above code and my db just stays empty....

    To be honest: i don't know why this code is taking so long to figure out, i've been battling this thing for 2 weeks now, taking a look at the code everyday, and still i haven't solved the problem...

    I don't know why i can echo $GP$i but when i try
    $GP = $GP$i
    it just doesn't go.....nothing is being put in the db...
    Man....i'm reallyyyy stressed now (thank god it's friday )
    "Against All Odds"

  26. #26
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    what do you get whane you

    echo $_REQUEST['GP'];

    what does your form look like?
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  27. #27

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    My form looks like this

    It's a big ass one

    PHP Code:
    <?php
    /*
        mysql_connect (blabla);
        mysql_select_db (blabla);
        $result = mysql_query("INSERT INTO nbalive_daybydaytotal (Date, Place, Attendance, Notes, Game) VALUES ('$Date', '$Place', '$Attendance', '$Notes', '$Game')");
    */
    $id mysql_insert_id();
    ?>

    Your previous data has been entered. <br>

    <form name="nbalivestats" action="nbainput3.php">
    <input type="hidden" name="DateID" value="<?php $id ?>"> 
    <input type="hidden" name="Attendance" value="<?php $Attendance ?>"> 
    <table border="1">
    <tr>
    <td align="center">Nickname</td>
    <td align="center">GP</td>
    <td align="center">PTS</td>
    <td align="center">PPG</td>
    <td align="center">FGM</td>
    <td align="center">FGA</td>
    <td align="center">FG%</td>
    <td align="center">3PM</td>
    <td align="center">3PA</td>
    <td align="center">3P%</td>
    <td align="center">FTM</td>
    <td align="center">FTA</td>
    <td align="center">FT%</td>
    <td align="center">REB</td>
    <td align="center">RPG</td>
    <td align="center">BLK</td>
    <td align="center">BPG</td>
    <td align="center">STL</td>
    <td align="center">SPG</td>
    <td align="center">AST</td>
    <td align="center">APG</td>
    <td align="center">FL</td>
    <td align="center">FPG</td>
    <td align="center">PF</td>
    <td align="center">PFG</td>
    <td align="center">PA</td>
    <td align="center">PAG</td>
    <td align="center">OR</td>
    <td align="center">ORG</td>
    <td align="center">DR</td>
    <td align="center">DRG</td>
    <td align="center">TO</td>
    <td align="center">TPG</td></tr>

    <?php
    $i
    =;
    while (
    $i <= $Attendance


        echo
    "<tr>";

    echo
    "<td><select name=\"Nickname" .$i"\">";

                
    mysql_connect (localhostthemainclickthem1455);
                
    mysql_select_db (themainclick);
                
    $result mysql_query("SELECT * FROM nbalive_player ORDER BY Nickname ASC");

                while (
    $row=mysql_fetch_array($result,MYSQL_ASSOC)) 
            { 
            print 
    "<option value=".$row["PlayerID"].">".$row["Nickname"]."</option>\n"
            }; 

    echo
    "        </select></td>";



        echo
    "<td><input type=text name=\"GP" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"PTS" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].PPG" .$i".value = (parseInt(document.forms['nbalivestats'].PTS" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"PPG" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"FGM" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"FGA" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].FGP" .$i".value = (parseInt(document.forms['nbalivestats'].FGM" .$i".value, 10) / parseInt(document.forms['nbalivestats'].FGA" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"FGP" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"TPM" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"TPA" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].TPP" .$i".value = (parseInt(document.forms['nbalivestats'].TPM" .$i".value, 10) / parseInt(document.forms['nbalivestats'].TPA" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"TPP" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"FTM" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"FTA" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].FTP" .$i".value = (parseInt(document.forms['nbalivestats'].FTM" .$i".value, 10) / parseInt(document.forms['nbalivestats'].FTA" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"FTP" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"REB" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].RPG" .$i".value = (parseInt(document.forms['nbalivestats'].REB" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"RPG" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"BLK" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].BPG" .$i".value = (parseInt(document.forms['nbalivestats'].BLK" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"BPG" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"STL" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].SPG" .$i".value = (parseInt(document.forms['nbalivestats'].STL" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"SPG" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"AST" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].APG" .$i".value = (parseInt(document.forms['nbalivestats'].AST" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"APG" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"FL" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].FPG" .$i".value = (parseInt(document.forms['nbalivestats'].FL" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"FPG" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"PF" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].PFG" .$i".value = (parseInt(document.forms['nbalivestats'].PF" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"PFG" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"PA" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].PAG" .$i".value = (parseInt(document.forms['nbalivestats'].PA" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"PAG" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"OR" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].ORG" .$i".value = (parseInt(document.forms['nbalivestats'].OR" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"ORG" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"DR" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].DRG" .$i".value = (parseInt(document.forms['nbalivestats'].DR" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"DRG" .$i"\" size=5></td>";
        echo
    "<td><input type=text name=\"TO" .$i"\" size=5 onkeyup=\"document.forms['nbalivestats'].TOG" .$i".value = (parseInt(document.forms['nbalivestats'].TO" .$i".value, 10) / parseInt(document.forms['nbalivestats'].GP" .$i".value, 10))\"></td>";
        echo
    "<td><input type=text name=\"TPG" .$i"\" size=5></td>";
        echo
    "</tr>";
    $i++ ;
    }
    (simple submit button here).


    So when i submit it i get this url (i've discarde some of the values otherwise it will be too big for this explanation)

    http://www.blablabla.net/basketball/nbainput3.php?
    DateID=&Attendance=&Nickname1=2&GP1=32&PTS1=12&FGM1=15&FGA1=12&Nickname2=1&GP2=1
    2&PTS2=3&FGM2=1551&FGA2=155

    ========================================================
    and this code:
    ---------------------------------------------
    <html>
    <head>
    <title>NBA Live Stats Input page 3</title>
    <link rel="stylesheet" type="text/css" href="www.blablabla.net/mainstyle.css" />
    </head>

    <body>
    <p><p>
    PHP Code:
            mysql_connect (blablabla);
            
    mysql_select_db (blablabla);
            
    $i 1;
    $Attendance 3;
    while (
    $i <= $Attendance)
    {
    $GP $GP.$i ;
    $Nickname $Nickname.$i ;
    $PTS $PTS.$i ;
    $FGM $FGM.$i ;
    $FGA $FGA.$i ;
    echo 
    "$PTSb;
    $result mysql_query("INSERT INTO nbalive_daybyday (GP, Nickname, PTS, FGM, 
    FGA) VALUES ('
    $GP' , '$Nickname' , '$PTS', '$FGM' , '$FGA')");
    $i++ ;
    }
    echo 
    "<br>GP$i is one <br>";
    echo 
    "$GP$i is two<br>";
    echo 
    "PTS1 is $PTS1 ";
    echo 
    "PTS2 is $PTS2 <br><p>";
    $i 1;
    $cheese monkey;
    echo 
    $cheese.$i
    <br><p>Scores entered !

    </body>
    </html>
    ---------------------------------------
    =======================================================
    I get this:
    ----------------------------------------
    123
    GP4 is one
    4 is two
    PTS1 is 12 PTS2 is 3


    monkey1


    Scores entered !
    ----------------------------------------
    ================================================

    I tried with/without brackets....nada.
    echoing $result = mysql_query gives me nothing, just empty....so something is wrong with the code or so.
    Last edited by Choller; Aug 9th, 2002 at 09:20 AM.
    "Against All Odds"

  28. #28
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    holy mother of pearl

    ok, lets do this.

    echo"<td><input type=text name=\"GP" .$i. "\" size=5></td>";

    that line will read like this

    <td><input type=text name="GP1" size=5></td>

    so when it gets sent you will need to use this

    $_REQUEST['GP1'];


    so try this

    PHP Code:
    $result mysql_query
    ("INSERT INTO nbalive_daybyday 
    (GP, Nickname, PTS, FGM, FGA) 
    VALUES ('"
    .$_REQUEST['GP$i']."' , '".$_REQUEST['Nickname$i']."' , '".$_REQUEST['PTS$i']."', '".$_REQUEST['FGM$i']."' , '".$_REQUEST['FGA$i']."')"); 
    not sure if that will work.

    I would look into using arrays in that form of yours.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  29. #29

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    I've lost hope . It's still not working after trying above code(s).

    I've spent so much time in this thing thinking about how to figure it out and it's still not working after 2 weeks of just looking at the code above. This is really depressing.

    Thank you all for the help. Other boards have just ignored me or said to me RTFM. I really appreciate this board here (really).

    I could try the array route but i think i'm will just run into the same problem again.

    The previous pages ar allright, i'm 100% sure. I could see the values being passed in the url and they are allright. I can echo the values on the next page and they are ok....damn.

    /me gives up !!
    "Against All Odds"

  30. #30
    Lively Member scoutt's Avatar
    Join Date
    Aug 2002
    Posts
    84
    ok don't give up hope. any of the code here on this thread should have worked. give me your layout of the DB and 1 page and I will make it work. must be somehting you are doing wrong.
    Just Imagine what you can do with the power of php.

    257 Tutorials and counting.
    529 Snippets and growing.

    Add yours today @
    SnippetLibrary.com

  31. #31

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94

    Exclamation I'm back.

    Yeah, Choller's back with a vengeance.

    I have taken a break from this code but now i'm back to solve this problem.

    I'll start all over again with reviewing the code, hopefully i can let y'all know what is going on (meaning wrong).

    Now on to the code.... laterz...


    "Against All Odds"

  32. #32

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    94
    Ok,

    i've checked everything...

    Only thing that is not working is passing the values...

    look at this code

    $PTS = $pts.$i;


    I know it's wrong but what is the correct code?
    (for the rest of this history please look above )


    edit

    I got it !!!

    Code:
    <?
    $PTS=${"pts".$i}
    ?>
    !!!!!!
    Last edited by Choller; Sep 24th, 2002 at 07:55 AM.
    "Against All Odds"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width