Results 1 to 5 of 5

Thread: this will not add to my database

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139

    this will not add to my database

    PHP Code:
    <title>Stats Admin</title>


    <?php
    mysql_connect 
    (localhostuserpass);
    mysql_select_db (table);
    ?>

    <?php


    if ($action == "save")
    {

        
    $result mysql_query ("INSERT INTO DB_Stats Values ('','$name','$team,'$tries,'$goals','$fgoals','$total')");



    ?>
    <p>


    <br>
    <font face="Verdana">
    <strong><font size="2">THANK YOU<br>
    </font>
    </strong><font size="2">The new stats has been successfully setup.<br>
    &nbsp;</font></font>
    <p><font face="Verdana"
    size="2"><a href="adminaddnew.php?password=brandce">Return to the main menu</a>

    <?php


    } else {

    ?>
    <p>
    <FONT face=Verdana color=#004080 size=2><STRONG>player
    admin</STRONG></FONT>&nbsp; -
    </font>
    <font face="Verdana"
    size="1"> <a href="index.php?password=password">Back to admin main menu</a> | <a href="editstats.php">Edit Stats</a>  </font><p>
    <font face="Verdana" size="1">Enter your stat details below, if you have any 
    questions please contact <a href="mailto:[email protected]">me</a></font><hr>

    <form method="POST" action="adminaddnew.php?action=save">
      <table border="0" width="100%">
        <tr>
          <td width="50%"><font size="1" face="Verdana">Name:<br>
    <input type="text" name="name" size="20"></font></td>
          <td width="50%"><font size="1" face="Verdana">  
      Team:<select size="1" name="team">
     <option value="1">team1</option>
     <option value="2">team2</option>


      </select></font></td>
          <td width="100%"><font size="1" face="Verdana">Tries:<br>

    <input type="text" name="tries" size="5">

    </font></td>
          <td width="100%"><font size="1" face="Verdana">F Goals:<br> 
    <input type="text" name="goals" size="5"></font></td>
          <td width="100%"><font size="1" face="Verdana">Goals:<br> <input type="text" name="fgoals" size="5"></font></td>
          <td width="100%"><font size="1" face="Verdana">Total:<br> <input type="text" name="total" size="5"></font></td>
      
        </tr>
      </table>
      <p>



      <input type="submit" value="Submit New Stat Data" name="B1"></p>
    </form>

    <?php

    }


    ?>

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: this will not add to my database

    Originally posted by kiwis
    PHP Code:
    $result mysql_query ("INSERT INTO DB_Stats Values ('','$name','$team,'$tries,'$goals','$fgoals','$total')"); 
    Your SQL query is full of errors. It is always good practice to check your query has succeed and not just assume that it will as it is not only SQL errors which can cause it to fail. Use this code and it will tell you were your errors are:
    PHP Code:
    if (! mysql_query ("INSERT INTO DB_Stats Values ('','$name','$team,'$tries,'$goals','$fgoals','$total')"))
      die (
    'Query Failed: ' mysql_error()); 
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139
    this error

    Query Failed: You have an error in your SQL syntax near '1,'1','1','1')' at line 1

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Your quotes are out of sync. Each value should be enclosed in single quotes; some of them are not.

    Query Failed: You have an error in your SQL syntax near '1,'1','1','1')' at line 1

    In your PHP script:
    "INSERT INTO DB_Stats Values ('','$name','$team,'$tries,'$goals','$fgoals','$total');"
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2003
    Location
    Auckland
    Posts
    1,139
    sweet that works well now

    hey i'm displaying all the records in my database and just looping them over and over so I can edit the whole lot on one page. once I have change the information do we just run a script like this

    PHP Code:
    if (! mysql_query ("UPDATE DB_Stats Values ('','$name','$team','$tries','$goals','$fgoals','$total')")) 
      die (
    'Query Failed: ' mysql_error()); 

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