SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Script won't update

    I made a newsscript, and I'm now building the update/delete news section.

    Deleting the news goes nicely, but updating doesn't.
    Here's the code of the update page:
    PHP Code:
    <?php
        
    include("alku.php");
        include(
    "login.php");
        include(
    "config.inc.php");



        if( empty(
    $_POST['action']) )

        {

        
    // Haetaan uutisen ID



        
    }

        else if( 
    strcasecmp($_POST['action'], "Etsi uutinen")==)

        {

        
    $result mysql_query"SELECT news_date, news_msg FROM galleria_news WHERE news_id='".addslashes($_POST['newsid'])."'" );

        
    $nr mysql_num_rows$result );



        if( 
    $nr )

        {

            echo(
    "Uutista ei löytynyt tietokannasta!");

            echo(
    "<br><a href='adminindex.php'>Palaa hallintasivulle</a>");

            exit;

        }



        
    $row mysql_fetch_array$result );

        
    mysql_free_result$result );

        echo(
    "News ID: ".$_POST['newsid']."<br><br>");

        
    ?>



    <form name="news_edit" action="edit_news.php" method="post">

    <b>Muokkaa/poista uutinen:</b><br />

    Päivitä päivämäärä: <input type="text" name="date" value="<?php echo($row["news_date"]); ?>" /><br />

    Päivitä uutinen: <textarea name="msg" cols="30" rows="1"> <?php echo($row["news_msg"]); ?> </textarea><br />


    <input type="hidden" value="<?php echo($_POST['newsid']); ?>" name="newsid" />

    <input type="submit" value="Submit" name="palikka" />

    </form>

    <br />



    <form name="news_delete" action="edit_news.php" method="post">

    <b>Poista uutinen:</b><br />

    <input type="hidden" value="<?php echo($_POST['newsid']); ?>" name="newsid" />

    <input type="submit" value="Delete This news?" name="action" onclick="return confirm('Oletko varma, että haluat poistaa tämän uutisen?')" />

    </form>

    <a href="adminindex.php">Palaa hallintasivulle</a>

    <?php

            
    if( strcasecmp($_POST['palikka'], "Submit") == && !empty( $_POST['newsid'] ) )

            {

            
    edit_news($_POST['newsid'], $_POST['msg'], $_POST['date']);

            }

            else

            {

                echo(
    "Toimintaa ei ymmärretty <a href='adminindex.php'>Palaa hallintasivulle</a>"); exit;

            }

            if( 
    strcasecmp($_POST['action'], "Delete this news?")==&& !empty( $_POST['newsid'] ) )

            {

                
    delete_news($_POST['newsid']);

            }

            else

            {

                echo(
    "Toimintaa ei ymmärretty <a href='adminindex.php'>Palaa hallintasivulle</a>"); exit;

            }



            echo(
    "Toiminto suoritettu!");

            echo(
    "<br><a href='adminindex.php'>Palaa hallintasivulle</a>");

        }



    // funktiot

    function edit_news$uutinen_id$new_msg$new_date )

    {

    mysql_query"UPDATE galleria_news SET news_msg='".addslashes$new_msg )."', news_date='".addslashes$new_date )."' WHERE news_id='".addslashes$uutinen_id )."'"  );

    }



    function 
    delete_news($news_id)

    {

    mysql_query("

       DELETE FROM galleria_news

       WHERE news_id='" 
    addslashes($news_id) . "'

    "
    );

    }

    ?>
    <?php
    include("loppu.php");
    ?>
    When I try to submit the update, I only get a blank page, no errors.
    That's why I'm not sure what is wrong.
    Help is appreciated. Thanks.

  2. #2
    Tranceoholic lilleman's Avatar
    Join Date
    Feb 2004
    Location
    Örebro, Sweden
    Posts
    2,716
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Does this give you an error message?

    PHP Code:
    mysql_query"UPDATE galleria_news SET news_msg='".addslashes$new_msg )."', news_date='".addslashes$new_date )."' WHERE news_id='".addslashes$uutinen_id )."'"  ) or die('Query failed: 'mysql_error()); 
    ERIK RIKLUND :: Yes, I've been gone quite a while.

  3. #3
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No, it won't, only a blank page again. So it seems, it won't get that far.


Bookmarks

Posting Permissions

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