- 0
Uploading Photos, creating directory and updating row in table.
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Posts
-
By MikeK13 · Posted
What people who support this position of LibreOffice do not understand is that EuroOffice is not made to appease the open source enthusiasts (I am also one) and evangelists. EuroOffice was made because some European companies wanted independence from Microsoft Office Suite, which is something installable on your computer. This move to independence was pushed by public institutions and governments in Europe, as well. Using a proprietary FORMAT as default, does not make you dependent on MS. The actual program does. A format can be changed with a simple update in the future in a dystopian world where MS would manipulate the format to lock others out. However, using MS Office proprietary format, guarantees that all the current documents used by companies, organizations, institutions, etc, will be compatible with EuroOffice and the suite will have the best chances at adoption, especially by slow moving organizations like governments and the public sector. It is as simple as that. For the same reason, even the UI is incredibly similar to MS Office. For the same reason (adoption) the choice was made to be open source. Not because EU particularly loves open source ideologically, but because it gives the best starting point to create trust in the project and amass developers and contributions to the project quickly, to catch up with proprietary projects like MS Office. I don't understand how people don't realize it. -
By WaltC · Posted
How old is this tip? Seems 15-20 years old? Processor states for the CPU under Windows power options has been a thing for a long, long time. It certainly isn't new or hidden... Also, with laptops it doesn't make any difference what OS you are running, all of them are configured for battery longevity over performance, for obvious reasons. -
By WaltC · Posted
I can't believe Starmer is still there...his party lost so big. He's a stubborn coot, but this is largely unenforceable, so I would imagine he'll be resigning soon. A key here is for parents to buy their kids phones sans Internet access--and set up the Internet at home, where mom and day can, you know, act like parents instead expecting the government to raise their kids. -
By LoneWolfSL · Posted
EA launches in-game advertising platform for brands to "connect with audiences" by Pulasthi Ariyasinghe The gaming giant Electronic Arts is exploring more ways to inject real-life brands into its games. Announced today as EA Advertising, the new platform is attempting to make it easier for brands to reach out for deals with the company and put their products inside titles like EA Sports FC, Madden, NHL, Skate, or The Sims. EA revealed that its EA Sports side of the company brings in "hundreds of millions of players across console, PC, and mobile" every year. Fan engagement of these titles was also touted as being "extraordinary," with 23,000 NFL seasons worth of games being played in Madden NFL daily, while EA Sports FC sees over a billion matches a day. “Players come to EA’s games and live experiences every day to play, watch, create and connect,” said David Tinson, Chief Experiences Officer at Electronic Arts. “That gives brands a meaningful opportunity to show up in ways that add value and respect the player experience, while maintaining authenticity in the worlds our teams are building. With EA Advertising, we’re helping brands become part of those moments in ways that are relevant and built for players.” Using the new program EA Advertising, brands will be able to inject their products into games in real-time via dynamic placement. EA says partners will have access to everything from stadium signage in sports games and targeted adverts to in-game content custom-made for the brands. These are described as additions designed to "enhance, not disrupt" experiences. "In these interactive gameplay environments, brands become part of the game itself, reflecting how players engage with advertising in real-world contexts," adds the company "Brands can activate across live environments, tailoring placements to meet campaign objectives, and update campaigns with ongoing optimization informed by aggregated engagement insights." Current real-world brand partnerships EA has built into its games include Visa (EA Sports FC and College Football), Lowe's (EA Sports FC, Madden NFL, and College Football), Red Bull (EA SPORTS FC), Xfinity and Peacock (EA SPORTS FC), and Mountain Dew’s (College Football). -
By suni08 · Posted
Will be surprised if there isn't a new ver of youtube just for labelled educational content
-
-
Recent Achievements
-
Jeroen Wilms earned a badge
Week One Done
-
rolfus earned a badge
Week One Done
-
Leroy Jethro Gibbs earned a badge
One Month Later
-
flexorcist earned a badge
Conversation Starter
-
AndreaB earned a badge
One Month Later
-
-
Popular Contributors
-
Tell a friend
Question
seb86
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.
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.
Link to comment
https://www.neowin.net/forum/topic/649976-uploading-photos-creating-directory-and-updating-row-in-table/Share on other sites
20 answers to this question
Recommended Posts