Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9

Thread: wont INSERT

  1. #1
    Junior Member Colicab's Avatar
    Join Date
    Apr 2003
    Posts
    15
    Member #
    1112
    Hi all ive been codin away.. anyway i seem to have gotten a bit stuck.
    does any one know why this isnt inserting new avlues into the databse table?

    PHP Code:

    <?php
    /////////////////////////
    // TEMP RAS NEWS
    /////////////////////////
    error_reporting(E_ALL);

    function 
    css(){
    echo (
    "<link rel=\"stylesheet\" href=\"http://localhost/ras/cp.css\"></head>");
    }

    //CONFIG/////////////////
    $title "Ras News";
    $main_pass "raspost";
    $dated date("D the j of M Y");
    $newslast "5";
    $dbserver "localhost";
    $dbuser "root";
    $dbpass "password";
    $dbname "ib";
    /////////////////////////

    //NEWS On/Off ///////////
    $news_system "off";
    /////////////////////////

    //PHP REGISTER GLOBALS //
    $register_globals "on";
    /////////////////////////

    echo ("<html><head><title>$title</title>");
    css();

    if(
    $register_globals=="on")
    {
    $action $HTTP_GET_VARS['action'];
    }

    if(
    $news_system=="on")
    {

            
    $conn = @mysql_connect($dbserver,$dbuser,$dbpass) or die("Unable to Make Base Mysql Connection");
            
    $slectdb = @mysql_select_db($dbname,$conn) or die("Invalid Database Given");

            if(
    $action=="")
            {
            
    $action "show";
            }
            
    ///////////// DEFUALT PAGE ///////////////////////
            
    if($action=="post")
            {
            
    ?>

             <center><b>Add News Item</b><br><br>
             <form action="news.php" method="post">
             Name: <input type="text" name="username"
             size="30" value="username"><br>
             Pass: <input type="text" name="pass"
             size="30" value="pass"><br>
             Title: <input type="text" name="title"
             size="30" value="title"><br><br>
             News Post<br><textarea name="post"
             cols="30" rows="5"></textarea><br>
             <input type="submit" name="submit" value="submit"></form>
            



            <?
            
    if($pass=="$main_pass")
            {
            
    $add "INSERT INTO rasnewstemp (id, title, post, dated, username)
    values ( NULL, \"
    $title\", \"$post\", \"$dated\", \"$username\" )";
            
    $add_news mysql_query($add,$conn);
            if(
    $add_news != null){
            
    $action="submitted";
            }


            }

            if(
    $action=="submitted")
            {
            
    $page2 "<center><b>News submited thank you $username</b></center>";
            
    $page2.= "<br>To View your news click <a href=\"index.php?action=show\">here</a>";

            echo (
    "$page2");
            }
            }
            

            
            
    /////////////////////////////////////////////////////
            
            ///////////// SHOW NEW ARTCILES /////////////////////
            
    if($action=="show")
            {
            
    $paget "<center>Latest news</center><br><hr><br>";
            echo(
    "$paget");
            
            
    $showpost mysql_query("SELECT * FROM rasnewstemp ORDER BY id desc LIMIT $newslast");

                        while(
    $r mysql_fetch_array($showpost)){

                        
    $id=$r['id'];

                        
    $dated=$r['dated'];

                        
    $post=$r['post'];
                        
                        
    $title=$r['title'];

                        
    $username=$r['username'];

                    }
                    
                    
    $page3 "$title - posted $dated<br>";
                    
    $page3.= "$post<br>";
                    
    $page3.= "- $username<hr><br>";

                    echo 
    "$page3";
            }
            
    /////////////////////////////////////////////////////
            
            ///////////// INSTALL PAGE //////////////////////////
            
    if($action=="install")
            {
            
    $page4 "<b>Install Ras News<b><hr><br>";
            echo(
    "$page4");

            
    $query mysql_query ("CREATE TABLE rasnewstemp (id smallint(5) unsigned
    DEFAULT '0' NOT NULL auto_increment,title varchar(60) NOT NULL,post varchar(100)
    NOT NULL,user varchar(60)
    NOT NULL,dated varchar(100) NOT NULL,PRIMARY KEY (id))"
    )
    or die (
    "Couldnt create News Table");

                    if(
    $query != "")
                    {
                    echo (
    "News System Installed");
                    }

            }
            
    /////////////////////////////////////////////////////
            
    //////////
    }
    else
    {
    $off "<b>NEWS SYSTEM TURNED OFF!!</b><br>";
    $off.= "To turn it on please edit the news config";
    echo (
    "$off");
    }

    ?>
    I know its a bit lengthy etc but hey if you can fix it then be my giest and use it

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    And the error is...?
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Junior Member Colicab's Avatar
    Join Date
    Apr 2003
    Posts
    15
    Member #
    1112
    it just wont insert the data to the databse

    does any one know why this isnt inserting new avlues into the databse table?

  5. #4
    Senior Member iphong's Avatar
    Join Date
    Mar 2003
    Location
    Arlington, VA
    Posts
    751
    Member #
    916
    Use this one for the insert query:
    PHP Code:
    mysql_query("insert into table(field1, field2, field3)" "values('text1', 'text2', 'text3')"); 
    i get everything done with that.
    Vu Tuan Phong
    iPhongDesign

    http://iphong.com
    http://adstudio1.com

  6. #5
    Senior Member iphong's Avatar
    Join Date
    Mar 2003
    Location
    Arlington, VA
    Posts
    751
    Member #
    916
    "INSERT INTO rasnewstemp (id, title, post, dated, username) values ( NULL, \"$title\", \"$post\", \"$dated\", \"$username\" )"
    i think there is something wrong with this query?? i dont know but you can try mine
    Vu Tuan Phong
    iPhongDesign

    http://iphong.com
    http://adstudio1.com

  7. #6
    Junior Member
    Join Date
    Oct 2006
    Posts
    1
    Member #
    14156
    I would put a test line near your insert statement to make sure the post data is being sent.
    Firefox can cause problems

  8. #7
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    Digging a bit deep into the archives, aren't we? ;-)

  9. #8
    Senior Member karinne's Avatar
    Join Date
    Dec 2003
    Location
    Aylmer QC Canada
    Posts
    1,607
    Member #
    4335
    Liked
    8 times
    And since he/she(?) brought it back, what does a browser have to do with PHP?
    [a web design portfolio - Currently NOT AVAILABLE for work | web design | Re-coding | PSD-to-HTML]
    I'm also on: virb - facebook - twitter - flickr - del.icio.us

  10. #9
    Senior Member karinne's Avatar
    Join Date
    Dec 2003
    Location
    Aylmer QC Canada
    Posts
    1,607
    Member #
    4335
    Liked
    8 times
    And since he/she(?) brought it back, what does a browser have to do with how PHP is sending the info to the db?
    [a web design portfolio - Currently NOT AVAILABLE for work | web design | Re-coding | PSD-to-HTML]
    I'm also on: virb - facebook - twitter - flickr - del.icio.us


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 10:41 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com