How to update a photo using PHP? - Build2024-03-28T15:53:01Zhttps://build.ning.com/forum/topics/how-to-update-a-photo-using?commentId=6308082%3AComment%3A16911&feed=yes&xn_auth=noBelal - the code is posted on…tag:build.ning.com,2012-05-10:6308082:Comment:168352012-05-10T00:29:09.692ZPhillip Pearsonhttps://build.ning.com/profile/PhillipPearson
<p>Belal - the code is posted on Mahendra's own server. It requires PHP, so won't work if you just post it on a Ning page.</p>
<p></p>
<p>Mahendra - as Devin suggested, you should check that you are passing in the photoIdToUpdate parameter correctly. Looking at this part:</p>
<p></p>
<p><input type="hidden" id="photoIdToUpdate" name="photoIdToUpdate" value="<?php if(isset($_REQUEST["photoId"])) echo $_REQUEST["photoId"]; ?>" /></p>
<p></p>
<p>It seems that the photo ID will only…</p>
<p>Belal - the code is posted on Mahendra's own server. It requires PHP, so won't work if you just post it on a Ning page.</p>
<p></p>
<p>Mahendra - as Devin suggested, you should check that you are passing in the photoIdToUpdate parameter correctly. Looking at this part:</p>
<p></p>
<p><input type="hidden" id="photoIdToUpdate" name="photoIdToUpdate" value="<?php if(isset($_REQUEST["photoId"])) echo $_REQUEST["photoId"]; ?>" /></p>
<p></p>
<p>It seems that the photo ID will only be passed in if $_REQUEST["photoId"] is set. Can you double-check that in the PHP code, by adding in the code in <strong>bold</strong>?</p>
<p></p>
<p>$parts = array(<br/>"title" => $_POST["title"],<br/>"description" => $_POST["description"],<br/>"id" => $_POST["photoIdToUpdate"]<br/>);</p>
<p><strong>echo '$parts: '; </strong><strong>print_r($parts); </strong><strong>echo '<hr>';</strong></p>
<p>$result = NingApi::instance()->photo->updateById($parts);<br/>print_r($result);</p>
<p></p>
<p>Try editing the photo, and if it doesn't work, paste the info this prints out into this discussion and let me know the URL of the network you're working against, and I'll check things out.</p> Dear Mahendra,
I'm trying to…tag:build.ning.com,2012-05-08:6308082:Comment:169112012-05-08T15:27:58.621ZBelalhttps://build.ning.com/profile/Belal
<p>Dear Mahendra,</p>
<p>I'm trying to create a Photo Competition app/section for my network.</p>
<p>My question to you is where are you posting the above photo code ? Is it on your own server or on new Ning pages</p>
<p>on your Ning Network ?</p>
<p>Thanks</p>
<p>- Belal </p>
<p>Dear Mahendra,</p>
<p>I'm trying to create a Photo Competition app/section for my network.</p>
<p>My question to you is where are you posting the above photo code ? Is it on your own server or on new Ning pages</p>
<p>on your Ning Network ?</p>
<p>Thanks</p>
<p>- Belal </p> Hey Devin,
Thank you for ta…tag:build.ning.com,2011-05-09:6308082:Comment:44032011-05-09T16:32:17.250Zliyamahendra4https://build.ning.com/profile/liyamahendra4
<p>Hey Devin,</p>
<p> </p>
<p>Thank you for taking time to reply back. Here is my HTML Code:</p>
<p> </p>
<p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br></br><html xmlns="http://www.w3.org/1999/xhtml"><br></br><head><br></br><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br></br><title>Upload Photo</title><br></br></head><br></br><br></br><body><br></br> <div…</p>
<p>Hey Devin,</p>
<p> </p>
<p>Thank you for taking time to reply back. Here is my HTML Code:</p>
<p> </p>
<p><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br/><html xmlns="http://www.w3.org/1999/xhtml"><br/><head><br/><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><br/><title>Upload Photo</title><br/></head><br/><br/><body><br/> <div id="logoDiv" style='padding-top: 20px; padding-bottom: 20px;'><br/> <img src='logodrk.png' alt='logo' /><br/></div><br/><form action="upload.php" method="post" enctype="multipart/form-data"><br/> <p style='padding: 20px'><br/> <br/> <span> Title : </span> <br/> <br /><br/> <input type="text" name="title" id="title" /> <br /><br/> <span> Description : </span><br/> <br /><br/> <textarea name="description" id="description" cols="50" rows="5"> </textarea><br/> <br /><br/><br/> <input type="hidden" id="photoIdToUpdate" name="photoIdToUpdate" value="<?php if(isset($_REQUEST["photoId"])) echo $_REQUEST["photoId"]; ?>" /><br/> <input type="hidden" id="email" name="email" value="<?php if(isset($_REQUEST["email"])) echo $_REQUEST["email"]; ?>" /><br/> <input type="hidden" id="password" name="password" value="<?php if(isset($_REQUEST["password"])) echo $_REQUEST["password"]; ?>" /><br/><br/><br/> <?php <br/> if(!isset($_REQUEST["photoId"])) <br/> {<br/> ?><br/> <span> Picture to upload: </span><br/> <br /><br/><br/> <input type="file" name="file" id="file" /> <br/> <br /><br/> <input type='submit' value='Upload' style='width: 100px; text-align: center; padding: 0px;' /> <br/> <?php<br/><br/> }<br/> else<br/> {<br/> ?><br/> <br /><br/> <input type='submit' value='Update' style='width: 100px; text-align: center; padding: 0px;' /> <br/> <?php<br/><br/> }<br/> ?><br/><br/> <br/> <br/> </p><br/> </form><br/></body><br/></html></p>
<br />
<br />
Please let me know why is it not updating the photo?<br />
<br />
Thanks in advance. The PHP code you posted looks…tag:build.ning.com,2011-05-09:6308082:Comment:43042011-05-09T16:24:47.861ZDevinhttps://build.ning.com/profile/Devin
The PHP code you posted looks good, I'd check your HTML form and make sure that you are passing in the <em>photoIdToUpdate</em> properly. I'd add in a debug <em>print_r($parts)</em> before you make the request to Ning to verify your PHP code is receiving what you are expecting.<br/>
The PHP code you posted looks good, I'd check your HTML form and make sure that you are passing in the <em>photoIdToUpdate</em> properly. I'd add in a debug <em>print_r($parts)</em> before you make the request to Ning to verify your PHP code is receiving what you are expecting.<br/> Hello Devin,
You seem to be…tag:build.ning.com,2011-05-07:6308082:Comment:33582011-05-07T14:09:53.684Zliyamahendra4https://build.ning.com/profile/liyamahendra4
<p>Hello Devin,</p>
<p> </p>
<p>You seem to be the only person answer the questions here. Can you please spare some time to answer my question.</p>
<p> </p>
<p>Thanks,</p>
<p>Mahendra.</p>
<p>Hello Devin,</p>
<p> </p>
<p>You seem to be the only person answer the questions here. Can you please spare some time to answer my question.</p>
<p> </p>
<p>Thanks,</p>
<p>Mahendra.</p> Hello Devin,
Thank you for y…tag:build.ning.com,2011-04-29:6308082:Comment:37202011-04-29T19:57:02.107Zliyamahendra4https://build.ning.com/profile/liyamahendra4
Hello Devin,<br />
<br />
Thank you for your reply. Glad to know that my approach was correct.<br />
<br />
Following is the code which I used to udpate the Photo of the user:<br />
<br />
$ningApi = new NingApi($subdomain, $consumer_key, $consumer_secret);<br />
$email = $_POST["email"];<br />
$password = $_POST["password"];<br />
<br />
$loginMessage = "";<br />
try<br />
{<br />
$result = $ningApi->login($email, $password);<br />
$loginMessage = "success";<br />
}<br />
catch(Exception $e)<br />
{<br />
$loginMessage = $e->getMessage();<br />
}<br />
<br />
<br />
$parts = array(<br />
"title" =>…
Hello Devin,<br />
<br />
Thank you for your reply. Glad to know that my approach was correct.<br />
<br />
Following is the code which I used to udpate the Photo of the user:<br />
<br />
$ningApi = new NingApi($subdomain, $consumer_key, $consumer_secret);<br />
$email = $_POST["email"];<br />
$password = $_POST["password"];<br />
<br />
$loginMessage = "";<br />
try<br />
{<br />
$result = $ningApi->login($email, $password);<br />
$loginMessage = "success";<br />
}<br />
catch(Exception $e)<br />
{<br />
$loginMessage = $e->getMessage();<br />
}<br />
<br />
<br />
$parts = array(<br />
"title" => $_POST["title"],<br />
"description" => $_POST["description"],<br />
"id" => $_POST["photoIdToUpdate"]<br />
);<br />
<br />
$result = NingApi::instance()->photo->updateById($parts);<br />
print_r($result);<br />
<br />
print "Ning Update complete";<br />
<br />
<br />
It is giving me the following error:<br />
<br />
Fatal error: Uncaught Invalid or missing content id. (400) 5-7 thrown in C:\wamp\www\ning\NingException.php on line 56<br />
<br />
Can you please tell me why this is not working?<br />
<br />
Thanks,<br />
Mahendra. You are on the right track! Y…tag:build.ning.com,2011-04-28:6308082:Comment:33432011-04-28T17:44:31.364ZDevinhttps://build.ning.com/profile/Devin
<p>You are on the right track! You just need to add form fields for each of the photo's fields you want members to be able to update. Here is a sketch of the flow of information:</p>
<ol>
<li>Member clicks a photo</li>
<li>The photo's ID is passed into an HTML form as a hidden field</li>
<li>Member inputs fills in the fields they want to update such as title and description</li>
<li>Member clicks the submit button</li>
<li>Web browser sends the data to your server</li>
<li>Server receives the…</li>
</ol>
<p>You are on the right track! You just need to add form fields for each of the photo's fields you want members to be able to update. Here is a sketch of the flow of information:</p>
<ol>
<li>Member clicks a photo</li>
<li>The photo's ID is passed into an HTML form as a hidden field</li>
<li>Member inputs fills in the fields they want to update such as title and description</li>
<li>Member clicks the submit button</li>
<li>Web browser sends the data to your server</li>
<li>Server receives the request and translates it into a Ning API request</li>
<li>Member visits the network and see their changes</li>
</ol>