• 0

Uploading Photos, creating directory and updating row in table.


Question

I am trying to update a table row by adding photos. Now everything in the code below works, except it cannot work fully until I can get the $name = $_GET['name']; to read from the row in the table. If someone can help get it to detect this part then the rest should work.

These are the errors I get because I do not have the name displaying from the property details when creating the directory.

Warning: mkdir(http://www.site.com/photos/properties/username/) [function.mkdir]: No such file or directory in 

/home/account/public_html/panel/write-photos.php on line 158

Warning: move_uploaded_file(http://www.site.com/photo/properties/username/) [function.move-uploaded-file]: failed to open 

stream: HTTP wrapper does not support writeable connections. in /home/account/public_html/panel/write-photos.php on line 160

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpv1BtAb' to 

'http://www.site.com/photo/properties/username/' in /home/account/public_html/panel/write-photos.php on line 160

Warning: chmod() [function.chmod]: No such file or directory in /home/account/public_html/panel/write-photos.php on line 161

If you read the code below carefully you will see that the other POST fields are there becuase they are not to be overwritten.

This is the full page:-

<?
$sql = mysql_query("SELECT * FROM properties WHERE property_id='$id' AND username = '$session->username'");
while($propertyRow = mysql_fetch_array($sql))
	{
	$id = $propertyRow['property_id'];
	$status = $propertyRow['status'];
	$saletype = $propertyRow['sale_type'];
	$category = $propertyRow['category'];
	$name = $propertyRow['name'];
	$address = $propertyRow['address'];
	$village = $propertyRow['village'];
	$long = $propertyRow['long'];
	$lat = $propertyRow['lat'];
	$department = $propertyRow['department'];
	$postcode = $propertyRow['postcode'];
	$price = $propertyRow['price'];
	$featured = $propertyRow['featured'];
	$dateentered = $propertyRow['date_entered'];
	$sec = substr($propertyRow['date_entered'],17,2);
	$minute= substr($propertyRow['date_entered'],14,2);
	$hour = substr($propertyRow['date_entered'],11,2);
	$day = substr($propertyRow['date_entered'],8,2);
	$month = substr($propertyRow['date_entered'],5,2);
	$year = substr($propertyRow['date_entered'],0,4);
	$date_entered = $day."/".$month."/".$year." ".$hour.":".$minute.":".$sec;
	}
?>
<form action="write-photos.php?mode=update&?id=<? echo $id; ?>" method="post" enctype="multipart/form-data" style="border:0px; 

padding:0px; margin:0px;">
<?
if($_GET['mode'] == "update")
	{
	$id = $_GET['property_id'];
	$name = $_GET['name'];
	///// Upload Photos /////
	foreach ($_FILES["photo"]["error"] as $key => $error) 
	{
		if ($error == UPLOAD_ERR_OK){
			$tmp_name = $_FILES["photo"]["tmp_name"][$key];
			$photo = $_FILES["photo"]["file"][$key];
			mkdir("$SITEurl/photos/properties/$session->username/$name",0777);
			$file = preg_replace("/([^a-z0-9])+/i", "-", $photo);
			move_uploaded_file($tmp_name, "$SITEurl/photo/properties/$session->username/$name");
			chmod("$SITEurl/photo/properties/$session->username/$name", 0777);
			$picno = $key;
			$PHOTO[] = $photo;
			$sqlphoto = "UPDATE properties SET photo$picno = '$name' WHERE property_id = '$id'";
				if(@mysql_query($sqlphoto)){
					$msg = "Photo ".$picno." ".$photo." uploaded.</br>";
			}else{
					echo mysql_error();
			}
		}
	}
		///// Add Properties to DB /////
		$dateentered  = date("Y:m:d H:i:s");
		$status = $_POST['status'];
		$sale_type = $_POST['sale_type'];
		$category = $_POST['category'];
		$name = addslashes($_POST['name']);
		$address = $_POST['address'];
		$village = $_POST['village'];
		$lng = $_POST['lng'];
		$lat = $_POST['lat'];
		$department = $_POST['department'];
		$telephone = $_POST['telephone'];
		$mobile = $_POST['mobile'];
		$email = $_POST['email'];
		$description_fr = addslashes($_POST['description_fr']);
		$description_en = addslashes($_POST['description_en']);
		$price = $_POST['price'];
		$bedrooms = $_POST['bedrooms'];
		$bathrooms = $_POST['bathrooms'];
		$view = $_POST['view'];
		$meters = $_POST['meters'];
		$terrain = $_POST['terrain'];
		$pool = $_POST['pool'];
		$garage = $_POST['garage'];
		$garage_size = $_POST['garage_size'];
		$front_garden = $_POST['front_garden'];
		$rear_garden = $_POST['rear_garden'];
		$int_features = $_POST['int_features']; 
		$ext_features = $_POST['ext_features']; 
		$fees = $_POST['fees'];
		$tax = $_POST['tax'];
		if(isset($_POST['username']))
			{
			$username = serialize($_POST['username']);
			}else
				{
				$username = "";
				}
		if(isset($_POST['int_features']))
			{
			$int_features = serialize($_POST['int_features']);
			}else
				{
				$int_features = "";
				}
		if(isset($_POST['ext_features']))
			{
			$ext_features = serialize($_POST['ext_features']);
			}else
				{
				$ext_features = "";
				}
$sql = "UPDATE properties SET ('$id', '$session->username', '$dateentered', '$status', '$sale_type', '$category', '$name', 

'$address', '$village', '$lng', '$lat', '$department', '$postcode', '$telephone', '$mobile', '$email', '$description_fr', 

'$description_en', '$price', '', '$bedrooms', '$bathrooms', '$view', '$meters', '$terrain', '$pool', '$garage', '$garage_size', 

'$front_garden', '$rear_garden', '$int_features', '$ext_features', '$video_tour', 'no', '$fees', '$tax', '$PHOTO[1]', '$PHOTO

[2]', '$PHOTO[3]', '$PHOTO[4]', '$PHOTO[5]', '$PHOTO[6]', '$PHOTO[7]', '$PHOTO[8]', '$PHOTO[9]', '$PHOTO[10]', '$PHOTO[11]', 

'$PHOTO[12]', '', '', '', '1')";
	if(@mysql_query($sql))
	{
	$msg = "Your have succesfully added your photos to the property";
	}else{
	$msg = "There was an error uploading the photos, please contact <a href=\"mailto:[email protected]\">administrators</a> 

for help!";
	}
}
?>		
<div id="content">
	<? echo "<h3>".$msg."</h3>"; ?>
	<div id="sidebar-left">
	<ul id="post_options">
		<li class="current">Brief Details on Property</li>
		<li>ID: <? echo $id; ?><br>Name: <? echo $name; ?><br>Department: <? echo $department; ?><br>Price €<? 

echo $price; ?><br><br>Date Posted: <? echo $dateentered; ?></li>
		<li class="finish">Finished Adding Photos?</li>
		<li><select id="post_status" name="status" onchange="if (this.selectedIndex==1){this.form

['check'].style.visibility='visible'}else {this.form['check'].style.visibility='hidden'};">
			<option value="">no</option>
			<option value="">yes</option>
			</select></li>
		<li>
		<b><font color="#0099FF">Please double check your photos are in order as 
		you want them before attaching to the property.</font></b><br><br>
		<input type="checkbox" name="check" style="visibility:hidden;" onclick="this.form.Submit.disabled = !

this.checked;">Enable Save<br><br>
		<input class="save" name="Submit" type="submit" value="Save" disabled="disabled"></li>
		<li class="related"><b>Related Links</b></li>
		<li><a href="manage.php">Manage All Your Properties</a></li>
		<li><a href="manage-draft.php">View Your Drafts</a></li>
	</ul>
	</div>

	<div id="write-property">
	<script type="text/javascript">
	/* This function is called when user selects file in file dialog */
	function checkext(upload_field) 
	{
		var re_text = /\.jpeg|\.jpg/i;
		var filename = upload_field.value;
		/* Checking file type */
		if (filename.search(re_text) == -1)
		{
			alert("Please select a JPEG file.");
			upload_field.value = '';
		}
		return true;
	}
	</script>
	<table width="100%" border="0" cellpadding="0" cellspacing="4">
		<tr>
			<td>Main Photo</td>
			<td><input name="photo[1]" type="file" id="photo[1]" title="This field is required" size="30" 

onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 2</td>
			<td><input name="photo[2]" type="file" id="photo[2]" size="30" onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 3</td>
			<td><input name="photo[3]" type="file" id="photo[3]" size="30" onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 4</td>
			<td><input name="photo[4]" type="file" id="photo[4]" size="30" onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 5</td>
			<td><input name="photo[5]" type="file" id="photo[5]" size="30" onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 6</td>
			<td><input name="photo[6]" type="file" id="photo[6]" size="30" onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 7</td>
			<td><input name="photo[7]" type="file" id="photo[7]" size="30" onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 8</td>
			<td><input name="photo[8]" type="file" id="photo[8]" size="30" onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 9</td>
			<td><input name="photo[9]" type="file" id="photo[9]" size="30" onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 10</td>
			<td><input name="photo[10]" type="file" id="photo[10]" size="30" onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 11</td>
			<td><input name="photo[11]" type="file" id="photo[11]" size="30" onChange="return checkext(this)"></td>
		</tr>
		<tr>
			<td>Photo 12</td>
			<td><input name="photo[12]" type="file" id="photo[12]" size="30" onChange="return checkext(this)"></td>
		</tr>
	</table>
	</div>
</div>
<input name="MAX_FILE_SIZE" type="hidden" value="<?php echo $MAXimagesize; ?>">
</form>

This is the part that needs fixing:-

