Results 1 to 6 of 6

Thread: this does not add

  1. #1

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

    this does not add

    Does anyone know why this doe not work?
    nothing adds to my database and i can not see a error in my code

    PHP Code:

    ---------------------------------------------------------------------------------
     <?php 
    mysql_connect 
    (localhostusernamepass); 
    mysql_select_db (table); 
    ?> 

    <?php 


    if ($action == "save"


         
    $result mysql_query ("INSERT INTO news Values  ('','$header','$from','$IMG,'$body','$source','$re
     sult_id','
    $WRE','$AKL','$TRG','$PMR','$NPL','$WLG'
    ,'
    $OHA','$CHC','$DUD','$NZK','$NZW','$NZI','$AGE',
    '
    $EDI','$BCC','$BULLS','$FLA','$REP')"); 



    ?> 


    <title>Rugby League in New Zealand Admin - Add News</title> 


    <br> 
    <font face="Verdana"> 
    <strong><font size="2">All Done!<br> 
    </font> 
    </strong><font size="2">The news item has been added.<br> 
    &nbsp;</font></font></font></p> 
    <p><font face="Verdana" 
    size="2"><a style="text-decoration: none" href="index.php">Return to the main menu</a> 

    <?php 


    } else { 

    ?> 
    <p> 

    <font face="Verdana" size="1"> 
    <a style="text-decoration: none" href="index.php">Back to the main</a></font><p> 
    <font face="Verdana" size="1">If you have any questions please contact 
    <a style="text-decoration: none" href="mailto:[email protected]">Bevan</a></font><hr> 
    <font face="Verdana" size="2"> 

    <form method="POST" action="addnews.php?action=save"> 
       


    <font face="Verdana" size="2">Header: <br><input name="header" size="40" style="font-family: Verdana; border-style: solid; border-width: 1px"></font><p> 

    <font face="Verdana" size="2">From:<br> <input name="from" size="40" style="font-family: Verdana; border-style: solid; border-width: 1px"></font><p> 

    <font face="Verdana" size="2">Image:<br> <input name="IMG" size="40" style="font-family: Verdana; border-style: solid; border-width: 1px"></font><p> 

    <font face="Verdana" size="2">Body: <br><textarea rows="10" name="body" cols="77" style="font-family: Verdana; border-style: solid; border-width: 1px"></textarea> 

    <font face="Verdana" size="2">Source:<br> <input name="source" size="40" style="font-family: Verdana; border-style: solid; border-width: 1px"></font><p> 

    <font face="Verdana" size="2">Result ID:<br> <input name="result_id" size="40" style="font-family: Verdana; border-style: solid; border-width: 1px"></font><p> 





    <p> 
    <input type="checkbox" value="1" name="WRE"> Northland <br> 
    <input type="checkbox" value="1" name="AKL"> Auckland <br> 
    <input type="checkbox" value="1" name="TRG"> Waicoa Bay <br> 
    <input type="checkbox" value="1" name="PMR"> Western Alliance <br> 
    <input type="checkbox" value="1" name="NPL"> Taranaki <br> 
    <input type="checkbox" value="1" name="WLG"> Wellington <br> 
    <input type="checkbox" value="1" name="OHA"> Defence <br> 
    <input type="checkbox" value="1" name="CHC"> Canterbury RL <br> 
    <input type="checkbox" value="1" name="DUD"> Southern Alliance <br> 
    <input type="checkbox" value="1" name="NZK"> New Zealand Kiwis <br> 
    <input type="checkbox" value="1" name="NZW"> New Zealand Warriors <br> 
    <input type="checkbox" value="1" name="NZI"> New Zealand International <br> 
    <input type="checkbox" value="1" name="AGE"> Age Groups <br> 
    <input type="checkbox" value="1" name="EDI"> Editorials <br> 
    <input type="checkbox" value="1" name="BCC"> Bartercard Cup <br> 
    <input type="checkbox" value="1" name="BULLS"> Canterbury Bulls <br> 
    <input type="checkbox" value="1" name="FAL"> Central Falcons <br> 
    <input type="checkbox" value="1" name="REP"> Rep Footie 



      <p align="center"> 
          <br><br> 

      <input type="submit" value="Save" name="B1" style="border-style: solid; border-width: 1px"></p> 
    </form> 

    <?php 




    ?> 
    </body> 
    </font> 
    </html> 
    --------------------------------------------------------------------------------

    and my table is set up like this

    CREATE TABLE `news` (
    `id` int(10) NOT NULL auto_increment,
    `header` varchar(250) NOT NULL default '',
    `from` varchar(250) NOT NULL default '',
    `IMG` varchar(250) NOT NULL default '',
    `body` text NOT NULL,
    `source` varchar(250) NOT NULL default '',
    `result_id` int(11) default NULL,
    `WRE` int(11) default NULL,
    `AKL` int(11) default NULL,
    `TRG` int(11) default NULL,
    `PMR` int(11) default NULL,
    `NPL` int(11) default NULL,
    `OHA` int(11) default NULL,
    `WLG` int(11) default NULL,
    `CHC` int(11) default NULL,
    `DUD` int(11) default NULL,
    `NZK` int(11) default NULL,
    `NZW` int(11) default NULL,
    `NZI` int(11) default NULL,
    `AGE` int(11) default NULL,
    `EDI` int(11) default NULL,
    `BCC` int(11) default NULL,
    `BULLS` int(11) default NULL,
    `FAL` int(11) default NULL,
    `REP` int(11) default NULL,
    KEY `id` (`id`)
    ) TYPE=MyISAM AUTO_INCREMENT=2 ;

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Use mysql_error() after executing tthe query.
    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
    Originally posted by visualAd
    Use mysql_error() after executing tthe query.
    it's all ok, i dont get a error

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by kiwis
    it's all ok, i dont get a error
    How do you know that if you're not using mysql_error()?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906
    Originally posted by kiwis
    it's all ok, i dont get a error
    If I were MySql and you sent me your query, I would give you an error. You have posted queries with similar errors several times before, I and others have also shown you how to use the error checking functions.

    Use the SQL parser to check you queries not VBF members

    Heres what you need to do:
    PHP Code:
    $result mysql_query ("INSERT INTO news Values  ('','$header','$from','$IMG,'$body','$source','$re
     sult_id','
    $WRE','$AKL','$TRG','$PMR','$NPL','$WLG'
    ,'
    $OHA','$CHC','$DUD','$NZK','$NZW','$NZI','$AGE',
    '
    $EDI','$BCC','$BULLS','$FLA','$REP')");
       
    if (! 
    $result) die (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.

  6. #6
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    It might be smart to get familiar with the addslashes() and stripslashes() functions as well. If someone enters a ' into one of the text fields, it's going to cause an error in your query when it gets run to MySQL.

    That might be the problem you're having now.
    My evil laugh has a squeak in it.

    kristopherwilson.com

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