Jump to content
xisto Community

sonesay

Members
  • Content Count

    958
  • Joined

  • Last visited

  • Days Won

    5

Reputation Activity

  1. Upvote
    sonesay got a reaction from dsjoes in Header Error   
    The reason for that error is because you have already began outputting HTML code so redirecting after that point is not possible. You can move your whole PHP code block to the top before you begin your HTML output and it should work.

    <?php// Set Global Vars$HOST = "";$USERNAME = "";$PASSWORD = "";$DATABASE = "";$TABLE = "";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());//==================================================================// Check if anything is posted//==================================================================if (isset($_POST['delete'])) { $sql = ("delete from $TABLE where "); for ($i = 0; $i < count($_POST['checkbox']); $i++) { if ($i != 0) { $sql.= "OR "; } $sql .= " id='" . $_POST['checkbox'][$i] . "'"; //================================================================== // Select file to unlink based on id posted //================================================================== $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}"; $result_file_unlink = mysql_query($sql_file_unlink); $row_file_link = mysql_fetch_assoc($result_file_unlink); if($row_file_link) { unlink('../testimonial_files/' . $row_file_link['Download']); } //================================================================== } $result = mysql_query($sql); header('Location: index.php'); exit;} else { // select sql here $sql = "select * from `$TABLE` order by `id`;"; $result = mysql_query($sql);}?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/ xmlns="http://forums.xisto.com/no_longer_exists/ http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Testimonials</title><link href="../style.css" rel="stylesheet" type="text/css" /><link href="uploadify/uploadify.css" type="text/css" rel="stylesheet" /> <script type="text/javascript" src="uploadify/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="uploadify/swfobject.js"></script> <script type="text/javascript" src="uploadify/jquery.uploadify.v2.1.4.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $('#file_upload').uploadify({ 'uploader' : 'uploadify/uploadify.swf', 'script' : 'uploadify/uploadify.php', 'cancelImg' : 'uploadify/cancel.png', 'folder' : '../testimonial_files', 'auto' : true }); }); </script> </head><body><div class="container"> <div class="header"><br /><br /><br /> </div> <div class="sidebar1"> <ul class="nav"><b> <li><a href="../">Home</a></li> <li><a href="/admin/">Testimonials upload</a></li> <li><a href="audio/">Audio Testimonials upload</a></li> <li><a href="dvds/">Dvd's upload</a></li> <li><a href="newsletter/">Newsletter upload</a></li> <li><a href="news/">News box update</a></li> </b></ul></div> <div class="content"> <center><h2>Admin</h2></center> <br /><center><p><input id="file_upload" name="file_upload" type="file" /></p><p><table width="200" border="0"><form action="insert_test.php" method="post"> <tr> <td align="right">Name:</td> <td><input type="text" name="Name" /></td> </tr> <tr> <td align="right">Description:</td> <td><input type="text" name="Message" /></td> </tr> <tr> <td align="right">Download:</td> <td><input name="Download" type="text" /></td> </tr> <tr> <td colspan="2" align="center"><input type="submit" value="Submit" /></td> </tr></form></table></p><br /><br /><p><table align="center" width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td colspan="6" align="center"><strong>Testimonials</strong> </td> </tr> <tr> <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <table width="400" border="1" cellpadding="3" cellspacing="1"> <tr> <td align="center"><strong>Select</strong></td> <td align="center"><strong>ID</strong></td> <td align="center"><strong>Name</strong></td> <td align="center"><strong>Description</strong></td> <td align="center"><strong>Download</strong></td> <td align="center"><strong>Last Modified</strong></td> </tr><?php $row = mysql_fetch_assoc($result); ?><?php do { ?> <tr> <td align="center"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>"> </td> <td align="center"><?php echo $row['id']; ?></td> <td align="center"><?php echo $row['Name']; ?></td> <td align="center"><?php echo $row['Message']; ?></td> <td align="center"><a href="../testimonial_files/<?php echo $row['Download']; ?>">Download</a></td> <td align="center"><?php echo date("j/n/y", strtotime($row["Modified"])) ?></td> </tr> <?php } while ($row = mysql_fetch_assoc($result)); ?> <tr> <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> </table> </form> </td> </tr> </table></p></center></div> <div class="sidebar2"> <h4>Text here</h4> <p> </p> </div> <div class="footer"> <center><p>Š Copyright 2010</p></center> </div> </div></body></html>
  2. Upvote
    sonesay got a reaction from dsjoes in Error Message Help   
    Yeah your right. I didn't look at the entire code and just pasted the whole block in. the

    unlink('../admin/testimonial_files/' . $row['Download']); line you can delete I think because its not needed? if you look at http://php.net/manual/en/function.unlink.php this method deletes a file and I don't remember you mentioning there was any files you also needed deleting. If you do need to delete a file as well then you can paste that line back into the loop block.

    Edit: I just looked at your code again and by the looks of it you only want to be deleting (unlinking) the file if the user submits a delete post right? If that is the case then you would need to do:

    <?php// Set Global Vars$HOST = "database";$USERNAME = "sonint99";$PASSWORD = "C2sHF9Zxq3ULXCTV";$DATABASE = "Random";$TABLE = "Testimonials";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());//==================================================================// Check if anything is posted//==================================================================if (isset($_POST['delete'])) { $sql = ("delete from $TABLE where "); for ($i = 0; $i < count($_POST['checkbox']); $i++) { if ($i != 0) { $sql.= "OR "; } $sql .= " id='" . $_POST['checkbox'][$i] . "'"; //================================================================== // Select file to unlink based on id posted //================================================================== $sql_file_unlink = "select Download from $TABLE where id = {$_POST['checkbox'][$i]}"; $result_file_unlink = mysql_query($sql_file_unlink); $row_file_link = mysql_fetch_assoc($result_file_unlink); if($row_file_link) { unlink('../admin/testimonial_files/' . $row_file_link['Download']); } //================================================================== } $result = mysql_query($sql); header('Location: index.php'); exit;} else { // select sql here $sql = "select * from `$TABLE` order by `id`;"; $result = mysql_query($sql);}?><table align="center" width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td colspan="6" align="center"><strong>Testimonials</strong> </td> </tr> <tr> <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <table width="400" border="1" cellpadding="3" cellspacing="1"> <tr> <td align="center"><strong>Select</strong></td> <td align="center"><strong>ID</strong></td> <td align="center"><strong>Name</strong></td> <td align="center"><strong>Description</strong></td> <td align="center"><strong>Download</strong></td> <td align="center"><strong>Last Modified</strong></td> </tr> <?php $row = mysql_fetch_assoc($result); ?><?php do { ?> <tr> <td align="center"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>"> </td> <td align="center"><?php echo $row['id']; ?></td> <td align="center"><?php echo $row['Name']; ?></td> <td align="center"><?php echo $row['Message']; ?></td> <td align="center"><a href="/admin/testimonial_files/<?php echo $row['Download']; ?>">Download</a></td> <td align="center"><?php echo $row['Modified']; ?></td> </tr> <?php } while ($row = mysql_fetch_assoc($result)); ?> <tr> <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> </table> </form> </td> </tr> </table><?php
    I hope that's what you wanted. I removed some variables as it seems like they arnt being used like the delete id from the submit button.
  3. Upvote
    sonesay got a reaction from dsjoes in Error Message Help   
    Yeah I thought that's what you wanted but I wasn't too sure so I had to ask. all the code for the part where you delete needs to go in the correct if block in your statement. The part where you query for your result and use it in the mysql_fetch_assoc() needs to go in the else block.

    Try this:

    <?php// Set Global Vars$HOST = "XXXXXXX";$USERNAME = "XXXX";$PASSWORD = "XXXXX";$DATABASE = "XXXXX";$TABLE = "Testimonials";// Establish a connectionmysql_connect($HOST, $USERNAME, $PASSWORD) or die(mysql_error());mysql_select_db($DATABASE) or die(mysql_error());if (isset($_POST['delete'])) { // delete sql here $DELETE_ID = mysql_real_escape_string($_POST['delete']); unlink('../admin/testimonial_files/' . $row['Download']); $sql = ("delete from $TABLE where "); for ($i = 0; $i < count($_POST['checkbox']); $i++) { if ($i != 0) { $sql.= "AND "; } $sql .= " id='" . $_POST['checkbox'][$i] . "'"; } $result = mysql_query($sql); header('Location: index.php'); exit;} else { // select sql here $sql = "select * from `$TABLE` order by `id`;"; $result = mysql_query($sql);}?><table align="center" width="400" border="0" cellspacing="1" cellpadding="0"> <tr> <td><form name="delete" method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <table width="400" border="1" cellpadding="3" cellspacing="1"> <tr> <td colspan="6" align="center"><strong>Testimonials</strong> </td> </tr> <tr> <td align="center"><strong>Select</strong></td> <td align="center"><strong>ID</strong></td> <td align="center"><strong>Name</strong></td> <td align="center"><strong>Description</strong></td> <td align="center"><strong>Download</strong></td> <td align="center"><strong>Last Modified</strong></td> </tr><?php $row = mysql_fetch_assoc($result); ?><?php do { ?> <tr> <td align="center"> <input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row['id']; ?>"> </td> <td align="center"><?php echo $row['id']; ?></td> <td align="center"><?php echo $row['Name']; ?></td> <td align="center"><?php echo $row['Message']; ?></td> <td align="center"><a href="/admin/testimonial_files/<?php echo $row['Download']; ?>">Download</a></td> <td align="center"><?php echo $row['Modified']; ?></td> </tr> <tr> <td colspan="6" align="center"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> </table> </form> </td> </tr> </table><?php } while ($row = mysql_fetch_assoc($result)); ?>
  4. Upvote
    sonesay got a reaction from dsjoes in Sql/php Table Help   
    <td><? echo <a href='/docs"$row['Download']"'>Download</a>; ?></td>
    Try not to mix standard HTML tags with your echo PHP statement. It makes it more organized and less prone to errors as what ever editor you may be using can highlight the HTML code.


    This is how I would write it but its really up to personal preference.
    <td><a href="/docs/<?php echo $row['Download']; ?>">Download</a></td>
  5. Upvote
    sonesay got a reaction from dsjoes in Sql/php Table Help   
    It's probably because your $row['Download'] is not a table field name (column) or the records just contain an empty string. Verify the field name and records for it in the database.

    Good luck
  6. Upvote
    sonesay got a reaction from dsjoes in Sql/php Table Help   
    Hi, First of all what does the $row['Download'] output? If it is just the file name then you will need to build the anchor tag your self. You should know where the file is being uploaded to so build the anchor tag accordingly.


    while($row = mysql_fetch_array($result)){echo "<tr>";echo "<td width='150'>" . $row['Name'] . "</td>";echo "<td width='250'>" . $row['Message'] . "</td>";echo "<td width='100'>" . $row['Download'] . "</td>";echo "</tr>";}echo "</table>";
    Something like ?

    while($row = mysql_fetch_array($result)){echo "<tr>";echo "<td width='150'>" . $row['Name'] . "</td>";echo "<td width='250'>" . $row['Message'] . "</td>";echo "<td width='100'><a href='PATH_TO_FILE".$row['Download']."'>" . $row['Download'] . "</a></td>";echo "</tr>";}echo "</table>";
    Assuming $row['Download'] contains your file name...
    Good luck
  7. Upvote
    sonesay got a reaction from rob86 in Thoughts About Knowledgesutra. What is happening?   
    Hey guys I know its been a while since I posted but I still return because this place is unique. The free hosting is just a bonus because the amount of content you can find here is more vast, diverse and of higher quality than most other forums I have been to. Sure there are others but sometimes they focus on only one topic of interest so you really only go there and leave after you found what you are looking for. In my opinion coming here shouldn't really just be about getting free hosting. You can get it at other sites (not sure i should say that here or even if its allowed). The hosting here isn't perfect but its good from what I remember... I'm not sure what happen to my hosting account but I was inactive for a long time due to stress of work and study so my account went over due and the last I remember I accumulated so much invoices that I couldn't even pay it with my cents. I worked out a deal to pay for a few months off the invoices just to get the data I have on my account since I lost all copies on my end. My portfolio site was up there and I needed it bad to look for a job. I dont particularly like how rude some people come across expecting the owner to cater to their every needs. This isn't a free service so don't expect that. Criticizing the moderators too when I know for a fact they help out when they can. Complaining isn't going to help you get help any quicker. Please just learn to be more patient and considerate. I'm sorry I just had to express my dislike for such behaviors. I was hoping maybe I could start over again in getting my hosting back up using mycents but by the looks of things it seems to be very bad here recently. I cant even log into my billing account using the password recover is this broken? I get the password sent to me but logging does not work. Other then wanting free hosting like most do I would like to network with people who share the same interest. I've progressed a lot during this year and have been developing in java, java fx mainly but I wish to return to PHP and I am currently picking up Zend Framework as well. It seems easier this time round since I have a much better understanding of software development principles. If anyones in need of any help with zend framework or wish to discuss about better programming practices using MVC then hit me up I would be more then happy to help. I have struggled with getting to grips with it in the past and would have liked someone to teach me the ropes in the begging but there was really no one. The best way to learn is through peers and teaching I think.I am pretty excited about progressing more and expanding my knowledge here so I hope this place keeps thriving. I hope to hear about all the exciting projects everyones been working or currently as I am naturally curious about others.
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.