if($_GET['mode'] == "update")
	{
	$id = $_GET['property_id'];
	$name = $_GET['name'];
	///// Upload Photos /////
	foreach ($_FILES["photo"]["error"] as $key => $error) 
	{
		if ($error == UPLOAD_ERR_OK){
			$tmp_name = $_FILES["photo"]["tmp_name"][$key];
			$photo = $_FILES["photo"]["file"][$key];
			mkdir("$SITEurl/photos/properties/$session->username/$name",0777);
			$file = preg_replace("/([^a-z0-9])+/i", "-", $photo);
			move_uploaded_file($tmp_name, "$SITEurl/photo/properties/$session->username/$name");
			chmod("$SITEurl/photo/properties/$session->username/$name", 0777);
			$picno = $key;
			$PHOTO[] = $photo;
			$sqlphoto = "UPDATE properties SET photo$picno = '$name' WHERE property_id = '$id'";
				if(@mysql_query($sqlphoto)){
					$msg = "Photo ".$picno." ".$photo." uploaded.</br>";
			}else{
					echo mysql_error();
			}
		}
	}

Now if the error was to show again because of something else the warning should read like this:-

Warning: mkdir(http://www.site.com/photos/properties/username/name) [function.mkdir]: No such file or directory in

/home/account/public_html/panel/write-photos.php on line 158

Warning: move_uploaded_file(http://www.site.com/photo/properties/username/name) [function.move-uploaded-file]: failed to open

stream: HTTP wrapper does not support writeable connections. in /home/account/public_html/panel/write-photos.php on line 160

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpv1BtAb' to

'http://www.site.com/photo/properties/username/name' in /home/account/public_html/panel/write-photos.php on line 160

Warning: chmod() [function.chmod]: No such file or directory in /home/account/public_html/panel/write-photos.php on line 161

Notice name in bold, that part is not reading from the table, that is whats missing. I would really like to get this to work.

20 answers to this question

Recommended Posts

  • 0

1) you're using <? again instead of <?php. stop it stop it stop it stop it stop it. please.

2) what on earth is going on at the start, you're grabbing records from the database, then for each one overwriting the contents of load of variables, the end result of which is that you've simply copied the data from the last result...

if you're trying to do stuff for multiple records from the database, then you've failed to do so! if you're trying to do stuff for just one user then: i) add LIMIT 1 to the end of your query ii) add a check to make sure a user record has been found and if not display an error iii) and then three put $propertyRow = mysql_fetch_array($sql); within the braces and get rid of the while statement.

infact why bother extracting the data into separate variables, it's a waste of time! the data is already in an array, leave it there! if you think $propertyRow['status'] is a bit long rename the array so it's something like just $data['status']? one problem to note is when using array entries in a string, you need to wrap it in braces e.g. echo "text {$arr['data']} text";.

3) on lines 34 and 35 you're trying to get the name and id, however these are not set in the url!!!

you're also trying to get loads of other data from your form in lines 58-107 which as far as i can tell, also don't exist

you REALLY need to throw in that code i gave you previously to force all errors to display!

  • 0

Another major issue with your code, aside from what theblazingangel said is your use of the mkdir(), move_uploaded_file(), and chmod() functions. You cannot use a URL with any of these functions. You must provide the absolute (real) filesystem path. See the PHP manual page for mkdir(), chmod(), and move_uploaded_file().

  • 0

Just for the hell of it heres my pic upload script with mysql entry.

Modify it as you wish

 if (isset($_POST['submit'])) {
  $file_upload="true";
 if (isset($_FILES['userfile']['size']) &amp;&amp; $_FILES['userfile']['size']&gt;300000){
  $var = "Your uploaded file size is more than 300KB so please reduce the file size and then upload.&lt;BR&gt;";
  $file_upload="false";
}
if (isset($_FILES['userfile']['type']) &amp;&amp; !($_FILES['userfile']['type'] =="image/jpeg" OR $_FILES['userfile']['type'] =="image/png" OR $_FILES['userfile']['type'] =="image/gif")){
 $var = "Your uploaded file must be of JPG or GIF. Other file types are not allowed&lt;BR&gt;";
 $file_upload="false";
}

if($file_upload=="true") {
 $uploadfile = 'memberuploads/' . $_FILES['userfile']['name'];
 if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)){
  $var = "Successfully Uploaded";
  $image = $_FILES['userfile']['name'];
  mysql_query("UPDATE members SET image = '$image' WHERE name = '$name'");
 } 
 else {
  $var = "Failed to upload file";
 }
}
}
}

The form

&lt;form enctype="multipart/form-data" action="editpersonalpage.php?option=pic" method=POST style='padding: 0; margin: 0;'&gt;
Upload this file: &lt;input name="userfile" type="file"&gt;
&lt;input type="checkbox" name="picdefault"&gt;
&lt;span style='font-size:12;'&gt;Restore Default?&lt;br/&gt;&lt;br/&gt;
&lt;input type="submit" VALUE="Send File" name='submit'&gt;&lt;/FORM&gt;
&lt;?if (isset($var)) { echo $var; }?&gt;&lt;/span&gt;

Also i'm not sure quite whats going on with your $_FILES["photo"]["file"][$key] thing. I thought you just had to use that string without the key..? Maybe you need ' instead of " in it to.

Edited by dave164
  • 0

Ok I have fixed a number of errors for uploading the photos and it works but it still needs a bit of work as it comes up with the same error for the other 11 photos that are uploaded.

Warning: mkdir(../photos/properties/username/name/) [function.mkdir]: File exists in /home/account/public_html/panel/write-photos.php on line 138

This should not show and it should be trying to create the directory once.

Now the main problem I have once the photos have been uploaded to the directory set is that the database does not update the id with the photos filename.

There are 12 photos in total that the user can upload maximum. All 12 upload succesfully but the database does nothing with the values. Now maybe they are in the wrong place or they are not there and I have'nt realised were they are missing or something else is causing the database not to update the database with the 12 photos. Also it does not update the 'last_edit' value with the date when the user started to edit the property to add the photos. I have posted the latest code of the page below along with my property table structure. I hope some one can help me get it to work.

