Jump to content

daebat

Members
  • Posts

    83
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

daebat's Achievements

Member

Member (2/5)

0

Reputation

  1. Doesn't session expire really quickly though?
  2. I'm working on a five star voting system for a website and I have very limited knowledge of cookies and javascript for that matter. I'm attempting to limit users to only one vote per instance so I'm guessing I'll need some sort of count and a cookie tracking system that could delete after a couple days. I'm not necessarily worried about people clearing cache as the votes aren't incredibly important but I definitely don't want the ability to keep voting via click. Here is what I've accomplished so far: <script> $(document).ready(function() { $('.rate_widget').each(function(i) { var widget = this; var out_data = { widget_id : $(widget).attr('id'), fetch: 1 }; $.post( 'ratings.php', out_data, function(INFO) { $(widget).data( 'fsr', INFO ); set_votes(widget); }, 'json' ); }); $('.ratings_stars').hover( function() { $(this).prevAll().andSelf().addClass('ratings_over'); $(this).nextAll().removeClass('ratings_vote'); }, function() { $(this).prevAll().andSelf().removeClass('ratings_over'); // can't use 'this' because it wont contain the updated data set_votes($(this).parent()); } ); $('.ratings_stars').bind('click', function() { var star = this; var widget = $(this).parent(); var clicked_data = { clicked_on : $(star).attr('class'), widget_id : $(star).parent().attr('id') }; $.post( 'ratings.php', clicked_data, function(INFO) { widget.data( 'fsr', INFO ); set_votes(widget); }, 'json' ); }); }); function set_votes(widget) { var avg = $(widget).data('fsr').whole_avg; var votes = $(widget).data('fsr').number_votes; var exact = $(widget).data('fsr').dec_avg; window.console && console.log('and now in set_votes, it thinks the fsr is ' + $(widget).data('fsr').number_votes); $(widget).find('.star_' + avg).prevAll().andSelf().addClass('ratings_vote'); $(widget).find('.star_' + avg).nextAll().removeClass('ratings_vote'); $(widget).find('.total_votes').text( votes + ' votes recorded (' + exact + ' rating)' ); } </script>
  3. I'm just installed Yet Another Featured Posts Plugin and it is working just fine but only outputting the title and text for my post. I have a featured image and it claims to have the functionality to do so but I can't figure out the call to the data. Here is what is provided in the documentation: http://dev.jonraasch.com/yafpp/docs For advanced users, YAFPP offers some useful output options which can be passed to the get_featured_posts() function like so: <?php get_featured_posts(array( 'method' => 'return')); ?> In this example we are setting YAFPP to return the formatted list of featured posts, as opposed to echoing it out like it does by default. Additionally you can pass 'arr' to get YAFPP to return an array of data for the featured posts. The format for this array is a list of the posts, each of which contain these keys: <?php array( 'id' => '', // id of the post 'title' => '', // title of the post 'excerpt' => '', // excerpt of the post 'url' => '', // the post permalink 'image' => '', // an array of data for a YAPB image, if it exists 'author' => '', // the post's author ); ?> Currently my code is very simple like this: <?php get_featured_posts(); ?> Thanks for the help!
  4. My mistake. Everything worked! Thanks guys!
  5. Still no dice... I'm getting the confirmation echo of 'deleted!' but something must be wrong with this: if(isset($cmd)&&$cmd=='delete') { $sql = "DELETE FROM verizon WHERE id='$delID'"; /* <------------- */ $result = mysql_query($sql); /* <------------ */ echo "<h1 style='text-align:center;'>deleted!</h1>"; }
  6. I swapped out the code and it didn't work :\ not sure what's going on here?
  7. nah I just didn't show the portion just before it. Here is the full script with my new stuff added: if($session->logged_in){ $cmd=$_GET['cmd']; //If cmd has not been initialized if(!isset($cmd)) { //display all the news $result = mysql_query("select * from verizon order by id"); //run the while loop that grabs all the news scripts while($r=mysql_fetch_array($result)) { //grab the title and the ID of the enws $title=$r["title"];//take out the title $id=$r["id"];//take out the id $thumb=$r["thumb"]; echo "<div id='delete'> <table> <tr> <td width='350px'><strong>$title</strong></td><td><a href='verizondelete.php?cmd=delete&id=$id'> Delete</a></td> </tr> <td colspan='2' align='center'><img src='../upload/verizon/$thumb'></td> </table> </div><br />"; } } if($cmd=="delete") { $sql = "DELETE * FROM verizon WHERE id=$id"; $result = mysql_query($sql); echo "<h1 style='text-align:center;'>deleted!</h1>"; } } else{ echo "<div style='text-align:center'>[<a href='../main.php'>Please Login</a>] </div>"; } The script is now returning the echo of "Deleted!" but the query isn't running because it never deletes.
  8. Ok, I got it one step forward. By setting $cmd=$_GET['cmd']; I got it to run through the if statement but now it's not performing the actual query to delete the item from the database. I tried setting up $id=$_GET['id']; but it didn't work.
  9. I'm working on an old cms I built a few years ago and for some reason my Delete page isn't working. It has to be something simple I'm overlooking. The database connection is made just above this code and is pulling the thumb and title listed by id. When I push delete I'm getting the cmd=delete&id=2 passed on so something is up with my last if statement (I think). Here is the code: if(!isset($cmd)) { //display all the news $result = mysql_query("select * from verizon order by id"); //run the while loop that grabs all the news scripts while($r=mysql_fetch_array($result)) { //grab the title and the ID of the enws $title=$r["title"];//take out the title $id=$r["id"];//take out the id $thumb=$r["thumb"]; echo "<div id='delete'> <table> <tr> <td width='350px'><strong>$title</strong></td><td><a href='verizondelete.php?cmd=delete&id=$id'> Delete</a></td> </tr> <td colspan='2' align='center'><img src='../upload/verizon/$thumb'></td> </table> </div><br />"; } } if($cmd=="delete") { $sql = "DELETE FROM verizon WHERE id='$id'"; $result = mysql_query($sql); echo "<h1 style='text-align:center;'>deleted!</h1>"; } } ?>
  10. hmm I do see what you mean... I wonder why it works on my other version?
  11. The top form. There is a title field and a file upload field. The thing is, I have this same set up working in a previous install of my CMS but it's just more complicated; the only difference is that I have a session storing the ftp info rather than stating it... here is the code: The Form: $data = mysql_query("SELECT * FROM graphicscatalog WHERE id = '$id'") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { echo " <div id='edit'> <form method='post' action='graphicscatalogeditprocess.php?id=".$id ."' enctype='multipart/form-data'> <fieldset> <legend>".$info['title'] ."</legend> <table> <tr><td colspan='2' style='text-align:center'><img src='upload/graphicscatalog/".$info['thumb'] ."'><br /><br /></tr></td> <tr><td>Order #:</td> <td> <input type='text' name='ordering' value='".$info['ordering'] ."'> </td></tr> <tr> <td> Title:</td> <td> <input type='text' name='title' value='".$info['title'] ."'> </td></tr> <td> Description:</td> <td> <input type='text' name='description' value='".$info['description'] ."'> </td></tr> <tr><td> Image: </td><td> <input type='file' name='image'></td></tr> <tr><td> Image Thumbnail: </td><td> <input type='file' name='thumb'></td></tr> <tr><td> EPS: </td><td> <input type='file' name='eps'></td></tr> <tr><td> PDF: </td><td> <input type='file' name='pdf'></td></tr> <tr><td> PNG: </td><td> <input type='file' name='png'></td></tr> </table> <br/> <br/> <input TYPE='submit' name='upload' title='Add data to the Database' value='Submit'/> </fieldset> </form> <a href='graphicscataloglist.php'><img src='images/backButton.jpg'></a> </div><br />"; The Processor: $target = "/home/path/public_html/sgktoolbox/upload/graphicscatalog/"; //This gets all the other information from the form $ordering=$_POST['ordering']; $title=$_POST['title']; $description=$_POST['description']; $id=$_GET['id']; // Connects to your Database mysql_connect("localhost", "user", "pass") or die(mysql_error()) ; mysql_select_db("database") or die(mysql_error()) ; if ($image != ''){ $image = ($_FILES['image']['name']); foreach($_FILES as $file) { move_uploaded_file($file['tmp_name'], $target . $file['name']); } mysql_query("UPDATE graphicscatalog SET image ='$image' WHERE id ='$id'"); } if ($thumb != ''){ $thumb = ($_FILES['thumb']['name']); foreach($_FILES as $file) { move_uploaded_file($file['tmp_name'], $target . $file['name']); } mysql_query("UPDATE graphicscatalog SET thumb ='$thumb' WHERE id ='$id'"); } if ($eps !=''){ $eps=($_FILES['eps']['name']); foreach($_FILES as $file) { move_uploaded_file($file['tmp_name'], $target . $file['name']); } mysql_query("UPDATE graphicscatalog SET eps ='$eps' WHERE id ='$id'"); } if ($pdf !=''){ $pdf=($_FILES['pdf']['name']); foreach($_FILES as $file) { move_uploaded_file($file['tmp_name'], $target . $file['name']); } mysql_query("UPDATE graphicscatalog SET pdf ='$pdf' WHERE id ='$id'"); } if ($png !=''){ $png=($_FILES['png']['name']); foreach($_FILES as $file) { move_uploaded_file($file['tmp_name'], $target . $file['name']); } mysql_query("UPDATE graphicscatalog SET png ='$png' WHERE id ='$id'"); } //Writes the information to the database mysql_query("UPDATE graphicscatalog SET ordering = '$ordering', title = '$title', description = '$description' WHERE id ='$id' "); I've gone line by line and can't seem to see what's triggering the problem. Could it be my tables in the database? I'm pretty sure they are the same but I could be wrong. Here is a screen cap... [attachment deleted by admin]
  12. I just didn't include the rest of the html. I'm pretty sure that what's going on is that something is wrong with the if statement. Basically it's saying check to see if the upload field is empty. If it has data then overwrite what's in the database. It seems that it isn't being passed on. Not sure why? I can update the Title portion just fine. The image part is what isn't working. (btw I use the same code (without the if statement) for the first time upload form (this is the edit form).
  13. I did a big upgrade to my CMS and now the editing of an upload doesn't seem to work. The id is pulled from a list on the previous page and is functional. Here is the form: $id=$_GET['id']; $data = mysql_query("SELECT * FROM headerimg WHERE id = '$id'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo " <div id='edit'> <form method='post' action='headerimgeditprocess.php?id=".$id ."' enctype='multipart/form-data'> <fieldset> <legend>".$info['title'] ."</legend> <table> <tr><td colspan='2' style='text-align:center'><img src='../upload/headerimg/".$info['image'] ."' width='300'><br /><br /></tr></td> <td> Title:</td> <td> <input type='text' name='title' value='".$info['title'] ."'> </td></tr> <tr><td> Image: </td><td> <input type='file' name='image'></td></tr> </table> <br/> <br/> <input TYPE='submit' name='upload' title='Add data to the Database' value='Submit'/> </fieldset> </form> Here is the processor: $target = "/var/chroot/home/content/87/6409087/html/upload/headerimg/"; //This gets all the other information from the form $title=$_POST['title']; $id=$_GET['id']; if ($image != ''){ $image = ($_FILES['image']['name']); foreach($_FILES as $file) { move_uploaded_file($file['tmp_name'], $target . $file['name']); } mysql_query("UPDATE headerimg SET image ='$image' WHERE id ='$id'"); } //Writes the information to the database mysql_query("UPDATE headerimg SET title = '$title' WHERE id ='$id' "); ?> <p>Update Successful... <a href="../main.php">click here</a> to return to the administration area.</p>
  14. I really don't know that it would be running from your hard drive without some sort of extra software bridge that connects the two. You're talking some high level stuff. Good luck!
  15. Let me get this straight... you want a script to read and run from your hard drive?
×
×
  • Create New...

Important Information

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.