Forum Sementara Putera.com

Bersama kita perkemaskan forum ini sementara forum asal dalam pemulihan.

Forum putera dah kembali. Masalah sudah berjaya diselesaikan. Sila lawati http://forum.putera.com/tanya


    probz update

    Share

    syira86
    Ahli Baharu
    Ahli Baharu

    Gender : Female Number of posts : 108
    Age : 30
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    probz update

    Post by syira86 on Wed Oct 21, 2009 4:08 pm

    salam...nk tnye ape mlsh edit.php...bla nk update ...juz kuar info title shje...description n image xkuar..tp ia msuk dlm databse if sy update ,cume bla display kt edit.php je , ia jdi blank for image n description...cmne nk atsi mslh nie..harap abg2 n kak2 kt cni dpt bantu sy

    nie code

    Code:

    <html>
    <head></head>
    <body>
    <!-- standard page header -->
    <?php




    //open database connection
    //var utk database
       $username = 'root';
       $password = '';
       $database = 'suke';
       $con = mysql_connect('localhost',$username,$password) or die ("Error connecting to database");
            $sel = mysql_select_db($database) or die ("Error selecting database");

    // generate and execute query
    $id = $_GET['id'];
    $query = ("SELECT title,image,description FROM pic WHERE id = '$id'");
    $result = mysql_query($query)
    or die ("Error in query: $query. " . mysql_error());
    // if a result is returned
    if (mysql_num_rows($result) > 0)
    {
    // turn it into an object
    $row = mysql_fetch_object($result);

    ?>
    <table cellspacing="5" cellpadding="5">
    <form method="POST" action="update.php">
    <input type="hidden" name="id" value="<?php echo $id; ?>">
    <tr>
    <td valign="top"><b><font size="-1">Title</font></b></td>
    <td>
    <input size="50" maxlength="250" type="text" name="title"
    value="<?php echo $row->title; ?>">
    </td>
    </tr>
    <tr>
    <td valign="top"><b><font size="-1">Description</font></b></td>
    <td>
    <textarea name="description" cols="40" rows="10"
    value="<?php echo $row->description; ?>"></textarea>
    </td>
    </tr>
    <tr>
    <td valign="top"><font size="-1">Image</font></td>
    <td>
    <input type="file" name="myfile" size="45"
    value="<?php echo $row->image; ?>">

    </td>
    </tr>
    <tr>
    <td colspan=2>
    <input type="Submit" name="submit" value="submit">
    </td>
    </tr>
    </form>
    </table>
    <?php
    }
    // no result returned
    // print graceful error message
    else
    {
    echo '<font size=-1>That press release could not be located ↵
    in our database.</font>';
    }

    ?>
    <!-- standard page footer -->
    </body>
    </html>

    Farlee
    Ahli Baharu
    Ahli Baharu

    Gender : Male Number of posts : 38
    Age : 33
    Location : Kuala Lumpur, Kuala Terengganu (Malaysia)
    Job/hobbies : Looking at Computer
    Registration date : 16/03/2009

    Re: probz update

    Post by Farlee on Wed Oct 21, 2009 4:52 pm

    syira86 wrote:
    Code:

    ...
    <tr>
    <td valign="top"><b><font size="-1">Description</font></b></td>
    <td>
    <textarea name="description" cols="40" rows="10"
    value="<?php echo $row->description; ?>"></textarea>
    </td>
    </tr>
    ...
    textarea tak kuar value mcm tu... kena letak echo antara dua tag <textarea>

    Code:
    <textarea name="description" cols="40" rows="10">
    <?php echo $row->description; ?>
    </textarea>

    syira86 wrote:
    Code:

    ...
    <tr>
    <td valign="top"><font size="-1">Image</font></td>
    <td>
    <input type="file" name="myfile" size="45"
    value="<?php echo $row->image; ?>">
    ...
    yg ini x paham... nk view as nama file ke atau imej?

    ayoi
    Moderators
    Moderators

    Gender : Male Number of posts : 1090
    Age : 86
    Registration date : 04/03/2009

    Re: probz update

    Post by ayoi on Wed Oct 21, 2009 5:02 pm

    letak double quotes

    $username = 'root';
    $password = '';
    $database = 'suke';

    "root"
    ""
    "suke"


    --------------------------------------------
    ku mencuba survey
    Don't break my heart

    syira86
    Ahli Baharu
    Ahli Baharu

    Gender : Female Number of posts : 108
    Age : 30
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Re: probz update

    Post by syira86 on Wed Oct 21, 2009 5:08 pm

    Farlee...sy nk view sbgai image

    syira86
    Ahli Baharu
    Ahli Baharu

    Gender : Female Number of posts : 108
    Age : 30
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Re: probz update

    Post by syira86 on Wed Oct 21, 2009 5:13 pm

    kt form description kuar bnde nie

    Code:
    <br />
    <b>Notice</b>:  Trying to get property of non-object in <b>C:\wamp\www\suke\suke\edit.php</b> on line <b>45</b><br />
    [url][/url]

    ayoi
    Moderators
    Moderators

    Gender : Male Number of posts : 1090
    Age : 86
    Registration date : 04/03/2009

    Re: probz update

    Post by ayoi on Wed Oct 21, 2009 7:15 pm

    bagi code upload edit ngan form html... senang citer nak tau kat mana errror...

    rasa macam takde header utk image file type

    aku guna cam ni je
    Code:
    <?
    if ($submit) {

    // connect to the database

    $connect=mysql_connect("localhost","user","pass");
    mysql_select_db("test", $connect);

    $data = addslashes(fread(fopen($form_data, "rb"), $form_data_size));

    $result=MYSQL_QUERY("INSERT INTO images (description,image,filename,filesize,filetype) ".
    "VALUES ('$form_description','$data','$form_data_name','$form_data_size','$form_data_t ype')");
    $id= mysql_insert_id();
    print "<p>This file has the following Database ID: <b>$id</b>";
    echo "<BR>$form_data_name";
    echo "<BR>$form_data_type";
    MYSQL_CLOSE();
    }
    ?>

    utk get image


    Code:
    <?
    if($id) {
    $connect=mysql_connect("localhost","user","pass");
    mysql_select_db("test", $connect);
    $query = "select * from images where id=$id";
    $result = mysql_query($query, $connect);
    $row = mysql_fetch_array($result);
    $size = $row["filesize"];
    $name = $row["filename"];
    $data = $row["image"];
    $type = $row["filetype"];
    Header("Content-disposition: filename=".$name);
    Header("Content-type: $type");
    Header("Content-length: $size");
    echo $data;

    };
    ?>

    sebab aku kurang ingat php aku guna Xselerator
    try la Xselerator

    * code di atas generate php ke ?


    --------------------------------------------
    ku mencuba survey
    Don't break my heart

    syira86
    Ahli Baharu
    Ahli Baharu

    Gender : Female Number of posts : 108
    Age : 30
    Location : kedah
    Job/hobbies : explore
    Registration date : 04/03/2009

    Re: probz update

    Post by syira86 on Thu Oct 22, 2009 2:53 pm

    a'ah code php..........sy dah blur sgt nape kt textarea n image upload 2 ade mslh bla nk update

    Sponsored content

    Re: probz update

    Post by Sponsored content Today at 11:57 am


      Current date/time is Thu Dec 08, 2016 11:57 am