Property Table Structure

  `property_id` int(11) NOT NULL auto_increment,
  `username` varchar(20) collate utf8_bin NOT NULL,
  `date_entered` datetime NOT NULL default '0000-00-00 00:00:00',
  `status` varchar(20) collate utf8_bin NOT NULL default 'Draft',
  `sale_type` varchar(255) collate utf8_bin NOT NULL,
  `category` varchar(255) collate utf8_bin NOT NULL,
  `name` varchar(255) collate utf8_bin NOT NULL default '',
  `address` varchar(255) collate utf8_bin NOT NULL default '',
  `village` varchar(255) collate utf8_bin NOT NULL,
  `lng` float(10,6) NOT NULL,
  `lat` float(10,6) NOT NULL,
  `department` varchar(255) collate utf8_bin NOT NULL,
  `postcode` varchar(255) collate utf8_bin NOT NULL,
  `telephone` varchar(255) collate utf8_bin NOT NULL default '',
  `mobile` varchar(255) collate utf8_bin NOT NULL,
  `email` varchar(255) collate utf8_bin NOT NULL default '',
  `description_fr` text collate utf8_bin NOT NULL,
  `description_en` text collate utf8_bin NOT NULL,
  `price` varchar(255) collate utf8_bin NOT NULL,
  `price_change` varchar(255) collate utf8_bin NOT NULL default 'no',
  `bedrooms` char(1) collate utf8_bin NOT NULL default '0',
  `bathrooms` char(1) collate utf8_bin NOT NULL default '0',
  `view` varchar(255) collate utf8_bin NOT NULL default '',
  `meters` varchar(20) collate utf8_bin NOT NULL,
  `terrain` varchar(255) collate utf8_bin NOT NULL,
  `pool` varchar(3) collate utf8_bin NOT NULL default 'no',
  `garage` varchar(3) collate utf8_bin NOT NULL default 'no',
  `garage_size` varchar(11) collate utf8_bin NOT NULL default '',
  `front_garden` varchar(5) collate utf8_bin NOT NULL,
  `rear_garden` varchar(5) collate utf8_bin NOT NULL,
  `int_features` text collate utf8_bin NOT NULL,
  `ext_features` text collate utf8_bin NOT NULL,
  `video_tour` text collate utf8_bin NOT NULL,
  `featured` char(3) collate utf8_bin NOT NULL default 'no',
  `fees` varchar(255) collate utf8_bin NOT NULL default '',
  `tax` varchar(255) collate utf8_bin NOT NULL default '',
  `photo1` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo2` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo3` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo4` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo5` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo6` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo7` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo8` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo9` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo10` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo11` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `photo12` varchar(255) collate utf8_bin NOT NULL default 'empty',
  `visits` varchar(255) collate utf8_bin NOT NULL,
  `last_visit` datetime NOT NULL default '0000-00-00 00:00:00',
  `last_edit` datetime NOT NULL default '0000-00-00 00:00:00',
  `active` tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (`property_id`),
  KEY `user_id` (`username`),
  FULLTEXT KEY `category` (`category`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='This table stores the properties posted by the users.' AUTO_INCREMENT=1;

write-photos.php

&lt;?php
if($_GET['mode'] == "update")
	{
	$id = $_GET['property_id'];
		if(isset($_POST['username']))
			{
			$username = serialize($_POST['username']);
		}else{
			$username = "";
			}
		if(isset($_POST['int_features']))
			{
			$int_features = serialize($_POST['int_features']);
		}else{
			$int_features = "";
			}
		if(isset($_POST['ext_features']))
			{
			$ext_features = serialize($_POST['ext_features']);
		}else{
			$ext_features = "";
			}
	///// Upload Photos /////
	$picname = str_replace(" ","_",$_POST['name']);
	foreach ($_FILES["photo"]["error"] as $key =&gt; $error)
	{
	if ($error == UPLOAD_ERR_OK){
		$tmp_name = $_FILES["photo"]["tmp_name"][$key];
		$photo = $_FILES["photo"]["name"][$key];
		mkdir("../photos/properties/$session-&gt;username/$name/",0777);
		$photo = preg_replace("/([^a-z0-9])+/i", ".", $photo);
		move_uploaded_file($tmp_name, "../photos/properties/$session-&gt;username/$name/$photo");
		chmod("../photos/properties/$session-&gt;username/$name/$photo", 0777);
		$msg = "Photo ".$picno." ".$photo." uploaded.&lt;/br&gt;";
		$picno = $key;
		$PHOTO[] = $photo;
		$sqlphoto = "UPDATE properties SET photo$picno = '$photo' WHERE property_id = '$id'";
		if(@mysql_query($sqlphoto)){
			$msg = "Your have succesfully added your photos to this property!&lt;br&gt;";
		}else{
			$msg = "There was an error uploading the photos, please contact &lt;a href=\"mailto:[email protected]?subject=Uploading Photo Problem\"&gt;administrators&lt;/a&gt; for help!&lt;br&gt;";
		}
	}
}
		///// Update Property to DB /////
		$newname = str_replace(" ","_",$photo);
		$status = $_POST['status'];
		$sale_type = $_POST['sale_type'];
		$category = $_POST['category'];
		$name = addslashes($_POST['name']);
		$address = $_POST['address'];
		$village = $_POST['village'];
		$lng = $_POST['lng'];
		$lat = $_POST['lat'];
		$department = $_POST['department'];
		$postcode = $_POST['postcode'];
		$description_fr = addslashes($_POST['description_fr']);
		$description_en = addslashes($_POST['description_en']);
		$price = $_POST['price'];
		$bedrooms = $_POST['bedrooms'];
		$bathrooms = $_POST['bathrooms'];
		$view = $_POST['view'];
		$meters = $_POST['meters'];
		$terrain = $_POST['terrain'];
		$pool = $_POST['pool'];
		$garage = $_POST['garage'];
		$garage_size = $_POST['garage_size'];
		$front_garden = $_POST['front_garden'];
		$rear_garden = $_POST['rear_garden'];
		$int_features = $_POST['int_features'];
		$ext_features = $_POST['ext_features'];
		$fees = $_POST['fees'];
		$tax = $_POST['tax'];
		$photo1 = $_POST['photo1'];
		$photo2 = $_POST['photo2'];
		$photo3 = $_POST['photo3'];
		$photo4 = $_POST['photo4'];
		$photo5 = $_POST['photo5'];
		$photo6 = $_POST['photo6'];
		$photo7 = $_POST['photo7'];
		$photo8 = $_POST['photo8'];		
		$photo9 = $_POST['photo9'];
		$photo10 = $_POST['photo10'];		
		$photo11 = $_POST['photo11'];
		$photo12 = $_POST['photo12'];
		$lastedit  = date("Y:m:d H:i:s");
	$sql = "UPDATE properties SET status = '$status', sale_type = '$sale_type', category ='$category', name = '$name', address = '$address', village = '$village', lng = '$lng', lat = '$lat', department = '$department', postcode = '$postcode', last_edit = '$lastedit' WHERE property_id = '$id'";
	if(@mysql_query($sql)){
		$msg = "Congratulations, your property &lt;b&gt;".$name."&lt;/b&gt; is now complete. If you set your property status to Draft click &lt;a href=\"manage-edit.php?id=$id\"&gt;here&lt;/a&gt; to change it to Published!";
	}else{
		$msg = "We will make sure that your photos are added to your property asap.";
	}
}
?&gt;

&lt;?php
$sql = mysql_query("SELECT * FROM properties WHERE property_id='$id' AND username = '$session-&gt;username'");
while($propertyRow = mysql_fetch_array($sql))
	{
	$id = $propertyRow['property_id'];
	$status = $propertyRow['status'];
	$saletype = $propertyRow['sale_type'];
	$category = $propertyRow['category'];
	$name = $propertyRow['name'];
	$address = $propertyRow['address'];
	$village = $propertyRow['village'];
	$long = $propertyRow['long'];
	$lat = $propertyRow['lat'];
	$department = $propertyRow['department'];
	$postcode = $propertyRow['postcode'];
	$price = $propertyRow['price'];
	$lastedit = $propertyRow['last_edit'];
	$dateentered = $propertyRow['date_entered'];
	$sec = substr($propertyRow['date_entered'],17,2);
	$minute= substr($propertyRow['date_entered'],14,2);
	$hour = substr($propertyRow['date_entered'],11,2);
	$day = substr($propertyRow['date_entered'],8,2);
	$month = substr($propertyRow['date_entered'],5,2);
	$year = substr($propertyRow['date_entered'],0,4);
	$date_entered = $day."/".$month."/".$year." ".$hour.":".$minute.":".$sec;
	}
?&gt;
&lt;form action="write-photos.php?mode=update&amp;?id=&lt;? echo $id; ?&gt;" method="post" enctype="multipart/form-data" style="border:0px; padding:0px; margin:0px;"&gt;
&lt;div id="content"&gt;
	&lt;h2&gt;&lt;? echo getLang('attachphotos'); ?&gt;&lt;/h2&gt;
	&lt;? echo "&lt;h3&gt;".$msg."&lt;/h3&gt;"; ?&gt;
	&lt;div id="sidebar-left"&gt;
	&lt;ul id="post_options"&gt;
		&lt;li class="current"&gt;&lt;? echo getLang('briefdetails'); ?&gt;&lt;/li&gt;
		&lt;li&gt;ID: &lt;? echo $id; ?&gt;&lt;br&gt;&lt;? echo getLang('name'); ?&gt;: &lt;? echo $name; ?&gt;&lt;br&gt;&lt;? echo getLang('department'); ?&gt;: &lt;? echo $department; ?&gt;&lt;br&gt;&lt;? echo getLang('price'); ?&gt; ?&lt;? echo $price; ?&gt;&lt;br&gt;&lt;br&gt;&lt;? echo getLang('dateposted'); ?&gt;: &lt;? echo $dateentered; ?&gt;&lt;/li&gt;
		&lt;li class="finish"&gt;&lt;? echo getLang('finishedadding'); ?&gt;&lt;/li&gt;
		&lt;li&gt;&lt;select id="post_status" name="status" onchange="if (this.selectedIndex==1){this.form['check'].style.visibility='visible'}else {this.form['check'].style.visibility='hidden'};"&gt;
			&lt;option value=""&gt;&lt;? echo getLang('no'); ?&gt;&lt;/option&gt;
			&lt;option value=""&gt;&lt;? echo getLang('yes'); ?&gt;&lt;/option&gt;
			&lt;/select&gt;&lt;/li&gt;
		&lt;li&gt;
		&lt;b&gt;&lt;font color="#0099FF"&gt;&lt;? echo getLang('checkphotos'); ?&gt;&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;
		&lt;input type="checkbox" name="check" style="visibility:hidden;" onclick="this.form.Submit.disabled = !this.checked;"&gt;&lt;? echo getLang('enablesave'); ?&gt;&lt;br&gt;&lt;br&gt;
		&lt;input class="save" name="Submit" type="submit" value="&lt;? echo getLang('save'); ?&gt;" disabled="disabled"&gt;&lt;/li&gt;
		&lt;li class="related"&gt;&lt;b&gt;&lt;? echo getLang('relatedlinks'); ?&gt;&lt;/b&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="manage.php"&gt;&lt;? echo getLang('manageyourproperties'); ?&gt;&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="manage-draft.php"&gt;&lt;? echo getLang('viewyourdrafts'); ?&gt;&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
	&lt;/div&gt;

	&lt;div id="write-property"&gt;
	&lt;script type="text/javascript"&gt;
	/* This function is called when user selects file in file dialog */
	function checkext(upload_field)
	{
		var re_text = /\.jpeg|\.jpg/i;
		var filename = upload_field.value;
		/* Checking file type */
		if (filename.search(re_text) == -1)
		{
			alert("Please select a JPEG file.");
			upload_field.value = '';
		}
		return true;
	}
	&lt;/script&gt;
	&lt;table width="100%" border="0" cellpadding="0" cellspacing="4"&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo1'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[1]" type="file" id="photo[1]" title="&lt;? echo getLang('fieldrequired'); ?&gt;" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo2'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[2]" type="file" id="photo[2]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo3'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[3]" type="file" id="photo[3]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo4'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[4]" type="file" id="photo[4]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo5'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[5]" type="file" id="photo[5]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo6'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[6]" type="file" id="photo[6]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo7'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[7]" type="file" id="photo[7]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo8'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[8]" type="file" id="photo[8]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo9'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[9]" type="file" id="photo[9]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo10'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[10]" type="file" id="photo[10]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo11'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[11]" type="file" id="photo[11]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
		&lt;tr&gt;
			&lt;td&gt;&lt;? echo getLang('photo12'); ?&gt;&lt;/td&gt;
			&lt;td&gt;&lt;input name="photo[12]" type="file" id="photo[12]" size="30" onChange="return checkext(this)"&gt;&lt;/td&gt;
		&lt;/tr&gt;
	&lt;/table&gt;
	&lt;/div&gt;
&lt;/div&gt;
&lt;input name="MAX_FILE_SIZE" type="hidden" value="&lt;?php echo $MAXimagesize; ?&gt;"&gt;
&lt;input name="name" type="hidden" value="&lt;? echo $name; ?&gt;"&gt;
&lt;input name="last_edit" type="hidden" id="last_edit" value="&lt;? echo $lastedit; ?&gt;"&gt;
&lt;/form&gt;

Look forward to your answers.

  • 0

	///// Upload Photos /////
	$picname = str_replace(" ","_",$_POST['name']);
	foreach ($_FILES["photo"]["error"] as $key =&gt; $error)
	{
	if ($error == UPLOAD_ERR_OK){
		$tmp_name = $_FILES["photo"]["tmp_name"][$key];
		$photo = $_FILES["photo"]["name"][$key];
		mkdir("../photos/properties/$session-&gt;username/$name/",0777);
		$photo = preg_replace("/([^a-z0-9])+/i", ".", $photo);
		move_uploaded_file($tmp_name, "../photos/properties/$session-&gt;username/$name/$photo");
		chmod("../photos/properties/$session-&gt;username/$name/$photo", 0777);
		$msg = "Photo ".$picno." ".$photo." uploaded.&lt;/br&gt;";
		$picno = $key;
		$PHOTO[] = $photo;
		$sqlphoto = "UPDATE properties SET photo$picno = '$photo' WHERE property_id = '$id'";
		if(@mysql_query($sqlphoto)){
			$msg = "Your have succesfully added your photos to this property!&lt;br&gt;";
		}else{
			$msg = "There was an error uploading the photos, please contact &lt;a href=\"mailto:[email protected]?subject=Uploading Photo Problem\"&gt;administrators&lt;/a&gt; for help!&lt;br&gt;";
		}
	}
}

Your main problem here is where you are trying to include the pic number in the SQL query. You cannot simply but a variable name against plaintext and have PHP parse it. You should do this to make PHP parse the variable correctly:

$sqlphoto = "UPDATE properties SET photo{$picno} = '$photo' WHERE property_id = '$id'";

Also in the above snippet that I quoted, you are creating a new array $PHOTO[], but are not using it anywhere. Is this intentional for future?

Secondly, the snippet I've quoted below refers to $_POST['photo1'] and so on, however, the snippet above shows that they are in an array. That's another part of your problem, although you are not using them at any point in the SQL query either.

///// Update Property to DB /////
		$newname = str_replace(" ","_",$photo);
		$status = $_POST['status'];
		$sale_type = $_POST['sale_type'];
		$category = $_POST['category'];
		$name = addslashes($_POST['name']);
		$address = $_POST['address'];
		$village = $_POST['village'];
		$lng = $_POST['lng'];
		$lat = $_POST['lat'];
		$department = $_POST['department'];
		$postcode = $_POST['postcode'];
		$description_fr = addslashes($_POST['description_fr']);
		$description_en = addslashes($_POST['description_en']);
		$price = $_POST['price'];
		$bedrooms = $_POST['bedrooms'];
		$bathrooms = $_POST['bathrooms'];
		$view = $_POST['view'];
		$meters = $_POST['meters'];
		$terrain = $_POST['terrain'];
		$pool = $_POST['pool'];
		$garage = $_POST['garage'];
		$garage_size = $_POST['garage_size'];
		$front_garden = $_POST['front_garden'];
		$rear_garden = $_POST['rear_garden'];
		$int_features = $_POST['int_features'];
		$ext_features = $_POST['ext_features'];
		$fees = $_POST['fees'];
		$tax = $_POST['tax'];
		$photo1 = $_POST['photo1'];
		$photo2 = $_POST['photo2'];
		$photo3 = $_POST['photo3'];
		$photo4 = $_POST['photo4'];
		$photo5 = $_POST['photo5'];
		$photo6 = $_POST['photo6'];
		$photo7 = $_POST['photo7'];
		$photo8 = $_POST['photo8'];		
		$photo9 = $_POST['photo9'];
		$photo10 = $_POST['photo10'];		
		$photo11 = $_POST['photo11'];
		$photo12 = $_POST['photo12'];
		$lastedit  = date("Y:m:d H:i:s");
	$sql = "UPDATE properties SET status = '$status', sale_type = '$sale_type', category ='$category', name = '$name', address = '$address', village = '$village', lng = '$lng', lat = '$lat', department = '$department', postcode = '$postcode', last_edit = '$lastedit' WHERE property_id = '$id'";
	if(@mysql_query($sql)){
		$msg = "Congratulations, your property &lt;b&gt;".$name."&lt;/b&gt; is now complete. If you set your property status to Draft click &lt;a href=\"manage-edit.php?id=$id\"&gt;here&lt;/a&gt; to change it to Published!";
	}else{
		$msg = "We will make sure that your photos are added to your property asap.";
	}
}
?&gt;

  • 0

