- 0
Uploading Photos, creating directory and updating row in table.
-
Recently Browsing 0 members
- No registered users viewing this page.
-
Posts
-
By Nas · Posted
The blatant anti-competitive nature of the EU's DMA rules are obscenely IRONIC and wholly damaging to upwards innovations from within the EU. Why?! Because it penalizes marketplace competitors whom the users CHOOSE to sign contracts with (basically dictating the product management models and strategies whilst handicapping popular marketplace choices) all under the guise of 'fair competition' and assuring continued operations. The only beneficiary (as the DMA is written and applied) are the toxic wannabes with whom most consumers have chosen to NOT do business with! What kind of bass-ackwards nonsense is that?! Not everyone in the marketplace that's lower-ranked deserves some sort of advantage whilst being otherwise garbage and toxic. Ugh, so dumb. -
By LoneWolfSL · Posted
Assetto Corsa Competizione, House Flipper 2, and more join Xbox Free Play Days by Pulasthi Ariyasinghe There is a brand-new Free Play Days offer available to Xbox players, giving them a chance to try out a new selection of games over the weekend. Microsoft's latest promotion brings in three games for Xbox players to try out, and they are House Flipper 2, Blades of Fire, and Assetto Corsa Competizione. Unlike in recent weeks, no games from this selection are being offered without a Game Pass subscription this time. This means only Xbox Game Pass Ultimate, Premium, and Essential members can jump into the three titles, even if they are single-player. From the trio, House Flipper 2 is for simulation fans. The title lets you buy run-down properties, renovate them, and sell them for a profit. A sandbox mode even lets you build houses from scratch too. Next, Blades of Fire lands as a fantasy adventure that combines metroidvania exploration with punishing combat. One unique aspect is that instead of finding loot, you'll be physically forging your own weapons. Lastly, we go back to simulators with Assetto Corsa Competizione, with the hit racing title offering a hardcore, highly competitive racing game focused entirely on GT3 and GT4 class cars. Everything from the tracks and tire physics to the dynamic weather conditions are focused on giving players an authentic driving experience. Here are the announced games and the platforms they are available to play on: House Flipper 2 (Xbox Series X|S) Blades of Fire (Xbox Series X|S) Assetto Corsa Competizione (Xbox Series X|S, Xbox One) To easily find the titles on Xbox consoles, first head to the Store, and then in the sidebar, find the Home section. In there, open the Subscriptions tab. All the games from the Free Play Days collection will show up in this section for quick access. This week's Free Play Days promotions will end on Sunday, June 28, at 11:59 pm PT. -
By FloatingFatMan · Posted
Just what I wanted, an even bigger bomb in my Chinese spy phone. -
By TCA · Posted
Be sure to toss in a couple tacos to sweeten the deal, no one else sells better bridges! -
By TCA · Posted
Online didn't launch until October of 2013. So no one could play it. Even then there were issues.
-
-
Recent Achievements
-
kinowa earned a badge
First Post
-
krychek57 went up a rank
Rookie
-
Jaybonaut went up a rank
Grand Master
-
Philsl earned a badge
One Year In
-
Scoobystu earned a badge
Dedicated
-
-
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