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> </td>
URL code is http://www.mysite.com/insert.php?property_id=6
add.html is as follow
<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
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($fp, filesize($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.