I changed the part of code with what you gave me and nothing has changed to the database.

$sqlphoto = "UPDATE properties SET photo{$picno} = '$photo' WHERE property_id = '$id'";

This $PHOTO[] = $photo; is suppose to help update the database by setting as $PHOTO[1] = $photo, $PHOTO[2] = $photo and so on, but I guess it doesn't because maybe something is missing. I would of thought that $key would autogenerate the number of the photo and place it in like so $PHOTO[$key].

Should I also remove these since they don't seem to be doing anything.

$photo1 = $_POST['photo1'];
$photo2 = $_POST['photo2'];
$photo3 = $_POST['photo3'];
$photo4 = $_POST['photo4'];
$photo5 = $_POST['photo5'];
$photo6 = $_POST['photo6'];
$photo7 = $_POST['photo7'];
$photo8 = $_POST['photo8'];		
$photo9 = $_POST['photo9'];
$photo10 = $_POST['photo10'];		
$photo11 = $_POST['photo11'];
$photo12 = $_POST['photo12'];

  • 0
haven't got time at the minute to look at your code properly, but if your form field is name="photo[]" then you need to access it with $_POST['photo'][1] (i believe)

I tried that, didn't do anything and don't forget I am allowing the user to upload 12 photos in total, no more. And I only want one directory created not having the function do it again 11 more times.

EDIT: I also tried this and still nothing happened.

$sqlphoto = "UPDATE properties SET photo1 = '$photo', photo2 = '$photo', photo3 = '$photo', photo4 = '$photo', photo5 = '$photo', photo6 = '$photo', photo7 = '$photo', photo8 = '$photo', photo9 = '$photo', photo10 = '$photo', photo11 = '$photo', photo12 = '$photo' WHERE property_id = '$id'";

Edited by admin2gd1
  • 0

try this code and see where we get. it's pretty hard to know for certain there are no problems with it because i can't actually run it. to run it i need all the rest of your code, structures of all your database tables, and sample data from all of your tables.

