SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Post Update Image against URL ID

    Dear
    I am not good in PHP but I try following code to insert or update image against URL ID but when I check in database no updation or insertion found. Kindly check the code may be coding error is it.I have two pages. add.html and insert.php

    URL script is <a href="insert.php?property_id=$property_id" class="txt_content03_bold">Add Photos</a>&nbsp;&nbsp;&nbsp;</td>

    URL code is http://www.mysite.com/insert.php?property_id=6

    add.html is as follow

    HTML Code:
    <html>
    <form enctype="multipart/form-data" action="insert.php" method="post" name="changer">
    <input name="MAX_FILE_SIZE" value="102400" type="hidden">
    <input name="image" accept="image/jpeg" type="file">
    <input value="Submit" type="submit">
    
    </html>

    insert.php is follow


    PHP Code:
    <?php 

    include_once("add.html");
    $id $_POST['property_id'];
    $username "okokok";
    $password "okokok";
    $host "localhost";
    $database "okokok";

    // Make the connect to MySQL or die
    // and display an error.
    $link mysql_connect($host$username$password);
    if (!
    $link) {
    die(
    'Could not connect: ' mysql_error());
    }

    // Select your database
    mysql_select_db ($database);


    //$ordercode = $_POST['ordercode']; 
    //$property_id=getVal(property_id);

    if (isset($_FILES['image']) && $_FILES['image']['size'] > 0) { 


    // Temporary file name stored on the server
    $tmpName $_FILES['image']['tmp_name']; 

    // Read the file 
    $fp fopen($tmpName'r');
    $data fread($fpfilesize($tmpName));
    $data addslashes($data);
    fclose($fp);


    // Create the query and insert
    // into our database.

    $query "update qatproperty_mst set image ='$data' WHERE property_id ='$id'";

    :)
    //in URL code property_id is 6 so when I enter property_id=6 (manually) it works fine in above $query updation but when if it is like this property_id ='$id' its not getting property_id from URL and no record //was updated.property_id is primary key in the table and also auto increase.:)

    $results mysql_query($query$link);

    // Print results
    print "Thank you, your file has been uploaded.";

    }
    else {
    print 
    "No image selected/uploaded";
    }

    // Close our MySQL Link
    mysql_close($link);

    ?>
    Kindly help me and thanks in advance.
    Last edited by SpacePhoenix; Jan 16, 2011 at 00:55. Reason: placed appropriate syntax highlighting tags around code

  2. #2
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    4,904
    Mentioned
    93 Post(s)
    Tagged
    0 Thread(s)
    Your missing on the HTML form a property_id input and the php script needs to get the value for property_id from the $_POST array
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  3. #3
    SitePoint Member
    Join Date
    Jan 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by SpacePhoenix View Post
    Your missing on the HTML form a property_id input and the php script needs to get the value for property_id from the $_POST array
    How to add property_id input in HTML kindly edit html form for me..

    thank you


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
  •