Jump to content

daebat

Members
  • Posts

    83
  • Joined

  • Last visited

Everything posted by daebat

  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?
  16. <?php $main_dir ="/var/chroot/home/content/36/6817636/html/xtrajam"; $main_open = opendir($main_dir); while(($main_file = readdir($main_open)) != FALSE) { echo $main_file."<br />"; } closedir($main_open); ?> assuming that you have placed a folder named 'xtrajam' in your webspace.
  17. You have webspace correct? Create a php file named phpinfo.php in the root directory and place this snippet of code in it: <?php phpinfo(); ?> Next go to whatever your domain is /phpinfo.php (example: http://mysite.com/phpinfo.php) This will tell you all kinds of statistics about your site. Go to the bottom and it will have an area that will state "document root" and it should look something like this: /var/myname/home/content/87/64090/html/ (the above was an example from godaddy... most aren't as complex as this).
  18. install a phpinfo file, find your document root, use that file structure.
  19. I'm not a big wordpress guy and you should have probably posted this in the CMS area where you'll probably get better answers but from what I can see there isn't really a built in functionality for editing profiles on the front-end but here is a plugin that allows for you to do so: http://wordpress.org/extend/plugins/frontend-edit-profile/
  20. sorry I'm not very good with PHP yet. what's wrong with that code? I have the same code working in another area of the cms. Here is a working version: $ordering=$_POST['ordering']; $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 tablename 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 tablename SET thumb ='$thumb' WHERE id ='$id'"); } mysql_query("UPDATE tablename SET ordering = '$ordering', title = '$title' WHERE id ='$id' ");
  21. argg I just rewrote all of my code in a little different way and it still does the same thing. I'm wondering if somehow I set up the database wrong? It is just an int storing the ID and varchar storing a 250 char image name...
  22. While I am working on this it is set to 777. I'm also not getting anything written to the database so it's a double oops somewhere.
  23. I'm having some trouble with an image upload form. I have a few instances of this code that works in other areas of my site so I'm pretty sure there is just something small that I'm missing: The Form: <? include("../include/session.php"); ?> <html> <head> <title>Template Configuration</title> <link rel="stylesheet" type="text/css" href="../css/backend.css"> </head> <body> <? if($session->logged_in){ $data = mysql_query("SELECT * FROM template WHERE id = '1'") or die(mysql_error()); while($info = mysql_fetch_array( $data )) { echo " <h1 style='text-align:center;'>Template Configuration</h1> <div id='textedit'> <form method='post' action='templateprocess.php' enctype='multipart/form-data'> <table> <tr><td><h2>Header Image</h2></td></tr> <tr><td colspan='2' style='text-align:center'><img src='../upload/template/".$info['headerimg'] ."'><br /><br /></tr></td> <tr> <td>Image Upload:</td> <td> <input type='file' name='headerimg'> </td> </tr> </table <input type='hidden' name='id' value='1'> <input TYPE='submit' name='upload' title='Add data to the Database' value='Submit'/> </form> <a href='../main.php'><img src='../images/backButton.jpg'></a> </div> "; } } else{ echo "[<a href='../main.php'>Please Login</a>] "; } ?> </body> </html> The Processor: <? include("../include/session.php"); ?> <html> <head> <title>Template Configuration</title> <link rel="stylesheet" type="text/css" href="../css/backend.css"> </head> <body> <div id='process'> <? if($session->logged_in){ $target = "/path/to/folder/upload/template/"; if ($headerimg != ''){ $headerimg = ($_FILES['headerimg']['name']); foreach($_FILES as $file) { move_uploaded_file($file['tmp_name'], $target . $file['name']); } mysql_query("UPDATE template SET headerimg ='$headerimg' WHERE id ='1'"); } ?> <p>Update Successful... <a href="../main.php">click here</a> to return to the administration area.</p> <?php } else{ echo "[<a href='../main.php'>Please Login</a>] "; } ?> </div> </body> </html> My database has a table named 'template' with two fields of 'id' and 'headerimg'. I have inserted into the table (id) '1' and (headerimg) 'header-image.png' and is reading this as a preview above. I can't, however, get the 'headerimg' field to update and the image never uploads into my template folder.
  24. daebat

    IE 7 Issue

    The site in development: http://pointthinktank.aquablueweb.com My problem... IE7. I am doing a conditional call for IE7 styles but for some reason if a style is already previously declared in the regular stylesheets, the IE7 version doesn't overwrite them (and I've even used !important). Using IEtester I can see that the styles get applied but it seems to be choosing the regular stylesheet over IE7 styles. I know that it is working because if I input #top {display:none;} the top div disappears. Any help would be appreciated. (I know that the site is way overloaded with Social bullcrap but our client insists on all of this design...)
×
×
  • 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.