Results 1 to 10 of 10
  1. #1
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default [PHP] Doesn't update mySQL

    It's a code with 3 text boxes, when someone presses 'submit' it doesn't edit the mySQL. +rep to all help/suggestions.

    PHP Code:
    <?php
    include "mainsite_config.php";

    $action $_GET ["action"];
    if (
    $action == "update_settings") {
        
    $site_title $_POST ["title"];
        
    $welcome_content $_POST ["welcome_content"];
        
    $logo $_POST ["logo"];
        
        
    mysql_query ("update settings SET logo = '$logo', update settings SET welcome_content = '$welcome_content', update settings SET title = '$title'");
        
    echo 
    "Site settings updated. <meta http-equiv=\"refresh\" content=\"2;url=settings.php\">";

        }
        
        else {
    ?>
    <form action="?action=update_settings" method="post">
    <label>Site Title - <span>this is the title your browser displays for your website.</span></label><br />
    <input class="textbox" name="title" type="text" value="<?php
    include "mainsite_config.php";

    $sql "SELECT * FROM settings";
    $check mysql_query("SELECT title FROM settings") or die("There is currently no title. Edit this with your own.");

    while (
    $display mysql_fetch_array($check)) {

        
    $title $display['title'];
        echo 
    "$title";
        }
    ?>"/><br />
    <br />
    <label>Main Content - <span>this is the text you see when you navigate to the homepage, above the news.</span></label>
    <textarea class="textarea" name="welcome_content" type="text">
    <?php
    include "mainsite_config.php";

    $sql "SELECT * FROM settings";
    $check mysql_query("SELECT welcome_content FROM settings") or die("There is currently no welcome content. Edit this with your own.");

    while (
    $display mysql_fetch_array($check)) {

        
    $welcome $display['welcome_content'];
        echo 
    "$welcome";
        }
    ?>
    </textarea><br />
    <br />
    <label>Logo - <span>this is the URL to your site's main logo, above your welcome content.</span></label>
    <input class="textbox" name="logo" type="text" value="<?php
    include "mainsite_config.php";

    $sql "SELECT * FROM settings";
    $check mysql_query("SELECT logo FROM settings") or die("You have no logo URL. Edit this with your own.");

    while (
    $display mysql_fetch_array($check)) {

        
    $logo $display['logo'];
        echo 
    "$logo";
        }
    ?>"/><br />
    <br />
    <input class="submit" type="submit" value="Update Settings"  class="textbox" />
    </form>
    <?php ?>

  2. #2
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    PHP Code:
    <?php
    include "mainsite_config.php";

    $action $_GET ["action"];
    if (
    $action == "update_settings") {
        
    $site_title $_POST ["title"];
        
    $welcome_content $_POST ["welcome_content"];
        
    $logo $_POST ["logo"];
        
        
    mysql_query ("update settings SET logo = '$logo', welcome_content = '$welcome_content', title = '$title'");
        
    echo 
    "Site settings updated. <meta http-equiv=\"refresh\" content=\"2;url=settings.php\">";

        }
        
        else {
    ?>
    <form action="?action=update_settings" method="post">
    <label>Site Title - <span>this is the title your browser displays for your website.</span></label><br />
    <input class="textbox" name="title" type="text" value="<?php
    include "mainsite_config.php";

    $sql "SELECT * FROM settings";
    $check mysql_query("SELECT title FROM settings") or die("There is currently no title. Edit this with your own.");

    while (
    $display mysql_fetch_array($check)) {

        
    $title $display['title'];
        echo 
    "$title";
        }
    ?>"/><br />
    <br />
    <label>Main Content - <span>this is the text you see when you navigate to the homepage, above the news.</span></label>
    <textarea class="textarea" name="welcome_content" type="text">
    <?php
    include "mainsite_config.php";

    $sql "SELECT * FROM settings";
    $check mysql_query("SELECT welcome_content FROM settings") or die("There is currently no welcome content. Edit this with your own.");

    while (
    $display mysql_fetch_array($check)) {

        
    $welcome $display['welcome_content'];
        echo 
    "$welcome";
        }
    ?>
    </textarea><br />
    <br />
    <label>Logo - <span>this is the URL to your site's main logo, above your welcome content.</span></label>
    <input class="textbox" name="logo" type="text" value="<?php
    include "mainsite_config.php";

    $sql "SELECT * FROM settings";
    $check mysql_query("SELECT logo FROM settings") or die("You have no logo URL. Edit this with your own.");

    while (
    $display mysql_fetch_array($check)) {

        
    $logo $display['logo'];
        echo 
    "$logo";
        }
    ?>"/><br />
    <br />
    <input class="submit" type="submit" value="Update Settings"  class="textbox" />
    </form>
    <?php ?>


  3. #3
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    Now, instead of updating the mySQL it deletes it.

  4. #4
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    link mainsite config, also for good practice, take it out of all ifs, and replace it above, unless theres anything not needing it,....

    edit: poor coding ;S

    whats this doing
    PHP Code:
    $sql "SELECT * FROM settings"//this aint doing anything, i see nothing using it :S 
    </span>
    Last edited by Hypertext; 14-02-2008 at 12:59 AM.
    How could this hapen to meeeeeeeeeeeeeee?lol.

  5. #5
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    Yeah, I know that isn't doing anything. Why at the end of your post does it say "</span>".

    Here's my mainsite_config:
    PHP Code:
    <?php
    $conn 
    mysql_connect("localhost","blackwal_main","site"); 
    mysql_select_db(blackwal_steep) or die(mysql_error());
    ?>
    That shouldn't be it though, that's worked for every script I've created.

  6. #6
    Join Date
    Sep 2006
    Location
    Evanston, Illinois.
    Posts
    2,361
    Tokens
    0

    Latest Awards:

    Default

    try
    PHP Code:
    <?php
    include "mainsite_config.php";

    $action $_GET ["action"];
    if (
    $action == "update_settings") {
        
    $site_title $_POST ["title"];
        
    $welcome_content $_POST ["welcome_content"];
        
    $logo $_POST ["logo"];
        
        
    mysql_query ("update settings SET logo = '$logo', update settings SET welcome_content = '$welcome_content', update settings SET title = '$title'");
        
    echo 
    "Site settings updated. <meta http-equiv=\"refresh\" content=\"2;url=settings.php\">";

        }
        
        else {
    ?>
    <form action="?action=update_settings" method="post">
    <label>Site Title - <span>this is the title your browser displays for your website.</span></label><br />
    <input class="textbox" name="title" type="text" value="<?php
    include "mainsite_config.php";

    $sql "SELECT * FROM settings";
    $check mysql_query("SELECT title FROM settings") or die("There is currently no title. Edit this with your own.");

    while (
    $display mysql_fetch_array($check)) {

        
    $title $display['title'];
        echo 
    "$title";
        }
    ?>"/><br />
    <br />
    <label>Main Content - <span>this is the text you see when you navigate to the homepage, above the news.</span></label>
    <textarea class="textarea" name="welcome_content" type="text">
    <?php
    include "mainsite_config.php";

    $sql "SELECT * FROM settings";
    $check mysql_query("SELECT welcome_content FROM settings") or die("There is currently no welcome content. Edit this with your own.");

    while (
    $display mysql_fetch_array($check)) {

        
    $welcome $display['welcome_content'];
        echo 
    "$welcome";
        }
    ?>
    </textarea><br />
    <br />
    <label>Logo - <span>this is the URL to your site's main logo, above your welcome content.</span></label>
    <input class="textbox" name="logo" type="text" value="<?php
    include "mainsite_config.php";

    $sql "SELECT * FROM settings";
    $check mysql_query("SELECT logo FROM settings") or die("You have no logo URL. Edit this with your own.");

    while (
    $display mysql_fetch_array($check)) {

        
    $logo $display['logo'];
        echo 
    "$logo";
        }
    ?>"/><br />
    <br />
    <input class="submit" type="submit" value="update_settings"  class="textbox" />
    </form>
    <?php ?>
    How could this hapen to meeeeeeeeeeeeeee?lol.

  7. #7
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    No, that didn't do anything.

  8. #8
    Join Date
    Oct 2007
    Location
    Luton, England
    Posts
    1,548
    Tokens
    388
    Habbo
    DeejayMachoo

    Latest Awards:

    Default

    Quote Originally Posted by loserWILL View Post
    No, that didn't do anything.
    why do you include mainsite_config.php twice?


  9. #9
    Join Date
    Oct 2006
    Location
    Peterborough, UK
    Posts
    3,855
    Tokens
    216

    Latest Awards:

    Default

    Use this code, and don't do ******ed styling, use:
    textarea {
    /*
    style for textarea here
    */
    }
    input {
    /*
    style for input here
    */
    }
    instead of classes unless you're doing that differently

    PHP Code:
    <?php

    include( "mainsite_config.php" );
    if( 
    $_GET["action"] == "update_settings" )
    {
        
    $title $_POST["title"];
        
    $content $_POST["content"];
        
    $logo $_POST["logo"];
        @
    mysql_query"UPDATE `settings` SET `welcome_content` = '$content', `logo` = '$logo', `title` = '$title'" );
    }
    else 
    {
        
    $fetch = @mysql_fetch_arraymysql_query"SELECT * FROM `settings`" ) );
        
    $title $fetch["title"];
        
    $content $fetch["welcome_content"];
        
    $logo $fetch["logo"];
    }
    $html = <<<HTML
        <form action="?action=update_settings" method="post">
        Site Title - this is the title your browser displays for your website.<br />
        <input name="title" type="text" value="
    $title" />
        <br />
        <br />
        Main Content - this is the text you see when you navigate to the homepage, above the news.
        <textarea name="welcome_content">
        
    $content
        </textarea><br />
        <br />
        Logo - this is the URL to your site's main logo, above your welcome content.
        <input name="logo" type="text" value="
    $logo" />
        <br />
        <br />
        <input type="submit" value="Update Settings" />
        </form>
    HTML;

        echo( 
    $html );

    ?>
    note: HTML; has to be the first thing on the line (you can't have ANY spaces or tabs before it)


    visit my internet web site on the internet
    http://dong.engineer/
    it is just videos by bill wurtz videos you have been warned

  10. #10
    Join Date
    Dec 2007
    Location
    Toronto, Ontario, Canada
    Posts
    689
    Tokens
    0

    Default

    Thanks, I mixed my code with a couple of things your code had and it worked. +rep to all.

Posting Permissions

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