&lt;?php
if ( (isset($_GET['mode']) &amp;&amp; ($_GET['mode'] == "update") )
{
	$id = $_GET['id'];
	$username = (isset($_POST['username'])) ? serialize($_POST['username']) : '';
	$int_features = (isset($_POST['int_features'])) ? serialize($_POST['int_features']) : '';
	$ext_features = (isset($_POST['ext_features'])) ? serialize($_POST['ext_features']) : '';

	///// Upload Photos /////
	$PHOTOS = array();
	$picname = str_replace(" ","_",$_POST['name']);
	foreach ($_FILES["photo"]["error"] as $key =&gt; $error)
	{
		if ($error == UPLOAD_ERR_OK)
		{
			$tmp_name = mysql_real_escape_string($_FILES["photo"]["tmp_name"][$key]);
			$photo = mysql_real_escape_string($_FILES["photo"]["name"][$key]);
			mkdir("../photos/properties/$session-&gt;username/$name/",0777);
			$photo = preg_replace("/([^a-z0-9])+/i", ".", $photo);
			move_uploaded_file($tmp_name, "../photos/properties/{$session-&gt;username}/$name/$photo");
			chmod("../photos/properties/{$session-&gt;username}/$name/$photo", 0777);
			$picno = $key;
			$msg = "Photo ".$picno." ".$photo." uploaded.&lt;br /&gt;";
			$PHOTO[$picno] = $photo;
		} else {
			$msg = "Photo number $key failed to upload!&lt;br /&gt;";
		}
	}

	$PHOTOS_SQL = array();
	foreach ($PHOTOS as $key =&gt; $value)
	{
		$PHOTOS_SQL[] = "`photo{$key}`='{$value}'";
	}
	if (! empty($PHOTOS_SQL))
	{
		$PHOTOS_SQL = implode(', ', $PHOTOS_SQL);
		$sqlphotos = "UPDATE properties SET {$PHOTOS_SQL} WHERE `property_id`='$id'";
		if(mysql_query($sqlphotos))
		{
			$msg = "Successfully added uploaded photos to this property!&lt;br&gt;";
		}else{
			$msg = "There was an error adding uploaded photos to the property, please contact &lt;a href=\"mailto:[email protected]?subject=Uploading Photo Problem\"&gt;administrators&lt;/a&gt; for help!&lt;br&gt;";
		}
	} else {
		$msg = "No uploaded photos to attach to the property!";
	}

	///// Update Property to DB /////
	$newname = str_replace(" ","_",$photo);
	$status = mysql_real_escape_string($_POST['status']);
	$sale_type = mysql_real_escape_string($_POST['sale_type']);
	$category = mysql_real_escape_string($_POST['category']);
	$name = addslashes(mysql_real_escape_string($_POST['name']));
	$address = mysql_real_escape_string($_POST['address']);
	$village = mysql_real_escape_string($_POST['village']);
	$lng = mysql_real_escape_string($_POST['lng']);
	$lat = mysql_real_escape_string($_POST['lat']);
	$department = mysql_real_escape_string($_POST['department']);
	$postcode = mysql_real_escape_string($_POST['postcode']);
	$description_fr = addslashes(mysql_real_escape_string($_POST['description_fr']));
	$description_en = addslashes(mysql_real_escape_string($_POST['description_en']));
	$price = mysql_real_escape_string($_POST['price']);
	$bedrooms = mysql_real_escape_string($_POST['bedrooms']);
	$bathrooms = $_POST['bathrooms'];
	$view = mysql_real_escape_string($_POST['view']);
	$meters = mysql_real_escape_string($_POST['meters']);
	$terrain = mysql_real_escape_string($_POST['terrain']);
	$pool = mysql_real_escape_string($_POST['pool']);
	$garage = mysql_real_escape_string($_POST['garage']);
	$garage_size = mysql_real_escape_string($_POST['garage_size']);
	$front_garden = mysql_real_escape_string($_POST['front_garden']);
	$rear_garden = mysql_real_escape_string($_POST['rear_garden']);
	$int_features = mysql_real_escape_string($_POST['int_features']);
	$ext_features = mysql_real_escape_string($_POST['ext_features']);
	$fees = mysql_real_escape_string($_POST['fees']);
	$tax = mysql_real_escape_string($_POST['tax']);
	$lastedit  = date("Y:m:d H:i:s");

	$sql = "UPDATE properties SET `status`='$status', `sale_type`='$sale_type', `category`='$category', `name`='$name', `address`='$address', `village`='$village', `lng`='$lng', `lat`='$lat', `department`='$department', `postcode`='$postcode', `last_edit`='$lastedit' WHERE `property_id`='$id'";
	if (mysql_query($sql))
	{
		$msg = "Congratulations, your property &lt;b&gt;".$name."&lt;/b&gt; is now complete. If you set your property status to Draft click &lt;a href=\"manage-edit.php?id=$id\"&gt;here&lt;/a&gt; to change it to Published!";
	}else{
		$msg = "We will make sure that your photos are added to your property asap.";
	}
}
?&gt;

&lt;?php
$sql = mysql_query("SELECT * FROM properties WHERE `property_id`='$id' AND `username`='{$session-&gt;username}'");
while($propertyRow = mysql_fetch_array($sql))
{
	$id = $propertyRow['property_id'];
	$status = $propertyRow['status'];
	$saletype = $propertyRow['sale_type'];
	$category = $propertyRow['category'];
	$name = $propertyRow['name'];
	$address = $propertyRow['address'];
	$village = $propertyRow['village'];
	$long = $propertyRow['long'];
	$lat = $propertyRow['lat'];
	$department = $propertyRow['department'];
	$postcode = $propertyRow['postcode'];
	$price = $propertyRow['price'];
	$lastedit = $propertyRow['last_edit'];
	$dateentered = $propertyRow['date_entered'];
	$sec = substr($propertyRow['date_entered'],17,2);
	$minute= substr($propertyRow['date_entered'],14,2);
	$hour = substr($propertyRow['date_entered'],11,2);
	$day = substr($propertyRow['date_entered'],8,2);
	$month = substr($propertyRow['date_entered'],5,2);
	$year = substr($propertyRow['date_entered'],0,4);
	$date_entered = $day."/".$month."/".$year." ".$hour.":".$minute.":".$sec;
}
?&gt;
&lt;form action="write-photos.php?mode=update&amp;?id=&lt;?php echo $id; ?&gt;" method="post" enctype="multipart/form-data" style="border:0px; padding:0px; margin:0px;"&gt;
	&lt;input name="MAX_FILE_SIZE" type="hidden" value="&lt;?php echo $MAXimagesize; ?&gt;" /&gt; &lt;!-- must proceed file input fields! --&gt;
	&lt;input name="name" type="hidden" value="&lt;?php echo $name; ?&gt;" /&gt;
	&lt;input name="last_edit" type="hidden" id="last_edit" value="&lt;?php echo $lastedit; ?&gt;" /&gt;
	&lt;div id="content"&gt;
		&lt;h2&gt;&lt;?php echo getLang('attachphotos'); ?&gt;&lt;/h2&gt;
		&lt;?php echo "&lt;h3&gt;".$msg."&lt;/h3&gt;"; ?&gt;
		&lt;div id="sidebar-left"&gt;
			&lt;ul id="post_options"&gt;
				&lt;li class="current"&gt;&lt;?php echo getLang('briefdetails'); ?&gt;&lt;/li&gt;
				&lt;li&gt;ID: &lt;?php echo $id; ?&gt;&lt;br&gt;&lt;?php echo getLang('name'); ?&gt;: &lt;?php echo $name; ?&gt;&lt;br&gt;&lt;?php echo getLang('department'); ?&gt;: &lt;?php echo $department; ?&gt;&lt;br&gt;&lt;?php echo getLang('price'); ?&gt; ?&lt;?php echo $price; ?&gt;&lt;br&gt;&lt;br&gt;&lt;?php echo getLang('dateposted'); ?&gt;: &lt;?php echo $dateentered; ?&gt;&lt;/li&gt;
				&lt;li class="finish"&gt;&lt;?php echo getLang('finishedadding'); ?&gt;&lt;/li&gt;
				&lt;li&gt;
					&lt;select id="post_status" name="status" onchange="if (this.selectedIndex==1){this.form['check'].style.visibility='visible'}else {this.form['check'].style.visibility='hidden'};"&gt;
						&lt;option value=""&gt;&lt;?php echo getLang('no'); ?&gt;&lt;/option&gt;
						&lt;option value=""&gt;&lt;?php echo getLang('yes'); ?&gt;&lt;/option&gt;
					&lt;/select&gt;
				&lt;/li&gt;
				&lt;li&gt;
					&lt;b&gt;&lt;font color="#0099FF"&gt;&lt;?php echo getLang('checkphotos'); ?&gt;&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;
					&lt;input type="checkbox" name="check" style="visibility:hidden;" onclick="this.form.Submit.disabled = !this.checked;"&gt;&lt;?php echo getLang('enablesave'); ?&gt;&lt;br&gt;&lt;br&gt;
					&lt;input class="save" name="Submit" type="submit" value="&lt;?php echo getLang('save'); ?&gt;" disabled="disabled"&gt;
				&lt;/li&gt;
				&lt;li class="related"&gt;&lt;b&gt;&lt;?php echo getLang('relatedlinks'); ?&gt;&lt;/b&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="manage.php"&gt;&lt;?php echo getLang('manageyourproperties'); ?&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="manage-draft.php"&gt;&lt;?php echo getLang('viewyourdrafts'); ?&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/div&gt;

		&lt;div id="write-property"&gt;
			&lt;script type="text/javascript"&gt;
				/* This function is called when user selects file in file dialog */
				function checkext(upload_field)
				{
					var re_text = /\.jpeg|\.jpg/i;
					var filename = upload_field.value;
					/* Checking file type */
					if (filename.search(re_text) == -1)
					{
						alert("Please select a JPEG file.");
						upload_field.value = '';
					}
					return true;
				}
			&lt;/script&gt;
			&lt;table width="100%" border="0" cellpadding="0" cellspacing="4"&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo1'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[1]" type="file" id="photo[1]" title="&lt;?php echo getLang('fieldrequired'); ?&gt;" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo2'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[2]" type="file" id="photo[2]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo3'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[3]" type="file" id="photo[3]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo4'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[4]" type="file" id="photo[4]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo5'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[5]" type="file" id="photo[5]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo6'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[6]" type="file" id="photo[6]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo7'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[7]" type="file" id="photo[7]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo8'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[8]" type="file" id="photo[8]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo9'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[9]" type="file" id="photo[9]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo10'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[10]" type="file" id="photo[10]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo11'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[11]" type="file" id="photo[11]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo12'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[12]" type="file" id="photo[12]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
			&lt;/table&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/form&gt;

  • 0
try this code and see where we get. it's pretty hard to know for certain there are no problems with it because i can't actually run it. to run it i need all the rest of your code, structures of all your database tables, and sample data from all of your tables.

&lt;?php
if ( (isset($_GET['mode']) &amp;&amp; ($_GET['mode'] == "update") )
{

The code above, that starts at the begining of the entire code you gave me does not like this symbol '{' . So that needs fixing and could you also write a thumbnail function for me. I need these sizes for thumbnails but i want the filename to be the same as the original photos so, if you could get the uploading to generate a thumbnail for each photo for each size in there own folder that would be great. I have set out the directories below along with the sizes I need and they must be jpg only please.

Sizes:

50 x 50

75 x 80

100 x 100

170 x 170

Directories:

This is the main directory for the original photos to go into ../photos/properties/$session->username/$name/

The thumbnail photos for each size should go like this

50 x 50 ../photos/properties/$session->username/$name/50/

75 x 80 ../photos/properties/$session->username/$name/75/

100 x 100 ../photos/properties/$session->username/$name/100/

170 x 170 ../photos/properties/$session->username/$name/170/

The filenames should be the same so that the site can read the thumbnails.

So if original in ../photos/properties/$session->username/$name/$photo1 is photo1.jpg, then the filename should be the same in

../photos/properties/$session->username/$name/100/$photo1 as photo1.jpg for 100 x 100 thumbnails.

This would be a great help if you could include this for me. I would really appreciate it very much.

P.S. For some reason I can't update any information in my database but I can add or delete information from the database using a form. I have never had any problems with updating information before and I have spoken to my web host and they said there is nothing that they can do. I have checked my priviliges to see if I have permission to write on all and they are all ticked, so I don't know what could be wrong.

Do you think I should create a new database and re-insert my tables and see if that helps with the problem.

  • 0
The code above, that starts at the begining of the entire code you gave me does not like this symbol '{' . So that needs fixing

oops, there's a parenthesis missing, replace with

&lt;?php
if ( (isset($_GET['mode'])) &amp;&amp; ($_GET['mode'] == "update") )
{

and could you also write a thumbnail function for me

i'm afraid i have no experience of image manipulation with php, so i'm going to have to leave that for someone else unless i find the time to research it.

P.S. For some reason I can't update any information in my database but I can add or delete information from the database using a form. I have never had any problems with updating information before and I have spoken to my web host and they said there is nothing that they can do. I have checked my priviliges to see if I have permission to write on all and they are all ticked, so I don't know what could be wrong.

Do you think I should create a new database and re-insert my tables and see if that helps with the problem.

there could be any number of factors involved in your update query failing, from a broken query, to conflicts with other records due to unique columns, to permissions at row/column/table/database levels. with previous code of yours we added a check after each query, which if the query failed would print a message telling the user so, and also if in debug mode would display the error. you need to make sure you do this for all queries, you never know when one might fail! this will be able to tell you why your query is failing and will lead to an appropriate solution.

  • 0
oops, there's a parenthesis missing, replace with
&lt;?php
if ( (isset($_GET['mode'])) &amp;&amp; ($_GET['mode'] == "update") )
{

i'm afraid i have no experience of image manipulation with php, so i'm going to have to leave that for someone else unless i find the time to research it.

there could be any number of factors involved in your update query failing, from a broken query, to conflicts with other records due to unique columns, to permissions at row/column/table/database levels. with previous code of yours we added a check after each query, which if the query failed would print a message telling the user so, and also if in debug mode would display the error. you need to make sure you do this for all queries, you never know when one might fail! this will be able to tell you why your query is failing and will lead to an appropriate solution.

Ok your code works great, but it still won't update the database with the photos for the property. What do you think I should do? No errors show up but I do get uploaded successfully and the photos are in the uploaded directory.

I still get

Warning: mkdir(../photos/properties/username/name/) [function.mkdir]: File exists in /home/account/public_html/panel/write-photos.php on line 138

etc... for the other 11 photos uploaded. Why does it create 12 directories instead of 1?

  • 0

ok, make sure you're including those constants.php and lib.inc.php files you had before, and then try this copy

&lt;?php
if ( (isset($_GET['mode'])) &amp;&amp; ($_GET['mode'] == "update") )
{
	$id = $_GET['id'];
	$username = (isset($_POST['username'])) ? serialize($_POST['username']) : '';
	$int_features = (isset($_POST['int_features'])) ? serialize($_POST['int_features']) : '';
	$ext_features = (isset($_POST['ext_features'])) ? serialize($_POST['ext_features']) : '';

	///// Upload Photos /////
	$PHOTOS = array();
	$picname = str_replace(" ","_",$_POST['name']);
	mkdir("../photos/properties/{$session-&gt;username}/$name/",0777);
	foreach ($_FILES["photo"]["error"] as $key =&gt; $error)
	{
		if ($error == UPLOAD_ERR_OK)
		{
			$tmp_name = mysql_real_escape_string($_FILES["photo"]["tmp_name"][$key]);
			$photo = mysql_real_escape_string($_FILES["photo"]["name"][$key]);
			$photo = preg_replace("/([^a-z0-9])+/i", ".", $photo);
			move_uploaded_file($tmp_name, "../photos/properties/{$session-&gt;username}/$name/$photo");
			chmod("../photos/properties/{$session-&gt;username}/$name/$photo", 0777);
			$picno = $key;
			$msg = "Photo ".$picno." ".$photo." uploaded.&lt;br /&gt;";
			$PHOTO[$picno] = $photo;
		} else {
			$msg = "Photo number $key failed to upload!&lt;br /&gt;";
		}
	}

	$PHOTOS_SQL = array();
	foreach ($PHOTOS as $key =&gt; $value)
	{
		$PHOTOS_SQL[] = "`photo{$key}`='{$value}'";
	}
	if (! empty($PHOTOS_SQL))
	{
		$PHOTOS_SQL = implode(', ', $PHOTOS_SQL);
		$sqlphotos = "UPDATE properties SET {$PHOTOS_SQL} WHERE `property_id`='$id'";
		if(mysql_query($sqlphotos) === false)
		{
			$msg = "There was an error adding uploaded photos to the property, please contact &lt;a href=\"mailto:[email protected]?subject=Uploading Photo Problem\"&gt;administrators&lt;/a&gt; for help!&lt;br&gt;";
			echo sqlError(__FILE__, __LINE);
		}else{
			$msg = "Successfully added uploaded photos to this property!&lt;br&gt;";
		}
	} else {
		$msg = "No uploaded photos to attach to the property!";
	}

	///// Update Property to DB /////
	$newname = str_replace(" ","_",$photo);
	$status = mysql_real_escape_string($_POST['status']);
	$sale_type = mysql_real_escape_string($_POST['sale_type']);
	$category = mysql_real_escape_string($_POST['category']);
	$name = addslashes(mysql_real_escape_string($_POST['name']));
	$address = mysql_real_escape_string($_POST['address']);
	$village = mysql_real_escape_string($_POST['village']);
	$lng = mysql_real_escape_string($_POST['lng']);
	$lat = mysql_real_escape_string($_POST['lat']);
	$department = mysql_real_escape_string($_POST['department']);
	$postcode = mysql_real_escape_string($_POST['postcode']);
	$description_fr = addslashes(mysql_real_escape_string($_POST['description_fr']));
	$description_en = addslashes(mysql_real_escape_string($_POST['description_en']));
	$price = mysql_real_escape_string($_POST['price']);
	$bedrooms = mysql_real_escape_string($_POST['bedrooms']);
	$bathrooms = $_POST['bathrooms'];
	$view = mysql_real_escape_string($_POST['view']);
	$meters = mysql_real_escape_string($_POST['meters']);
	$terrain = mysql_real_escape_string($_POST['terrain']);
	$pool = mysql_real_escape_string($_POST['pool']);
	$garage = mysql_real_escape_string($_POST['garage']);
	$garage_size = mysql_real_escape_string($_POST['garage_size']);
	$front_garden = mysql_real_escape_string($_POST['front_garden']);
	$rear_garden = mysql_real_escape_string($_POST['rear_garden']);
	$int_features = mysql_real_escape_string($_POST['int_features']);
	$ext_features = mysql_real_escape_string($_POST['ext_features']);
	$fees = mysql_real_escape_string($_POST['fees']);
	$tax = mysql_real_escape_string($_POST['tax']);
	$lastedit  = date("Y:m:d H:i:s");

	$sql = "UPDATE properties SET `status`='$status', `sale_type`='$sale_type', `category`='$category', `name`='$name', `address`='$address', `village`='$village', `lng`='$lng', `lat`='$lat', `department`='$department', `postcode`='$postcode', `last_edit`='$lastedit' WHERE `property_id`='$id'";
	if (mysql_query($sql) === false)
	{
		$msg = "Error occured updating property data.";
		echo sqlError(__FILE__, __LINE);
	}else{
		$msg = "Congratulations, your property &lt;b&gt;".$name."&lt;/b&gt; is now complete. If you set your property status to Draft click &lt;a href=\"manage-edit.php?id=$id\"&gt;here&lt;/a&gt; to change it to Published!";
	}
}
?&gt;

&lt;?php
$sql = mysql_query("SELECT * FROM properties WHERE `property_id`='$id' AND `username`='{$session-&gt;username}'");
$result = mysql_query($sql);
if ($result === false)
{
	$msg = "Error occured fetching data.";
	echo sqlError(__FILE__, __LINE);
}
while($propertyRow = mysql_fetch_array($sql))
{
	$id = $propertyRow['property_id'];
	$status = $propertyRow['status'];
	$saletype = $propertyRow['sale_type'];
	$category = $propertyRow['category'];
	$name = $propertyRow['name'];
	$address = $propertyRow['address'];
	$village = $propertyRow['village'];
	$long = $propertyRow['long'];
	$lat = $propertyRow['lat'];
	$department = $propertyRow['department'];
	$postcode = $propertyRow['postcode'];
	$price = $propertyRow['price'];
	$lastedit = $propertyRow['last_edit'];
	$dateentered = $propertyRow['date_entered'];
	$sec = substr($propertyRow['date_entered'],17,2);
	$minute= substr($propertyRow['date_entered'],14,2);
	$hour = substr($propertyRow['date_entered'],11,2);
	$day = substr($propertyRow['date_entered'],8,2);
	$month = substr($propertyRow['date_entered'],5,2);
	$year = substr($propertyRow['date_entered'],0,4);
	$date_entered = $day."/".$month."/".$year." ".$hour.":".$minute.":".$sec;
}
?&gt;
&lt;form action="write-photos.php?mode=update&amp;?id=&lt;?php echo $id; ?&gt;" method="post" enctype="multipart/form-data" style="border:0px; padding:0px; margin:0px;"&gt;
	&lt;input name="MAX_FILE_SIZE" type="hidden" value="&lt;?php echo $MAXimagesize; ?&gt;" /&gt; &lt;!-- must proceed file input fields! --&gt;
	&lt;input name="name" type="hidden" value="&lt;?php echo $name; ?&gt;" /&gt;
	&lt;input name="last_edit" type="hidden" id="last_edit" value="&lt;?php echo $lastedit; ?&gt;" /&gt;
	&lt;div id="content"&gt;
		&lt;h2&gt;&lt;?php echo getLang('attachphotos'); ?&gt;&lt;/h2&gt;
		&lt;?php echo "&lt;h3&gt;".$msg."&lt;/h3&gt;"; ?&gt;
		&lt;div id="sidebar-left"&gt;
			&lt;ul id="post_options"&gt;
				&lt;li class="current"&gt;&lt;?php echo getLang('briefdetails'); ?&gt;&lt;/li&gt;
				&lt;li&gt;ID: &lt;?php echo $id; ?&gt;&lt;br&gt;&lt;?php echo getLang('name'); ?&gt;: &lt;?php echo $name; ?&gt;&lt;br&gt;&lt;?php echo getLang('department'); ?&gt;: &lt;?php echo $department; ?&gt;&lt;br&gt;&lt;?php echo getLang('price'); ?&gt; ?&lt;?php echo $price; ?&gt;&lt;br&gt;&lt;br&gt;&lt;?php echo getLang('dateposted'); ?&gt;: &lt;?php echo $dateentered; ?&gt;&lt;/li&gt;
				&lt;li class="finish"&gt;&lt;?php echo getLang('finishedadding'); ?&gt;&lt;/li&gt;
				&lt;li&gt;
					&lt;select id="post_status" name="status" onchange="if (this.selectedIndex==1){this.form['check'].style.visibility='visible'}else {this.form['check'].style.visibility='hidden'};"&gt;
						&lt;option value=""&gt;&lt;?php echo getLang('no'); ?&gt;&lt;/option&gt;
						&lt;option value=""&gt;&lt;?php echo getLang('yes'); ?&gt;&lt;/option&gt;
					&lt;/select&gt;
				&lt;/li&gt;
				&lt;li&gt;
					&lt;b&gt;&lt;font color="#0099FF"&gt;&lt;?php echo getLang('checkphotos'); ?&gt;&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;
					&lt;input type="checkbox" name="check" style="visibility:hidden;" onclick="this.form.Submit.disabled = !this.checked;"&gt;&lt;?php echo getLang('enablesave'); ?&gt;&lt;br&gt;&lt;br&gt;
					&lt;input class="save" name="Submit" type="submit" value="&lt;?php echo getLang('save'); ?&gt;" disabled="disabled"&gt;
				&lt;/li&gt;
				&lt;li class="related"&gt;&lt;b&gt;&lt;?php echo getLang('relatedlinks'); ?&gt;&lt;/b&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="manage.php"&gt;&lt;?php echo getLang('manageyourproperties'); ?&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="manage-draft.php"&gt;&lt;?php echo getLang('viewyourdrafts'); ?&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/div&gt;

		&lt;div id="write-property"&gt;
			&lt;script type="text/javascript"&gt;
				/* This function is called when user selects file in file dialog */
				function checkext(upload_field)
				{
					var re_text = /\.jpeg|\.jpg/i;
					var filename = upload_field.value;
					/* Checking file type */
					if (filename.search(re_text) == -1)
					{
						alert("Please select a JPEG file.");
						upload_field.value = '';
					}
					return true;
				}
			&lt;/script&gt;
			&lt;table width="100%" border="0" cellpadding="0" cellspacing="4"&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo1'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[1]" type="file" id="photo[1]" title="&lt;?php echo getLang('fieldrequired'); ?&gt;" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo2'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[2]" type="file" id="photo[2]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo3'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[3]" type="file" id="photo[3]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo4'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[4]" type="file" id="photo[4]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo5'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[5]" type="file" id="photo[5]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo6'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[6]" type="file" id="photo[6]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo7'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[7]" type="file" id="photo[7]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo8'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[8]" type="file" id="photo[8]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo9'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[9]" type="file" id="photo[9]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo10'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[10]" type="file" id="photo[10]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo11'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[11]" type="file" id="photo[11]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo12'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[12]" type="file" id="photo[12]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
			&lt;/table&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/form&gt;

Edited by Anaron
  • 0
ok, make sure you're including those constants.php and lib.inc.php files you had before, and then try this copy

The mkdir is fixed so thank you for that.

Ok I did what you said by including those files. Now on this other tweak you did for me.

if ($result === false)
{
	$msg = "Error occured fetching data.";
	echo sqlError(__FILE__, __LINE);
}

This shows up before pressing the submit button to update the photos. Is that an error it's self because the data must be fetched as I can see the property details in the brief section and the rest is in the background so why does it say 'Error occured fetching data.' ?

P.S. Database will still not update, maybe that is related to what I'm asking.

  • 0

oops, i noticed a couple of bugs, new copy:

&lt;?php
if ( (isset($_GET['mode'])) &amp;&amp; ($_GET['mode'] == "update") )
{
	$id = $_GET['id'];
	$username = (isset($_POST['username'])) ? serialize($_POST['username']) : '';
	$int_features = (isset($_POST['int_features'])) ? serialize($_POST['int_features']) : '';
	$ext_features = (isset($_POST['ext_features'])) ? serialize($_POST['ext_features']) : '';

	///// Upload Photos /////
	$PHOTOS = array();
	$picname = str_replace(" ","_",$_POST['name']);
	if (! is_dir("../photos/properties/{$session-&gt;username}/$name/")) { mkdir("../photos/properties/{$session-&gt;username}/$name/",0777); }
	foreach ($_FILES["photo"]["error"] as $key =&gt; $error)
	{
		if ($error == UPLOAD_ERR_OK)
		{
			$tmp_name = mysql_real_escape_string($_FILES["photo"]["tmp_name"][$key]);
			$photo = mysql_real_escape_string($_FILES["photo"]["name"][$key]);
			$photo = preg_replace("/([^a-z0-9])+/i", ".", $photo);
			move_uploaded_file($tmp_name, "../photos/properties/{$session-&gt;username}/$name/$photo");
			chmod("../photos/properties/{$session-&gt;username}/$name/$photo", 0777);
			$picno = $key;
			$msg = "Photo ".$picno." ".$photo." uploaded.&lt;br /&gt;";
			$PHOTO[$picno] = $photo;
		} else {
			$msg = "Photo number $key failed to upload!&lt;br /&gt;";
		}
	}

	$PHOTOS_SQL = array();
	foreach ($PHOTOS as $key =&gt; $value)
	{
		$PHOTOS_SQL[] = "`photo{$key}`='{$value}'";
	}
	if (! empty($PHOTOS_SQL))
	{
		$PHOTOS_SQL = implode(', ', $PHOTOS_SQL);
		$sqlphotos = "UPDATE properties SET {$PHOTOS_SQL} WHERE `property_id`='$id'";
		if(mysql_query($sqlphotos) === false)
		{
			$msg = "There was an error adding uploaded photos to the property, please contact &lt;a href=\"mailto:[email protected]?subject=Uploading Photo Problem\"&gt;administrators&lt;/a&gt; for help!&lt;br&gt;";
			echo sqlError(__FILE__, __LINE__);
		}else{
			$msg = "Successfully added uploaded photos to this property!&lt;br&gt;";
		}
	} else {
		$msg = "No uploaded photos to attach to the property!";
	}

	///// Update Property to DB /////
	$newname = str_replace(" ","_",$photo);
	$status = mysql_real_escape_string($_POST['status']);
	$sale_type = mysql_real_escape_string($_POST['sale_type']);
	$category = mysql_real_escape_string($_POST['category']);
	$name = addslashes(mysql_real_escape_string($_POST['name']));
	$address = mysql_real_escape_string($_POST['address']);
	$village = mysql_real_escape_string($_POST['village']);
	$lng = mysql_real_escape_string($_POST['lng']);
	$lat = mysql_real_escape_string($_POST['lat']);
	$department = mysql_real_escape_string($_POST['department']);
	$postcode = mysql_real_escape_string($_POST['postcode']);
	$description_fr = addslashes(mysql_real_escape_string($_POST['description_fr']));
	$description_en = addslashes(mysql_real_escape_string($_POST['description_en']));
	$price = mysql_real_escape_string($_POST['price']);
	$bedrooms = mysql_real_escape_string($_POST['bedrooms']);
	$bathrooms = $_POST['bathrooms'];
	$view = mysql_real_escape_string($_POST['view']);
	$meters = mysql_real_escape_string($_POST['meters']);
	$terrain = mysql_real_escape_string($_POST['terrain']);
	$pool = mysql_real_escape_string($_POST['pool']);
	$garage = mysql_real_escape_string($_POST['garage']);
	$garage_size = mysql_real_escape_string($_POST['garage_size']);
	$front_garden = mysql_real_escape_string($_POST['front_garden']);
	$rear_garden = mysql_real_escape_string($_POST['rear_garden']);
	$int_features = mysql_real_escape_string($_POST['int_features']);
	$ext_features = mysql_real_escape_string($_POST['ext_features']);
	$fees = mysql_real_escape_string($_POST['fees']);
	$tax = mysql_real_escape_string($_POST['tax']);
	$lastedit  = date("Y:m:d H:i:s");

	$sql = "UPDATE properties SET `status`='$status', `sale_type`='$sale_type', `category`='$category', `name`='$name', `address`='$address', `village`='$village', `lng`='$lng', `lat`='$lat', `department`='$department', `postcode`='$postcode', `last_edit`='$lastedit' WHERE `property_id`='$id'";
	if (mysql_query($sql) === false)
	{
		$msg = "Error occured updating property data.";
		echo sqlError(__FILE__, __LINE__);
	}else{
		$msg = "Congratulations, your property &lt;b&gt;".$name."&lt;/b&gt; is now complete. If you set your property status to Draft click &lt;a href=\"manage-edit.php?id=$id\"&gt;here&lt;/a&gt; to change it to Published!";
	}
}
?&gt;

&lt;?php
$sql = "SELECT * FROM properties WHERE `property_id`='$id' AND `username`='{$session-&gt;username}'";
$result = mysql_query($sql);
if ($result === false)
{
	$msg = "Error occured fetching data.";
	echo sqlError(__FILE__, __LINE__);
}
while($propertyRow = mysql_fetch_array($sql))
{
	$id = $propertyRow['property_id'];
	$status = $propertyRow['status'];
	$saletype = $propertyRow['sale_type'];
	$category = $propertyRow['category'];
	$name = $propertyRow['name'];
	$address = $propertyRow['address'];
	$village = $propertyRow['village'];
	$long = $propertyRow['long'];
	$lat = $propertyRow['lat'];
	$department = $propertyRow['department'];
	$postcode = $propertyRow['postcode'];
	$price = $propertyRow['price'];
	$lastedit = $propertyRow['last_edit'];
	$dateentered = $propertyRow['date_entered'];
	$sec = substr($propertyRow['date_entered'],17,2);
	$minute= substr($propertyRow['date_entered'],14,2);
	$hour = substr($propertyRow['date_entered'],11,2);
	$day = substr($propertyRow['date_entered'],8,2);
	$month = substr($propertyRow['date_entered'],5,2);
	$year = substr($propertyRow['date_entered'],0,4);
	$date_entered = $day."/".$month."/".$year." ".$hour.":".$minute.":".$sec;
}
?&gt;
&lt;form action="write-photos.php?mode=update&amp;?id=&lt;?php echo $id; ?&gt;" method="post" enctype="multipart/form-data" style="border:0px; padding:0px; margin:0px;"&gt;
	&lt;input name="MAX_FILE_SIZE" type="hidden" value="&lt;?php echo $MAXimagesize; ?&gt;" /&gt; &lt;!-- must proceed file input fields! --&gt;
	&lt;input name="name" type="hidden" value="&lt;?php echo $name; ?&gt;" /&gt;
	&lt;input name="last_edit" type="hidden" id="last_edit" value="&lt;?php echo $lastedit; ?&gt;" /&gt;
	&lt;div id="content"&gt;
		&lt;h2&gt;&lt;?php echo getLang('attachphotos'); ?&gt;&lt;/h2&gt;
		&lt;?php echo "&lt;h3&gt;".$msg."&lt;/h3&gt;"; ?&gt;
		&lt;div id="sidebar-left"&gt;
			&lt;ul id="post_options"&gt;
				&lt;li class="current"&gt;&lt;?php echo getLang('briefdetails'); ?&gt;&lt;/li&gt;
				&lt;li&gt;ID: &lt;?php echo $id; ?&gt;&lt;br&gt;&lt;?php echo getLang('name'); ?&gt;: &lt;?php echo $name; ?&gt;&lt;br&gt;&lt;?php echo getLang('department'); ?&gt;: &lt;?php echo $department; ?&gt;&lt;br&gt;&lt;?php echo getLang('price'); ?&gt; ?&lt;?php echo $price; ?&gt;&lt;br&gt;&lt;br&gt;&lt;?php echo getLang('dateposted'); ?&gt;: &lt;?php echo $dateentered; ?&gt;&lt;/li&gt;
				&lt;li class="finish"&gt;&lt;?php echo getLang('finishedadding'); ?&gt;&lt;/li&gt;
				&lt;li&gt;
					&lt;select id="post_status" name="status" onchange="if (this.selectedIndex==1){this.form['check'].style.visibility='visible'}else {this.form['check'].style.visibility='hidden'};"&gt;
						&lt;option value=""&gt;&lt;?php echo getLang('no'); ?&gt;&lt;/option&gt;
						&lt;option value=""&gt;&lt;?php echo getLang('yes'); ?&gt;&lt;/option&gt;
					&lt;/select&gt;
				&lt;/li&gt;
				&lt;li&gt;
					&lt;b&gt;&lt;font color="#0099FF"&gt;&lt;?php echo getLang('checkphotos'); ?&gt;&lt;/font&gt;&lt;/b&gt;&lt;br&gt;&lt;br&gt;
					&lt;input type="checkbox" name="check" style="visibility:hidden;" onclick="this.form.Submit.disabled = !this.checked;"&gt;&lt;?php echo getLang('enablesave'); ?&gt;&lt;br&gt;&lt;br&gt;
					&lt;input class="save" name="Submit" type="submit" value="&lt;?php echo getLang('save'); ?&gt;" disabled="disabled"&gt;
				&lt;/li&gt;
				&lt;li class="related"&gt;&lt;b&gt;&lt;?php echo getLang('relatedlinks'); ?&gt;&lt;/b&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="manage.php"&gt;&lt;?php echo getLang('manageyourproperties'); ?&gt;&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="manage-draft.php"&gt;&lt;?php echo getLang('viewyourdrafts'); ?&gt;&lt;/a&gt;&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/div&gt;

		&lt;div id="write-property"&gt;
			&lt;script type="text/javascript"&gt;
				/* This function is called when user selects file in file dialog */
				function checkext(upload_field)
				{
					var re_text = /\.jpeg|\.jpg/i;
					var filename = upload_field.value;
					/* Checking file type */
					if (filename.search(re_text) == -1)
					{
						alert("Please select a JPEG file.");
						upload_field.value = '';
					}
					return true;
				}
			&lt;/script&gt;
			&lt;table width="100%" border="0" cellpadding="0" cellspacing="4"&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo1'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[1]" type="file" id="photo[1]" title="&lt;?php echo getLang('fieldrequired'); ?&gt;" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo2'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[2]" type="file" id="photo[2]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo3'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[3]" type="file" id="photo[3]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo4'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[4]" type="file" id="photo[4]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo5'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[5]" type="file" id="photo[5]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo6'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[6]" type="file" id="photo[6]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo7'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[7]" type="file" id="photo[7]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo8'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[8]" type="file" id="photo[8]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo9'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[9]" type="file" id="photo[9]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo10'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[10]" type="file" id="photo[10]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo11'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[11]" type="file" id="photo[11]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
				&lt;tr&gt;
					&lt;td&gt;&lt;?php echo getLang('photo12'); ?&gt;&lt;/td&gt;
					&lt;td&gt;&lt;input name="photo[12]" type="file" id="photo[12]" size="30" onChange="return checkext(this)" /&gt;&lt;/td&gt;
				&lt;/tr&gt;
			&lt;/table&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/form&gt;

it's harder to write code without bugs when you can't actually run it :/

edit: fixed another couple of bugs :rofl:

Edited by Anaron
  • 0

}
while($propertyRow = mysql_fetch_array($sql))
{

This for some reason is causing this error.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamaiso1/public_html/worldwide/france/panel/write-photos4.php on line 207

Also the new code does not fetch the data at all except the ID number now that is proberly because of this error.

  • 0
ooh, another bug, change $sql in that line to $result

Ok I made a few changes by removing some of the stuff that is no longer needed. I have also managed to get the last edit to work. So I know the update function is now working, so no I need to fix the part that tells the database the photo file for each photo because that is still not working. I am also wondering why all the messages don't show when the form is processed. It only seems to show the last one. Each message begins with $msg. I have uploaded the entire page to you so that you can see the code properly.

I have placed the code that is still causing problems.

$PHOTOS_SQL = array();
	foreach ($PHOTOS as $key =&gt; $photo)
	{
		$picno = $key;
		$PHOTOS_SQL[] = "`photo{$key}`='{$photo}'";
	}
	if (! empty($PHOTOS_SQL))
	{
		$PHOTOS_SQL = implode(', ', $PHOTOS_SQL);
		$sqlphotos = "UPDATE properties SET {$PHOTOS_SQL} `last_edit`='$lastedit' WHERE `property_id`='$id'";
		if(mysql_query($sqlphotos) === false)
		{
			$msg = "There was an error adding uploaded photos to the property, please contact &lt;a href=\"mailto:[email protected]?subject=Uploading Photo Problem\"&gt;administrators&lt;/a&gt; for help!&lt;br&gt;";
			$msg = "No uploaded photos attached to the property!";
			echo sqlError(__FILE__, __LINE__);
		}else{
			$msg = "Successfully added uploaded photos to this property!&lt;br&gt;";
		}
}

This is the only thing that is holding me back from finishing the website so all of your help would be most appreciated.

write_photos5.php

  • 0

your messages aren't all showing because every time you set a message, you're overwriting the contents of $msg with the new message. you either need to echo out the messages rather than sticking them in a variable, or you need to concatenate the message to the string, e.g.

$msg = "first message";
$msg = $msg . "&lt;br /&gt;\n" . "second message"; //concatenate method 1
$msg .= "&lt;br /&gt;\n" . "third message"; //concatenate method 2

is the code above displaying an error? if so what?

i think there might be an error in the sql, replace

$sqlphotos = "UPDATE properties SET {$PHOTOS_SQL} `last_edit`='$lastedit' WHERE `property_id`='$id'";

with

$sqlphotos = "UPDATE properties SET {$PHOTOS_SQL}, `last_edit`='$lastedit' WHERE `property_id`='$id'";

  • 0

Thank you guys for the previous help you have all given me on this topic. I would like to know why this topic is no longer under my account. All of my other previous topics are. Could an administrator or moderator check this out please. Thank you.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Oh no...the wallet is already screaming. So many games and so little time. Being old and responsible is awful!
    • LibreWolf 152.0.2-1 by Razvan Serea LibreWolf is an independent “fork” of Firefox, with the primary goals of privacy security and user freedom. It is the community run successor to LibreFox. LibreWolf is designed to increase protection against tracking and fingerprinting techniques, while also including a few security improvements. This is achieved through our privacy and security oriented settings and patches. LibreWolf also aims to remove all the telemetry, data collection and annoyances, as well as disabling anti-freedom features like DRM. LibreWolf features: Latest Firefox — LibreWolf is compiled directly from the latest build of Firefox Stable. You will have the the latest features, and security updates. Independent Build — LibreWolf uses a build independent of Firefox and has its own settings, profile folder and installation path. As a result, it can be installed alongside Firefox or any other browser. No phoning home — Embedded server links and other calling home functions are removed. In other words, minimal background connections by default. User settings updates Extensions firewall: limit internet access for extensions. Multi-platform (Windows/Linux/Mac/and soon Android) Community-Driven Dark theme (classic and advanced) LibreWolf privacy features: Delete cookies and website data on close. Include only privacy respecting search engines like DuckDuckGo and Searx. Include uBlockOrigin with custom default filter lists, and Tracking Protection in strict mode, to block trackers and ads. Strip tracking elements from URLs, both natively and through uBO. Enable dFPI, also known as Total Cookie Protection. Enable RFP which is part of the Tor Uplift project. RFP is considered the best in class anti-fingerprinting solution, and its goal is to make users look the same and cover as many metrics as possible, in an effort to block fingerprinting techniques. Always display user language as en-US to websites, in order to protect the language used in the browser and in the OS. Disable WebGL, as it is a strong fingerprinting vector. Prevent access to the location services of the OS, and use Mozilla's location API instead of Google's API. Limit ICE candidates generation to a single interface when sharing video or audio during a videoconference. Force DNS and WebRTC inside the proxy, when one is being used. Trim cross-origin referrers, so that they don't include the full URI. Disable link prefetching and speculative connections. Disable disk cache and clear temporary files on close. Disable form autofill. Disable search and form history...and more. Download: LibreWolf 64-bit | Portable 64-bit | ~100.0 MB (Open Source) Download: ARM64 | Portable ARM64 Links: LibreWolf Home Page | Addons | Screenshot | Reddit Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Hands on with iFlyTek AINote 2 E-Ink tablet: insanely thin and smart by Taras Buria During Amazon Prime Day 2026, iFlyTek is offering its E-Ink tablets with big discounts. The AINOTE 2 is now available at 20% off, allowing you to save quite a lot on one of the thinnest E-Ink tablets out there. I was offered a chance to look at the device, so here are my impressions. The AINOTE 2 is a large 10.65-inch E-Ink tablet that strikes you the moment you take it out of the box. It is extremely thin. At just 4.2 mm, this tablet is at the edge of what is possible for a device with a USB Type-C port. It is also very light, which makes it comfortable and enjoyable during long reading sessions. The tablet has a gold metal chassis with the front and back made of plastic. The back also features four rubber feet that prevent it from sliding around your desk when writing. Besides a USB Type-C port and an LED indicator, there are two buttons mounted on the top edge: a power button with a built-in fingerprint scanner and a dedicated AI button. I would say the fingerprint scanner is quite mid. Given that iFlyTek positions the device as a digital notebook, it makes sense to have a biometric scanner to protect sensitive information. However, it is not the fastest fingerprint reader, and sometimes it fails to recognize my finger. I assume that is due to the tablet's insane thinness. A dedicated AI button is an interesting choice, especially in the middle of the top edge. I can see this button being useful for those who heavily rely on AI and use it frequently, but I cannot help but think its placement is impractical. Having it on one of the longer sides would make so much more sense. The AINOTE 2 is a very pretty device. Gold finish with thin chassis and nearly symmetrical front bezels create a fantastic combination, and iFlyTek cleverly hides the front chin with a section that looks like an extension of the screen, housing two touch-capacitive buttons: one for AI and one for quick notes. This section can also scroll pages when you swipe from the middle to the left or right. It is a cool idea, and very handy when you need to scroll tens of pages at once. AINOTE 2's elegant look extends from its exterior to its software. The user interface is very clean and not cluttered with an abundance of buttons. The tablet prioritizes the note-taking experience, and when you unlock it, it defaults to the list of all notes and folders. Additionally, there is a separate "Schedule" section with your calendar, tasks, memos, and other productivity features. You can connect your Outlook or Google account or use a local calendar. The tablet has quite a lot of AI features powered by OpenAI's GPT-5 and Google's Gemini 3. Besides a standard app with all your chats, you can invoke AI by pressing its dedicated button and dictating your request. It is not limited to just chats. It works with the built-in calendar, and you can tell it to create events, tasks, notes, and more. Additionally, AI features are integrated into the built-in notepad, allowing you to summarize notes, ask questions about your notes, and more. The tablet can OCR handwritten text in different languages (about 120 languages, which is very impressive), and it surprised me with very good accuracy. Voice note transcription is also available, including a "multiplayer" mode where the tablet detects each speaker. Unfortunately, the AINOTE 2 has no built-in speakers (even though it somehow makes a tapping noise when you flip pages using the Quick Bar), so the only way to listen to something is to connect a Bluetooth speaker or headphones. However, there are four front-facing mics for dictation, voice notes, AI chats, and more. Unfortunately, certain features require a Pro subscription that costs $5.99/mo or $59.99/year. Those include offline voice transcription, access to better AI models, the ability to edit notes on a PC or mobile app, and extended service coverage similar to Apple Care. It is a bummer to see yet another app, especially in a device that costs $649, but at least they give a free 90-day trial so that you can see if the benefits justify the price. As for the reader, it supports PDF, EPUB, TXT, MOBI, AZW3, DOC(X), XLS(X), PPT(X), JPEG, JPG, and PNG. The app is quite customizable, with features like text contrast/boldness/size adjustments, margins and spacing customization, and the ability to load custom fonts. Plus, you can annotate books with the stylus, add text notes, and use AI to work with them. Just keep in mind that most AI features require an active internet connection. Like with other E-Ink tablets with Android inside, you can load any other reader you want from the Google Play Store or a third-party source. Despite its hefty price tag of $629 or $519 by the time of publishing this article during Prime Day 2026, the AINOTE 2 has quite modest hardware inside. There is only 4 GB of RAM and about 42GB of storage. It is powered by the RockChip RK3576 processor with 8 cores at 2.2 GHz. Given that the tablet runs Android 14 and has Google Play, you can install Android apps, but do not expect much from this thing performance-wise. As for the battery, there is a 4,000 Li-Ion battery, which, on full charge, lasted me for about one week of active daily use of reading and note-taking. The screen has a resolution of 1920x2560 pixels, which equals 300 PPI, a perfect spot for a sharp, nice-to-read display. It supports EMR styluses that do not require charging, and I have to say that the note-taking experience on this tablet is fantastic. Stylus lag is nearly imperceivable, creating a very natural, paper-like feel. The stylus comes in the box (including two extra nibs), and it features an extra button for various actions and an eraser on top. It magnetically attaches to the tablet and stays safely secured. The stylus has a very nice coarse texture, and thanks to using Wacom tech, you can swap it for any other EMR pen if you wish. The AINOTE 2 has no front light, and because of that, the display sits very close to the screen surface, reducing the distance between the stylus tip/your finger and the display to a minimum. No front light is certainly an inconvenience in certain scenarios, but the screen makes up for that with a seriously impressive paper-like feel and writing experience. In dark conditions, you will have to find a lamp, but the good thing is that the screen has a solid anti-glare surface that diffuses light. The display has two modes: Crisp and Fast. Crisp ensures the image stays, well, crisp and sharp, while Fast speeds up refresh rate and response by toning down display resolution and making everything a bit more jagged. In my testing, I only used Fast mode when browsing the web for a much faster render time. The iFlyTek AINOTE is an impressive device, but it's not flawless. A few things disappointed me during a week of using it. Software localization has a bunch of not necessarily broken, but certainly awkward, machine-translated English. System navigation is not good, as there is no universal "Home" gesture. To go to the main page, you have to swipe up and then press the Home button from the multi-tasking window. There are many gestures for various actions, such as display cleanup, screenshot, undo/redo, but no back/forward or Home gestures. I really hate that the tablet won't let me update its software without creating an iFlyTek account first. Finally, privacy could be a concern for some, as most tablets' features require an active internet connection, an iFlyTek account, and sharing data when using AI. If you can overlook its quirks, some of which could be addressed with software updates (I received two with massive changelogs over a single week), and accept a $519 price tag (with a discount), you will be happy with the AINOTE 2. However, if you do not need that many AI features in an E-Ink reader or you want something a bit more affordable, you'd better look at cheaper competitors from BOOX or Amazon, such as the BOOX Go 10.3 Gen 2 or the Kindle Scribe, which is currently 24% off during Prime Day sales. Buy iFlyTek AINOTE 2 on Amazon - $519 | 20% off with Prime What I liked What I disliked Very impressive hardware Beautiful design Fantastic display with an EMR stylus Supports offline voice transcription Easy-to-use software Clever, useful, and well-made AI features A fingerprint scanner Very expensive Some features require a subscription Poor system navigation Mandates a user account No speakers Privacy could be a concern Note: iFlyTek provided the review unit without any editorial input or review guidance. As an Amazon Associate, we earn from qualifying purchases.
    • Look up "greed". If you are willing to buy that it's only inflation, I've got a bridge to sell you.
    • Very umm, blue?  
  • Recent Achievements

    • First Post
      kinowa earned a badge
      First Post
    • Rookie
      krychek57 went up a rank
      Rookie
    • Grand Master
      Jaybonaut went up a rank
      Grand Master
    • One Year In
      Philsl earned a badge
      One Year In
    • Dedicated
      Scoobystu earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      416
    2. 2
      +Edouard
      168
    3. 3
      PsYcHoKiLLa
      132
    4. 4
      Xenon
      73
    5. 5
      Michael Scrip
      73
  • Tell a friend

    Love Neowin? Tell a friend!